1 #include <stdio.h>
2 #include "Original.h"
3
CandWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)4 LRESULT APIENTRY CandWndProc(HWND hWnd,
5 UINT msg,
6 WPARAM wParam,
7 LPARAM lParam)
8 {
9 switch (msg)
10 {
11 case WM_PAINT:
12 PaintCandWindow(hWnd);
13 break;
14
15 case WM_SETCURSOR:
16 case WM_MOUSEMOVE:
17 case WM_LBUTTONUP:
18 case WM_RBUTTONUP:
19 DragUI(hWnd, NULL, msg, wParam, lParam, FALSE);
20 if ((msg == WM_SETCURSOR) &&
21 (HIWORD(lParam) != WM_LBUTTONDOWN) &&
22 (HIWORD(lParam) != WM_RBUTTONDOWN))
23 return DefWindowProc(hWnd, msg, wParam, lParam);
24 if ((msg == WM_LBUTTONUP) || (msg == WM_RBUTTONUP))
25 SetWindowLong(hWnd, FIGWL_MOUSE, 0L);
26 break;
27
28 default:
29 if (!MyIsIMEMessage(msg)){
30 return DefWindowProc(hWnd, msg, wParam, lParam);
31 }
32 break;
33 }
34 return 0L;
35 }
36
UICreateCandWindow(HWND hUIWnd)37 void UICreateCandWindow(HWND hUIWnd)
38 {
39 if (!IsWindow(uiCand.hWnd))
40 {
41 HDC hDC;
42 HFONT oldFont;
43 TCHAR szStr[100];
44 SIZE sz;
45
46 uiCand.hWnd =
47 CreateWindowEx(WS_EX_WINDOWEDGE, UICANDCLASSNAME ,NULL,
48 WS_DISABLED | WS_POPUP | WS_DLGFRAME,
49 0, 0, 1, 1, hUIWnd,NULL,hInst,NULL);
50 SetWindowLong(uiCand.hWnd, FIGWL_SVRWND, (DWORD)hUIWnd);
51
52 hDC = GetDC(uiCand.hWnd);
53 oldFont = (HFONT)SelectObject(hDC, hUIFont);
54
55 _stprintf(szStr,_T("<< 1���O 2���O 3���O 4���O 5���O 6���O 7���O 8���O 9���O 0���O >>"));
56 GetTextExtentPoint(hDC, szStr, _tcslen(szStr), &sz);
57
58 SelectObject(hDC, oldFont);
59 ReleaseDC(uiCand.hWnd,hDC);
60
61 uiCand.sz.cx = sz.cx;
62 uiCand.sz.cy = sz.cy + 15;
63 }
64 ShowWindow(uiCand.hWnd, SW_HIDE);
65 return;
66 }
67
GetCandPosFromCompWnd(LPSIZE lpsz)68 BOOL GetCandPosFromCompWnd(LPSIZE lpsz)
69 {
70 if (IsWindow(uiComp.hWnd))
71 {
72 RECT rc, screenrc;
73 POINT pt;
74
75 GetWindowRect(uiComp.hWnd, &rc);
76
77 pt.x = rc.left;
78 pt.y = rc.bottom + 2;
79
80 SystemParametersInfo(SPI_GETWORKAREA,
81 0,
82 &screenrc,
83 0);
84 if( (pt.x + lpsz->cx) > screenrc.right)
85 pt.x = rc.left - lpsz->cx - 5;
86 if( (pt.y + lpsz->cy) > screenrc.bottom)
87 pt.y = screenrc.bottom - lpsz->cy;
88
89 uiCand.pt.x = pt.x;
90 uiCand.pt.y = pt.y;
91 return TRUE;
92 }
93 return FALSE;
94 }
95
UIMoveCandWindow(HWND hUIWnd,LPTSTR lpStr)96 void UIMoveCandWindow(HWND hUIWnd, LPTSTR lpStr)
97 {
98 free(lpCandStr);
99 lpCandStr = _tcsdup(lpStr);
100 if(!_tcscmp(lpStr, _T("")))
101 {
102 UIHideCandWindow();
103 return;
104 }
105
106 if (!IsWindow(uiCand.hWnd))
107 UICreateCandWindow(hUIWnd);
108
109 if (IsWindow(uiCand.hWnd))
110 {
111 HDC hDC;
112 HFONT oldFont;
113 SIZE sz;
114
115 sz.cx = 0;
116 sz.cy = 0;
117
118 // �S�� Cand
119 if(lpStr == NULL) {
120 ShowWindow(uiCand.hWnd, SW_HIDE);
121 return;
122 }
123 hDC = GetDC(uiCand.hWnd);
124 oldFont = (HFONT)SelectObject(hDC, hUIFont);
125 GetTextExtentPoint(hDC, lpStr, _tcslen(lpStr), &sz);
126 SelectObject(hDC, oldFont);
127 ReleaseDC(uiCand.hWnd,hDC);
128 if(_tcslen(lpStr))
129 sz.cx += 3 * sz.cx / _tcslen(lpStr);
130 if(sz.cx < uiCand.sz.cx)
131 sz.cx = uiCand.sz.cx;
132 sz.cy = uiCand.sz.cy;
133
134 GetCandPosFromCompWnd(&sz);
135
136 MoveWindow(uiCand.hWnd,
137 uiCand.pt.x,
138 uiCand.pt.y,
139 sz.cx,
140 sz.cy,
141 TRUE);
142 ShowWindow(uiCand.hWnd, SW_SHOWNOACTIVATE);
143 InvalidateRect(uiCand.hWnd, NULL, FALSE);
144 }
145 }
146
PaintCandWindow(HWND hCandWnd)147 void PaintCandWindow(HWND hCandWnd)
148 {
149 PAINTSTRUCT ps;
150 HDC hDC;
151 HFONT oldFont;
152 RECT rc;
153 DWORD i;
154 HBRUSH hBrush = (HBRUSH)NULL;
155 HBRUSH hOldBrush = (HBRUSH)NULL;
156 HPEN hPen = (HPEN)NULL;
157 HPEN hOldPen = (HPEN)NULL;
158
159 hDC = BeginPaint(hCandWnd,&ps);
160 oldFont = (HFONT)SelectObject(hDC, hUIFont);
161
162 GetClientRect(hCandWnd,&rc);
163
164 hBrush = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
165 hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
166 PatBlt(hDC,
167 rc.left,
168 rc.top ,
169 rc.right - GetSystemMetrics(SM_CXEDGE)/2,
170 rc.bottom - GetSystemMetrics(SM_CYEDGE)/2,
171 PATCOPY);
172 if(hBrush && hOldBrush)
173 SelectObject(hDC,hOldBrush);
174
175 hPen = (HPEN)GetStockObject(WHITE_PEN);
176 hOldPen = (HPEN)SelectObject(hDC,hPen);
177 MoveToEx(hDC,0,rc.bottom - GetSystemMetrics(SM_CXEDGE)/2,NULL);
178 LineTo(hDC,rc.right-GetSystemMetrics(SM_CXEDGE)/2,rc.bottom - GetSystemMetrics(SM_CXEDGE)/2);
179 LineTo(hDC,rc.right-GetSystemMetrics(SM_CXEDGE)/2,0);
180
181 hPen = CreatePen(PS_SOLID ,0,RGB(128,128,128));
182 SelectObject(hDC,hPen);
183 MoveToEx(hDC,rc.right-GetSystemMetrics(SM_CXEDGE)/2,0,NULL);
184 LineTo(hDC,0,0);
185 LineTo(hDC,0,rc.bottom-GetSystemMetrics(SM_CYEDGE)/2);
186
187 SelectObject(hDC,hOldPen);
188 DeleteObject(hPen);
189
190
191 if(lpCandStr)
192 {
193 SetBkMode(hDC,TRANSPARENT);
194 TextOut(hDC, 1, 3, lpCandStr, _tcslen(lpCandStr));
195 }
196
197 SelectObject(hDC, oldFont);
198 EndPaint(hCandWnd,&ps);
199 }
200
UIShowCandWindow()201 void UIShowCandWindow()
202 {
203 if (IsWindow(uiCand.hWnd))
204 ShowWindow(uiCand.hWnd, SW_SHOWNOACTIVATE);
205 }
206
UIHideCandWindow()207 void UIHideCandWindow()
208 {
209 if (IsWindow(uiCand.hWnd))
210 ShowWindow(uiCand.hWnd, SW_HIDE);
211 }
212