2 * Common controls functions
4 * Copyright 1997 Dimitrie O. Paun
5 * Copyright 1998,2000 Eric Kohl
6 * Copyright 2014-2015 Michael Müller
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 * This code was audited for completeness against the documented features
25 * of Comctl32.dll version 6.0 on Oct. 21, 2002, by Christian Neumair.
27 * Unless otherwise noted, we believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features, or bugs, please note them below.
32 * -- implement GetMUILanguage + InitMUILanguage
33 * -- finish NOTES for MenuHelp, GetEffectiveClientRect and GetStatusTextW
34 * -- FIXMEs + BUGS (search for them)
37 * -- ICC_ANIMATE_CLASS
42 * -- ICC_INTERNET_CLASSES
44 * -- ICC_LISTVIEW_CLASSES
45 * -- ICC_NATIVEFNTCTL_CLASS
46 * -- ICC_PAGESCROLLER_CLASS
47 * -- ICC_PROGRESS_CLASS
48 * -- ICC_STANDARD_CLASSES (not yet implemented)
50 * -- ICC_TREEVIEW_CLASSES
52 * -- ICC_USEREX_CLASSES
53 * -- ICC_WIN95_CLASSES
58 #define NO_SHLWAPI_STREAM
61 WINE_DEFAULT_DEBUG_CHANNEL(commctrl
);
64 static LRESULT WINAPI
COMCTL32_SubclassProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
66 static LPWSTR COMCTL32_wSubclass
= NULL
;
67 HMODULE COMCTL32_hModule
= 0;
68 static LANGID COMCTL32_uiLang
= MAKELANGID(LANG_NEUTRAL
, SUBLANG_NEUTRAL
);
69 HBRUSH COMCTL32_hPattern55AABrush
= NULL
;
70 COMCTL32_SysColor comctl32_color
;
72 static HBITMAP COMCTL32_hPattern55AABitmap
= NULL
;
74 static const WORD wPattern55AA
[] =
76 0x5555, 0xaaaa, 0x5555, 0xaaaa,
77 0x5555, 0xaaaa, 0x5555, 0xaaaa
80 static const WCHAR strCC32SubclassInfo
[] = {
81 'C','C','3','2','S','u','b','c','l','a','s','s','I','n','f','o',0
88 #define NAME L"microsoft.windows.common-controls"
89 #define VERSION_V5 L"5.82.2600.2982"
90 #define VERSION L"6.0.2600.2982"
91 #define PUBLIC_KEY L"6595b64144ccf1df"
95 #elif defined __x86_64__
101 static const WCHAR manifest_filename
[] = ARCH L
"_" NAME L
"_" PUBLIC_KEY L
"_" VERSION L
"_none_deadbeef.manifest";
102 static const WCHAR manifest_filename_v5
[] = ARCH L
"_" NAME L
"_" PUBLIC_KEY L
"_" VERSION_V5 L
"_none_deadbeef.manifest";
104 static WCHAR
* GetManifestPath(BOOL create
, BOOL bV6
)
109 pwszBuf
= HeapAlloc(GetProcessHeap(), 0, MAX_PATH
* sizeof(WCHAR
));
113 GetWindowsDirectoryW(pwszBuf
, MAX_PATH
);
114 hres
= StringCchCatW(pwszBuf
, MAX_PATH
, L
"\\winsxs");
118 CreateDirectoryW(pwszBuf
, NULL
);
119 hres
= StringCchCatW(pwszBuf
, MAX_PATH
, L
"\\manifests\\");
123 CreateDirectoryW(pwszBuf
, NULL
);
125 hres
= StringCchCatW(pwszBuf
, MAX_PATH
, bV6
? manifest_filename
: manifest_filename_v5
);
132 static BOOL
create_manifest(BOOL install
, BOOL bV6
)
138 DWORD cbManifest
, cbWritten
;
143 hResInfo
= FindResourceW(COMCTL32_hModule
, L
"WINE_MANIFEST", (LPWSTR
)RT_MANIFEST
);
145 hResInfo
= FindResourceW(COMCTL32_hModule
, L
"WINE_MANIFESTV5", (LPWSTR
)RT_MANIFEST
);
150 cbManifest
= SizeofResource(COMCTL32_hModule
, hResInfo
);
154 hResData
= LoadResource(COMCTL32_hModule
, hResInfo
);
158 pManifest
= LockResource(hResData
);
162 pwszBuf
= GetManifestPath(TRUE
, bV6
);
168 hFile
= CreateFileW(pwszBuf
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
169 if (hFile
!= INVALID_HANDLE_VALUE
)
171 if (WriteFile(hFile
, pManifest
, cbManifest
, &cbWritten
, NULL
) && cbWritten
== cbManifest
)
177 DeleteFileW(pwszBuf
);
179 TRACE("created %s\n", debugstr_w(pwszBuf
));
183 bRet
= DeleteFileW(pwszBuf
);
185 HeapFree(GetProcessHeap(), 0, pwszBuf
);
190 static HANDLE
CreateComctl32ActCtx(BOOL bV6
)
194 ACTCTXW ActCtx
= {sizeof(ACTCTX
)};
196 pwstrSource
= GetManifestPath(FALSE
, bV6
);
199 ERR("GetManifestPath failed! bV6=%d\n", bV6
);
200 return INVALID_HANDLE_VALUE
;
202 ActCtx
.lpSource
= pwstrSource
;
203 ret
= CreateActCtxW(&ActCtx
);
204 HeapFree(GetProcessHeap(), 0, pwstrSource
);
205 if (ret
== INVALID_HANDLE_VALUE
)
206 ERR("CreateActCtxW failed! bV6=%d\n", bV6
);
210 static void RegisterControls(BOOL bV6
)
214 DATETIME_Register ();
218 IPADDRESS_Register ();
219 LISTVIEW_Register ();
220 MONTHCAL_Register ();
221 NATIVEFONT_Register ();
223 PROGRESS_Register ();
228 TOOLTIPS_Register ();
229 TRACKBAR_Register ();
230 TREEVIEW_Register ();
240 TOOLBARv6_Register();
244 static void UnregisterControls(BOOL bV6
)
246 ANIMATE_Unregister ();
247 COMBOEX_Unregister ();
248 DATETIME_Unregister ();
249 FLATSB_Unregister ();
250 HEADER_Unregister ();
251 HOTKEY_Unregister ();
252 IPADDRESS_Unregister ();
253 LISTVIEW_Unregister ();
254 MONTHCAL_Unregister ();
255 NATIVEFONT_Unregister ();
257 PROGRESS_Unregister ();
259 STATUS_Unregister ();
260 SYSLINK_Unregister ();
262 TOOLTIPS_Unregister ();
263 TRACKBAR_Unregister ();
264 TREEVIEW_Unregister ();
265 UPDOWN_Unregister ();
269 TOOLBAR_Unregister ();
274 TOOLBARv6_Unregister ();
279 static void InitializeClasses()
281 HANDLE hActCtx5
, hActCtx6
;
285 /* like comctl32 5.82+ register all the common control classes */
286 /* Register the classes once no matter what */
287 hActCtx5
= CreateComctl32ActCtx(FALSE
);
288 activated
= (hActCtx5
!= INVALID_HANDLE_VALUE
? ActivateActCtx(hActCtx5
, &ulCookie
) : FALSE
);
289 RegisterControls(FALSE
); /* Register the classes pretending to be v5 */
290 if (activated
) DeactivateActCtx(0, ulCookie
);
292 hActCtx6
= CreateComctl32ActCtx(TRUE
);
293 if (hActCtx6
!= INVALID_HANDLE_VALUE
)
295 activated
= ActivateActCtx(hActCtx6
, &ulCookie
);
296 RegisterControls(TRUE
); /* Register the classes pretending to be v6 */
297 if (activated
) DeactivateActCtx(0, ulCookie
);
299 /* Initialize the themed controls only when the v6 manifest is present */
300 THEMING_Initialize (hActCtx5
, hActCtx6
);
304 static void UninitializeClasses()
306 HANDLE hActCtx5
, hActCtx6
;
310 hActCtx5
= CreateComctl32ActCtx(FALSE
);
311 activated
= (hActCtx5
!= INVALID_HANDLE_VALUE
? ActivateActCtx(hActCtx5
, &ulCookie
) : FALSE
);
312 UnregisterControls(FALSE
);
313 if (activated
) DeactivateActCtx(0, ulCookie
);
315 hActCtx6
= CreateComctl32ActCtx(TRUE
);
316 if (hActCtx6
!= INVALID_HANDLE_VALUE
)
318 activated
= ActivateActCtx(hActCtx6
, &ulCookie
);
319 THEMING_Uninitialize();
320 UnregisterControls(TRUE
);
321 if (activated
) DeactivateActCtx(0, ulCookie
);
325 /***********************************************************************
326 * RegisterClassNameW [COMCTL32.@]
328 * Register window class again while using as SxS module.
330 BOOLEAN WINAPI
RegisterClassNameW(LPCWSTR className
)
338 /***********************************************************************
341 * Initializes the internal 'COMCTL32.DLL'.
344 * hinstDLL [I] handle to the 'dlls' instance
346 * lpvReserved [I] reserved, must be NULL
353 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
355 TRACE("%p,%x,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
358 case DLL_PROCESS_ATTACH
:
359 DisableThreadLibraryCalls(hinstDLL
);
361 COMCTL32_hModule
= hinstDLL
;
363 /* add global subclassing atom (used by 'tooltip' and 'updown') */
364 COMCTL32_wSubclass
= (LPWSTR
)(DWORD_PTR
)GlobalAddAtomW (strCC32SubclassInfo
);
365 TRACE("Subclassing atom added: %p\n", COMCTL32_wSubclass
);
367 /* create local pattern brush */
368 COMCTL32_hPattern55AABitmap
= CreateBitmap (8, 8, 1, 1, wPattern55AA
);
369 COMCTL32_hPattern55AABrush
= CreatePatternBrush (COMCTL32_hPattern55AABitmap
);
371 /* Get all the colors at DLL load */
372 COMCTL32_RefreshSysColors();
375 /* like comctl32 5.82+ register all the common control classes */
378 DATETIME_Register ();
382 IPADDRESS_Register ();
383 LISTVIEW_Register ();
384 MONTHCAL_Register ();
385 NATIVEFONT_Register ();
387 PROGRESS_Register ();
393 TOOLTIPS_Register ();
394 TRACKBAR_Register ();
395 TREEVIEW_Register ();
398 /* subclass user32 controls */
399 THEMING_Initialize ();
406 case DLL_PROCESS_DETACH
:
407 if (lpvReserved
) break;
409 /* clean up subclassing */
410 THEMING_Uninitialize();
412 /* unregister all common control classes */
413 ANIMATE_Unregister ();
414 COMBOEX_Unregister ();
415 DATETIME_Unregister ();
416 FLATSB_Unregister ();
417 HEADER_Unregister ();
418 HOTKEY_Unregister ();
419 IPADDRESS_Unregister ();
420 LISTVIEW_Unregister ();
421 MONTHCAL_Unregister ();
422 NATIVEFONT_Unregister ();
424 PROGRESS_Unregister ();
426 STATUS_Unregister ();
427 SYSLINK_Unregister ();
429 TOOLBAR_Unregister ();
430 TOOLTIPS_Unregister ();
431 TRACKBAR_Unregister ();
432 TREEVIEW_Unregister ();
433 UPDOWN_Unregister ();
435 UninitializeClasses();
437 /* delete local pattern brush */
438 DeleteObject (COMCTL32_hPattern55AABrush
);
439 DeleteObject (COMCTL32_hPattern55AABitmap
);
441 /* delete global subclassing atom */
442 GlobalDeleteAtom (LOWORD(COMCTL32_wSubclass
));
443 TRACE("Subclassing atom deleted: %p\n", COMCTL32_wSubclass
);
451 /***********************************************************************
452 * MenuHelp [COMCTL32.2]
454 * Handles the setting of status bar help messages when the user
455 * selects menu items.
458 * uMsg [I] message (WM_MENUSELECT) (see NOTES)
459 * wParam [I] wParam of the message uMsg
460 * lParam [I] lParam of the message uMsg
461 * hMainMenu [I] handle to the application's main menu
462 * hInst [I] handle to the module that contains string resources
463 * hwndStatus [I] handle to the status bar window
464 * lpwIDs [I] pointer to an array of integers (see NOTES)
470 * The official documentation is incomplete!
471 * This is the correct documentation:
474 * MenuHelp() does NOT handle WM_COMMAND messages! It only handles
475 * WM_MENUSELECT messages.
478 * (will be written ...)
482 MenuHelp (UINT uMsg
, WPARAM wParam
, LPARAM lParam
, HMENU hMainMenu
,
483 HINSTANCE hInst
, HWND hwndStatus
, UINT
* lpwIDs
)
487 if (!IsWindow (hwndStatus
))
492 TRACE("WM_MENUSELECT wParam=0x%lX lParam=0x%lX\n",
495 if ((HIWORD(wParam
) == 0xFFFF) && (lParam
== 0)) {
496 /* menu was closed */
497 TRACE("menu was closed!\n");
498 SendMessageW (hwndStatus
, SB_SIMPLE
, FALSE
, 0);
501 /* menu item was selected */
502 if (HIWORD(wParam
) & MF_POPUP
)
503 uMenuID
= *(lpwIDs
+1);
505 uMenuID
= (UINT
)LOWORD(wParam
);
506 TRACE("uMenuID = %u\n", uMenuID
);
511 if (!LoadStringW (hInst
, uMenuID
, szText
, sizeof(szText
)/sizeof(szText
[0])))
514 SendMessageW (hwndStatus
, SB_SETTEXTW
,
515 255 | SBT_NOBORDERS
, (LPARAM
)szText
);
516 SendMessageW (hwndStatus
, SB_SIMPLE
, TRUE
, 0);
522 TRACE("WM_COMMAND wParam=0x%lX lParam=0x%lX\n",
524 /* WM_COMMAND is not invalid since it is documented
525 * in the windows api reference. So don't output
526 * any FIXME for WM_COMMAND
528 WARN("We don't care about the WM_COMMAND\n");
532 FIXME("Invalid Message 0x%x!\n", uMsg
);
538 /***********************************************************************
539 * ShowHideMenuCtl [COMCTL32.3]
541 * Shows or hides controls and updates the corresponding menu item.
544 * hwnd [I] handle to the client window.
545 * uFlags [I] menu command id.
546 * lpInfo [I] pointer to an array of integers. (See NOTES.)
553 * The official documentation is incomplete!
554 * This is the correct documentation:
557 * Handle to the window that contains the menu and controls.
560 * Identifier of the menu item to receive or lose a check mark.
563 * The array of integers contains pairs of values. BOTH values of
564 * the first pair must be the handles to the application's main menu.
565 * Each subsequent pair consists of a menu id and control id.
569 ShowHideMenuCtl (HWND hwnd
, UINT_PTR uFlags
, LPINT lpInfo
)
573 TRACE("%p, %lx, %p\n", hwnd
, uFlags
, lpInfo
);
578 if (!(lpInfo
[0]) || !(lpInfo
[1]))
581 /* search for control */
582 lpMenuId
= &lpInfo
[2];
583 while (*lpMenuId
!= uFlags
)
586 if (GetMenuState ((HMENU
)(DWORD_PTR
)lpInfo
[1], uFlags
, MF_BYCOMMAND
) & MFS_CHECKED
) {
587 /* uncheck menu item */
588 CheckMenuItem ((HMENU
)(DWORD_PTR
)lpInfo
[0], *lpMenuId
, MF_BYCOMMAND
| MF_UNCHECKED
);
592 SetWindowPos (GetDlgItem (hwnd
, *lpMenuId
), 0, 0, 0, 0, 0,
596 /* check menu item */
597 CheckMenuItem ((HMENU
)(DWORD_PTR
)lpInfo
[0], *lpMenuId
, MF_BYCOMMAND
| MF_CHECKED
);
601 SetWindowPos (GetDlgItem (hwnd
, *lpMenuId
), 0, 0, 0, 0, 0,
609 /***********************************************************************
610 * GetEffectiveClientRect [COMCTL32.4]
612 * Calculates the coordinates of a rectangle in the client area.
615 * hwnd [I] handle to the client window.
616 * lpRect [O] pointer to the rectangle of the client window
617 * lpInfo [I] pointer to an array of integers (see NOTES)
623 * The official documentation is incomplete!
624 * This is the correct documentation:
627 * (will be written ...)
631 GetEffectiveClientRect (HWND hwnd
, LPRECT lpRect
, const INT
*lpInfo
)
637 TRACE("(%p %p %p)\n",
638 hwnd
, lpRect
, lpInfo
);
640 GetClientRect (hwnd
, lpRect
);
648 hwndCtrl
= GetDlgItem (hwnd
, *lpRun
);
649 if (GetWindowLongW (hwndCtrl
, GWL_STYLE
) & WS_VISIBLE
) {
650 TRACE("control id 0x%x\n", *lpRun
);
651 GetWindowRect (hwndCtrl
, &rcCtrl
);
652 MapWindowPoints (NULL
, hwnd
, (LPPOINT
)&rcCtrl
, 2);
653 SubtractRect (lpRect
, lpRect
, &rcCtrl
);
660 /***********************************************************************
661 * DrawStatusTextW [COMCTL32.@]
663 * Draws text with borders, like in a status bar.
666 * hdc [I] handle to the window's display context
667 * lprc [I] pointer to a rectangle
668 * text [I] pointer to the text
669 * style [I] drawing style
675 * The style variable can have one of the following values:
676 * (will be written ...)
679 void WINAPI
DrawStatusTextW (HDC hdc
, LPCRECT lprc
, LPCWSTR text
, UINT style
)
682 UINT border
= BDR_SUNKENOUTER
;
684 if (style
& SBT_POPOUT
)
685 border
= BDR_RAISEDOUTER
;
686 else if (style
& SBT_NOBORDERS
)
689 DrawEdge (hdc
, &r
, border
, BF_RECT
|BF_ADJUST
);
693 int oldbkmode
= SetBkMode (hdc
, TRANSPARENT
);
694 UINT align
= DT_LEFT
;
697 if (style
& SBT_RTLREADING
)
698 FIXME("Unsupported RTL style!\n");
703 DrawTextW (hdc
, text
- strCnt
, strCnt
, &r
, align
|DT_VCENTER
|DT_SINGLELINE
|DT_NOPREFIX
);
706 if (align
==DT_RIGHT
) {
709 align
= (align
==DT_LEFT
? DT_CENTER
: DT_RIGHT
);
715 if (strCnt
) DrawTextW (hdc
, text
- strCnt
, -1, &r
, align
|DT_VCENTER
|DT_SINGLELINE
|DT_NOPREFIX
);
716 SetBkMode(hdc
, oldbkmode
);
721 /***********************************************************************
722 * DrawStatusText [COMCTL32.@]
723 * DrawStatusTextA [COMCTL32.5]
725 * Draws text with borders, like in a status bar.
728 * hdc [I] handle to the window's display context
729 * lprc [I] pointer to a rectangle
730 * text [I] pointer to the text
731 * style [I] drawing style
737 void WINAPI
DrawStatusTextA (HDC hdc
, LPCRECT lprc
, LPCSTR text
, UINT style
)
743 if ( (len
= MultiByteToWideChar( CP_ACP
, 0, text
, -1, NULL
, 0 )) ) {
744 if ( (textW
= Alloc( len
* sizeof(WCHAR
) )) )
745 MultiByteToWideChar( CP_ACP
, 0, text
, -1, textW
, len
);
748 DrawStatusTextW( hdc
, lprc
, textW
, style
);
753 /***********************************************************************
754 * CreateStatusWindow [COMCTL32.@]
755 * CreateStatusWindowA [COMCTL32.6]
757 * Creates a status bar
760 * style [I] window style
761 * text [I] pointer to the window text
762 * parent [I] handle to the parent window
763 * wid [I] control id of the status bar
766 * Success: handle to the status window
771 CreateStatusWindowA (LONG style
, LPCSTR text
, HWND parent
, UINT wid
)
773 return CreateWindowA(STATUSCLASSNAMEA
, text
, style
,
774 CW_USEDEFAULT
, CW_USEDEFAULT
,
775 CW_USEDEFAULT
, CW_USEDEFAULT
,
776 parent
, (HMENU
)(DWORD_PTR
)wid
, 0, 0);
780 /***********************************************************************
781 * CreateStatusWindowW [COMCTL32.@]
783 * Creates a status bar control
786 * style [I] window style
787 * text [I] pointer to the window text
788 * parent [I] handle to the parent window
789 * wid [I] control id of the status bar
792 * Success: handle to the status window
797 CreateStatusWindowW (LONG style
, LPCWSTR text
, HWND parent
, UINT wid
)
799 return CreateWindowW(STATUSCLASSNAMEW
, text
, style
,
800 CW_USEDEFAULT
, CW_USEDEFAULT
,
801 CW_USEDEFAULT
, CW_USEDEFAULT
,
802 parent
, (HMENU
)(DWORD_PTR
)wid
, 0, 0);
806 /***********************************************************************
807 * CreateUpDownControl [COMCTL32.16]
809 * Creates an up-down control
812 * style [I] window styles
813 * x [I] horizontal position of the control
814 * y [I] vertical position of the control
815 * cx [I] with of the control
816 * cy [I] height of the control
817 * parent [I] handle to the parent window
818 * id [I] the control's identifier
819 * inst [I] handle to the application's module instance
820 * buddy [I] handle to the buddy window, can be NULL
821 * maxVal [I] upper limit of the control
822 * minVal [I] lower limit of the control
823 * curVal [I] current value of the control
826 * Success: handle to the updown control
831 CreateUpDownControl (DWORD style
, INT x
, INT y
, INT cx
, INT cy
,
832 HWND parent
, INT id
, HINSTANCE inst
,
833 HWND buddy
, INT maxVal
, INT minVal
, INT curVal
)
836 CreateWindowW (UPDOWN_CLASSW
, 0, style
, x
, y
, cx
, cy
,
837 parent
, (HMENU
)(DWORD_PTR
)id
, inst
, 0);
839 SendMessageW (hUD
, UDM_SETBUDDY
, (WPARAM
)buddy
, 0);
840 SendMessageW (hUD
, UDM_SETRANGE
, 0, MAKELONG(maxVal
, minVal
));
841 SendMessageW (hUD
, UDM_SETPOS
, 0, MAKELONG(curVal
, 0));
848 /***********************************************************************
849 * InitCommonControls [COMCTL32.17]
851 * Registers the common controls.
860 * This function is just a dummy - all the controls are registered at
861 * the DLL initialization time. See InitCommonContolsEx for details.
865 InitCommonControls (void)
870 /***********************************************************************
871 * InitCommonControlsEx [COMCTL32.@]
873 * Registers the common controls.
876 * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
883 * Probably all versions of comctl32 initializes the Win95 controls in DllMain
884 * during DLL initialization. Starting from comctl32 v5.82 all the controls
885 * are initialized there. We follow this behaviour and this function is just
888 * Note: when writing programs under Windows, if you don't call any function
889 * from comctl32 the linker may not link this DLL. If InitCommonControlsEx
890 * was the only comctl32 function you were calling and you remove it you may
891 * have a false impression that InitCommonControlsEx actually did something.
895 InitCommonControlsEx (const INITCOMMONCONTROLSEX
*lpInitCtrls
)
897 if (!lpInitCtrls
|| lpInitCtrls
->dwSize
!= sizeof(INITCOMMONCONTROLSEX
))
900 TRACE("(0x%08x)\n", lpInitCtrls
->dwICC
);
905 /***********************************************************************
906 * CreateToolbarEx [COMCTL32.@]
908 * Creates a toolbar window.
926 * Success: handle to the tool bar control
931 CreateToolbarEx (HWND hwnd
, DWORD style
, UINT wID
, INT nBitmaps
,
932 HINSTANCE hBMInst
, UINT_PTR wBMID
, LPCTBBUTTON lpButtons
,
933 INT iNumButtons
, INT dxButton
, INT dyButton
,
934 INT dxBitmap
, INT dyBitmap
, UINT uStructSize
)
939 CreateWindowExW(0, TOOLBARCLASSNAMEW
, NULL
, style
|WS_CHILD
, 0,0,100,30,
940 hwnd
, (HMENU
)(DWORD_PTR
)wID
, COMCTL32_hModule
, NULL
);
944 SendMessageW (hwndTB
, TB_BUTTONSTRUCTSIZE
, uStructSize
, 0);
946 /* set bitmap and button size */
947 /*If CreateToolbarEx receives 0, windows sets default values*/
952 if (dxBitmap
== 0 || dyBitmap
== 0)
953 dxBitmap
= dyBitmap
= 16;
954 SendMessageW(hwndTB
, TB_SETBITMAPSIZE
, 0, MAKELPARAM(dxBitmap
, dyBitmap
));
960 /* TB_SETBUTTONSIZE -> TB_SETBITMAPSIZE bug introduced for Windows compatibility */
961 if (dxButton
!= 0 && dyButton
!= 0)
962 SendMessageW(hwndTB
, TB_SETBITMAPSIZE
, 0, MAKELPARAM(dxButton
, dyButton
));
966 if (nBitmaps
> 0 || hBMInst
== HINST_COMMCTRL
)
968 tbab
.hInst
= hBMInst
;
971 SendMessageW (hwndTB
, TB_ADDBITMAP
, nBitmaps
, (LPARAM
)&tbab
);
975 SendMessageW (hwndTB
, TB_ADDBUTTONSW
, iNumButtons
, (LPARAM
)lpButtons
);
982 /***********************************************************************
983 * CreateMappedBitmap [COMCTL32.8]
985 * Loads a bitmap resource using a colour map.
988 * hInstance [I] Handle to the module containing the bitmap.
989 * idBitmap [I] The bitmap resource ID.
990 * wFlags [I] CMB_MASKED for using bitmap as a mask or 0 for normal.
991 * lpColorMap [I] Colour information needed for the bitmap or NULL (uses system colours).
992 * iNumMaps [I] Number of COLORMAP's pointed to by lpColorMap.
995 * Success: handle to the new bitmap
1000 CreateMappedBitmap (HINSTANCE hInstance
, INT_PTR idBitmap
, UINT wFlags
,
1001 LPCOLORMAP lpColorMap
, INT iNumMaps
)
1005 const BITMAPINFOHEADER
*lpBitmap
;
1006 LPBITMAPINFOHEADER lpBitmapInfo
;
1007 UINT nSize
, nColorTableSize
, iColor
;
1008 RGBQUAD
*pColorTable
;
1009 INT i
, iMaps
, nWidth
, nHeight
;
1012 LPCOLORMAP sysColorMap
;
1014 COLORMAP internalColorMap
[4] =
1015 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
1017 /* initialize pointer to colortable and default color table */
1020 sysColorMap
= lpColorMap
;
1023 internalColorMap
[0].to
= GetSysColor (COLOR_BTNTEXT
);
1024 internalColorMap
[1].to
= GetSysColor (COLOR_BTNSHADOW
);
1025 internalColorMap
[2].to
= GetSysColor (COLOR_BTNFACE
);
1026 internalColorMap
[3].to
= GetSysColor (COLOR_BTNHIGHLIGHT
);
1028 sysColorMap
= internalColorMap
;
1031 hRsrc
= FindResourceW (hInstance
, (LPWSTR
)idBitmap
, (LPWSTR
)RT_BITMAP
);
1034 hglb
= LoadResource (hInstance
, hRsrc
);
1037 lpBitmap
= LockResource (hglb
);
1038 if (lpBitmap
== NULL
)
1041 if (lpBitmap
->biSize
>= sizeof(BITMAPINFOHEADER
) && lpBitmap
->biClrUsed
)
1042 nColorTableSize
= lpBitmap
->biClrUsed
;
1043 else if (lpBitmap
->biBitCount
<= 8)
1044 nColorTableSize
= (1 << lpBitmap
->biBitCount
);
1046 nColorTableSize
= 0;
1047 nSize
= lpBitmap
->biSize
;
1048 if (nSize
== sizeof(BITMAPINFOHEADER
) && lpBitmap
->biCompression
== BI_BITFIELDS
)
1049 nSize
+= 3 * sizeof(DWORD
);
1050 nSize
+= nColorTableSize
* sizeof(RGBQUAD
);
1051 lpBitmapInfo
= GlobalAlloc (GMEM_FIXED
, nSize
);
1052 if (lpBitmapInfo
== NULL
)
1054 RtlMoveMemory (lpBitmapInfo
, lpBitmap
, nSize
);
1056 pColorTable
= (RGBQUAD
*)(((LPBYTE
)lpBitmapInfo
) + lpBitmapInfo
->biSize
);
1058 for (iColor
= 0; iColor
< nColorTableSize
; iColor
++) {
1059 for (i
= 0; i
< iMaps
; i
++) {
1060 cRef
= RGB(pColorTable
[iColor
].rgbRed
,
1061 pColorTable
[iColor
].rgbGreen
,
1062 pColorTable
[iColor
].rgbBlue
);
1063 if ( cRef
== sysColorMap
[i
].from
) {
1065 if (wFlags
& CBS_MASKED
) {
1066 if (sysColorMap
[i
].to
!= COLOR_BTNTEXT
)
1067 pColorTable
[iColor
] = RGB(255, 255, 255);
1071 pColorTable
[iColor
].rgbBlue
= GetBValue(sysColorMap
[i
].to
);
1072 pColorTable
[iColor
].rgbGreen
= GetGValue(sysColorMap
[i
].to
);
1073 pColorTable
[iColor
].rgbRed
= GetRValue(sysColorMap
[i
].to
);
1078 nWidth
= lpBitmapInfo
->biWidth
;
1079 nHeight
= lpBitmapInfo
->biHeight
;
1080 hdcScreen
= GetDC (NULL
);
1081 hbm
= CreateCompatibleBitmap (hdcScreen
, nWidth
, nHeight
);
1083 HDC hdcDst
= CreateCompatibleDC (hdcScreen
);
1084 HBITMAP hbmOld
= SelectObject (hdcDst
, hbm
);
1085 const BYTE
*lpBits
= (const BYTE
*)lpBitmap
+ nSize
;
1086 StretchDIBits (hdcDst
, 0, 0, nWidth
, nHeight
, 0, 0, nWidth
, nHeight
,
1087 lpBits
, (LPBITMAPINFO
)lpBitmapInfo
, DIB_RGB_COLORS
,
1089 SelectObject (hdcDst
, hbmOld
);
1092 ReleaseDC (NULL
, hdcScreen
);
1093 GlobalFree (lpBitmapInfo
);
1094 FreeResource (hglb
);
1100 /***********************************************************************
1101 * CreateToolbar [COMCTL32.7]
1103 * Creates a toolbar control.
1116 * Success: handle to the tool bar control
1120 * Do not use this function anymore. Use CreateToolbarEx instead.
1124 CreateToolbar (HWND hwnd
, DWORD style
, UINT wID
, INT nBitmaps
,
1125 HINSTANCE hBMInst
, UINT wBMID
,
1126 LPCTBBUTTON lpButtons
,INT iNumButtons
)
1128 return CreateToolbarEx (hwnd
, style
| CCS_NODIVIDER
, wID
, nBitmaps
,
1129 hBMInst
, wBMID
, lpButtons
,
1130 iNumButtons
, 0, 0, 0, 0, CCSIZEOF_STRUCT(TBBUTTON
, dwData
));
1134 /***********************************************************************
1135 * DllGetVersion [COMCTL32.@]
1137 * Retrieves version information of the 'COMCTL32.DLL'
1140 * pdvi [O] pointer to version information structure.
1144 * Failure: E_INVALIDARG
1147 * Returns version of a comctl32.dll from IE4.01 SP1.
1150 HRESULT WINAPI
DllGetVersion (DLLVERSIONINFO
*pdvi
)
1152 if (pdvi
->cbSize
!= sizeof(DLLVERSIONINFO
)) {
1153 WARN("wrong DLLVERSIONINFO size from app\n");
1154 return E_INVALIDARG
;
1157 pdvi
->dwMajorVersion
= COMCTL32_VERSION
;
1158 pdvi
->dwMinorVersion
= COMCTL32_VERSION_MINOR
;
1159 pdvi
->dwBuildNumber
= 2919;
1160 pdvi
->dwPlatformID
= 6304;
1162 TRACE("%u.%u.%u.%u\n",
1163 pdvi
->dwMajorVersion
, pdvi
->dwMinorVersion
,
1164 pdvi
->dwBuildNumber
, pdvi
->dwPlatformID
);
1169 /***********************************************************************
1170 * DllInstall (COMCTL32.@)
1172 * Installs the ComCtl32 DLL.
1176 * Failure: A HRESULT error
1178 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
1180 TRACE("(%u, %s): stub\n", bInstall
, debugstr_w(cmdline
));
1184 if (!create_manifest(bInstall
, TRUE
))
1186 ERR("Failed to install comctl32 v6 manifest!\n");
1187 return HRESULT_FROM_WIN32(GetLastError());
1190 if (!create_manifest(bInstall
, FALSE
))
1192 ERR("Failed to install comctl32 v5 manifest!\n");
1193 return HRESULT_FROM_WIN32(GetLastError());
1200 /***********************************************************************
1201 * _TrackMouseEvent [COMCTL32.@]
1203 * Requests notification of mouse events
1205 * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
1206 * to the hwnd specified in the ptme structure. After the event message
1207 * is posted to the hwnd, the entry in the queue is removed.
1209 * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
1210 * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
1211 * immediately and the TME_LEAVE flag being ignored.
1214 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
1220 * IMPLEMENTATION moved to USER32.TrackMouseEvent
1225 _TrackMouseEvent (TRACKMOUSEEVENT
*ptme
)
1227 return TrackMouseEvent (ptme
);
1230 /*************************************************************************
1231 * GetMUILanguage [COMCTL32.@]
1233 * Returns the user interface language in use by the current process.
1236 * Language ID in use by the current process.
1238 LANGID WINAPI
GetMUILanguage (VOID
)
1240 return COMCTL32_uiLang
;
1244 /*************************************************************************
1245 * InitMUILanguage [COMCTL32.@]
1247 * Sets the user interface language to be used by the current process.
1252 VOID WINAPI
InitMUILanguage (LANGID uiLang
)
1254 COMCTL32_uiLang
= uiLang
;
1258 /***********************************************************************
1259 * SetWindowSubclass [COMCTL32.410]
1261 * Starts a window subclass
1264 * hWnd [in] handle to window subclass.
1265 * pfnSubclass [in] Pointer to new window procedure.
1266 * uIDSubclass [in] Unique identifier of subclass together with pfnSubclass.
1267 * dwRef [in] Reference data to pass to window procedure.
1274 * If an application manually subclasses a window after subclassing it with
1275 * this API and then with this API again, then none of the previous
1276 * subclasses get called or the original window procedure.
1279 BOOL WINAPI
SetWindowSubclass (HWND hWnd
, SUBCLASSPROC pfnSubclass
,
1280 UINT_PTR uIDSubclass
, DWORD_PTR dwRef
)
1282 LPSUBCLASS_INFO stack
;
1283 LPSUBCLASSPROCS proc
;
1285 TRACE ("(%p, %p, %lx, %lx)\n", hWnd
, pfnSubclass
, uIDSubclass
, dwRef
);
1287 /* Since the window procedure that we set here has two additional arguments,
1288 * we can't simply set it as the new window procedure of the window. So we
1289 * set our own window procedure and then calculate the other two arguments
1292 /* See if we have been called for this window */
1293 stack
= GetPropW (hWnd
, COMCTL32_wSubclass
);
1295 /* allocate stack */
1296 stack
= Alloc (sizeof(SUBCLASS_INFO
));
1298 ERR ("Failed to allocate our Subclassing stack\n");
1301 SetPropW (hWnd
, COMCTL32_wSubclass
, stack
);
1303 /* set window procedure to our own and save the current one */
1304 if (IsWindowUnicode (hWnd
))
1305 stack
->origproc
= (WNDPROC
)SetWindowLongPtrW (hWnd
, GWLP_WNDPROC
,
1306 (DWORD_PTR
)COMCTL32_SubclassProc
);
1308 stack
->origproc
= (WNDPROC
)SetWindowLongPtrA (hWnd
, GWLP_WNDPROC
,
1309 (DWORD_PTR
)COMCTL32_SubclassProc
);
1312 /* Check to see if we have called this function with the same uIDSubClass
1313 * and pfnSubclass */
1314 proc
= stack
->SubclassProcs
;
1316 if ((proc
->id
== uIDSubclass
) &&
1317 (proc
->subproc
== pfnSubclass
)) {
1325 proc
= Alloc(sizeof(SUBCLASSPROCS
));
1327 ERR ("Failed to allocate subclass entry in stack\n");
1328 if (IsWindowUnicode (hWnd
))
1329 SetWindowLongPtrW (hWnd
, GWLP_WNDPROC
, (DWORD_PTR
)stack
->origproc
);
1331 SetWindowLongPtrA (hWnd
, GWLP_WNDPROC
, (DWORD_PTR
)stack
->origproc
);
1333 RemovePropW( hWnd
, COMCTL32_wSubclass
);
1337 proc
->subproc
= pfnSubclass
;
1339 proc
->id
= uIDSubclass
;
1340 proc
->next
= stack
->SubclassProcs
;
1341 stack
->SubclassProcs
= proc
;
1347 /***********************************************************************
1348 * GetWindowSubclass [COMCTL32.411]
1350 * Gets the Reference data from a subclass.
1353 * hWnd [in] Handle to the window which we are subclassing
1354 * pfnSubclass [in] Pointer to the subclass procedure
1355 * uID [in] Unique identifier of the subclassing procedure
1356 * pdwRef [out] Pointer to the reference data
1363 BOOL WINAPI
GetWindowSubclass (HWND hWnd
, SUBCLASSPROC pfnSubclass
,
1364 UINT_PTR uID
, DWORD_PTR
*pdwRef
)
1366 const SUBCLASS_INFO
*stack
;
1367 const SUBCLASSPROCS
*proc
;
1369 TRACE ("(%p, %p, %lx, %p)\n", hWnd
, pfnSubclass
, uID
, pdwRef
);
1371 /* See if we have been called for this window */
1372 stack
= GetPropW (hWnd
, COMCTL32_wSubclass
);
1376 proc
= stack
->SubclassProcs
;
1378 if ((proc
->id
== uID
) &&
1379 (proc
->subproc
== pfnSubclass
)) {
1380 *pdwRef
= proc
->ref
;
1390 /***********************************************************************
1391 * RemoveWindowSubclass [COMCTL32.412]
1393 * Removes a window subclass.
1396 * hWnd [in] Handle to the window which we are subclassing
1397 * pfnSubclass [in] Pointer to the subclass procedure
1398 * uID [in] Unique identifier of this subclass
1405 BOOL WINAPI
RemoveWindowSubclass(HWND hWnd
, SUBCLASSPROC pfnSubclass
, UINT_PTR uID
)
1407 LPSUBCLASS_INFO stack
;
1408 LPSUBCLASSPROCS prevproc
= NULL
;
1409 LPSUBCLASSPROCS proc
;
1412 TRACE ("(%p, %p, %lx)\n", hWnd
, pfnSubclass
, uID
);
1414 /* Find the Subclass to remove */
1415 stack
= GetPropW (hWnd
, COMCTL32_wSubclass
);
1419 proc
= stack
->SubclassProcs
;
1421 if ((proc
->id
== uID
) &&
1422 (proc
->subproc
== pfnSubclass
)) {
1425 stack
->SubclassProcs
= proc
->next
;
1427 prevproc
->next
= proc
->next
;
1429 if (stack
->stackpos
== proc
)
1430 stack
->stackpos
= stack
->stackpos
->next
;
1440 if (!stack
->SubclassProcs
&& !stack
->running
) {
1441 TRACE("Last Subclass removed, cleaning up\n");
1442 /* clean up our heap and reset the original window procedure */
1443 if (IsWindowUnicode (hWnd
))
1444 SetWindowLongPtrW (hWnd
, GWLP_WNDPROC
, (DWORD_PTR
)stack
->origproc
);
1446 SetWindowLongPtrA (hWnd
, GWLP_WNDPROC
, (DWORD_PTR
)stack
->origproc
);
1448 RemovePropW( hWnd
, COMCTL32_wSubclass
);
1454 /***********************************************************************
1455 * COMCTL32_SubclassProc (internal)
1457 * Window procedure for all subclassed windows.
1458 * Saves the current subclassing stack position to support nested messages
1460 static LRESULT WINAPI
COMCTL32_SubclassProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1462 LPSUBCLASS_INFO stack
;
1463 LPSUBCLASSPROCS proc
;
1466 TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd
, uMsg
, wParam
, lParam
);
1468 stack
= GetPropW (hWnd
, COMCTL32_wSubclass
);
1470 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd
);
1474 /* Save our old stackpos to properly handle nested messages */
1475 proc
= stack
->stackpos
;
1476 stack
->stackpos
= stack
->SubclassProcs
;
1478 ret
= DefSubclassProc(hWnd
, uMsg
, wParam
, lParam
);
1480 stack
->stackpos
= proc
;
1482 if (!stack
->SubclassProcs
&& !stack
->running
) {
1483 TRACE("Last Subclass removed, cleaning up\n");
1484 /* clean up our heap and reset the original window procedure */
1485 if (IsWindowUnicode (hWnd
))
1486 SetWindowLongPtrW (hWnd
, GWLP_WNDPROC
, (DWORD_PTR
)stack
->origproc
);
1488 SetWindowLongPtrA (hWnd
, GWLP_WNDPROC
, (DWORD_PTR
)stack
->origproc
);
1490 RemovePropW( hWnd
, COMCTL32_wSubclass
);
1495 /***********************************************************************
1496 * DefSubclassProc [COMCTL32.413]
1498 * Calls the next window procedure (i.e. the one before this subclass)
1501 * hWnd [in] The window that we're subclassing
1503 * wParam [in] WPARAM
1504 * lParam [in] LPARAM
1511 LRESULT WINAPI
DefSubclassProc (HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1513 LPSUBCLASS_INFO stack
;
1516 TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd
, uMsg
, wParam
, lParam
);
1518 /* retrieve our little stack from the Properties */
1519 stack
= GetPropW (hWnd
, COMCTL32_wSubclass
);
1521 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd
);
1525 /* If we are at the end of stack then we have to call the original
1526 * window procedure */
1527 if (!stack
->stackpos
) {
1528 if (IsWindowUnicode (hWnd
))
1529 ret
= CallWindowProcW (stack
->origproc
, hWnd
, uMsg
, wParam
, lParam
);
1531 ret
= CallWindowProcA (stack
->origproc
, hWnd
, uMsg
, wParam
, lParam
);
1533 const SUBCLASSPROCS
*proc
= stack
->stackpos
;
1534 stack
->stackpos
= stack
->stackpos
->next
;
1535 /* call the Subclass procedure from the stack */
1536 ret
= proc
->subproc (hWnd
, uMsg
, wParam
, lParam
,
1537 proc
->id
, proc
->ref
);
1544 /***********************************************************************
1545 * COMCTL32_CreateToolTip [NOT AN API]
1547 * Creates a tooltip for the control specified in hwnd and does all
1548 * necessary setup and notifications.
1551 * hwndOwner [I] Handle to the window that will own the tool tip.
1554 * Success: Handle of tool tip window.
1559 COMCTL32_CreateToolTip(HWND hwndOwner
)
1563 hwndToolTip
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, WS_POPUP
,
1564 CW_USEDEFAULT
, CW_USEDEFAULT
,
1565 CW_USEDEFAULT
, CW_USEDEFAULT
, hwndOwner
,
1568 /* Send NM_TOOLTIPSCREATED notification */
1571 NMTOOLTIPSCREATED nmttc
;
1572 /* true owner can be different if hwndOwner is a child window */
1573 HWND hwndTrueOwner
= GetWindow(hwndToolTip
, GW_OWNER
);
1574 nmttc
.hdr
.hwndFrom
= hwndTrueOwner
;
1575 nmttc
.hdr
.idFrom
= GetWindowLongPtrW(hwndTrueOwner
, GWLP_ID
);
1576 nmttc
.hdr
.code
= NM_TOOLTIPSCREATED
;
1577 nmttc
.hwndToolTips
= hwndToolTip
;
1579 SendMessageW(GetParent(hwndTrueOwner
), WM_NOTIFY
,
1580 GetWindowLongPtrW(hwndTrueOwner
, GWLP_ID
), (LPARAM
)&nmttc
);
1587 /***********************************************************************
1588 * COMCTL32_RefreshSysColors [NOT AN API]
1590 * Invoked on any control recognizing a WM_SYSCOLORCHANGE message to
1591 * refresh the color values in the color structure
1601 COMCTL32_RefreshSysColors(void)
1603 comctl32_color
.clrBtnHighlight
= GetSysColor (COLOR_BTNHIGHLIGHT
);
1604 comctl32_color
.clrBtnShadow
= GetSysColor (COLOR_BTNSHADOW
);
1605 comctl32_color
.clrBtnText
= GetSysColor (COLOR_BTNTEXT
);
1606 comctl32_color
.clrBtnFace
= GetSysColor (COLOR_BTNFACE
);
1607 comctl32_color
.clrHighlight
= GetSysColor (COLOR_HIGHLIGHT
);
1608 comctl32_color
.clrHighlightText
= GetSysColor (COLOR_HIGHLIGHTTEXT
);
1609 comctl32_color
.clrHotTrackingColor
= GetSysColor (COLOR_HOTLIGHT
);
1610 comctl32_color
.clr3dHilight
= GetSysColor (COLOR_3DHILIGHT
);
1611 comctl32_color
.clr3dShadow
= GetSysColor (COLOR_3DSHADOW
);
1612 comctl32_color
.clr3dDkShadow
= GetSysColor (COLOR_3DDKSHADOW
);
1613 comctl32_color
.clr3dFace
= GetSysColor (COLOR_3DFACE
);
1614 comctl32_color
.clrWindow
= GetSysColor (COLOR_WINDOW
);
1615 comctl32_color
.clrWindowText
= GetSysColor (COLOR_WINDOWTEXT
);
1616 comctl32_color
.clrGrayText
= GetSysColor (COLOR_GRAYTEXT
);
1617 comctl32_color
.clrActiveCaption
= GetSysColor (COLOR_ACTIVECAPTION
);
1618 comctl32_color
.clrInfoBk
= GetSysColor (COLOR_INFOBK
);
1619 comctl32_color
.clrInfoText
= GetSysColor (COLOR_INFOTEXT
);
1622 /***********************************************************************
1623 * COMCTL32_DrawInsertMark [NOT AN API]
1625 * Draws an insertion mark (which looks similar to an 'I').
1628 * hDC [I] Device context to draw onto.
1629 * lpRect [I] Co-ordinates of insertion mark.
1630 * clrInsertMark [I] Colour of the insertion mark.
1631 * bHorizontal [I] True if insert mark should be drawn horizontally,
1632 * vertical otherwise.
1638 * Draws up to but not including the bottom co-ordinate when drawing
1639 * vertically or the right co-ordinate when horizontal.
1641 void COMCTL32_DrawInsertMark(HDC hDC
, const RECT
*lpRect
, COLORREF clrInsertMark
, BOOL bHorizontal
)
1643 HPEN hPen
= CreatePen(PS_SOLID
, 1, clrInsertMark
);
1645 static const DWORD adwPolyPoints
[] = {4,4,4};
1646 LONG lCentre
= (bHorizontal
?
1647 lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
)/2 :
1648 lpRect
->left
+ (lpRect
->right
- lpRect
->left
)/2);
1649 LONG l1
= (bHorizontal
? lpRect
->left
: lpRect
->top
);
1650 LONG l2
= (bHorizontal
? lpRect
->right
: lpRect
->bottom
);
1651 const POINT aptInsertMark
[] =
1653 /* top (V) or left (H) arrow */
1657 {lCentre
+ 1, l1
+ 2},
1661 {lCentre
+ 1, l1
- 1},
1662 {lCentre
+ 1, l2
- 2},
1663 /* bottom (V) or right (H) arrow */
1665 {lCentre
- 2, l2
- 1},
1666 {lCentre
+ 3, l2
- 1},
1667 {lCentre
+ 1, l2
- 3},
1669 hOldPen
= SelectObject(hDC
, hPen
);
1670 PolyPolyline(hDC
, aptInsertMark
, adwPolyPoints
, sizeof(adwPolyPoints
)/sizeof(adwPolyPoints
[0]));
1671 SelectObject(hDC
, hOldPen
);
1675 /***********************************************************************
1676 * COMCTL32_EnsureBitmapSize [internal]
1678 * If needed, enlarge the bitmap so that the width is at least cxMinWidth and
1679 * the height is at least cyMinHeight. If the bitmap already has these
1680 * dimensions nothing changes.
1683 * hBitmap [I/O] Bitmap to modify. The handle may change
1684 * cxMinWidth [I] If the width of the bitmap is smaller, then it will
1685 * be enlarged to this value
1686 * cyMinHeight [I] If the height of the bitmap is smaller, then it will
1687 * be enlarged to this value
1688 * cyBackground [I] The color with which the new area will be filled
1693 void COMCTL32_EnsureBitmapSize(HBITMAP
*pBitmap
, int cxMinWidth
, int cyMinHeight
, COLORREF crBackground
)
1698 HBITMAP hNewDCBitmap
, hOldDCBitmap
;
1702 if (!GetObjectW(*pBitmap
, sizeof(BITMAP
), &bmp
))
1704 cxNew
= (cxMinWidth
> bmp
.bmWidth
? cxMinWidth
: bmp
.bmWidth
);
1705 cyNew
= (cyMinHeight
> bmp
.bmHeight
? cyMinHeight
: bmp
.bmHeight
);
1706 if (cxNew
== bmp
.bmWidth
&& cyNew
== bmp
.bmHeight
)
1709 hdcNew
= CreateCompatibleDC(NULL
);
1710 hNewBitmap
= CreateBitmap(cxNew
, cyNew
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
1711 hNewDCBitmap
= SelectObject(hdcNew
, hNewBitmap
);
1712 hNewDCBrush
= SelectObject(hdcNew
, CreateSolidBrush(crBackground
));
1714 hdcOld
= CreateCompatibleDC(NULL
);
1715 hOldDCBitmap
= SelectObject(hdcOld
, *pBitmap
);
1717 BitBlt(hdcNew
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
, hdcOld
, 0, 0, SRCCOPY
);
1718 if (bmp
.bmWidth
< cxMinWidth
)
1719 PatBlt(hdcNew
, bmp
.bmWidth
, 0, cxNew
, bmp
.bmHeight
, PATCOPY
);
1720 if (bmp
.bmHeight
< cyMinHeight
)
1721 PatBlt(hdcNew
, 0, bmp
.bmHeight
, bmp
.bmWidth
, cyNew
, PATCOPY
);
1722 if (bmp
.bmWidth
< cxMinWidth
&& bmp
.bmHeight
< cyMinHeight
)
1723 PatBlt(hdcNew
, bmp
.bmWidth
, bmp
.bmHeight
, cxNew
, cyNew
, PATCOPY
);
1725 SelectObject(hdcNew
, hNewDCBitmap
);
1726 DeleteObject(SelectObject(hdcNew
, hNewDCBrush
));
1728 SelectObject(hdcOld
, hOldDCBitmap
);
1731 DeleteObject(*pBitmap
);
1732 *pBitmap
= hNewBitmap
;
1736 void COMCTL32_GetFontMetrics(HFONT hFont
, TEXTMETRICW
*ptm
)
1738 HDC hdc
= GetDC(NULL
);
1741 hOldFont
= SelectObject(hdc
, hFont
);
1742 GetTextMetricsW(hdc
, ptm
);
1743 SelectObject(hdc
, hOldFont
);
1744 ReleaseDC(NULL
, hdc
);
1747 #ifndef OCM__BASE /* avoid including olectl.h */
1748 #define OCM__BASE (WM_USER+0x1c00)
1751 /***********************************************************************
1752 * COMCTL32_IsReflectedMessage [internal]
1754 * Some parents reflect notify messages - for some messages sent by the child,
1755 * they send it back with the message code increased by OCM__BASE (0x2000).
1756 * This allows better subclassing of controls. We don't need to handle such
1757 * messages but we don't want to print ERRs for them, so this helper function
1760 * Some of the codes are in the CCM_FIRST..CCM_LAST range, but there is no
1761 * collision with defined CCM_ codes.
1763 BOOL
COMCTL32_IsReflectedMessage(UINT uMsg
)
1767 case OCM__BASE
+ WM_COMMAND
:
1768 case OCM__BASE
+ WM_CTLCOLORBTN
:
1769 case OCM__BASE
+ WM_CTLCOLOREDIT
:
1770 case OCM__BASE
+ WM_CTLCOLORDLG
:
1771 case OCM__BASE
+ WM_CTLCOLORLISTBOX
:
1772 case OCM__BASE
+ WM_CTLCOLORMSGBOX
:
1773 case OCM__BASE
+ WM_CTLCOLORSCROLLBAR
:
1774 case OCM__BASE
+ WM_CTLCOLORSTATIC
:
1775 case OCM__BASE
+ WM_DRAWITEM
:
1776 case OCM__BASE
+ WM_MEASUREITEM
:
1777 case OCM__BASE
+ WM_DELETEITEM
:
1778 case OCM__BASE
+ WM_VKEYTOITEM
:
1779 case OCM__BASE
+ WM_CHARTOITEM
:
1780 case OCM__BASE
+ WM_COMPAREITEM
:
1781 case OCM__BASE
+ WM_HSCROLL
:
1782 case OCM__BASE
+ WM_VSCROLL
:
1783 case OCM__BASE
+ WM_PARENTNOTIFY
:
1784 case OCM__BASE
+ WM_NOTIFY
:
1791 /***********************************************************************
1792 * MirrorIcon [COMCTL32.414]
1794 * Mirrors an icon so that it will appear correctly on a mirrored DC.
1797 * phicon1 [I/O] Icon.
1798 * phicon2 [I/O] Icon.
1804 BOOL WINAPI
MirrorIcon(HICON
*phicon1
, HICON
*phicon2
)
1806 FIXME("(%p, %p): stub\n", phicon1
, phicon2
);
1810 static inline BOOL
IsDelimiter(WCHAR c
)
1823 static int CALLBACK
PathWordBreakProc(LPCWSTR lpch
, int ichCurrent
, int cch
, int code
)
1825 if (code
== WB_ISDELIMITER
)
1826 return IsDelimiter(lpch
[ichCurrent
]);
1829 int dir
= (code
== WB_LEFT
) ? -1 : 1;
1830 for(; 0 <= ichCurrent
&& ichCurrent
< cch
; ichCurrent
+= dir
)
1831 if (IsDelimiter(lpch
[ichCurrent
])) return ichCurrent
;
1836 /***********************************************************************
1837 * SetPathWordBreakProc [COMCTL32.384]
1839 * Sets the word break procedure for an edit control to one that understands
1840 * paths so that the user can jump over directories.
1843 * hwnd [I] Handle to edit control.
1844 * bSet [I] If this is TRUE then the word break proc is set, otherwise it is removed.
1847 * Result from EM_SETWORDBREAKPROC message.
1849 LRESULT WINAPI
SetPathWordBreakProc(HWND hwnd
, BOOL bSet
)
1851 return SendMessageW(hwnd
, EM_SETWORDBREAKPROC
, 0,
1852 (LPARAM
)(bSet
? PathWordBreakProc
: NULL
));
1855 /***********************************************************************
1856 * DrawShadowText [COMCTL32.@]
1858 * Draw text with shadow.
1860 int WINAPI
DrawShadowText(HDC hdc
, LPCWSTR pszText
, UINT cch
, RECT
*prc
, DWORD dwFlags
,
1861 COLORREF crText
, COLORREF crShadow
, int ixOffset
, int iyOffset
)
1865 INT iRet
, x
, y
, x2
, y2
;
1867 HBITMAP hbm
, hbmOld
;
1873 /* Create 32 bit DIB section for the shadow */
1874 ZeroMemory(&bi
, sizeof(bi
));
1875 bi
.bmiHeader
.biSize
= sizeof(bi
.bmiHeader
);
1876 bi
.bmiHeader
.biWidth
= prc
->right
- prc
->left
+ 4;
1877 bi
.bmiHeader
.biHeight
= prc
->bottom
- prc
->top
+ 5; // bottom-up DIB
1878 bi
.bmiHeader
.biPlanes
= 1;
1879 bi
.bmiHeader
.biBitCount
= 32;
1880 bi
.bmiHeader
.biCompression
= BI_RGB
;
1881 hbm
= CreateDIBSection(hdc
, &bi
, DIB_RGB_COLORS
, (PVOID
*)&pBits
, NULL
, 0);
1884 ERR("CreateDIBSection failed\n");
1888 /* Create memory device context for new DIB section and select it */
1889 hdcMem
= CreateCompatibleDC(hdc
);
1892 ERR("CreateCompatibleDC failed\n");
1897 hbmOld
= (HBITMAP
)SelectObject(hdcMem
, hbm
);
1899 /* Draw text on our helper bitmap */
1900 hOldFont
= (HFONT
)SelectObject(hdcMem
, GetCurrentObject(hdc
, OBJ_FONT
));
1901 SetTextColor(hdcMem
, RGB(16, 16, 16));
1902 SetBkColor(hdcMem
, RGB(0, 0, 0));
1903 SetBkMode(hdcMem
, TRANSPARENT
);
1904 SetRect(&rcText
, 0, 0, prc
->right
- prc
->left
, prc
->bottom
- prc
->top
);
1905 DrawTextW(hdcMem
, pszText
, cch
, &rcText
, dwFlags
);
1906 SelectObject(hdcMem
, hOldFont
);
1908 /* Flush GDI so data pointed by pBits is valid */
1911 /* Set alpha of pixels (forget about colors for now. They will be changed in next loop).
1912 We copy text image 4*5 times and each time alpha is added */
1913 for (x
= 0; x
< bi
.bmiHeader
.biWidth
; ++x
)
1914 for (y
= 0; y
< bi
.bmiHeader
.biHeight
; ++y
)
1916 BYTE
*pDest
= &pBits
[(y
* bi
.bmiHeader
.biWidth
+ x
) * 4];
1919 for (x2
= x
- 4 + 1; x2
<= x
; ++x2
)
1920 for (y2
= y
; y2
< y
+ 5; ++y2
)
1922 if (x2
>= 0 && x2
< bi
.bmiHeader
.biWidth
&& y2
>= 0 && y2
< bi
.bmiHeader
.biHeight
)
1924 BYTE
*pSrc
= &pBits
[(y2
* bi
.bmiHeader
.biWidth
+ x2
) * 4];
1934 /* Now set the color of each pixel to shadow color * alpha (see GdiAlphaBlend) */
1935 for (x
= 0; x
< bi
.bmiHeader
.biWidth
; ++x
)
1936 for (y
= 0; y
< bi
.bmiHeader
.biHeight
; ++y
)
1938 BYTE
*pDest
= &pBits
[(y
* bi
.bmiHeader
.biWidth
+ x
) * 4];
1939 pDest
[0] = GetBValue(crShadow
) * pDest
[3] / 255;
1940 pDest
[1] = GetGValue(crShadow
) * pDest
[3] / 255;
1941 pDest
[2] = GetRValue(crShadow
) * pDest
[3] / 255;
1944 /* Fix ixOffset of the shadow (tested on Win) */
1948 /* Alpha blend helper image to destination DC */
1949 bf
.BlendOp
= AC_SRC_OVER
;
1951 bf
.SourceConstantAlpha
= 255;
1952 bf
.AlphaFormat
= AC_SRC_ALPHA
;
1953 GdiAlphaBlend(hdc
, prc
->left
+ ixOffset
, prc
->top
+ iyOffset
, bi
.bmiHeader
.biWidth
, bi
.bmiHeader
.biHeight
, hdcMem
, 0, 0, bi
.bmiHeader
.biWidth
, bi
.bmiHeader
.biHeight
, bf
);
1955 /* Delete the helper bitmap */
1956 SelectObject(hdcMem
, hbmOld
);
1960 /* Finally draw the text over shadow */
1961 crOldText
= SetTextColor(hdc
, crText
);
1962 SetBkMode(hdc
, TRANSPARENT
);
1963 iRet
= DrawTextW(hdc
, pszText
, cch
, prc
, dwFlags
);
1964 SetTextColor(hdc
, crOldText
);
1969 /***********************************************************************
1970 * LoadIconWithScaleDown [COMCTL32.@]
1972 HRESULT WINAPI
LoadIconWithScaleDown(HINSTANCE hinst
, const WCHAR
*name
, int cx
, int cy
, HICON
*icon
)
1974 TRACE("(%p, %s, %d, %d, %p)\n", hinst
, debugstr_w(name
), cx
, cy
, icon
);
1979 return E_INVALIDARG
;
1981 *icon
= LoadImageW(hinst
, name
, IMAGE_ICON
, cx
, cy
,
1982 (hinst
|| IS_INTRESOURCE(name
)) ? 0 : LR_LOADFROMFILE
);
1984 return HRESULT_FROM_WIN32(GetLastError());
1989 /***********************************************************************
1990 * LoadIconMetric [COMCTL32.@]
1992 HRESULT WINAPI
LoadIconMetric(HINSTANCE hinst
, const WCHAR
*name
, int size
, HICON
*icon
)
1996 TRACE("(%p, %s, %d, %p)\n", hinst
, debugstr_w(name
), size
, icon
);
1998 if (size
== LIM_SMALL
)
2000 cx
= GetSystemMetrics(SM_CXSMICON
);
2001 cy
= GetSystemMetrics(SM_CYSMICON
);
2003 else if (size
== LIM_LARGE
)
2005 cx
= GetSystemMetrics(SM_CXICON
);
2006 cy
= GetSystemMetrics(SM_CYICON
);
2011 return E_INVALIDARG
;
2014 return LoadIconWithScaleDown(hinst
, name
, cx
, cy
, icon
);