1 | /* $Id: comctl32.c,v 1.14 2000-02-14 17:31:39 cbratschi Exp $ */
|
---|
2 | /*
|
---|
3 | * Win32 common controls implementation
|
---|
4 | *
|
---|
5 | * Copyright (C) 1999 Achim Hasenmueller
|
---|
6 | *
|
---|
7 | * Based on the work of the WINE group (www.winehq.com)
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 | /*
|
---|
15 | - Corel 20000212 level
|
---|
16 | - WINE 20000130 level (commctrl.c)
|
---|
17 | */
|
---|
18 |
|
---|
19 | #include "comctl32.h"
|
---|
20 | #include "winerror.h"
|
---|
21 | #include "progress.h"
|
---|
22 | #include "comboex.h"
|
---|
23 | #include "animate.h"
|
---|
24 | #include "datetime.h"
|
---|
25 | #include "flatsb.h"
|
---|
26 | #include "hotkey.h"
|
---|
27 | #include "ipaddress.h"
|
---|
28 | #include "monthcal.h"
|
---|
29 | #include "nativefont.h"
|
---|
30 | #include "pager.h"
|
---|
31 | #include "tab.h"
|
---|
32 | #include "status.h"
|
---|
33 | #include "header.h"
|
---|
34 | #include "updown.h"
|
---|
35 | #include "rebar.h"
|
---|
36 | #include "trackbar.h"
|
---|
37 | #include "tooltips.h"
|
---|
38 | #include "toolbar.h"
|
---|
39 | #include "treeview.h"
|
---|
40 | #include "listview.h"
|
---|
41 |
|
---|
42 | HANDLE COMCTL32_hHeap = (HANDLE)NULL;
|
---|
43 | HMODULE COMCTL32_hModule = 0;
|
---|
44 | LPSTR COMCTL32_aSubclass = (LPSTR)NULL;
|
---|
45 |
|
---|
46 | void CDECL RegisterCOMCTL32WindowClasses(unsigned long hinstDLL)
|
---|
47 | {
|
---|
48 | /* create private heap */
|
---|
49 | COMCTL32_hHeap = HeapCreate(0, 0x10000, 0);
|
---|
50 | /* add global subclassing atom (used by 'tooltip' and 'updown') */
|
---|
51 | COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
|
---|
52 | /* This will be wrong for any other process attching in this address-space! */
|
---|
53 | COMCTL32_hModule = (HMODULE)hinstDLL;
|
---|
54 |
|
---|
55 | /* register controls */
|
---|
56 | PROGRESS_Register();
|
---|
57 | COMBOEX_Register();
|
---|
58 | ANIMATE_Register();
|
---|
59 | DATETIME_Register();
|
---|
60 | FLATSB_Register();
|
---|
61 | HOTKEY_Register();
|
---|
62 | IPADDRESS_Register();
|
---|
63 | MONTHCAL_Register();
|
---|
64 | NATIVEFONT_Register();
|
---|
65 | PAGER_Register();
|
---|
66 | TAB_Register();
|
---|
67 | STATUS_Register();
|
---|
68 | HEADER_Register();
|
---|
69 | UPDOWN_Register();
|
---|
70 | REBAR_Register();
|
---|
71 | TRACKBAR_Register();
|
---|
72 | TOOLTIPS_Register();
|
---|
73 | TOOLBAR_Register();
|
---|
74 | TREEVIEW_Register();
|
---|
75 | LISTVIEW_Register();
|
---|
76 | }
|
---|
77 |
|
---|
78 | void CDECL UnregisterCOMCTL32WindowClasses(void)
|
---|
79 | {
|
---|
80 | /* unregister controls */
|
---|
81 | PROGRESS_Unregister();
|
---|
82 | COMBOEX_Unregister();
|
---|
83 | ANIMATE_Unregister();
|
---|
84 | DATETIME_Unregister();
|
---|
85 | FLATSB_Unregister();
|
---|
86 | HOTKEY_Unregister();
|
---|
87 | IPADDRESS_Unregister();
|
---|
88 | MONTHCAL_Unregister();
|
---|
89 | NATIVEFONT_Unregister();
|
---|
90 | PAGER_Unregister();
|
---|
91 | TAB_Unregister();
|
---|
92 | STATUS_Unregister();
|
---|
93 | HEADER_Unregister();
|
---|
94 | UPDOWN_Unregister();
|
---|
95 | REBAR_Unregister();
|
---|
96 | TRACKBAR_Unregister();
|
---|
97 | TOOLTIPS_Unregister();
|
---|
98 | TOOLBAR_Unregister();
|
---|
99 | TREEVIEW_Unregister();
|
---|
100 | LISTVIEW_Unregister();
|
---|
101 |
|
---|
102 | /* destroy private heap */
|
---|
103 | HeapDestroy(COMCTL32_hHeap);
|
---|
104 | COMCTL32_hHeap = (HANDLE)NULL;
|
---|
105 | }
|
---|
106 |
|
---|
107 | /***********************************************************************
|
---|
108 | * MenuHelp [COMCTL32.2]
|
---|
109 | *
|
---|
110 | * PARAMS
|
---|
111 | * uMsg [I] message (WM_MENUSELECT) (see NOTES)
|
---|
112 | * wParam [I] wParam of the message uMsg
|
---|
113 | * lParam [I] lParam of the message uMsg
|
---|
114 | * hMainMenu [I] handle to the application's main menu
|
---|
115 | * hInst [I] handle to the module that contains string resources
|
---|
116 | * hwndStatus [I] handle to the status bar window
|
---|
117 | * lpwIDs [I] pointer to an array of intergers (see NOTES)
|
---|
118 | *
|
---|
119 | * RETURNS
|
---|
120 | * No return value
|
---|
121 | *
|
---|
122 | * NOTES
|
---|
123 | * The official documentation is incomplete!
|
---|
124 | * This is the correct documentation:
|
---|
125 | *
|
---|
126 | * uMsg:
|
---|
127 | * MenuHelp() does NOT handle WM_COMMAND messages! It only handes
|
---|
128 | * WM_MENUSELECT messages.
|
---|
129 | *
|
---|
130 | * lpwIDs:
|
---|
131 | * (will be written ...)
|
---|
132 | */
|
---|
133 |
|
---|
134 | VOID WINAPI
|
---|
135 | MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
|
---|
136 | HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
|
---|
137 | {
|
---|
138 | UINT uMenuID = 0;
|
---|
139 |
|
---|
140 | dprintf(("COMCTL32: MenuHelp"));
|
---|
141 |
|
---|
142 | if (!IsWindow (hwndStatus))
|
---|
143 | return;
|
---|
144 |
|
---|
145 | switch (uMsg) {
|
---|
146 | case WM_MENUSELECT:
|
---|
147 | // TRACE (commctrl, "WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
|
---|
148 | // wParam, lParam);
|
---|
149 |
|
---|
150 | if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
|
---|
151 | /* menu was closed */
|
---|
152 | // TRACE (commctrl, "menu was closed!\n");
|
---|
153 | SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
|
---|
154 | }
|
---|
155 | else {
|
---|
156 | /* menu item was selected */
|
---|
157 | if (HIWORD(wParam) & MF_POPUP)
|
---|
158 | uMenuID = (UINT)*(lpwIDs+1);
|
---|
159 | else
|
---|
160 | uMenuID = (UINT)LOWORD(wParam);
|
---|
161 | // TRACE (commctrl, "uMenuID = %u\n", uMenuID);
|
---|
162 |
|
---|
163 | if (uMenuID) {
|
---|
164 | CHAR szText[256];
|
---|
165 |
|
---|
166 | if (!LoadStringA (hInst, uMenuID, szText, 256))
|
---|
167 | szText[0] = '\0';
|
---|
168 |
|
---|
169 | SendMessageA (hwndStatus, SB_SETTEXTA,
|
---|
170 | 255 | SBT_NOBORDERS, (LPARAM)szText);
|
---|
171 | SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0);
|
---|
172 | }
|
---|
173 | }
|
---|
174 | break;
|
---|
175 |
|
---|
176 | case WM_COMMAND :
|
---|
177 | // TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
|
---|
178 | // wParam, lParam);
|
---|
179 | /* WM_COMMAND is not invalid since it is documented
|
---|
180 | * in the windows api reference. So don't output
|
---|
181 | * any FIXME for WM_COMMAND
|
---|
182 | */
|
---|
183 | // WARN("We don't care about the WM_COMMAND\n");
|
---|
184 | break;
|
---|
185 |
|
---|
186 | default:
|
---|
187 | // FIXME (commctrl, "Invalid Message 0x%x!\n", uMsg);
|
---|
188 | break;
|
---|
189 | }
|
---|
190 | }
|
---|
191 |
|
---|
192 | /***********************************************************************
|
---|
193 | * ShowHideMenuCtl [COMCTL32.3]
|
---|
194 | *
|
---|
195 | * Shows or hides controls and updates the corresponding menu item.
|
---|
196 | *
|
---|
197 | * PARAMS
|
---|
198 | * hwnd [I] handle to the client window.
|
---|
199 | * uFlags [I] menu command id.
|
---|
200 | * lpInfo [I] pointer to an array of integers. (See NOTES.)
|
---|
201 | *
|
---|
202 | * RETURNS
|
---|
203 | * Success: TRUE
|
---|
204 | * Failure: FALSE
|
---|
205 | *
|
---|
206 | * NOTES
|
---|
207 | * The official documentation is incomplete!
|
---|
208 | * This is the correct documentation:
|
---|
209 | *
|
---|
210 | * hwnd
|
---|
211 | * Handle to the window that contains the menu and controls.
|
---|
212 | *
|
---|
213 | * uFlags
|
---|
214 | * Identifier of the menu item to receive or loose a check mark.
|
---|
215 | *
|
---|
216 | * lpInfo
|
---|
217 | * The array of integers contains pairs of values. BOTH values of
|
---|
218 | * the first pair must be the handles to the application's main menu.
|
---|
219 | * Each subsequent pair consists of a menu id and control id.
|
---|
220 | */
|
---|
221 |
|
---|
222 | BOOL WINAPI
|
---|
223 | ShowHideMenuCtl (HWND hwnd, UINT uFlags, LPINT lpInfo)
|
---|
224 | {
|
---|
225 | LPINT lpMenuId;
|
---|
226 |
|
---|
227 | // TRACE (commctrl, "%x, %x, %p\n", hwnd, uFlags, lpInfo);
|
---|
228 |
|
---|
229 | dprintf(("COMCTL32: ShowHideMenuCtl"));
|
---|
230 |
|
---|
231 | if (lpInfo == NULL)
|
---|
232 | return FALSE;
|
---|
233 |
|
---|
234 | if (!(lpInfo[0]) || !(lpInfo[1]))
|
---|
235 | return FALSE;
|
---|
236 |
|
---|
237 | /* search for control */
|
---|
238 | lpMenuId = &lpInfo[2];
|
---|
239 | while (*lpMenuId != uFlags)
|
---|
240 | lpMenuId += 2;
|
---|
241 |
|
---|
242 | if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
|
---|
243 | /* uncheck menu item */
|
---|
244 | CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
|
---|
245 |
|
---|
246 | /* hide control */
|
---|
247 | lpMenuId++;
|
---|
248 | SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
|
---|
249 | SWP_HIDEWINDOW);
|
---|
250 | }
|
---|
251 | else {
|
---|
252 | /* check menu item */
|
---|
253 | CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
|
---|
254 |
|
---|
255 | /* show control */
|
---|
256 | lpMenuId++;
|
---|
257 | SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
|
---|
258 | SWP_SHOWWINDOW);
|
---|
259 | }
|
---|
260 |
|
---|
261 | return TRUE;
|
---|
262 | }
|
---|
263 |
|
---|
264 | /***********************************************************************
|
---|
265 | * GetEffectiveClientRect [COMCTL32.4]
|
---|
266 | *
|
---|
267 | * PARAMS
|
---|
268 | * hwnd [I] handle to the client window.
|
---|
269 | * lpRect [O] pointer to the rectangle of the client window
|
---|
270 | * lpInfo [I] pointer to an array of integers (see NOTES)
|
---|
271 | *
|
---|
272 | * RETURNS
|
---|
273 | * No return value.
|
---|
274 | *
|
---|
275 | * NOTES
|
---|
276 | * The official documentation is incomplete!
|
---|
277 | * This is the correct documentation:
|
---|
278 | *
|
---|
279 | * lpInfo
|
---|
280 | * (will be written...)
|
---|
281 | */
|
---|
282 |
|
---|
283 | VOID WINAPI
|
---|
284 | GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
|
---|
285 | {
|
---|
286 | RECT rcCtrl;
|
---|
287 | INT *lpRun;
|
---|
288 | HWND hwndCtrl;
|
---|
289 |
|
---|
290 | // TRACE (commctrl, "(0x%08lx 0x%08lx 0x%08lx)\n",
|
---|
291 | // (DWORD)hwnd, (DWORD)lpRect, (DWORD)lpInfo);
|
---|
292 |
|
---|
293 | dprintf(("COMCTL32: GetEffectiveClientRect"));
|
---|
294 |
|
---|
295 | GetClientRect (hwnd, lpRect);
|
---|
296 | lpRun = lpInfo;
|
---|
297 |
|
---|
298 | do {
|
---|
299 | lpRun += 2;
|
---|
300 | if (*lpRun == 0)
|
---|
301 | return;
|
---|
302 | lpRun++;
|
---|
303 | hwndCtrl = GetDlgItem (hwnd, *lpRun);
|
---|
304 | if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
|
---|
305 | // TRACE (commctrl, "control id 0x%x\n", *lpRun);
|
---|
306 | GetWindowRect (hwndCtrl, &rcCtrl);
|
---|
307 | MapWindowPoints ((HWND)0, hwnd, (LPPOINT)&rcCtrl, 2);
|
---|
308 | SubtractRect (lpRect, lpRect, &rcCtrl);
|
---|
309 | }
|
---|
310 | lpRun++;
|
---|
311 | } while (*lpRun);
|
---|
312 | }
|
---|
313 |
|
---|
314 | /***********************************************************************
|
---|
315 | * DrawStatusText32A [COMCTL32.5][COMCTL32.27]
|
---|
316 | *
|
---|
317 | * Draws text with borders, like in a status bar.
|
---|
318 | *
|
---|
319 | * PARAMS
|
---|
320 | * hdc [I] handle to the window's display context
|
---|
321 | * lprc [I] pointer to a rectangle
|
---|
322 | * text [I] pointer to the text
|
---|
323 | * style [I] drawing style
|
---|
324 | *
|
---|
325 | * RETURNS
|
---|
326 | * No return value.
|
---|
327 | *
|
---|
328 | * NOTES
|
---|
329 | * The style variable can have one of the following values:
|
---|
330 | * (will be written ...)
|
---|
331 | */
|
---|
332 |
|
---|
333 | VOID WINAPI
|
---|
334 | DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
|
---|
335 | {
|
---|
336 | RECT r = *lprc;
|
---|
337 | UINT border = BDR_SUNKENOUTER;
|
---|
338 |
|
---|
339 | dprintf(("COMCTL32: DrawStatusTextA"));
|
---|
340 |
|
---|
341 | if (style & SBT_POPOUT)
|
---|
342 | border = BDR_RAISEDOUTER;
|
---|
343 | else if (style & SBT_NOBORDERS)
|
---|
344 | border = 0;
|
---|
345 |
|
---|
346 | DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST|BF_MIDDLE);
|
---|
347 |
|
---|
348 | /* now draw text */
|
---|
349 | if (text) {
|
---|
350 | int oldbkmode = SetBkMode (hdc, TRANSPARENT);
|
---|
351 | r.left += 3;
|
---|
352 | DrawTextA (hdc, text, lstrlenA(text),
|
---|
353 | &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
|
---|
354 | if (oldbkmode != TRANSPARENT)
|
---|
355 | SetBkMode(hdc, oldbkmode);
|
---|
356 | }
|
---|
357 | }
|
---|
358 |
|
---|
359 |
|
---|
360 | /***********************************************************************
|
---|
361 | * DrawStatusText32W [COMCTL32.28]
|
---|
362 | *
|
---|
363 | * Draws text with borders, like in a status bar.
|
---|
364 | *
|
---|
365 | * PARAMS
|
---|
366 | * hdc [I] handle to the window's display context
|
---|
367 | * lprc [I] pointer to a rectangle
|
---|
368 | * text [I] pointer to the text
|
---|
369 | * style [I] drawing style
|
---|
370 | *
|
---|
371 | * RETURNS
|
---|
372 | * No return value.
|
---|
373 | */
|
---|
374 |
|
---|
375 | VOID WINAPI
|
---|
376 | DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
|
---|
377 | {
|
---|
378 | LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, text);
|
---|
379 |
|
---|
380 | dprintf(("COMCTL32: DrawStatusTextW"));
|
---|
381 |
|
---|
382 | DrawStatusTextA (hdc, lprc, p, style);
|
---|
383 | HeapFree (GetProcessHeap (), 0, p );
|
---|
384 | }
|
---|
385 |
|
---|
386 |
|
---|
387 | /***********************************************************************
|
---|
388 | * CreateStatusWindow32A [COMCTL32.6][COMCTL32.21]
|
---|
389 | *
|
---|
390 | * Creates a status bar
|
---|
391 | *
|
---|
392 | * PARAMS
|
---|
393 | * style [I] window style
|
---|
394 | * text [I] pointer to the window text
|
---|
395 | * parent [I] handle to the parent window
|
---|
396 | * wid [I] control id of the status bar
|
---|
397 | *
|
---|
398 | * RETURNS
|
---|
399 | * Success: handle to the status window
|
---|
400 | * Failure: 0
|
---|
401 | */
|
---|
402 |
|
---|
403 | HWND WINAPI
|
---|
404 | CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
|
---|
405 | {
|
---|
406 | dprintf(("COMCTL32: CreateStatusWindowA"));
|
---|
407 |
|
---|
408 | return CreateWindowA(STATUSCLASSNAMEA, text, style,
|
---|
409 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
410 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
411 | parent, wid, 0, 0);
|
---|
412 | }
|
---|
413 |
|
---|
414 |
|
---|
415 | /***********************************************************************
|
---|
416 | * CreateStatusWindow32W [COMCTL32.22] Creates a status bar control
|
---|
417 | *
|
---|
418 | * PARAMS
|
---|
419 | * style [I] window style
|
---|
420 | * text [I] pointer to the window text
|
---|
421 | * parent [I] handle to the parent window
|
---|
422 | * wid [I] control id of the status bar
|
---|
423 | *
|
---|
424 | * RETURNS
|
---|
425 | * Success: handle to the status window
|
---|
426 | * Failure: 0
|
---|
427 | */
|
---|
428 |
|
---|
429 | HWND WINAPI
|
---|
430 | CreateStatusWindowW (INT style, LPCWSTR text, HWND parent, UINT wid)
|
---|
431 | {
|
---|
432 | dprintf(("COMCTL32: CreateStatusWindowW"));
|
---|
433 |
|
---|
434 | return CreateWindowW(STATUSCLASSNAMEW, text, style,
|
---|
435 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
436 | CW_USEDEFAULT, CW_USEDEFAULT,
|
---|
437 | parent, wid, 0, 0);
|
---|
438 | }
|
---|
439 |
|
---|
440 |
|
---|
441 | /***********************************************************************
|
---|
442 | * CreateUpDownControl [COMCTL32.16] Creates an up-down control
|
---|
443 | *
|
---|
444 | * PARAMS
|
---|
445 | * style [I] window styles
|
---|
446 | * x [I] horizontal position of the control
|
---|
447 | * y [I] vertical position of the control
|
---|
448 | * cx [I] with of the control
|
---|
449 | * cy [I] height of the control
|
---|
450 | * parent [I] handle to the parent window
|
---|
451 | * id [I] the control's identifier
|
---|
452 | * inst [I] handle to the application's module instance
|
---|
453 | * buddy [I] handle to the buddy window, can be NULL
|
---|
454 | * maxVal [I] upper limit of the control
|
---|
455 | * minVal [I] lower limit of the control
|
---|
456 | * curVal [I] current value of the control
|
---|
457 | *
|
---|
458 | * RETURNS
|
---|
459 | * Success: handle to the updown control
|
---|
460 | * Failure: 0
|
---|
461 | */
|
---|
462 |
|
---|
463 | HWND WINAPI
|
---|
464 | CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
|
---|
465 | HWND parent, INT id, HINSTANCE inst,
|
---|
466 | HWND buddy, INT maxVal, INT minVal, INT curVal)
|
---|
467 | {
|
---|
468 | HWND hUD;
|
---|
469 |
|
---|
470 | dprintf(("COMCTL32: CreateUpDownControl"));
|
---|
471 |
|
---|
472 | hUD = CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
|
---|
473 | parent, id, inst, 0);
|
---|
474 | if (hUD) {
|
---|
475 | SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
|
---|
476 | SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
|
---|
477 | SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
|
---|
478 | }
|
---|
479 |
|
---|
480 | return hUD;
|
---|
481 | }
|
---|
482 |
|
---|
483 | /***********************************************************************
|
---|
484 | * InitCommonControls [COMCTL32.17]
|
---|
485 | *
|
---|
486 | * Registers the common controls.
|
---|
487 | *
|
---|
488 | * PARAMS
|
---|
489 | * No parameters.
|
---|
490 | *
|
---|
491 | * RETURNS
|
---|
492 | * No return values.
|
---|
493 | *
|
---|
494 | * NOTES
|
---|
495 | * This function is just a dummy.
|
---|
496 | * The Win95 controls are registered at the DLL's initialization.
|
---|
497 | * To register other controls InitCommonControlsEx() must be used.
|
---|
498 | */
|
---|
499 |
|
---|
500 | VOID WINAPI InitCommonControls(VOID)
|
---|
501 | {
|
---|
502 | dprintf(("COMCTL32: InitCommonControls"));
|
---|
503 | }
|
---|
504 |
|
---|
505 | /***********************************************************************
|
---|
506 | * InitCommonControlsEx [COMCTL32.81]
|
---|
507 | *
|
---|
508 | * Registers the common controls.
|
---|
509 | *
|
---|
510 | * PARAMS
|
---|
511 | * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
|
---|
512 | *
|
---|
513 | * RETURNS
|
---|
514 | * Success: TRUE
|
---|
515 | * Failure: FALSE
|
---|
516 | *
|
---|
517 | * NOTES
|
---|
518 | * Only the additinal common controls are registered by this function.
|
---|
519 | * The Win95 controls are registered at the DLL's initialization.
|
---|
520 | */
|
---|
521 |
|
---|
522 | BOOL WINAPI
|
---|
523 | InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
|
---|
524 | {
|
---|
525 | INT cCount;
|
---|
526 | DWORD dwMask;
|
---|
527 |
|
---|
528 | dprintf(("COMCTL32: InitCommonControlsEx"));
|
---|
529 |
|
---|
530 | if (!lpInitCtrls)
|
---|
531 | return FALSE;
|
---|
532 | if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
|
---|
533 | return FALSE;
|
---|
534 |
|
---|
535 | // TRACE(commctrl,"(0x%08lx)\n", lpInitCtrls->dwICC);
|
---|
536 |
|
---|
537 | for (cCount = 0; cCount < 32; cCount++) {
|
---|
538 | dwMask = 1 << cCount;
|
---|
539 | if (!(lpInitCtrls->dwICC & dwMask))
|
---|
540 | continue;
|
---|
541 |
|
---|
542 | switch (lpInitCtrls->dwICC & dwMask) {
|
---|
543 | /* dummy initialization */
|
---|
544 | case ICC_ANIMATE_CLASS:
|
---|
545 | case ICC_BAR_CLASSES:
|
---|
546 | case ICC_LISTVIEW_CLASSES:
|
---|
547 | case ICC_TREEVIEW_CLASSES:
|
---|
548 | case ICC_TAB_CLASSES:
|
---|
549 | case ICC_UPDOWN_CLASS:
|
---|
550 | case ICC_PROGRESS_CLASS:
|
---|
551 | case ICC_HOTKEY_CLASS:
|
---|
552 | break;
|
---|
553 |
|
---|
554 | /* advanced classes - not included in Win95 */
|
---|
555 | case ICC_DATE_CLASSES:
|
---|
556 | MONTHCAL_Register ();
|
---|
557 | DATETIME_Register ();
|
---|
558 | break;
|
---|
559 |
|
---|
560 | case ICC_USEREX_CLASSES:
|
---|
561 | COMBOEX_Register ();
|
---|
562 | break;
|
---|
563 |
|
---|
564 | case ICC_COOL_CLASSES:
|
---|
565 | REBAR_Register ();
|
---|
566 | break;
|
---|
567 |
|
---|
568 | case ICC_INTERNET_CLASSES:
|
---|
569 | IPADDRESS_Register ();
|
---|
570 | break;
|
---|
571 |
|
---|
572 | case ICC_PAGESCROLLER_CLASS:
|
---|
573 | PAGER_Register ();
|
---|
574 | break;
|
---|
575 |
|
---|
576 | case ICC_NATIVEFNTCTL_CLASS:
|
---|
577 | NATIVEFONT_Register ();
|
---|
578 | break;
|
---|
579 |
|
---|
580 | default:
|
---|
581 | // FIXME (commctrl, "Unknown class! dwICC=0x%lX\n", dwMask);
|
---|
582 | break;
|
---|
583 | }
|
---|
584 | }
|
---|
585 |
|
---|
586 | return TRUE;
|
---|
587 | }
|
---|
588 |
|
---|
589 | /***********************************************************************
|
---|
590 | * CreateToolbarEx [COMCTL32.32] Creates a tool bar window
|
---|
591 | *
|
---|
592 | * PARAMS
|
---|
593 | * hwnd
|
---|
594 | * style
|
---|
595 | * wID
|
---|
596 | * nBitmaps
|
---|
597 | * hBMInst
|
---|
598 | * wBMID
|
---|
599 | * lpButtons
|
---|
600 | * iNumButtons
|
---|
601 | * dxButton
|
---|
602 | * dyButton
|
---|
603 | * dxBitmap
|
---|
604 | * dyBitmap
|
---|
605 | * uStructSize
|
---|
606 | *
|
---|
607 | * RETURNS
|
---|
608 | * Success: handle to the tool bar control
|
---|
609 | * Failure: 0
|
---|
610 | */
|
---|
611 |
|
---|
612 | HWND WINAPI
|
---|
613 | CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
|
---|
614 | HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
|
---|
615 | INT iNumButtons, INT dxButton, INT dyButton,
|
---|
616 | INT dxBitmap, INT dyBitmap, UINT uStructSize)
|
---|
617 | {
|
---|
618 | HWND hwndTB;
|
---|
619 |
|
---|
620 | dprintf(("COMCTL32: CreateToolbarEx"));
|
---|
621 |
|
---|
622 | hwndTB = CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style, 0, 0, 0, 0,
|
---|
623 | hwnd, (HMENU)wID, 0, NULL);
|
---|
624 | if(hwndTB) {
|
---|
625 | TBADDBITMAP tbab;
|
---|
626 |
|
---|
627 | SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
|
---|
628 | (WPARAM)uStructSize, 0);
|
---|
629 |
|
---|
630 | /* set bitmap and button size */
|
---|
631 | /*If CreateToolbarEx receive 0, windows set default values*/
|
---|
632 | if (dyBitmap <= 0)
|
---|
633 | dyBitmap = 16;
|
---|
634 | if (dxBitmap <= 0)
|
---|
635 | dxBitmap = 16;
|
---|
636 |
|
---|
637 | SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
|
---|
638 | MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap));
|
---|
639 | SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
|
---|
640 | MAKELPARAM((WORD)dxButton, (WORD)dyButton));
|
---|
641 |
|
---|
642 |
|
---|
643 | /* add bitmaps */
|
---|
644 | if (nBitmaps > 0)
|
---|
645 | {
|
---|
646 | tbab.hInst = hBMInst;
|
---|
647 | tbab.nID = wBMID;
|
---|
648 |
|
---|
649 | SendMessageA (hwndTB, TB_ADDBITMAP,
|
---|
650 | (WPARAM)nBitmaps, (LPARAM)&tbab);
|
---|
651 | }
|
---|
652 | /* add buttons */
|
---|
653 | if(iNumButtons > 0)
|
---|
654 | SendMessageA (hwndTB, TB_ADDBUTTONSA,
|
---|
655 | (WPARAM)iNumButtons, (LPARAM)lpButtons);
|
---|
656 | }
|
---|
657 |
|
---|
658 | return hwndTB;
|
---|
659 | }
|
---|
660 |
|
---|
661 |
|
---|
662 | /***********************************************************************
|
---|
663 | * CreateMappedBitmap [COMCTL32.8]
|
---|
664 | *
|
---|
665 | * PARAMS
|
---|
666 | * hInstance [I]
|
---|
667 | * idBitmap [I]
|
---|
668 | * wFlags [I]
|
---|
669 | * lpColorMap [I]
|
---|
670 | * iNumMaps [I]
|
---|
671 | *
|
---|
672 | * RETURNS
|
---|
673 | * Success: handle to the new bitmap
|
---|
674 | * Failure: 0
|
---|
675 | */
|
---|
676 |
|
---|
677 | HBITMAP WINAPI
|
---|
678 | CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
|
---|
679 | LPCOLORMAP lpColorMap, INT iNumMaps)
|
---|
680 | {
|
---|
681 | HGLOBAL hglb;
|
---|
682 | HRSRC hRsrc;
|
---|
683 | LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
|
---|
684 | UINT nSize, nColorTableSize;
|
---|
685 | RGBQUAD *pColorTable;
|
---|
686 | INT iColor, i, iMaps, nWidth, nHeight;
|
---|
687 | HDC hdcScreen;
|
---|
688 | HBITMAP hbm;
|
---|
689 | LPCOLORMAP sysColorMap;
|
---|
690 | COLORREF cRef;
|
---|
691 | COLORMAP internalColorMap[4] =
|
---|
692 | {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
|
---|
693 |
|
---|
694 | dprintf(("COMCTL32: CreateMappedBitmap"));
|
---|
695 |
|
---|
696 | /* initialize pointer to colortable and default color table */
|
---|
697 | if (lpColorMap) {
|
---|
698 | iMaps = iNumMaps;
|
---|
699 | sysColorMap = lpColorMap;
|
---|
700 | }
|
---|
701 | else {
|
---|
702 | internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
|
---|
703 | internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
|
---|
704 | internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
|
---|
705 | internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
|
---|
706 | iMaps = 4;
|
---|
707 | sysColorMap = (LPCOLORMAP)internalColorMap;
|
---|
708 | }
|
---|
709 |
|
---|
710 | hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
|
---|
711 | if (hRsrc == 0)
|
---|
712 | return 0;
|
---|
713 | hglb = LoadResource (hInstance, hRsrc);
|
---|
714 | if (hglb == 0)
|
---|
715 | return 0;
|
---|
716 | lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
|
---|
717 | if (lpBitmap == NULL)
|
---|
718 | return 0;
|
---|
719 |
|
---|
720 | nColorTableSize = (1 << lpBitmap->biBitCount);
|
---|
721 | nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
|
---|
722 | lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
|
---|
723 | if (lpBitmapInfo == NULL)
|
---|
724 | return 0;
|
---|
725 | RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
|
---|
726 |
|
---|
727 | pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
|
---|
728 |
|
---|
729 | for (iColor = 0; iColor < nColorTableSize; iColor++) {
|
---|
730 | for (i = 0; i < iMaps; i++) {
|
---|
731 | cRef = RGB(pColorTable[iColor].rgbRed,
|
---|
732 | pColorTable[iColor].rgbGreen,
|
---|
733 | pColorTable[iColor].rgbBlue);
|
---|
734 | if ( cRef == sysColorMap[i].from) {
|
---|
735 | #if 0
|
---|
736 | if (wFlags & CBS_MASKED) {
|
---|
737 | if (sysColorMap[i].to != COLOR_BTNTEXT)
|
---|
738 | pColorTable[iColor] = RGB(255, 255, 255);
|
---|
739 | }
|
---|
740 | else
|
---|
741 | #endif
|
---|
742 | pColorTable[iColor].rgbBlue = GetBValue(sysColorMap[i].to);
|
---|
743 | pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
|
---|
744 | pColorTable[iColor].rgbRed = GetRValue(sysColorMap[i].to);
|
---|
745 | break;
|
---|
746 | }
|
---|
747 | }
|
---|
748 | }
|
---|
749 | nWidth = (INT)lpBitmapInfo->biWidth;
|
---|
750 | nHeight = (INT)lpBitmapInfo->biHeight;
|
---|
751 | hdcScreen = GetDC ((HWND)0);
|
---|
752 | hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
|
---|
753 | if (hbm) {
|
---|
754 | HDC hdcDst = CreateCompatibleDC (hdcScreen);
|
---|
755 | HBITMAP hbmOld = SelectObject (hdcDst, hbm);
|
---|
756 | LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
|
---|
757 | lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
|
---|
758 | StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
|
---|
759 | lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
|
---|
760 | SRCCOPY);
|
---|
761 | SelectObject (hdcDst, hbmOld);
|
---|
762 | DeleteDC (hdcDst);
|
---|
763 | }
|
---|
764 | ReleaseDC ((HWND)0, hdcScreen);
|
---|
765 | GlobalFree ((HGLOBAL)lpBitmapInfo);
|
---|
766 | FreeResource (hglb);
|
---|
767 |
|
---|
768 | return hbm;
|
---|
769 | }
|
---|
770 |
|
---|
771 |
|
---|
772 | /***********************************************************************
|
---|
773 | * CreateToolbar [COMCTL32.7] Creates a tool bar control
|
---|
774 | *
|
---|
775 | * PARAMS
|
---|
776 | * hwnd
|
---|
777 | * style
|
---|
778 | * wID
|
---|
779 | * nBitmaps
|
---|
780 | * hBMInst
|
---|
781 | * wBMID
|
---|
782 | * lpButtons
|
---|
783 | * iNumButtons
|
---|
784 | *
|
---|
785 | * RETURNS
|
---|
786 | * Success: handle to the tool bar control
|
---|
787 | * Failure: 0
|
---|
788 | *
|
---|
789 | * NOTES
|
---|
790 | * Do not use this functions anymore. Use CreateToolbarEx instead.
|
---|
791 | */
|
---|
792 |
|
---|
793 | HWND WINAPI
|
---|
794 | CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
|
---|
795 | HINSTANCE hBMInst, UINT wBMID,
|
---|
796 | LPCOLDTBBUTTON lpButtons,INT iNumButtons)
|
---|
797 | {
|
---|
798 | dprintf(("COMCTL32: CreateToolbar"));
|
---|
799 |
|
---|
800 | return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
|
---|
801 | hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
|
---|
802 | iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
|
---|
803 | }
|
---|
804 |
|
---|
805 |
|
---|
806 | /***********************************************************************
|
---|
807 | * DllGetVersion [COMCTL32.25]
|
---|
808 | *
|
---|
809 | * Retrieves version information of the 'COMCTL32.DLL'
|
---|
810 | *
|
---|
811 | * PARAMS
|
---|
812 | * pdvi [O] pointer to version information structure.
|
---|
813 | *
|
---|
814 | * RETURNS
|
---|
815 | * Success: S_OK
|
---|
816 | * Failure: E_INVALIDARG
|
---|
817 | *
|
---|
818 | * NOTES
|
---|
819 | * Returns version of a comctl32.dll from IE4.01 SP1.
|
---|
820 | */
|
---|
821 |
|
---|
822 | HRESULT WINAPI
|
---|
823 | COMCTL32_DllGetVersion (DLLVERSIONINFO *pdvi)
|
---|
824 | {
|
---|
825 | if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
|
---|
826 | // WARN (commctrl, "wrong DLLVERSIONINFO size from app");
|
---|
827 | return E_INVALIDARG;
|
---|
828 | }
|
---|
829 |
|
---|
830 | pdvi->dwMajorVersion = 4;
|
---|
831 | pdvi->dwMinorVersion = 72;
|
---|
832 | pdvi->dwBuildNumber = 3110;
|
---|
833 | pdvi->dwPlatformID = 1;
|
---|
834 |
|
---|
835 | // TRACE (commctrl, "%lu.%lu.%lu.%lu\n",
|
---|
836 | // pdvi->dwMajorVersion, pdvi->dwMinorVersion,
|
---|
837 | // pdvi->dwBuildNumber, pdvi->dwPlatformID);
|
---|
838 |
|
---|
839 | return S_OK;
|
---|
840 | }
|
---|
841 |
|
---|
842 | static int iTrackMax = 0;
|
---|
843 | static HWND TrackingList[10];
|
---|
844 | static UINT timer;
|
---|
845 |
|
---|
846 | static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT idEvent, DWORD dwTime) {
|
---|
847 | int i = 0;
|
---|
848 | POINT pos;
|
---|
849 | HWND hwnd;
|
---|
850 | BOOL keepTracking = FALSE;
|
---|
851 | GetCursorPos(&pos);
|
---|
852 | hwnd = WindowFromPoint(pos);
|
---|
853 | /* Loop through the list of windows waiting on mouse exit */
|
---|
854 | while (i < iTrackMax) {
|
---|
855 | if (TrackingList[i] != hwnd)
|
---|
856 | PostMessageA(TrackingList[i], WM_MOUSELEAVE, 0, 0);
|
---|
857 | else
|
---|
858 | keepTracking = TRUE;
|
---|
859 |
|
---|
860 |
|
---|
861 | i++;
|
---|
862 | }
|
---|
863 |
|
---|
864 | if (keepTracking) {
|
---|
865 | iTrackMax = 1;
|
---|
866 | TrackingList[0] = hwnd;
|
---|
867 | }
|
---|
868 | else
|
---|
869 | KillTimer(0, timer);
|
---|
870 | }
|
---|
871 |
|
---|
872 | /***********************************************************************
|
---|
873 | * _TrackMouseEvent [COMCTL32.25]
|
---|
874 | *
|
---|
875 | * Requests notification of mouse events
|
---|
876 | *
|
---|
877 | * PARAMS
|
---|
878 | * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
|
---|
879 | *
|
---|
880 | * RETURNS
|
---|
881 | * Success: non-zero
|
---|
882 | * Failure: zero
|
---|
883 | *
|
---|
884 | */
|
---|
885 |
|
---|
886 | BOOL WINAPI
|
---|
887 | _TrackMouseEvent (TRACKMOUSEEVENT *ptme)
|
---|
888 | {
|
---|
889 | DWORD flags = 0;
|
---|
890 | int i;
|
---|
891 | BOOL cancel = 0, hover = 0, leave = 0, query = 0;
|
---|
892 | if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
|
---|
893 | //WARN("wrong TRACKMOUSEEVENT size from app");
|
---|
894 | return E_INVALIDARG;
|
---|
895 | }
|
---|
896 |
|
---|
897 | //TRACE("%lx, %lx, %x, %lx\n", ptme->cbSize, ptme->dwFlags, ptme->hwndTrack, ptme->dwHoverTime);
|
---|
898 |
|
---|
899 | flags = ptme->dwFlags;
|
---|
900 | if ( flags & TME_CANCEL ) {
|
---|
901 | cancel = 1;
|
---|
902 | flags &= ~ TME_CANCEL;
|
---|
903 | }
|
---|
904 | if ( flags & TME_HOVER ) {
|
---|
905 | hover = 1;
|
---|
906 | flags &= ~ TME_HOVER;
|
---|
907 | //FIXME("TME_HOVER unimplemented\n" );
|
---|
908 | }
|
---|
909 | if ( flags & TME_LEAVE ) {
|
---|
910 | leave = 1;
|
---|
911 | flags &= ~ TME_LEAVE;
|
---|
912 | }
|
---|
913 | if ( flags & TME_QUERY ) {
|
---|
914 | query = 1;
|
---|
915 | flags &= ~ TME_QUERY;
|
---|
916 | //FIXME("TME_QUERY unimplemented\n" );
|
---|
917 | }
|
---|
918 |
|
---|
919 | //if ( flags )
|
---|
920 | // FIXME("Unknown flag(s) %ld\n", flags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_QUERY) );
|
---|
921 |
|
---|
922 | if (leave) {
|
---|
923 | if (cancel) {
|
---|
924 | for (i = 0; i < iTrackMax; i++)
|
---|
925 | if (TrackingList[i] == ptme->hwndTrack)
|
---|
926 | TrackingList[i] = TrackingList[--iTrackMax];
|
---|
927 | }
|
---|
928 | else {
|
---|
929 | if (iTrackMax == sizeof (TrackingList) / sizeof *TrackingList)
|
---|
930 | return FALSE;
|
---|
931 |
|
---|
932 | /* Add hwndTrack to the track list */
|
---|
933 | TrackingList[iTrackMax++] = ptme->hwndTrack;
|
---|
934 | if (!timer)
|
---|
935 | timer = SetTimer(0, 0, 50, TrackMouseEventProc);
|
---|
936 | }
|
---|
937 | }
|
---|
938 |
|
---|
939 | return TRUE;
|
---|
940 | }
|
---|
941 |
|
---|
942 |
|
---|