source: trunk/src/comctl32/comctl32.c@ 2820

Last change on this file since 2820 was 2820, checked in by cbratschi, 26 years ago

* empty log message *

File size: 25.3 KB
Line 
1/* $Id: comctl32.c,v 1.15 2000-02-18 17:13:37 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
42HANDLE COMCTL32_hHeap = (HANDLE)NULL;
43HMODULE COMCTL32_hModule = 0;
44LPSTR COMCTL32_aSubclass = (LPSTR)NULL;
45
46void 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
78void 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
134VOID WINAPI
135MenuHelp (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
222BOOL WINAPI
223ShowHideMenuCtl (HWND hwnd, UINT uFlags, LPINT lpInfo)
224{
225 LPINT lpMenuId;
226
227 dprintf(("COMCTL32: ShowHideMenuCtl"));
228
229 if (lpInfo == NULL)
230 return FALSE;
231
232 if (!(lpInfo[0]) || !(lpInfo[1]))
233 return FALSE;
234
235 /* search for control */
236 lpMenuId = &lpInfo[2];
237 while (*lpMenuId != uFlags)
238 lpMenuId += 2;
239
240 if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
241 /* uncheck menu item */
242 CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
243
244 /* hide control */
245 lpMenuId++;
246 SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
247 SWP_HIDEWINDOW);
248 }
249 else {
250 /* check menu item */
251 CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
252
253 /* show control */
254 lpMenuId++;
255 SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
256 SWP_SHOWWINDOW);
257 }
258
259 return TRUE;
260}
261
262/***********************************************************************
263 * GetEffectiveClientRect [COMCTL32.4]
264 *
265 * PARAMS
266 * hwnd [I] handle to the client window.
267 * lpRect [O] pointer to the rectangle of the client window
268 * lpInfo [I] pointer to an array of integers (see NOTES)
269 *
270 * RETURNS
271 * No return value.
272 *
273 * NOTES
274 * The official documentation is incomplete!
275 * This is the correct documentation:
276 *
277 * lpInfo
278 * (will be written...)
279 */
280
281VOID WINAPI
282GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
283{
284 RECT rcCtrl;
285 INT *lpRun;
286 HWND hwndCtrl;
287
288 dprintf(("COMCTL32: GetEffectiveClientRect"));
289
290 GetClientRect (hwnd, lpRect);
291 lpRun = lpInfo;
292
293 do {
294 lpRun += 2;
295 if (*lpRun == 0)
296 return;
297 lpRun++;
298 hwndCtrl = GetDlgItem (hwnd, *lpRun);
299 if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
300// TRACE (commctrl, "control id 0x%x\n", *lpRun);
301 GetWindowRect (hwndCtrl, &rcCtrl);
302 MapWindowPoints ((HWND)0, hwnd, (LPPOINT)&rcCtrl, 2);
303 SubtractRect (lpRect, lpRect, &rcCtrl);
304 }
305 lpRun++;
306 } while (*lpRun);
307}
308
309/***********************************************************************
310 * DrawStatusText32A [COMCTL32.5][COMCTL32.27]
311 *
312 * Draws text with borders, like in a status bar.
313 *
314 * PARAMS
315 * hdc [I] handle to the window's display context
316 * lprc [I] pointer to a rectangle
317 * text [I] pointer to the text
318 * style [I] drawing style
319 *
320 * RETURNS
321 * No return value.
322 *
323 * NOTES
324 * The style variable can have one of the following values:
325 * (will be written ...)
326 */
327
328VOID WINAPI
329DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
330{
331 RECT r = *lprc;
332 UINT border = BDR_SUNKENOUTER;
333
334 dprintf(("COMCTL32: DrawStatusTextA"));
335
336 if (style & SBT_POPOUT)
337 border = BDR_RAISEDOUTER;
338 else if (style & SBT_NOBORDERS)
339 border = 0;
340
341 DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST|BF_MIDDLE);
342
343 /* now draw text */
344 if (text) {
345 int oldbkmode = SetBkMode (hdc, TRANSPARENT);
346 r.left += 3;
347 DrawTextA (hdc, text, lstrlenA(text),
348 &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
349 if (oldbkmode != TRANSPARENT)
350 SetBkMode(hdc, oldbkmode);
351 }
352}
353
354
355/***********************************************************************
356 * DrawStatusText32W [COMCTL32.28]
357 *
358 * Draws text with borders, like in a status bar.
359 *
360 * PARAMS
361 * hdc [I] handle to the window's display context
362 * lprc [I] pointer to a rectangle
363 * text [I] pointer to the text
364 * style [I] drawing style
365 *
366 * RETURNS
367 * No return value.
368 */
369
370VOID WINAPI
371DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
372{
373 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, text);
374
375 dprintf(("COMCTL32: DrawStatusTextW"));
376
377 DrawStatusTextA (hdc, lprc, p, style);
378 HeapFree (GetProcessHeap (), 0, p );
379}
380
381
382/***********************************************************************
383 * CreateStatusWindow32A [COMCTL32.6][COMCTL32.21]
384 *
385 * Creates a status bar
386 *
387 * PARAMS
388 * style [I] window style
389 * text [I] pointer to the window text
390 * parent [I] handle to the parent window
391 * wid [I] control id of the status bar
392 *
393 * RETURNS
394 * Success: handle to the status window
395 * Failure: 0
396 */
397
398HWND WINAPI
399CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
400{
401 dprintf(("COMCTL32: CreateStatusWindowA"));
402
403 return CreateWindowA(STATUSCLASSNAMEA, text, style,
404 CW_USEDEFAULT, CW_USEDEFAULT,
405 CW_USEDEFAULT, CW_USEDEFAULT,
406 parent, wid, 0, 0);
407}
408
409
410/***********************************************************************
411 * CreateStatusWindow32W [COMCTL32.22] Creates a status bar control
412 *
413 * PARAMS
414 * style [I] window style
415 * text [I] pointer to the window text
416 * parent [I] handle to the parent window
417 * wid [I] control id of the status bar
418 *
419 * RETURNS
420 * Success: handle to the status window
421 * Failure: 0
422 */
423
424HWND WINAPI
425CreateStatusWindowW (INT style, LPCWSTR text, HWND parent, UINT wid)
426{
427 dprintf(("COMCTL32: CreateStatusWindowW"));
428
429 return CreateWindowW(STATUSCLASSNAMEW, text, style,
430 CW_USEDEFAULT, CW_USEDEFAULT,
431 CW_USEDEFAULT, CW_USEDEFAULT,
432 parent, wid, 0, 0);
433}
434
435
436/***********************************************************************
437 * CreateUpDownControl [COMCTL32.16] Creates an up-down control
438 *
439 * PARAMS
440 * style [I] window styles
441 * x [I] horizontal position of the control
442 * y [I] vertical position of the control
443 * cx [I] with of the control
444 * cy [I] height of the control
445 * parent [I] handle to the parent window
446 * id [I] the control's identifier
447 * inst [I] handle to the application's module instance
448 * buddy [I] handle to the buddy window, can be NULL
449 * maxVal [I] upper limit of the control
450 * minVal [I] lower limit of the control
451 * curVal [I] current value of the control
452 *
453 * RETURNS
454 * Success: handle to the updown control
455 * Failure: 0
456 */
457
458HWND WINAPI
459CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
460 HWND parent, INT id, HINSTANCE inst,
461 HWND buddy, INT maxVal, INT minVal, INT curVal)
462{
463 HWND hUD;
464
465 dprintf(("COMCTL32: CreateUpDownControl"));
466
467 hUD = CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
468 parent, id, inst, 0);
469 if (hUD) {
470 SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
471 SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
472 SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
473 }
474
475 return hUD;
476}
477
478/***********************************************************************
479 * InitCommonControls [COMCTL32.17]
480 *
481 * Registers the common controls.
482 *
483 * PARAMS
484 * No parameters.
485 *
486 * RETURNS
487 * No return values.
488 *
489 * NOTES
490 * This function is just a dummy.
491 * The Win95 controls are registered at the DLL's initialization.
492 * To register other controls InitCommonControlsEx() must be used.
493 */
494
495VOID WINAPI InitCommonControls(VOID)
496{
497 dprintf(("COMCTL32: InitCommonControls"));
498}
499
500/***********************************************************************
501 * InitCommonControlsEx [COMCTL32.81]
502 *
503 * Registers the common controls.
504 *
505 * PARAMS
506 * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
507 *
508 * RETURNS
509 * Success: TRUE
510 * Failure: FALSE
511 *
512 * NOTES
513 * Only the additinal common controls are registered by this function.
514 * The Win95 controls are registered at the DLL's initialization.
515 */
516
517BOOL WINAPI
518InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
519{
520 INT cCount;
521 DWORD dwMask;
522
523 dprintf(("COMCTL32: InitCommonControlsEx"));
524
525 if (!lpInitCtrls)
526 return FALSE;
527 if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
528 return FALSE;
529
530// TRACE(commctrl,"(0x%08lx)\n", lpInitCtrls->dwICC);
531
532 for (cCount = 0; cCount < 32; cCount++) {
533 dwMask = 1 << cCount;
534 if (!(lpInitCtrls->dwICC & dwMask))
535 continue;
536
537 switch (lpInitCtrls->dwICC & dwMask) {
538 /* dummy initialization */
539 case ICC_ANIMATE_CLASS:
540 case ICC_BAR_CLASSES:
541 case ICC_LISTVIEW_CLASSES:
542 case ICC_TREEVIEW_CLASSES:
543 case ICC_TAB_CLASSES:
544 case ICC_UPDOWN_CLASS:
545 case ICC_PROGRESS_CLASS:
546 case ICC_HOTKEY_CLASS:
547 break;
548
549 /* advanced classes - not included in Win95 */
550 case ICC_DATE_CLASSES:
551 MONTHCAL_Register ();
552 DATETIME_Register ();
553 break;
554
555 case ICC_USEREX_CLASSES:
556 COMBOEX_Register ();
557 break;
558
559 case ICC_COOL_CLASSES:
560 REBAR_Register ();
561 break;
562
563 case ICC_INTERNET_CLASSES:
564 IPADDRESS_Register ();
565 break;
566
567 case ICC_PAGESCROLLER_CLASS:
568 PAGER_Register ();
569 break;
570
571 case ICC_NATIVEFNTCTL_CLASS:
572 NATIVEFONT_Register ();
573 break;
574
575 default:
576// FIXME (commctrl, "Unknown class! dwICC=0x%lX\n", dwMask);
577 break;
578 }
579 }
580
581 return TRUE;
582}
583
584/***********************************************************************
585 * CreateToolbarEx [COMCTL32.32] Creates a tool bar window
586 *
587 * PARAMS
588 * hwnd
589 * style
590 * wID
591 * nBitmaps
592 * hBMInst
593 * wBMID
594 * lpButtons
595 * iNumButtons
596 * dxButton
597 * dyButton
598 * dxBitmap
599 * dyBitmap
600 * uStructSize
601 *
602 * RETURNS
603 * Success: handle to the tool bar control
604 * Failure: 0
605 */
606
607HWND WINAPI
608CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
609 HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
610 INT iNumButtons, INT dxButton, INT dyButton,
611 INT dxBitmap, INT dyBitmap, UINT uStructSize)
612{
613 HWND hwndTB;
614
615 dprintf(("COMCTL32: CreateToolbarEx"));
616
617 hwndTB = CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style, 0, 0, 0, 0,
618 hwnd, (HMENU)wID, 0, NULL);
619 if(hwndTB) {
620 TBADDBITMAP tbab;
621
622 SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
623 (WPARAM)uStructSize, 0);
624
625 /* set bitmap and button size */
626 /*If CreateToolbarEx receive 0, windows set default values*/
627 if (dyBitmap <= 0)
628 dyBitmap = 16;
629 if (dxBitmap <= 0)
630 dxBitmap = 16;
631
632 SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
633 MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap));
634 SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
635 MAKELPARAM((WORD)dxButton, (WORD)dyButton));
636
637
638 /* add bitmaps */
639 if (nBitmaps > 0)
640 {
641 tbab.hInst = hBMInst;
642 tbab.nID = wBMID;
643
644 SendMessageA (hwndTB, TB_ADDBITMAP,
645 (WPARAM)nBitmaps, (LPARAM)&tbab);
646 }
647 /* add buttons */
648 if(iNumButtons > 0)
649 SendMessageA (hwndTB, TB_ADDBUTTONSA,
650 (WPARAM)iNumButtons, (LPARAM)lpButtons);
651 }
652
653 return hwndTB;
654}
655
656
657/***********************************************************************
658 * CreateMappedBitmap [COMCTL32.8]
659 *
660 * PARAMS
661 * hInstance [I]
662 * idBitmap [I]
663 * wFlags [I]
664 * lpColorMap [I]
665 * iNumMaps [I]
666 *
667 * RETURNS
668 * Success: handle to the new bitmap
669 * Failure: 0
670 */
671
672HBITMAP WINAPI
673CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
674 LPCOLORMAP lpColorMap, INT iNumMaps)
675{
676 HGLOBAL hglb;
677 HRSRC hRsrc;
678 LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
679 UINT nSize, nColorTableSize;
680 RGBQUAD *pColorTable;
681 INT iColor, i, iMaps, nWidth, nHeight;
682 HDC hdcScreen;
683 HBITMAP hbm;
684 LPCOLORMAP sysColorMap;
685 COLORREF cRef;
686 COLORMAP internalColorMap[4] =
687 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
688
689 dprintf(("COMCTL32: CreateMappedBitmap"));
690
691 /* initialize pointer to colortable and default color table */
692 if (lpColorMap) {
693 iMaps = iNumMaps;
694 sysColorMap = lpColorMap;
695 }
696 else {
697 internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
698 internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
699 internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
700 internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
701 iMaps = 4;
702 sysColorMap = (LPCOLORMAP)internalColorMap;
703 }
704
705 hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
706 if (hRsrc == 0)
707 return 0;
708 hglb = LoadResource (hInstance, hRsrc);
709 if (hglb == 0)
710 return 0;
711 lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
712 if (lpBitmap == NULL)
713 return 0;
714
715 nColorTableSize = (1 << lpBitmap->biBitCount);
716 nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
717 lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
718 if (lpBitmapInfo == NULL)
719 return 0;
720 RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
721
722 pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
723
724 for (iColor = 0; iColor < nColorTableSize; iColor++) {
725 for (i = 0; i < iMaps; i++) {
726 cRef = RGB(pColorTable[iColor].rgbRed,
727 pColorTable[iColor].rgbGreen,
728 pColorTable[iColor].rgbBlue);
729 if ( cRef == sysColorMap[i].from) {
730#if 0
731 if (wFlags & CBS_MASKED) {
732 if (sysColorMap[i].to != COLOR_BTNTEXT)
733 pColorTable[iColor] = RGB(255, 255, 255);
734 }
735 else
736#endif
737 pColorTable[iColor].rgbBlue = GetBValue(sysColorMap[i].to);
738 pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
739 pColorTable[iColor].rgbRed = GetRValue(sysColorMap[i].to);
740 break;
741 }
742 }
743 }
744 nWidth = (INT)lpBitmapInfo->biWidth;
745 nHeight = (INT)lpBitmapInfo->biHeight;
746 hdcScreen = GetDC ((HWND)0);
747 hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
748 if (hbm) {
749 HDC hdcDst = CreateCompatibleDC (hdcScreen);
750 HBITMAP hbmOld = SelectObject (hdcDst, hbm);
751 LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
752 lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
753 StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
754 lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
755 SRCCOPY);
756 SelectObject (hdcDst, hbmOld);
757 DeleteDC (hdcDst);
758 }
759 ReleaseDC ((HWND)0, hdcScreen);
760 GlobalFree ((HGLOBAL)lpBitmapInfo);
761 FreeResource (hglb);
762
763 return hbm;
764}
765
766
767/***********************************************************************
768 * CreateToolbar [COMCTL32.7] Creates a tool bar control
769 *
770 * PARAMS
771 * hwnd
772 * style
773 * wID
774 * nBitmaps
775 * hBMInst
776 * wBMID
777 * lpButtons
778 * iNumButtons
779 *
780 * RETURNS
781 * Success: handle to the tool bar control
782 * Failure: 0
783 *
784 * NOTES
785 * Do not use this functions anymore. Use CreateToolbarEx instead.
786 */
787
788HWND WINAPI
789CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
790 HINSTANCE hBMInst, UINT wBMID,
791 LPCOLDTBBUTTON lpButtons,INT iNumButtons)
792{
793 dprintf(("COMCTL32: CreateToolbar"));
794
795 return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
796 hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
797 iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
798}
799
800
801/***********************************************************************
802 * DllGetVersion [COMCTL32.25]
803 *
804 * Retrieves version information of the 'COMCTL32.DLL'
805 *
806 * PARAMS
807 * pdvi [O] pointer to version information structure.
808 *
809 * RETURNS
810 * Success: S_OK
811 * Failure: E_INVALIDARG
812 *
813 * NOTES
814 * Returns version of a comctl32.dll from IE4.01 SP1.
815 */
816
817HRESULT WINAPI
818COMCTL32_DllGetVersion (DLLVERSIONINFO *pdvi)
819{
820 dprintf(("COMCTL32: COMCTL32_DllGetVersion"));
821
822 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
823// WARN (commctrl, "wrong DLLVERSIONINFO size from app");
824 return E_INVALIDARG;
825 }
826
827 pdvi->dwMajorVersion = 4;
828 pdvi->dwMinorVersion = 72;
829 pdvi->dwBuildNumber = 3110;
830 pdvi->dwPlatformID = 1;
831
832// TRACE (commctrl, "%lu.%lu.%lu.%lu\n",
833// pdvi->dwMajorVersion, pdvi->dwMinorVersion,
834// pdvi->dwBuildNumber, pdvi->dwPlatformID);
835
836 return S_OK;
837}
838
839static int iTrackMax = 0;
840static HWND TrackingList[10];
841static UINT timer;
842
843static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT idEvent, DWORD dwTime) {
844 int i = 0;
845 POINT pos;
846 HWND hwnd;
847 BOOL keepTracking = FALSE;
848 GetCursorPos(&pos);
849 hwnd = WindowFromPoint(pos);
850 /* Loop through the list of windows waiting on mouse exit */
851 while (i < iTrackMax) {
852 if (TrackingList[i] != hwnd)
853 PostMessageA(TrackingList[i], WM_MOUSELEAVE, 0, 0);
854 else
855 keepTracking = TRUE;
856
857
858 i++;
859 }
860
861 if (keepTracking) {
862 iTrackMax = 1;
863 TrackingList[0] = hwnd;
864 }
865 else
866 KillTimer(0, timer);
867}
868
869/***********************************************************************
870 * _TrackMouseEvent [COMCTL32.25]
871 *
872 * Requests notification of mouse events
873 *
874 * PARAMS
875 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
876 *
877 * RETURNS
878 * Success: non-zero
879 * Failure: zero
880 *
881 */
882
883BOOL WINAPI
884_TrackMouseEvent (TRACKMOUSEEVENT *ptme)
885{
886 DWORD flags = 0;
887 int i;
888 BOOL cancel = 0, hover = 0, leave = 0, query = 0;
889
890 dprintf(("COMCTL32: _TrackMouseEvent"));
891
892 if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
893 //WARN("wrong TRACKMOUSEEVENT size from app");
894 return E_INVALIDARG;
895 }
896
897 flags = ptme->dwFlags;
898 if ( flags & TME_CANCEL ) {
899 cancel = 1;
900 flags &= ~ TME_CANCEL;
901 }
902 if ( flags & TME_HOVER ) {
903 hover = 1;
904 flags &= ~ TME_HOVER;
905 //FIXME("TME_HOVER unimplemented\n" );
906 }
907 if ( flags & TME_LEAVE ) {
908 leave = 1;
909 flags &= ~ TME_LEAVE;
910 }
911 if ( flags & TME_QUERY ) {
912 query = 1;
913 flags &= ~ TME_QUERY;
914 //FIXME("TME_QUERY unimplemented\n" );
915 }
916
917 //if ( flags )
918 // FIXME("Unknown flag(s) %ld\n", flags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_QUERY) );
919
920 if (leave) {
921 if (cancel) {
922 for (i = 0; i < iTrackMax; i++)
923 if (TrackingList[i] == ptme->hwndTrack)
924 TrackingList[i] = TrackingList[--iTrackMax];
925 }
926 else {
927 if (iTrackMax == sizeof (TrackingList) / sizeof *TrackingList)
928 return FALSE;
929
930 /* Add hwndTrack to the track list */
931 TrackingList[iTrackMax++] = ptme->hwndTrack;
932 if (!timer)
933 timer = SetTimer(0, 0, 50, TrackMouseEventProc);
934 }
935 }
936
937 return TRUE;
938}
939
940
Note: See TracBrowser for help on using the repository browser.