2 * Common controls functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1998,2000 Eric Kohl
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Christian Neumair.
26 * Unless otherwise noted, we belive this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features, or bugs, please note them below.
31 * -- implement GetMUILanguage + InitMUILanguage
32 * -- LibMain => DLLMain ("DLLMain takes over the functionality of both the
33 * LibMain and the WEP function.", MSDN)
34 * -- finish NOTES for MenuHelp, GetEffectiveClientRect and GetStatusTextW
35 * -- FIXMEs + BUGS (search for them)
38 * -- ICC_ANIMATE_CLASS
43 * -- ICC_INTERNET_CLASSES
44 * -- ICC_LINK_CLASS (not yet implemented)
45 * -- ICC_LISTVIEW_CLASSES
46 * -- ICC_NATIVEFNTCTL_CLASS
47 * -- ICC_PAGESCROLLER_CLASS
48 * -- ICC_PROGRESS_CLASS
49 * -- ICC_STANDARD_CLASSES (not yet implemented)
51 * -- ICC_TREEVIEW_CLASSES
53 * -- ICC_USEREX_CLASSES
54 * -- ICC_WIN95_CLASSES
69 #define NO_SHLWAPI_STREAM
72 #include "wine/debug.h"
74 WINE_DEFAULT_DEBUG_CHANNEL(commctrl
);
76 extern void ANIMATE_Register(void);
77 extern void ANIMATE_Unregister(void);
78 extern void COMBOEX_Register(void);
79 extern void COMBOEX_Unregister(void);
80 extern void DATETIME_Register(void);
81 extern void DATETIME_Unregister(void);
82 extern void FLATSB_Register(void);
83 extern void FLATSB_Unregister(void);
84 extern void HEADER_Register(void);
85 extern void HEADER_Unregister(void);
86 extern void HOTKEY_Register(void);
87 extern void HOTKEY_Unregister(void);
88 extern void IPADDRESS_Register(void);
89 extern void IPADDRESS_Unregister(void);
90 extern void LISTVIEW_Register(void);
91 extern void LISTVIEW_Unregister(void);
92 extern void MONTHCAL_Register(void);
93 extern void MONTHCAL_Unregister(void);
94 extern void NATIVEFONT_Register(void);
95 extern void NATIVEFONT_Unregister(void);
96 extern void PAGER_Register(void);
97 extern void PAGER_Unregister(void);
98 extern void PROGRESS_Register(void);
99 extern void PROGRESS_Unregister(void);
100 extern void REBAR_Register(void);
101 extern void REBAR_Unregister(void);
102 extern void STATUS_Register(void);
103 extern void STATUS_Unregister(void);
104 extern void TAB_Register(void);
105 extern void TAB_Unregister(void);
106 extern void TOOLBAR_Register(void);
107 extern void TOOLBAR_Unregister(void);
108 extern void TOOLTIPS_Register(void);
109 extern void TOOLTIPS_Unregister(void);
110 extern void TRACKBAR_Register(void);
111 extern void TRACKBAR_Unregister(void);
112 extern void TREEVIEW_Register(void);
113 extern void TREEVIEW_Unregister(void);
114 extern void UPDOWN_Register(void);
115 extern void UPDOWN_Unregister(void);
118 HANDLE COMCTL32_hHeap
= NULL
;
119 LPSTR COMCTL32_aSubclass
= NULL
;
120 HMODULE COMCTL32_hModule
= 0;
121 LANGID COMCTL32_uiLang
= MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
);
122 HBRUSH COMCTL32_hPattern55AABrush
= NULL
;
123 COMCTL32_SysColor comctl32_color
;
125 static HBITMAP COMCTL32_hPattern55AABitmap
= NULL
;
127 static const WORD wPattern55AA
[] =
129 0x5555, 0xaaaa, 0x5555, 0xaaaa,
130 0x5555, 0xaaaa, 0x5555, 0xaaaa
134 /***********************************************************************
135 * DllMain [Internal] Initializes the internal 'COMCTL32.DLL'.
138 * hinstDLL [I] handle to the 'dlls' instance
140 * lpvReserved [I] reserverd, must be NULL
147 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
149 TRACE("%p,%lx,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
152 case DLL_PROCESS_ATTACH
:
153 DisableThreadLibraryCalls(hinstDLL
);
155 COMCTL32_hModule
= (HMODULE
)hinstDLL
;
157 /* create private heap */
158 COMCTL32_hHeap
= HeapCreate (0, 0x10000, 0);
159 TRACE("Heap created: %p\n", COMCTL32_hHeap
);
161 /* add global subclassing atom (used by 'tooltip' and 'updown') */
162 COMCTL32_aSubclass
= (LPSTR
)(DWORD
)GlobalAddAtomA ("CC32SubclassInfo");
163 TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass
);
165 /* create local pattern brush */
166 COMCTL32_hPattern55AABitmap
= CreateBitmap (8, 8, 1, 1, wPattern55AA
);
167 COMCTL32_hPattern55AABrush
= CreatePatternBrush (COMCTL32_hPattern55AABitmap
);
169 /* Get all the colors at DLL load */
170 COMCTL32_RefreshSysColors();
172 /* register all Win95 common control classes */
177 LISTVIEW_Register ();
178 PROGRESS_Register ();
182 TOOLTIPS_Register ();
183 TRACKBAR_Register ();
184 TREEVIEW_Register ();
188 case DLL_PROCESS_DETACH
:
189 /* unregister all common control classes */
190 ANIMATE_Unregister ();
191 COMBOEX_Unregister ();
192 DATETIME_Unregister ();
193 FLATSB_Unregister ();
194 HEADER_Unregister ();
195 HOTKEY_Unregister ();
196 IPADDRESS_Unregister ();
197 LISTVIEW_Unregister ();
198 MONTHCAL_Unregister ();
199 NATIVEFONT_Unregister ();
201 PROGRESS_Unregister ();
203 STATUS_Unregister ();
205 TOOLBAR_Unregister ();
206 TOOLTIPS_Unregister ();
207 TRACKBAR_Unregister ();
208 TREEVIEW_Unregister ();
209 UPDOWN_Unregister ();
211 /* delete local pattern brush */
212 DeleteObject (COMCTL32_hPattern55AABrush
);
213 COMCTL32_hPattern55AABrush
= NULL
;
214 DeleteObject (COMCTL32_hPattern55AABitmap
);
215 COMCTL32_hPattern55AABitmap
= NULL
;
217 /* delete global subclassing atom */
218 GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass
));
219 TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass
);
220 COMCTL32_aSubclass
= NULL
;
222 /* destroy private heap */
223 HeapDestroy (COMCTL32_hHeap
);
224 TRACE("Heap destroyed: %p\n", COMCTL32_hHeap
);
225 COMCTL32_hHeap
= NULL
;
233 /***********************************************************************
234 * MenuHelp [COMCTL32.2]
237 * uMsg [I] message (WM_MENUSELECT) (see NOTES)
238 * wParam [I] wParam of the message uMsg
239 * lParam [I] lParam of the message uMsg
240 * hMainMenu [I] handle to the application's main menu
241 * hInst [I] handle to the module that contains string resources
242 * hwndStatus [I] handle to the status bar window
243 * lpwIDs [I] pointer to an array of integers (see NOTES)
249 * The official documentation is incomplete!
250 * This is the correct documentation:
253 * MenuHelp() does NOT handle WM_COMMAND messages! It only handles
254 * WM_MENUSELECT messages.
257 * (will be written ...)
261 MenuHelp (UINT uMsg
, WPARAM wParam
, LPARAM lParam
, HMENU hMainMenu
,
262 HINSTANCE hInst
, HWND hwndStatus
, UINT
* lpwIDs
)
266 if (!IsWindow (hwndStatus
))
271 TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
274 if ((HIWORD(wParam
) == 0xFFFF) && (lParam
== 0)) {
275 /* menu was closed */
276 TRACE("menu was closed!\n");
277 SendMessageA (hwndStatus
, SB_SIMPLE
, FALSE
, 0);
280 /* menu item was selected */
281 if (HIWORD(wParam
) & MF_POPUP
)
282 uMenuID
= (UINT
)*(lpwIDs
+1);
284 uMenuID
= (UINT
)LOWORD(wParam
);
285 TRACE("uMenuID = %u\n", uMenuID
);
290 if (!LoadStringA (hInst
, uMenuID
, szText
, 256))
293 SendMessageA (hwndStatus
, SB_SETTEXTA
,
294 255 | SBT_NOBORDERS
, (LPARAM
)szText
);
295 SendMessageA (hwndStatus
, SB_SIMPLE
, TRUE
, 0);
301 TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
303 /* WM_COMMAND is not invalid since it is documented
304 * in the windows api reference. So don't output
305 * any FIXME for WM_COMMAND
307 WARN("We don't care about the WM_COMMAND\n");
311 FIXME("Invalid Message 0x%x!\n", uMsg
);
317 /***********************************************************************
318 * ShowHideMenuCtl [COMCTL32.3]
320 * Shows or hides controls and updates the corresponding menu item.
323 * hwnd [I] handle to the client window.
324 * uFlags [I] menu command id.
325 * lpInfo [I] pointer to an array of integers. (See NOTES.)
332 * The official documentation is incomplete!
333 * This is the correct documentation:
336 * Handle to the window that contains the menu and controls.
339 * Identifier of the menu item to receive or loose a check mark.
342 * The array of integers contains pairs of values. BOTH values of
343 * the first pair must be the handles to the application's main menu.
344 * Each subsequent pair consists of a menu id and control id.
348 ShowHideMenuCtl (HWND hwnd
, UINT uFlags
, LPINT lpInfo
)
352 TRACE("%p, %x, %p\n", hwnd
, uFlags
, lpInfo
);
357 if (!(lpInfo
[0]) || !(lpInfo
[1]))
360 /* search for control */
361 lpMenuId
= &lpInfo
[2];
362 while (*lpMenuId
!= uFlags
)
365 if (GetMenuState ((HMENU
)lpInfo
[1], uFlags
, MF_BYCOMMAND
) & MFS_CHECKED
) {
366 /* uncheck menu item */
367 CheckMenuItem ((HMENU
)lpInfo
[0], *lpMenuId
, MF_BYCOMMAND
| MF_UNCHECKED
);
371 SetWindowPos (GetDlgItem (hwnd
, *lpMenuId
), 0, 0, 0, 0, 0,
375 /* check menu item */
376 CheckMenuItem ((HMENU
)lpInfo
[0], *lpMenuId
, MF_BYCOMMAND
| MF_CHECKED
);
380 SetWindowPos (GetDlgItem (hwnd
, *lpMenuId
), 0, 0, 0, 0, 0,
388 /***********************************************************************
389 * GetEffectiveClientRect [COMCTL32.4]
392 * hwnd [I] handle to the client window.
393 * lpRect [O] pointer to the rectangle of the client window
394 * lpInfo [I] pointer to an array of integers (see NOTES)
400 * The official documentation is incomplete!
401 * This is the correct documentation:
404 * (will be written ...)
408 GetEffectiveClientRect (HWND hwnd
, LPRECT lpRect
, LPINT lpInfo
)
414 TRACE("(0x%08lx 0x%08lx 0x%08lx)\n",
415 (DWORD
)hwnd
, (DWORD
)lpRect
, (DWORD
)lpInfo
);
417 GetClientRect (hwnd
, lpRect
);
425 hwndCtrl
= GetDlgItem (hwnd
, *lpRun
);
426 if (GetWindowLongA (hwndCtrl
, GWL_STYLE
) & WS_VISIBLE
) {
427 TRACE("control id 0x%x\n", *lpRun
);
428 GetWindowRect (hwndCtrl
, &rcCtrl
);
429 MapWindowPoints (NULL
, hwnd
, (LPPOINT
)&rcCtrl
, 2);
430 SubtractRect (lpRect
, lpRect
, &rcCtrl
);
437 /***********************************************************************
438 * DrawStatusTextW [COMCTL32.@]
440 * Draws text with borders, like in a status bar.
443 * hdc [I] handle to the window's display context
444 * lprc [I] pointer to a rectangle
445 * text [I] pointer to the text
446 * style [I] drawing style
452 * The style variable can have one of the following values:
453 * (will be written ...)
456 void WINAPI
DrawStatusTextW (HDC hdc
, LPRECT lprc
, LPCWSTR text
, UINT style
)
459 UINT border
= BDR_SUNKENOUTER
;
461 if (style
& SBT_POPOUT
)
462 border
= BDR_RAISEDOUTER
;
463 else if (style
& SBT_NOBORDERS
)
466 DrawEdge (hdc
, &r
, border
, BF_RECT
|BF_ADJUST
);
470 int oldbkmode
= SetBkMode (hdc
, TRANSPARENT
);
471 UINT align
= DT_LEFT
;
472 if (*text
== L
'\t') {
475 if (*text
== L
'\t') {
481 if (style
& SBT_RTLREADING
)
482 FIXME("Unsupported RTL style!\n");
483 DrawTextW (hdc
, text
, -1, &r
, align
|DT_VCENTER
|DT_SINGLELINE
);
484 SetBkMode(hdc
, oldbkmode
);
489 /***********************************************************************
490 * DrawStatusText [COMCTL32.@]
491 * DrawStatusTextA [COMCTL32.5]
493 * Draws text with borders, like in a status bar.
496 * hdc [I] handle to the window's display context
497 * lprc [I] pointer to a rectangle
498 * text [I] pointer to the text
499 * style [I] drawing style
505 void WINAPI
DrawStatusTextA (HDC hdc
, LPRECT lprc
, LPCSTR text
, UINT style
)
511 if ( (len
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 )) ) {
512 if ( (textW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )) )
513 MultiByteToWideChar( CP_ACP
, 0, text
, -1, textW
, len
);
516 DrawStatusTextW( hdc
, lprc
, textW
, style
);
517 HeapFree( GetProcessHeap(), 0, textW
);
521 /***********************************************************************
522 * CreateStatusWindow [COMCTL32.@]
523 * CreateStatusWindowA [COMCTL32.6]
525 * Creates a status bar
528 * style [I] window style
529 * text [I] pointer to the window text
530 * parent [I] handle to the parent window
531 * wid [I] control id of the status bar
534 * Success: handle to the status window
539 CreateStatusWindowA (LONG style
, LPCSTR text
, HWND parent
, UINT wid
)
541 return CreateWindowA(STATUSCLASSNAMEA
, text
, style
,
542 CW_USEDEFAULT
, CW_USEDEFAULT
,
543 CW_USEDEFAULT
, CW_USEDEFAULT
,
544 parent
, (HMENU
)wid
, 0, 0);
548 /***********************************************************************
549 * CreateStatusWindowW [COMCTL32.@] Creates a status bar control
552 * style [I] window style
553 * text [I] pointer to the window text
554 * parent [I] handle to the parent window
555 * wid [I] control id of the status bar
558 * Success: handle to the status window
563 CreateStatusWindowW (LONG style
, LPCWSTR text
, HWND parent
, UINT wid
)
565 return CreateWindowW(STATUSCLASSNAMEW
, text
, style
,
566 CW_USEDEFAULT
, CW_USEDEFAULT
,
567 CW_USEDEFAULT
, CW_USEDEFAULT
,
568 parent
, (HMENU
)wid
, 0, 0);
572 /***********************************************************************
573 * CreateUpDownControl [COMCTL32.16] Creates an up-down control
576 * style [I] window styles
577 * x [I] horizontal position of the control
578 * y [I] vertical position of the control
579 * cx [I] with of the control
580 * cy [I] height of the control
581 * parent [I] handle to the parent window
582 * id [I] the control's identifier
583 * inst [I] handle to the application's module instance
584 * buddy [I] handle to the buddy window, can be NULL
585 * maxVal [I] upper limit of the control
586 * minVal [I] lower limit of the control
587 * curVal [I] current value of the control
590 * Success: handle to the updown control
595 CreateUpDownControl (DWORD style
, INT x
, INT y
, INT cx
, INT cy
,
596 HWND parent
, INT id
, HINSTANCE inst
,
597 HWND buddy
, INT maxVal
, INT minVal
, INT curVal
)
600 CreateWindowA (UPDOWN_CLASSA
, 0, style
, x
, y
, cx
, cy
,
601 parent
, (HMENU
)id
, inst
, 0);
603 SendMessageA (hUD
, UDM_SETBUDDY
, (WPARAM
)buddy
, 0);
604 SendMessageA (hUD
, UDM_SETRANGE
, 0, MAKELONG(maxVal
, minVal
));
605 SendMessageA (hUD
, UDM_SETPOS
, 0, MAKELONG(curVal
, 0));
612 /***********************************************************************
613 * InitCommonControls [COMCTL32.17]
615 * Registers the common controls.
624 * This function is just a dummy.
625 * The Win95 controls are registered at the DLL's initialization.
626 * To register other controls InitCommonControlsEx() must be used.
630 InitCommonControls (void)
635 /***********************************************************************
636 * InitCommonControlsEx [COMCTL32.@]
638 * Registers the common controls.
641 * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
648 * Only the additional common controls are registered by this function.
649 * The Win95 controls are registered at the DLL's initialization.
652 * implement the following control classes:
654 * ICC_STANDARD_CLASSES
658 InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls
)
665 if (lpInitCtrls
->dwSize
!= sizeof(INITCOMMONCONTROLSEX
))
668 TRACE("(0x%08lx)\n", lpInitCtrls
->dwICC
);
670 for (cCount
= 0; cCount
< 32; cCount
++) {
671 dwMask
= 1 << cCount
;
672 if (!(lpInitCtrls
->dwICC
& dwMask
))
675 switch (lpInitCtrls
->dwICC
& dwMask
) {
676 /* dummy initialization */
677 case ICC_ANIMATE_CLASS
:
678 case ICC_BAR_CLASSES
:
679 case ICC_LISTVIEW_CLASSES
:
680 case ICC_TREEVIEW_CLASSES
:
681 case ICC_TAB_CLASSES
:
682 case ICC_UPDOWN_CLASS
:
683 case ICC_PROGRESS_CLASS
:
684 case ICC_HOTKEY_CLASS
:
687 /* advanced classes - not included in Win95 */
688 case ICC_DATE_CLASSES
:
689 MONTHCAL_Register ();
690 DATETIME_Register ();
693 case ICC_USEREX_CLASSES
:
697 case ICC_COOL_CLASSES
:
701 case ICC_INTERNET_CLASSES
:
702 IPADDRESS_Register ();
705 case ICC_PAGESCROLLER_CLASS
:
709 case ICC_NATIVEFNTCTL_CLASS
:
710 NATIVEFONT_Register ();
714 FIXME("Unknown class! dwICC=0x%lX\n", dwMask
);
723 /***********************************************************************
724 * CreateToolbarEx [COMCTL32.@] Creates a tool bar window
742 * Success: handle to the tool bar control
747 CreateToolbarEx (HWND hwnd
, DWORD style
, UINT wID
, INT nBitmaps
,
748 HINSTANCE hBMInst
, UINT wBMID
, LPCTBBUTTON lpButtons
,
749 INT iNumButtons
, INT dxButton
, INT dyButton
,
750 INT dxBitmap
, INT dyBitmap
, UINT uStructSize
)
754 /* If not position is specified then put it at the top */
755 if ((style
& CCS_BOTTOM
) == 0) {
760 CreateWindowExA (0, TOOLBARCLASSNAMEA
, "", style
|WS_CHILD
, 0, 0, 0, 0,
761 hwnd
, (HMENU
)wID
, 0, NULL
);
765 SendMessageA (hwndTB
, TB_BUTTONSTRUCTSIZE
,
766 (WPARAM
)uStructSize
, 0);
768 /* set bitmap and button size */
769 /*If CreateToolbarEx receives 0, windows sets default values*/
774 SendMessageA (hwndTB
, TB_SETBITMAPSIZE
, 0,
775 MAKELPARAM((WORD
)dxBitmap
, (WORD
)dyBitmap
));
781 SendMessageA (hwndTB
, TB_SETBUTTONSIZE
, 0,
782 MAKELPARAM((WORD
)dxButton
, (WORD
)dyButton
));
788 tbab
.hInst
= hBMInst
;
791 SendMessageA (hwndTB
, TB_ADDBITMAP
,
792 (WPARAM
)nBitmaps
, (LPARAM
)&tbab
);
796 SendMessageA (hwndTB
, TB_ADDBUTTONSA
,
797 (WPARAM
)iNumButtons
, (LPARAM
)lpButtons
);
804 /***********************************************************************
805 * CreateMappedBitmap [COMCTL32.8]
815 * Success: handle to the new bitmap
820 CreateMappedBitmap (HINSTANCE hInstance
, INT idBitmap
, UINT wFlags
,
821 LPCOLORMAP lpColorMap
, INT iNumMaps
)
825 LPBITMAPINFOHEADER lpBitmap
, lpBitmapInfo
;
826 UINT nSize
, nColorTableSize
;
827 RGBQUAD
*pColorTable
;
828 INT iColor
, i
, iMaps
, nWidth
, nHeight
;
831 LPCOLORMAP sysColorMap
;
833 COLORMAP internalColorMap
[4] =
834 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
836 /* initialize pointer to colortable and default color table */
839 sysColorMap
= lpColorMap
;
842 internalColorMap
[0].to
= GetSysColor (COLOR_BTNTEXT
);
843 internalColorMap
[1].to
= GetSysColor (COLOR_BTNSHADOW
);
844 internalColorMap
[2].to
= GetSysColor (COLOR_BTNFACE
);
845 internalColorMap
[3].to
= GetSysColor (COLOR_BTNHIGHLIGHT
);
847 sysColorMap
= (LPCOLORMAP
)internalColorMap
;
850 hRsrc
= FindResourceA (hInstance
, (LPSTR
)idBitmap
, RT_BITMAPA
);
853 hglb
= LoadResource (hInstance
, hRsrc
);
856 lpBitmap
= (LPBITMAPINFOHEADER
)LockResource (hglb
);
857 if (lpBitmap
== NULL
)
860 nColorTableSize
= (1 << lpBitmap
->biBitCount
);
861 nSize
= lpBitmap
->biSize
+ nColorTableSize
* sizeof(RGBQUAD
);
862 lpBitmapInfo
= (LPBITMAPINFOHEADER
)GlobalAlloc (GMEM_FIXED
, nSize
);
863 if (lpBitmapInfo
== NULL
)
865 RtlMoveMemory (lpBitmapInfo
, lpBitmap
, nSize
);
867 pColorTable
= (RGBQUAD
*)(((LPBYTE
)lpBitmapInfo
)+(UINT
)lpBitmapInfo
->biSize
);
869 for (iColor
= 0; iColor
< nColorTableSize
; iColor
++) {
870 for (i
= 0; i
< iMaps
; i
++) {
871 cRef
= RGB(pColorTable
[iColor
].rgbRed
,
872 pColorTable
[iColor
].rgbGreen
,
873 pColorTable
[iColor
].rgbBlue
);
874 if ( cRef
== sysColorMap
[i
].from
) {
876 if (wFlags
& CBS_MASKED
) {
877 if (sysColorMap
[i
].to
!= COLOR_BTNTEXT
)
878 pColorTable
[iColor
] = RGB(255, 255, 255);
882 pColorTable
[iColor
].rgbBlue
= GetBValue(sysColorMap
[i
].to
);
883 pColorTable
[iColor
].rgbGreen
= GetGValue(sysColorMap
[i
].to
);
884 pColorTable
[iColor
].rgbRed
= GetRValue(sysColorMap
[i
].to
);
889 nWidth
= (INT
)lpBitmapInfo
->biWidth
;
890 nHeight
= (INT
)lpBitmapInfo
->biHeight
;
891 hdcScreen
= GetDC (NULL
);
892 hbm
= CreateCompatibleBitmap (hdcScreen
, nWidth
, nHeight
);
894 HDC hdcDst
= CreateCompatibleDC (hdcScreen
);
895 HBITMAP hbmOld
= SelectObject (hdcDst
, hbm
);
896 LPBYTE lpBits
= (LPBYTE
)(lpBitmap
+ 1);
897 lpBits
+= (1 << (lpBitmapInfo
->biBitCount
)) * sizeof(RGBQUAD
);
898 StretchDIBits (hdcDst
, 0, 0, nWidth
, nHeight
, 0, 0, nWidth
, nHeight
,
899 lpBits
, (LPBITMAPINFO
)lpBitmapInfo
, DIB_RGB_COLORS
,
901 SelectObject (hdcDst
, hbmOld
);
904 ReleaseDC (NULL
, hdcScreen
);
905 GlobalFree ((HGLOBAL
)lpBitmapInfo
);
912 /***********************************************************************
913 * CreateToolbar [COMCTL32.7] Creates a tool bar control
926 * Success: handle to the tool bar control
930 * Do not use this functions anymore. Use CreateToolbarEx instead.
934 CreateToolbar (HWND hwnd
, DWORD style
, UINT wID
, INT nBitmaps
,
935 HINSTANCE hBMInst
, UINT wBMID
,
936 LPCTBBUTTON lpButtons
,INT iNumButtons
)
938 return CreateToolbarEx (hwnd
, style
| CCS_NODIVIDER
, wID
, nBitmaps
,
939 hBMInst
, wBMID
, lpButtons
,
940 iNumButtons
, 0, 0, 0, 0, CCSIZEOF_STRUCT(TBBUTTON
, dwData
));
944 /***********************************************************************
945 * DllGetVersion [COMCTL32.@]
947 * Retrieves version information of the 'COMCTL32.DLL'
950 * pdvi [O] pointer to version information structure.
954 * Failure: E_INVALIDARG
957 * Returns version of a comctl32.dll from IE4.01 SP1.
961 COMCTL32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
963 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
)) {
964 WARN("wrong DLLVERSIONINFO size from app\n");
968 pdvi
->dwMajorVersion
= COMCTL32_VERSION
;
969 pdvi
->dwMinorVersion
= COMCTL32_VERSION_MINOR
;
970 pdvi
->dwBuildNumber
= 2919;
971 pdvi
->dwPlatformID
= 6304;
973 TRACE("%lu.%lu.%lu.%lu\n",
974 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
975 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
980 /***********************************************************************
981 * DllInstall (COMCTL32.@)
983 HRESULT WINAPI
COMCTL32_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
985 FIXME("(%s, %s): stub\n", bInstall
?"TRUE":"FALSE",
986 debugstr_w(cmdline
));
991 /***********************************************************************
992 * _TrackMouseEvent [COMCTL32.@]
994 * Requests notification of mouse events
996 * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
997 * to the hwnd specified in the ptme structure. After the event message
998 * is posted to the hwnd, the entry in the queue is removed.
1000 * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
1001 * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
1002 * immediately and the TME_LEAVE flag being ignored.
1005 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
1011 * IMPLEMENTATION moved to USER32.TrackMouseEvent
1016 _TrackMouseEvent (TRACKMOUSEEVENT
*ptme
)
1018 return TrackMouseEvent (ptme
);
1021 /*************************************************************************
1022 * GetMUILanguage [COMCTL32.@]
1024 * FIXME: "Returns the language currently in use by the common controls
1025 * for a particular process." (MSDN)
1028 LANGID WINAPI
GetMUILanguage (VOID
)
1030 return COMCTL32_uiLang
;
1034 /*************************************************************************
1035 * InitMUILanguage [COMCTL32.@]
1037 * FIXME: "Enables an application to specify a language to be used with
1038 * the common controls that is different than the system language." (MSDN)
1042 VOID WINAPI
InitMUILanguage (LANGID uiLang
)
1044 COMCTL32_uiLang
= uiLang
;
1048 /***********************************************************************
1049 * SetWindowSubclass [COMCTL32.410]
1051 * Starts a window subclass
1054 * hWnd [in] handle to window subclass.
1055 * pfnSubclass [in] Pointer to new window procedure.
1056 * uIDSubclass [in] Unique identifier of sublass together with pfnSubclass.
1057 * dwRef [in] Reference data to pass to window procedure.
1064 * If an application manually subclasses a window after subclassing it with
1065 * this API and then with this API again, then none of the previous
1066 * subclasses get called or the origional window procedure.
1069 BOOL WINAPI
SetWindowSubclass (HWND hWnd
, SUBCLASSPROC pfnSubclass
,
1070 UINT_PTR uIDSubclass
, DWORD_PTR dwRef
)
1072 LPSUBCLASS_INFO stack
;
1075 TRACE ("(%p, %p, %x, %lx)\n", hWnd
, pfnSubclass
, uIDSubclass
, dwRef
);
1077 /* Since the window procedure that we set here has two additional arguments,
1078 * we can't simply set it as the new window procedure of the window. So we
1079 * set our own window procedure and then calculate the other two arguments
1082 /* See if we have been called for this window */
1083 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1085 /* allocate stack */
1086 stack
= (LPSUBCLASS_INFO
)HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY
,
1087 sizeof(SUBCLASS_INFO
));
1089 ERR ("Failed to allocate our Subclassing stack");
1092 SetPropA (hWnd
, COMCTL32_aSubclass
, (HANDLE
)stack
);
1094 /* set window procedure to our own and save the current one */
1095 if (IsWindowUnicode (hWnd
))
1096 stack
->origproc
= (WNDPROC
)SetWindowLongW (hWnd
, GWL_WNDPROC
,
1097 (LONG
)DefSubclassProc
);
1099 stack
->origproc
= (WNDPROC
)SetWindowLongA (hWnd
, GWL_WNDPROC
,
1100 (LONG
)DefSubclassProc
);
1103 if (IsWindowUnicode (hWnd
))
1104 current
= (WNDPROC
)GetWindowLongW (hWnd
, GWL_WNDPROC
);
1106 current
= (WNDPROC
)GetWindowLongA (hWnd
, GWL_WNDPROC
);
1108 if (current
!= DefSubclassProc
) {
1109 ERR ("Application has subclassed with our procedure, then manually, then with us again. The current implementation can't handle this.\n");
1114 /* Check to see if we have called this function with the same uIDSubClass
1115 * and pfnSubclass */
1116 for (n
= 0; n
<= stack
->stacknum
+ stack
->stacknew
- 1; n
++)
1117 if ((stack
->SubclassProcs
[n
].id
== uIDSubclass
) &&
1118 (stack
->SubclassProcs
[n
].subproc
== pfnSubclass
)) {
1119 stack
->SubclassProcs
[n
].ref
= dwRef
;
1123 if ((stack
->stacknum
+ stack
->stacknew
) >= 32) {
1124 ERR ("We have a Subclass stack overflow, please increment size");
1128 /* we can't simply increment both stackpos and stacknum because there might
1129 * be a window procedure running lower in the stack, we can only get them
1130 * up to date once the last window procedure has run */
1131 if (stack
->stacknum
== stack
->stackpos
) {
1137 newnum
= stack
->stacknew
+ stack
->stacknum
- 1;
1139 stack
->SubclassProcs
[newnum
].subproc
= pfnSubclass
;
1140 stack
->SubclassProcs
[newnum
].ref
= dwRef
;
1141 stack
->SubclassProcs
[newnum
].id
= uIDSubclass
;
1147 /***********************************************************************
1148 * GetWindowSubclass [COMCTL32.411]
1150 * Gets the Reference data from a subclass.
1153 * hWnd [in] Handle to window which were subclassing
1154 * pfnSubclass [in] Pointer to the subclass procedure
1155 * uID [in] Unique indentifier of the subclassing procedure
1156 * pdwRef [out] Pointer to the reference data
1163 BOOL WINAPI
GetWindowSubclass (HWND hWnd
, SUBCLASSPROC pfnSubclass
,
1164 UINT_PTR uID
, DWORD_PTR
*pdwRef
)
1166 LPSUBCLASS_INFO stack
;
1169 TRACE ("(%p, %p, %x, %p)\n", hWnd
, pfnSubclass
, uID
, pdwRef
);
1171 /* See if we have been called for this window */
1172 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1176 for (n
= 0; n
<= stack
->stacknum
+ stack
->stacknew
- 1; n
++)
1177 if ((stack
->SubclassProcs
[n
].id
== uID
) &&
1178 (stack
->SubclassProcs
[n
].subproc
== pfnSubclass
)) {
1179 *pdwRef
= stack
->SubclassProcs
[n
].ref
;
1187 /***********************************************************************
1188 * RemoveWindowSubclass [COMCTL32.412]
1190 * Removes a window subclass.
1193 * hWnd [in] Handle to the window were subclassing
1194 * pfnSubclass [in] Pointer to the subclass procedure
1195 * uID [in] Unique identifier of this subclass
1202 BOOL WINAPI
RemoveWindowSubclass(HWND hWnd
, SUBCLASSPROC pfnSubclass
, UINT_PTR uID
)
1204 LPSUBCLASS_INFO stack
;
1207 TRACE ("(%p, %p, %x)\n", hWnd
, pfnSubclass
, uID
);
1209 /* Find the Subclass to remove */
1210 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1214 if ((stack
->stacknum
== stack
->stackpos
== 1) && !stack
->stacknew
) {
1215 TRACE("Last Subclass removed, cleaning up\n");
1216 /* clean up our heap and reset the origional window procedure */
1217 if (IsWindowUnicode (hWnd
))
1218 SetWindowLongW (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1220 SetWindowLongA (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1221 HeapFree (GetProcessHeap (), 0, stack
);
1222 RemovePropA( hWnd
, COMCTL32_aSubclass
);
1226 for (n
= stack
->stacknum
+ stack
->stacknew
- 1; n
>= 0; n
--)
1227 if ((stack
->SubclassProcs
[n
].id
== uID
) &&
1228 (stack
->SubclassProcs
[n
].subproc
== pfnSubclass
)) {
1229 if (n
!= (stack
->stacknum
+ stack
->stacknew
))
1230 /* Fill the hole in the stack */
1231 memmove (&stack
->SubclassProcs
[n
], &stack
->SubclassProcs
[n
+ 1],
1232 sizeof(stack
->SubclassProcs
[0]) * (stack
->stacknew
+ stack
->stacknum
- n
));
1233 stack
->SubclassProcs
[n
].subproc
= NULL
;
1234 stack
->SubclassProcs
[n
].ref
= 0;
1235 stack
->SubclassProcs
[n
].id
= 0;
1237 /* If we are currently running a window procedure we have to manipulate
1238 * the stack position pointers so that we don't corrupt the stack */
1239 if ((n
< stack
->stackpos
) || (stack
->stackpos
== stack
->stacknum
)) {
1242 } else if (n
>= stack
->stackpos
)
1251 /***********************************************************************
1252 * DefSubclassProc [COMCTL32.413]
1254 * Calls the next window procedure (ie. the one before this subclass)
1257 * hWnd [in] The window that we're subclassing
1259 * wParam [in] WPARAM
1260 * lParam [in] LPARAM
1267 LRESULT WINAPI
DefSubclassProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1269 LPSUBCLASS_INFO stack
;
1273 /* retrieve our little stack from the Properties */
1274 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1276 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd
);
1280 /* If we are at pos 0 then we have to call the origional window procedure */
1281 if (stack
->stackpos
== 0) {
1282 if (IsWindowUnicode (hWnd
))
1283 return CallWindowProcW (stack
->origproc
, hWnd
, uMsg
, wParam
, lParam
);
1285 return CallWindowProcA (stack
->origproc
, hWnd
, uMsg
, wParam
, lParam
);
1288 stackpos
= --stack
->stackpos
;
1289 /* call the Subclass procedure from the stack */
1290 ret
= stack
->SubclassProcs
[stackpos
].subproc (hWnd
, uMsg
, wParam
, lParam
,
1291 stack
->SubclassProcs
[stackpos
].id
, stack
->SubclassProcs
[stackpos
].ref
);
1294 if ((stack
->stackpos
== stack
->stacknum
) && stack
->stacknew
) {
1295 stack
->stacknum
+= stack
->stacknew
;
1296 stack
->stackpos
+= stack
->stacknew
;
1297 stack
->stacknew
= 0;
1300 /* If we removed the last entry in our stack while a window procedure was
1301 * running then we have to clean up */
1302 if (stack
->stackpos
== stack
->stacknum
== 0) {
1303 TRACE("Last Subclass removed, cleaning up\n");
1304 /* clean up our heap and reset the origional window procedure */
1305 if (IsWindowUnicode (hWnd
))
1306 SetWindowLongW (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1308 SetWindowLongA (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1309 HeapFree (GetProcessHeap (), 0, stack
);
1310 RemovePropA( hWnd
, COMCTL32_aSubclass
);
1318 /***********************************************************************
1319 * COMCTL32_CreateToolTip [NOT AN API]
1321 * Creates a tooltip for the control specified in hwnd and does all
1322 * necessary setup and notifications.
1325 * hwndOwner [I] Handle to the window that will own the tool tip.
1328 * Success: Handle of tool tip window.
1333 COMCTL32_CreateToolTip(HWND hwndOwner
)
1337 hwndToolTip
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
1338 CW_USEDEFAULT
, CW_USEDEFAULT
,
1339 CW_USEDEFAULT
, CW_USEDEFAULT
, hwndOwner
,
1342 /* Send NM_TOOLTIPSCREATED notification */
1345 NMTOOLTIPSCREATED nmttc
;
1346 /* true owner can be different if hwndOwner is a child window */
1347 HWND hwndTrueOwner
= GetWindow(hwndToolTip
, GW_OWNER
);
1348 nmttc
.hdr
.hwndFrom
= hwndTrueOwner
;
1349 nmttc
.hdr
.idFrom
= GetWindowLongA(hwndTrueOwner
, GWL_ID
);
1350 nmttc
.hdr
.code
= NM_TOOLTIPSCREATED
;
1351 nmttc
.hwndToolTips
= hwndToolTip
;
1353 SendMessageA(GetParent(hwndTrueOwner
), WM_NOTIFY
,
1354 (WPARAM
)GetWindowLongA(hwndTrueOwner
, GWL_ID
),
1362 /***********************************************************************
1363 * COMCTL32_RefreshSysColors [NOT AN API]
1365 * Invoked on any control recognizing a WM_SYSCOLORCHANGE message to
1366 * refresh the color values in the color structure
1376 COMCTL32_RefreshSysColors(void)
1378 comctl32_color
.clrBtnHighlight
= GetSysColor (COLOR_BTNHIGHLIGHT
);
1379 comctl32_color
.clrBtnShadow
= GetSysColor (COLOR_BTNSHADOW
);
1380 comctl32_color
.clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
1381 comctl32_color
.clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
1382 comctl32_color
.clrHighlight
= GetSysColor (COLOR_HIGHLIGHT
);
1383 comctl32_color
.clrHighlightText
= GetSysColor (COLOR_HIGHLIGHTTEXT
);
1384 comctl32_color
.clr3dHilight
= GetSysColor (COLOR_3DHILIGHT
);
1385 comctl32_color
.clr3dShadow
= GetSysColor (COLOR_3DSHADOW
);
1386 comctl32_color
.clr3dDkShadow
= GetSysColor (COLOR_3DDKSHADOW
);
1387 comctl32_color
.clr3dFace
= GetSysColor (COLOR_3DFACE
);
1388 comctl32_color
.clrWindow
= GetSysColor (COLOR_WINDOW
);
1389 comctl32_color
.clrWindowText
= GetSysColor (COLOR_WINDOWTEXT
);
1390 comctl32_color
.clrGrayText
= GetSysColor (COLOR_GRAYTEXT
);
1391 comctl32_color
.clrActiveCaption
= GetSysColor (COLOR_ACTIVECAPTION
);
1392 comctl32_color
.clrInfoBk
= GetSysColor (COLOR_INFOBK
);
1393 comctl32_color
.clrInfoText
= GetSysColor (COLOR_INFOTEXT
);