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 believe 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);
117 static LRESULT WINAPI
SubclassWndProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
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 /***********************************************************************
137 * Initializes the internal 'COMCTL32.DLL'.
140 * hinstDLL [I] handle to the 'dlls' instance
142 * lpvReserved [I] reserverd, must be NULL
149 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
151 TRACE("%p,%lx,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
154 case DLL_PROCESS_ATTACH
:
155 DisableThreadLibraryCalls(hinstDLL
);
157 COMCTL32_hModule
= (HMODULE
)hinstDLL
;
159 /* add global subclassing atom (used by 'tooltip' and 'updown') */
160 COMCTL32_aSubclass
= (LPSTR
)(DWORD
)GlobalAddAtomA ("CC32SubclassInfo");
161 TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass
);
163 /* create local pattern brush */
164 COMCTL32_hPattern55AABitmap
= CreateBitmap (8, 8, 1, 1, wPattern55AA
);
165 COMCTL32_hPattern55AABrush
= CreatePatternBrush (COMCTL32_hPattern55AABitmap
);
167 /* Get all the colors at DLL load */
168 COMCTL32_RefreshSysColors();
170 /* register all Win95 common control classes */
175 LISTVIEW_Register ();
176 PROGRESS_Register ();
180 TOOLTIPS_Register ();
181 TRACKBAR_Register ();
182 TREEVIEW_Register ();
186 case DLL_PROCESS_DETACH
:
187 /* unregister all common control classes */
188 ANIMATE_Unregister ();
189 COMBOEX_Unregister ();
190 DATETIME_Unregister ();
191 FLATSB_Unregister ();
192 HEADER_Unregister ();
193 HOTKEY_Unregister ();
194 IPADDRESS_Unregister ();
195 LISTVIEW_Unregister ();
196 MONTHCAL_Unregister ();
197 NATIVEFONT_Unregister ();
199 PROGRESS_Unregister ();
201 STATUS_Unregister ();
203 TOOLBAR_Unregister ();
204 TOOLTIPS_Unregister ();
205 TRACKBAR_Unregister ();
206 TREEVIEW_Unregister ();
207 UPDOWN_Unregister ();
209 /* delete local pattern brush */
210 DeleteObject (COMCTL32_hPattern55AABrush
);
211 COMCTL32_hPattern55AABrush
= NULL
;
212 DeleteObject (COMCTL32_hPattern55AABitmap
);
213 COMCTL32_hPattern55AABitmap
= NULL
;
215 /* delete global subclassing atom */
216 GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass
));
217 TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass
);
218 COMCTL32_aSubclass
= NULL
;
226 /***********************************************************************
227 * MenuHelp [COMCTL32.2]
229 * Handles the setting of status bar help messages when the user
230 * selects menu items.
233 * uMsg [I] message (WM_MENUSELECT) (see NOTES)
234 * wParam [I] wParam of the message uMsg
235 * lParam [I] lParam of the message uMsg
236 * hMainMenu [I] handle to the application's main menu
237 * hInst [I] handle to the module that contains string resources
238 * hwndStatus [I] handle to the status bar window
239 * lpwIDs [I] pointer to an array of integers (see NOTES)
245 * The official documentation is incomplete!
246 * This is the correct documentation:
249 * MenuHelp() does NOT handle WM_COMMAND messages! It only handles
250 * WM_MENUSELECT messages.
253 * (will be written ...)
257 MenuHelp (UINT uMsg
, WPARAM wParam
, LPARAM lParam
, HMENU hMainMenu
,
258 HINSTANCE hInst
, HWND hwndStatus
, UINT
* lpwIDs
)
262 if (!IsWindow (hwndStatus
))
267 TRACE("WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
270 if ((HIWORD(wParam
) == 0xFFFF) && (lParam
== 0)) {
271 /* menu was closed */
272 TRACE("menu was closed!\n");
273 SendMessageA (hwndStatus
, SB_SIMPLE
, FALSE
, 0);
276 /* menu item was selected */
277 if (HIWORD(wParam
) & MF_POPUP
)
278 uMenuID
= (UINT
)*(lpwIDs
+1);
280 uMenuID
= (UINT
)LOWORD(wParam
);
281 TRACE("uMenuID = %u\n", uMenuID
);
286 if (!LoadStringA (hInst
, uMenuID
, szText
, 256))
289 SendMessageA (hwndStatus
, SB_SETTEXTA
,
290 255 | SBT_NOBORDERS
, (LPARAM
)szText
);
291 SendMessageA (hwndStatus
, SB_SIMPLE
, TRUE
, 0);
297 TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
299 /* WM_COMMAND is not invalid since it is documented
300 * in the windows api reference. So don't output
301 * any FIXME for WM_COMMAND
303 WARN("We don't care about the WM_COMMAND\n");
307 FIXME("Invalid Message 0x%x!\n", uMsg
);
313 /***********************************************************************
314 * ShowHideMenuCtl [COMCTL32.3]
316 * Shows or hides controls and updates the corresponding menu item.
319 * hwnd [I] handle to the client window.
320 * uFlags [I] menu command id.
321 * lpInfo [I] pointer to an array of integers. (See NOTES.)
328 * The official documentation is incomplete!
329 * This is the correct documentation:
332 * Handle to the window that contains the menu and controls.
335 * Identifier of the menu item to receive or loose a check mark.
338 * The array of integers contains pairs of values. BOTH values of
339 * the first pair must be the handles to the application's main menu.
340 * Each subsequent pair consists of a menu id and control id.
344 ShowHideMenuCtl (HWND hwnd
, UINT uFlags
, LPINT lpInfo
)
348 TRACE("%p, %x, %p\n", hwnd
, uFlags
, lpInfo
);
353 if (!(lpInfo
[0]) || !(lpInfo
[1]))
356 /* search for control */
357 lpMenuId
= &lpInfo
[2];
358 while (*lpMenuId
!= uFlags
)
361 if (GetMenuState ((HMENU
)lpInfo
[1], uFlags
, MF_BYCOMMAND
) & MFS_CHECKED
) {
362 /* uncheck menu item */
363 CheckMenuItem ((HMENU
)lpInfo
[0], *lpMenuId
, MF_BYCOMMAND
| MF_UNCHECKED
);
367 SetWindowPos (GetDlgItem (hwnd
, *lpMenuId
), 0, 0, 0, 0, 0,
371 /* check menu item */
372 CheckMenuItem ((HMENU
)lpInfo
[0], *lpMenuId
, MF_BYCOMMAND
| MF_CHECKED
);
376 SetWindowPos (GetDlgItem (hwnd
, *lpMenuId
), 0, 0, 0, 0, 0,
384 /***********************************************************************
385 * GetEffectiveClientRect [COMCTL32.4]
387 * Calculates the coordinates of a rectangle in the client area.
390 * hwnd [I] handle to the client window.
391 * lpRect [O] pointer to the rectangle of the client window
392 * lpInfo [I] pointer to an array of integers (see NOTES)
398 * The official documentation is incomplete!
399 * This is the correct documentation:
402 * (will be written ...)
406 GetEffectiveClientRect (HWND hwnd
, LPRECT lpRect
, LPINT lpInfo
)
412 TRACE("(0x%08lx 0x%08lx 0x%08lx)\n",
413 (DWORD
)hwnd
, (DWORD
)lpRect
, (DWORD
)lpInfo
);
415 GetClientRect (hwnd
, lpRect
);
423 hwndCtrl
= GetDlgItem (hwnd
, *lpRun
);
424 if (GetWindowLongA (hwndCtrl
, GWL_STYLE
) & WS_VISIBLE
) {
425 TRACE("control id 0x%x\n", *lpRun
);
426 GetWindowRect (hwndCtrl
, &rcCtrl
);
427 MapWindowPoints (NULL
, hwnd
, (LPPOINT
)&rcCtrl
, 2);
428 SubtractRect (lpRect
, lpRect
, &rcCtrl
);
435 /***********************************************************************
436 * DrawStatusTextW [COMCTL32.@]
438 * Draws text with borders, like in a status bar.
441 * hdc [I] handle to the window's display context
442 * lprc [I] pointer to a rectangle
443 * text [I] pointer to the text
444 * style [I] drawing style
450 * The style variable can have one of the following values:
451 * (will be written ...)
454 void WINAPI
DrawStatusTextW (HDC hdc
, LPRECT lprc
, LPCWSTR text
, UINT style
)
457 UINT border
= BDR_SUNKENOUTER
;
459 if (style
& SBT_POPOUT
)
460 border
= BDR_RAISEDOUTER
;
461 else if (style
& SBT_NOBORDERS
)
464 DrawEdge (hdc
, &r
, border
, BF_RECT
|BF_ADJUST
);
468 int oldbkmode
= SetBkMode (hdc
, TRANSPARENT
);
469 UINT align
= DT_LEFT
;
470 if (*text
== L
'\t') {
473 if (*text
== L
'\t') {
479 if (style
& SBT_RTLREADING
)
480 FIXME("Unsupported RTL style!\n");
481 DrawTextW (hdc
, text
, -1, &r
, align
|DT_VCENTER
|DT_SINGLELINE
);
482 SetBkMode(hdc
, oldbkmode
);
487 /***********************************************************************
488 * DrawStatusText [COMCTL32.@]
489 * DrawStatusTextA [COMCTL32.5]
491 * Draws text with borders, like in a status bar.
494 * hdc [I] handle to the window's display context
495 * lprc [I] pointer to a rectangle
496 * text [I] pointer to the text
497 * style [I] drawing style
503 void WINAPI
DrawStatusTextA (HDC hdc
, LPRECT lprc
, LPCSTR text
, UINT style
)
509 if ( (len
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 )) ) {
510 if ( (textW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) )) )
511 MultiByteToWideChar( CP_ACP
, 0, text
, -1, textW
, len
);
514 DrawStatusTextW( hdc
, lprc
, textW
, style
);
515 HeapFree( GetProcessHeap(), 0, textW
);
519 /***********************************************************************
520 * CreateStatusWindow [COMCTL32.@]
521 * CreateStatusWindowA [COMCTL32.6]
523 * Creates a status bar
526 * style [I] window style
527 * text [I] pointer to the window text
528 * parent [I] handle to the parent window
529 * wid [I] control id of the status bar
532 * Success: handle to the status window
537 CreateStatusWindowA (LONG style
, LPCSTR text
, HWND parent
, UINT wid
)
539 return CreateWindowA(STATUSCLASSNAMEA
, text
, style
,
540 CW_USEDEFAULT
, CW_USEDEFAULT
,
541 CW_USEDEFAULT
, CW_USEDEFAULT
,
542 parent
, (HMENU
)wid
, 0, 0);
546 /***********************************************************************
547 * CreateStatusWindowW [COMCTL32.@]
549 * 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]
575 * Creates an up-down control
578 * style [I] window styles
579 * x [I] horizontal position of the control
580 * y [I] vertical position of the control
581 * cx [I] with of the control
582 * cy [I] height of the control
583 * parent [I] handle to the parent window
584 * id [I] the control's identifier
585 * inst [I] handle to the application's module instance
586 * buddy [I] handle to the buddy window, can be NULL
587 * maxVal [I] upper limit of the control
588 * minVal [I] lower limit of the control
589 * curVal [I] current value of the control
592 * Success: handle to the updown control
597 CreateUpDownControl (DWORD style
, INT x
, INT y
, INT cx
, INT cy
,
598 HWND parent
, INT id
, HINSTANCE inst
,
599 HWND buddy
, INT maxVal
, INT minVal
, INT curVal
)
602 CreateWindowA (UPDOWN_CLASSA
, 0, style
, x
, y
, cx
, cy
,
603 parent
, (HMENU
)id
, inst
, 0);
605 SendMessageA (hUD
, UDM_SETBUDDY
, (WPARAM
)buddy
, 0);
606 SendMessageA (hUD
, UDM_SETRANGE
, 0, MAKELONG(maxVal
, minVal
));
607 SendMessageA (hUD
, UDM_SETPOS
, 0, MAKELONG(curVal
, 0));
614 /***********************************************************************
615 * InitCommonControls [COMCTL32.17]
617 * Registers the common controls.
626 * This function is just a dummy.
627 * The Win95 controls are registered at the DLL's initialization.
628 * To register other controls InitCommonControlsEx() must be used.
632 InitCommonControls (void)
637 /***********************************************************************
638 * InitCommonControlsEx [COMCTL32.@]
640 * Registers the common controls.
643 * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
650 * Only the additional common controls are registered by this function.
651 * The Win95 controls are registered at the DLL's initialization.
654 * implement the following control classes:
656 * ICC_STANDARD_CLASSES
660 InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls
)
667 if (lpInitCtrls
->dwSize
!= sizeof(INITCOMMONCONTROLSEX
))
670 TRACE("(0x%08lx)\n", lpInitCtrls
->dwICC
);
672 for (cCount
= 0; cCount
< 32; cCount
++) {
673 dwMask
= 1 << cCount
;
674 if (!(lpInitCtrls
->dwICC
& dwMask
))
677 switch (lpInitCtrls
->dwICC
& dwMask
) {
678 /* dummy initialization */
679 case ICC_ANIMATE_CLASS
:
680 case ICC_BAR_CLASSES
:
681 case ICC_LISTVIEW_CLASSES
:
682 case ICC_TREEVIEW_CLASSES
:
683 case ICC_TAB_CLASSES
:
684 case ICC_UPDOWN_CLASS
:
685 case ICC_PROGRESS_CLASS
:
686 case ICC_HOTKEY_CLASS
:
689 /* advanced classes - not included in Win95 */
690 case ICC_DATE_CLASSES
:
691 MONTHCAL_Register ();
692 DATETIME_Register ();
695 case ICC_USEREX_CLASSES
:
699 case ICC_COOL_CLASSES
:
703 case ICC_INTERNET_CLASSES
:
704 IPADDRESS_Register ();
707 case ICC_PAGESCROLLER_CLASS
:
711 case ICC_NATIVEFNTCTL_CLASS
:
712 NATIVEFONT_Register ();
716 FIXME("Unknown class! dwICC=0x%lX\n", dwMask
);
725 /***********************************************************************
726 * CreateToolbarEx [COMCTL32.@]
728 * Creates a toolbar window.
746 * Success: handle to the tool bar control
751 CreateToolbarEx (HWND hwnd
, DWORD style
, UINT wID
, INT nBitmaps
,
752 HINSTANCE hBMInst
, UINT wBMID
, LPCTBBUTTON lpButtons
,
753 INT iNumButtons
, INT dxButton
, INT dyButton
,
754 INT dxBitmap
, INT dyBitmap
, UINT uStructSize
)
758 /* If not position is specified then put it at the top */
759 if ((style
& CCS_BOTTOM
) == 0) {
764 CreateWindowExA (0, TOOLBARCLASSNAMEA
, "", style
|WS_CHILD
, 0, 0, 0, 0,
765 hwnd
, (HMENU
)wID
, 0, NULL
);
769 SendMessageA (hwndTB
, TB_BUTTONSTRUCTSIZE
,
770 (WPARAM
)uStructSize
, 0);
772 /* set bitmap and button size */
773 /*If CreateToolbarEx receives 0, windows sets default values*/
778 SendMessageA (hwndTB
, TB_SETBITMAPSIZE
, 0,
779 MAKELPARAM((WORD
)dxBitmap
, (WORD
)dyBitmap
));
785 SendMessageA (hwndTB
, TB_SETBUTTONSIZE
, 0,
786 MAKELPARAM((WORD
)dxButton
, (WORD
)dyButton
));
792 tbab
.hInst
= hBMInst
;
795 SendMessageA (hwndTB
, TB_ADDBITMAP
,
796 (WPARAM
)nBitmaps
, (LPARAM
)&tbab
);
800 SendMessageA (hwndTB
, TB_ADDBUTTONSA
,
801 (WPARAM
)iNumButtons
, (LPARAM
)lpButtons
);
808 /***********************************************************************
809 * CreateMappedBitmap [COMCTL32.8]
811 * Loads a bitmap resource using a colour map.
814 * hInstance [I] Handle to the module containing the bitmap.
815 * idBitmap [I] The bitmap resource ID.
816 * wFlags [I] CMB_MASKED for using bitmap as a mask or 0 for normal.
817 * lpColorMap [I] Colour information needed for the bitmap or NULL (uses system colours).
818 * iNumMaps [I] Number of COLORMAP's pointed to by lpColorMap.
821 * Success: handle to the new bitmap
826 CreateMappedBitmap (HINSTANCE hInstance
, INT idBitmap
, UINT wFlags
,
827 LPCOLORMAP lpColorMap
, INT iNumMaps
)
831 LPBITMAPINFOHEADER lpBitmap
, lpBitmapInfo
;
832 UINT nSize
, nColorTableSize
;
833 RGBQUAD
*pColorTable
;
834 INT iColor
, i
, iMaps
, nWidth
, nHeight
;
837 LPCOLORMAP sysColorMap
;
839 COLORMAP internalColorMap
[4] =
840 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
842 /* initialize pointer to colortable and default color table */
845 sysColorMap
= lpColorMap
;
848 internalColorMap
[0].to
= GetSysColor (COLOR_BTNTEXT
);
849 internalColorMap
[1].to
= GetSysColor (COLOR_BTNSHADOW
);
850 internalColorMap
[2].to
= GetSysColor (COLOR_BTNFACE
);
851 internalColorMap
[3].to
= GetSysColor (COLOR_BTNHIGHLIGHT
);
853 sysColorMap
= (LPCOLORMAP
)internalColorMap
;
856 hRsrc
= FindResourceA (hInstance
, (LPSTR
)idBitmap
, (LPSTR
)RT_BITMAP
);
859 hglb
= LoadResource (hInstance
, hRsrc
);
862 lpBitmap
= (LPBITMAPINFOHEADER
)LockResource (hglb
);
863 if (lpBitmap
== NULL
)
866 nColorTableSize
= (1 << lpBitmap
->biBitCount
);
867 nSize
= lpBitmap
->biSize
+ nColorTableSize
* sizeof(RGBQUAD
);
868 lpBitmapInfo
= (LPBITMAPINFOHEADER
)GlobalAlloc (GMEM_FIXED
, nSize
);
869 if (lpBitmapInfo
== NULL
)
871 RtlMoveMemory (lpBitmapInfo
, lpBitmap
, nSize
);
873 pColorTable
= (RGBQUAD
*)(((LPBYTE
)lpBitmapInfo
)+(UINT
)lpBitmapInfo
->biSize
);
875 for (iColor
= 0; iColor
< nColorTableSize
; iColor
++) {
876 for (i
= 0; i
< iMaps
; i
++) {
877 cRef
= RGB(pColorTable
[iColor
].rgbRed
,
878 pColorTable
[iColor
].rgbGreen
,
879 pColorTable
[iColor
].rgbBlue
);
880 if ( cRef
== sysColorMap
[i
].from
) {
882 if (wFlags
& CBS_MASKED
) {
883 if (sysColorMap
[i
].to
!= COLOR_BTNTEXT
)
884 pColorTable
[iColor
] = RGB(255, 255, 255);
888 pColorTable
[iColor
].rgbBlue
= GetBValue(sysColorMap
[i
].to
);
889 pColorTable
[iColor
].rgbGreen
= GetGValue(sysColorMap
[i
].to
);
890 pColorTable
[iColor
].rgbRed
= GetRValue(sysColorMap
[i
].to
);
895 nWidth
= (INT
)lpBitmapInfo
->biWidth
;
896 nHeight
= (INT
)lpBitmapInfo
->biHeight
;
897 hdcScreen
= GetDC (NULL
);
898 hbm
= CreateCompatibleBitmap (hdcScreen
, nWidth
, nHeight
);
900 HDC hdcDst
= CreateCompatibleDC (hdcScreen
);
901 HBITMAP hbmOld
= SelectObject (hdcDst
, hbm
);
902 LPBYTE lpBits
= (LPBYTE
)(lpBitmap
+ 1);
903 lpBits
+= (1 << (lpBitmapInfo
->biBitCount
)) * sizeof(RGBQUAD
);
904 StretchDIBits (hdcDst
, 0, 0, nWidth
, nHeight
, 0, 0, nWidth
, nHeight
,
905 lpBits
, (LPBITMAPINFO
)lpBitmapInfo
, DIB_RGB_COLORS
,
907 SelectObject (hdcDst
, hbmOld
);
910 ReleaseDC (NULL
, hdcScreen
);
911 GlobalFree ((HGLOBAL
)lpBitmapInfo
);
918 /***********************************************************************
919 * CreateToolbar [COMCTL32.7]
921 * Creates a toolbar control.
934 * Success: handle to the tool bar control
938 * Do not use this functions anymore. Use CreateToolbarEx instead.
942 CreateToolbar (HWND hwnd
, DWORD style
, UINT wID
, INT nBitmaps
,
943 HINSTANCE hBMInst
, UINT wBMID
,
944 LPCTBBUTTON lpButtons
,INT iNumButtons
)
946 return CreateToolbarEx (hwnd
, style
| CCS_NODIVIDER
, wID
, nBitmaps
,
947 hBMInst
, wBMID
, lpButtons
,
948 iNumButtons
, 0, 0, 0, 0, CCSIZEOF_STRUCT(TBBUTTON
, dwData
));
952 /***********************************************************************
953 * DllGetVersion [COMCTL32.@]
955 * Retrieves version information of the 'COMCTL32.DLL'
958 * pdvi [O] pointer to version information structure.
962 * Failure: E_INVALIDARG
965 * Returns version of a comctl32.dll from IE4.01 SP1.
969 COMCTL32_DllGetVersion (DLLVERSIONINFO
*pdvi
)
971 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
)) {
972 WARN("wrong DLLVERSIONINFO size from app\n");
976 pdvi
->dwMajorVersion
= COMCTL32_VERSION
;
977 pdvi
->dwMinorVersion
= COMCTL32_VERSION_MINOR
;
978 pdvi
->dwBuildNumber
= 2919;
979 pdvi
->dwPlatformID
= 6304;
981 TRACE("%lu.%lu.%lu.%lu\n",
982 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
983 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
988 /***********************************************************************
989 * DllInstall (COMCTL32.@)
991 * Installs the ComCtl32 DLL.
995 * Failure: A HRESULT error
997 HRESULT WINAPI
COMCTL32_DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
999 FIXME("(%s, %s): stub\n", bInstall
?"TRUE":"FALSE",
1000 debugstr_w(cmdline
));
1005 /***********************************************************************
1006 * _TrackMouseEvent [COMCTL32.@]
1008 * Requests notification of mouse events
1010 * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
1011 * to the hwnd specified in the ptme structure. After the event message
1012 * is posted to the hwnd, the entry in the queue is removed.
1014 * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
1015 * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
1016 * immediately and the TME_LEAVE flag being ignored.
1019 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
1025 * IMPLEMENTATION moved to USER32.TrackMouseEvent
1030 _TrackMouseEvent (TRACKMOUSEEVENT
*ptme
)
1032 return TrackMouseEvent (ptme
);
1035 /*************************************************************************
1036 * GetMUILanguage [COMCTL32.@]
1038 * Returns the user interface language in use by the current process.
1041 * Language ID in use by the current process.
1043 LANGID WINAPI
GetMUILanguage (VOID
)
1045 return COMCTL32_uiLang
;
1049 /*************************************************************************
1050 * InitMUILanguage [COMCTL32.@]
1052 * Sets the user interface language to be used by the current process.
1057 VOID WINAPI
InitMUILanguage (LANGID uiLang
)
1059 COMCTL32_uiLang
= uiLang
;
1063 /***********************************************************************
1064 * SetWindowSubclass [COMCTL32.410]
1066 * Starts a window subclass
1069 * hWnd [in] handle to window subclass.
1070 * pfnSubclass [in] Pointer to new window procedure.
1071 * uIDSubclass [in] Unique identifier of sublass together with pfnSubclass.
1072 * dwRef [in] Reference data to pass to window procedure.
1079 * If an application manually subclasses a window after subclassing it with
1080 * this API and then with this API again, then none of the previous
1081 * subclasses get called or the origional window procedure.
1084 BOOL WINAPI
SetWindowSubclass (HWND hWnd
, SUBCLASSPROC pfnSubclass
,
1085 UINT_PTR uIDSubclass
, DWORD_PTR dwRef
)
1087 LPSUBCLASS_INFO stack
;
1090 TRACE ("(%p, %p, %x, %lx)\n", hWnd
, pfnSubclass
, uIDSubclass
, dwRef
);
1092 /* Since the window procedure that we set here has two additional arguments,
1093 * we can't simply set it as the new window procedure of the window. So we
1094 * set our own window procedure and then calculate the other two arguments
1097 /* See if we have been called for this window */
1098 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1100 /* allocate stack */
1101 stack
= (LPSUBCLASS_INFO
)HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY
,
1102 sizeof(SUBCLASS_INFO
));
1104 ERR ("Failed to allocate our Subclassing stack\n");
1107 SetPropA (hWnd
, COMCTL32_aSubclass
, (HANDLE
)stack
);
1109 /* set window procedure to our own and save the current one */
1110 if (IsWindowUnicode (hWnd
))
1111 stack
->origproc
= (WNDPROC
)SetWindowLongW (hWnd
, GWL_WNDPROC
,
1112 (LONG
)SubclassWndProc
);
1114 stack
->origproc
= (WNDPROC
)SetWindowLongA (hWnd
, GWL_WNDPROC
,
1115 (LONG
)SubclassWndProc
);
1118 if (IsWindowUnicode (hWnd
))
1119 current
= (WNDPROC
)GetWindowLongW (hWnd
, GWL_WNDPROC
);
1121 current
= (WNDPROC
)GetWindowLongA (hWnd
, GWL_WNDPROC
);
1123 if (current
!= SubclassWndProc
) {
1124 ERR ("Application has subclassed with our procedure, then manually, then with us again. The current implementation can't handle this.\n");
1129 /* Check to see if we have called this function with the same uIDSubClass
1130 * and pfnSubclass */
1131 for (n
= 0; n
<= stack
->stacknum
+ stack
->stacknew
- 1; n
++)
1132 if ((stack
->SubclassProcs
[n
].id
== uIDSubclass
) &&
1133 (stack
->SubclassProcs
[n
].subproc
== pfnSubclass
)) {
1134 stack
->SubclassProcs
[n
].ref
= dwRef
;
1138 if ((stack
->stacknum
+ stack
->stacknew
) >= 32) {
1139 ERR ("We have a Subclass stack overflow, please increment size\n");
1143 /* we can't simply increment both stackpos and stacknum because there might
1144 * be a window procedure running lower in the stack, we can only get them
1145 * up to date once the last window procedure has run */
1146 if (stack
->stacknum
== stack
->stackpos
) {
1152 newnum
= stack
->stacknew
+ stack
->stacknum
- 1;
1154 stack
->SubclassProcs
[newnum
].subproc
= pfnSubclass
;
1155 stack
->SubclassProcs
[newnum
].ref
= dwRef
;
1156 stack
->SubclassProcs
[newnum
].id
= uIDSubclass
;
1162 /***********************************************************************
1163 * GetWindowSubclass [COMCTL32.411]
1165 * Gets the Reference data from a subclass.
1168 * hWnd [in] Handle to window which were subclassing
1169 * pfnSubclass [in] Pointer to the subclass procedure
1170 * uID [in] Unique indentifier of the subclassing procedure
1171 * pdwRef [out] Pointer to the reference data
1178 BOOL WINAPI
GetWindowSubclass (HWND hWnd
, SUBCLASSPROC pfnSubclass
,
1179 UINT_PTR uID
, DWORD_PTR
*pdwRef
)
1181 LPSUBCLASS_INFO stack
;
1184 TRACE ("(%p, %p, %x, %p)\n", hWnd
, pfnSubclass
, uID
, pdwRef
);
1186 /* See if we have been called for this window */
1187 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1191 for (n
= 0; n
<= stack
->stacknum
+ stack
->stacknew
- 1; n
++)
1192 if ((stack
->SubclassProcs
[n
].id
== uID
) &&
1193 (stack
->SubclassProcs
[n
].subproc
== pfnSubclass
)) {
1194 *pdwRef
= stack
->SubclassProcs
[n
].ref
;
1202 /***********************************************************************
1203 * RemoveWindowSubclass [COMCTL32.412]
1205 * Removes a window subclass.
1208 * hWnd [in] Handle to the window were subclassing
1209 * pfnSubclass [in] Pointer to the subclass procedure
1210 * uID [in] Unique identifier of this subclass
1217 BOOL WINAPI
RemoveWindowSubclass(HWND hWnd
, SUBCLASSPROC pfnSubclass
, UINT_PTR uID
)
1219 LPSUBCLASS_INFO stack
;
1222 TRACE ("(%p, %p, %x)\n", hWnd
, pfnSubclass
, uID
);
1224 /* Find the Subclass to remove */
1225 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1229 if ((stack
->stacknum
== 1) && (stack
->stackpos
== 1) && !stack
->stacknew
) {
1230 TRACE("Last Subclass removed, cleaning up\n");
1231 /* clean up our heap and reset the origional window procedure */
1232 if (IsWindowUnicode (hWnd
))
1233 SetWindowLongW (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1235 SetWindowLongA (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1236 HeapFree (GetProcessHeap (), 0, stack
);
1237 RemovePropA( hWnd
, COMCTL32_aSubclass
);
1241 for (n
= stack
->stacknum
+ stack
->stacknew
- 1; n
>= 0; n
--)
1242 if ((stack
->SubclassProcs
[n
].id
== uID
) &&
1243 (stack
->SubclassProcs
[n
].subproc
== pfnSubclass
)) {
1244 if (n
!= (stack
->stacknum
+ stack
->stacknew
))
1245 /* Fill the hole in the stack */
1246 memmove (&stack
->SubclassProcs
[n
], &stack
->SubclassProcs
[n
+ 1],
1247 sizeof(stack
->SubclassProcs
[0]) * (stack
->stacknew
+ stack
->stacknum
- n
));
1248 stack
->SubclassProcs
[n
].subproc
= NULL
;
1249 stack
->SubclassProcs
[n
].ref
= 0;
1250 stack
->SubclassProcs
[n
].id
= 0;
1252 /* If we are currently running a window procedure we have to manipulate
1253 * the stack position pointers so that we don't corrupt the stack */
1254 if ((n
< stack
->stackpos
) || (stack
->stackpos
== stack
->stacknum
)) {
1257 } else if (n
>= stack
->stackpos
)
1266 /***********************************************************************
1267 * SubclassWndProc (internal)
1269 * Window procedure for all subclassed windows.
1270 * Saves the current subclassing stack position to support nested messages
1273 static LRESULT WINAPI
SubclassWndProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1275 LPSUBCLASS_INFO stack
;
1279 /* retrieve our little stack from the Properties */
1280 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1282 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd
);
1285 stackpos
= stack
->stackpos
;
1286 stack
->stackpos
= stack
->stacknum
;
1287 ret
= DefSubclassProc(hWnd
,uMsg
,wParam
,lParam
);
1288 stack
->stackpos
= stackpos
;
1293 /***********************************************************************
1294 * DefSubclassProc [COMCTL32.413]
1296 * Calls the next window procedure (ie. the one before this subclass)
1299 * hWnd [in] The window that we're subclassing
1301 * wParam [in] WPARAM
1302 * lParam [in] LPARAM
1309 LRESULT WINAPI
DefSubclassProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1311 LPSUBCLASS_INFO stack
;
1315 /* retrieve our little stack from the Properties */
1316 stack
= (LPSUBCLASS_INFO
)GetPropA (hWnd
, COMCTL32_aSubclass
);
1318 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd
);
1322 /* If we are at pos 0 then we have to call the origional window procedure */
1323 if (stack
->stackpos
== 0) {
1324 if (IsWindowUnicode (hWnd
))
1325 return CallWindowProcW (stack
->origproc
, hWnd
, uMsg
, wParam
, lParam
);
1327 return CallWindowProcA (stack
->origproc
, hWnd
, uMsg
, wParam
, lParam
);
1330 stackpos
= --stack
->stackpos
;
1331 /* call the Subclass procedure from the stack */
1332 ret
= stack
->SubclassProcs
[stackpos
].subproc (hWnd
, uMsg
, wParam
, lParam
,
1333 stack
->SubclassProcs
[stackpos
].id
, stack
->SubclassProcs
[stackpos
].ref
);
1336 if ((stack
->stackpos
== stack
->stacknum
) && stack
->stacknew
) {
1337 stack
->stacknum
+= stack
->stacknew
;
1338 stack
->stackpos
+= stack
->stacknew
;
1339 stack
->stacknew
= 0;
1342 /* If we removed the last entry in our stack while a window procedure was
1343 * running then we have to clean up */
1344 if ((stack
->stackpos
== 0) && (stack
->stacknum
== 0)) {
1345 TRACE("Last Subclass removed, cleaning up\n");
1346 /* clean up our heap and reset the origional window procedure */
1347 if (IsWindowUnicode (hWnd
))
1348 SetWindowLongW (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1350 SetWindowLongA (hWnd
, GWL_WNDPROC
, (LONG
)stack
->origproc
);
1351 HeapFree (GetProcessHeap (), 0, stack
);
1352 RemovePropA( hWnd
, COMCTL32_aSubclass
);
1360 /***********************************************************************
1361 * COMCTL32_CreateToolTip [NOT AN API]
1363 * Creates a tooltip for the control specified in hwnd and does all
1364 * necessary setup and notifications.
1367 * hwndOwner [I] Handle to the window that will own the tool tip.
1370 * Success: Handle of tool tip window.
1375 COMCTL32_CreateToolTip(HWND hwndOwner
)
1379 hwndToolTip
= CreateWindowExA(0, TOOLTIPS_CLASSA
, NULL
, 0,
1380 CW_USEDEFAULT
, CW_USEDEFAULT
,
1381 CW_USEDEFAULT
, CW_USEDEFAULT
, hwndOwner
,
1384 /* Send NM_TOOLTIPSCREATED notification */
1387 NMTOOLTIPSCREATED nmttc
;
1388 /* true owner can be different if hwndOwner is a child window */
1389 HWND hwndTrueOwner
= GetWindow(hwndToolTip
, GW_OWNER
);
1390 nmttc
.hdr
.hwndFrom
= hwndTrueOwner
;
1391 nmttc
.hdr
.idFrom
= GetWindowLongA(hwndTrueOwner
, GWL_ID
);
1392 nmttc
.hdr
.code
= NM_TOOLTIPSCREATED
;
1393 nmttc
.hwndToolTips
= hwndToolTip
;
1395 SendMessageA(GetParent(hwndTrueOwner
), WM_NOTIFY
,
1396 (WPARAM
)GetWindowLongA(hwndTrueOwner
, GWL_ID
),
1404 /***********************************************************************
1405 * COMCTL32_RefreshSysColors [NOT AN API]
1407 * Invoked on any control recognizing a WM_SYSCOLORCHANGE message to
1408 * refresh the color values in the color structure
1418 COMCTL32_RefreshSysColors(void)
1420 comctl32_color
.clrBtnHighlight
= GetSysColor (COLOR_BTNHIGHLIGHT
);
1421 comctl32_color
.clrBtnShadow
= GetSysColor (COLOR_BTNSHADOW
);
1422 comctl32_color
.clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
1423 comctl32_color
.clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
1424 comctl32_color
.clrHighlight
= GetSysColor (COLOR_HIGHLIGHT
);
1425 comctl32_color
.clrHighlightText
= GetSysColor (COLOR_HIGHLIGHTTEXT
);
1426 comctl32_color
.clr3dHilight
= GetSysColor (COLOR_3DHILIGHT
);
1427 comctl32_color
.clr3dShadow
= GetSysColor (COLOR_3DSHADOW
);
1428 comctl32_color
.clr3dDkShadow
= GetSysColor (COLOR_3DDKSHADOW
);
1429 comctl32_color
.clr3dFace
= GetSysColor (COLOR_3DFACE
);
1430 comctl32_color
.clrWindow
= GetSysColor (COLOR_WINDOW
);
1431 comctl32_color
.clrWindowText
= GetSysColor (COLOR_WINDOWTEXT
);
1432 comctl32_color
.clrGrayText
= GetSysColor (COLOR_GRAYTEXT
);
1433 comctl32_color
.clrActiveCaption
= GetSysColor (COLOR_ACTIVECAPTION
);
1434 comctl32_color
.clrInfoBk
= GetSysColor (COLOR_INFOBK
);
1435 comctl32_color
.clrInfoText
= GetSysColor (COLOR_INFOTEXT
);