comctl32: Fix missing toolbar button with HINST_COMMCTRL.
[wine/multimedia.git] / dlls / comctl32 / commctrl.c
blobc09bc04e44585ffd765da9f71dcfce0d90e01648
1 /*
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 * NOTES
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.
30 * TODO
31 * -- implement GetMUILanguage + InitMUILanguage
32 * -- finish NOTES for MenuHelp, GetEffectiveClientRect and GetStatusTextW
33 * -- FIXMEs + BUGS (search for them)
35 * Control Classes
36 * -- ICC_ANIMATE_CLASS
37 * -- ICC_BAR_CLASSES
38 * -- ICC_COOL_CLASSES
39 * -- ICC_DATE_CLASSES
40 * -- ICC_HOTKEY_CLASS
41 * -- ICC_INTERNET_CLASSES
42 * -- ICC_LINK_CLASS
43 * -- ICC_LISTVIEW_CLASSES
44 * -- ICC_NATIVEFNTCTL_CLASS
45 * -- ICC_PAGESCROLLER_CLASS
46 * -- ICC_PROGRESS_CLASS
47 * -- ICC_STANDARD_CLASSES (not yet implemented)
48 * -- ICC_TAB_CLASSES
49 * -- ICC_TREEVIEW_CLASSES
50 * -- ICC_UPDOWN_CLASS
51 * -- ICC_USEREX_CLASSES
52 * -- ICC_WIN95_CLASSES
55 #include <stdarg.h>
56 #include <string.h>
57 #include <stdlib.h>
59 #include "windef.h"
60 #include "winbase.h"
61 #include "wingdi.h"
62 #include "winuser.h"
63 #include "winnls.h"
64 #include "commctrl.h"
65 #include "winerror.h"
66 #include "winreg.h"
67 #define NO_SHLWAPI_STREAM
68 #include "shlwapi.h"
69 #include "comctl32.h"
70 #include "wine/debug.h"
72 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
74 LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
76 LPWSTR COMCTL32_wSubclass = NULL;
77 HMODULE COMCTL32_hModule = 0;
78 LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
79 HBRUSH COMCTL32_hPattern55AABrush = NULL;
80 COMCTL32_SysColor comctl32_color;
82 static HBITMAP COMCTL32_hPattern55AABitmap = NULL;
84 static const WORD wPattern55AA[] =
86 0x5555, 0xaaaa, 0x5555, 0xaaaa,
87 0x5555, 0xaaaa, 0x5555, 0xaaaa
90 static const WCHAR strCC32SubclassInfo[] = {
91 'C','C','3','2','S','u','b','c','l','a','s','s','I','n','f','o',0
94 /***********************************************************************
95 * DllMain [Internal]
97 * Initializes the internal 'COMCTL32.DLL'.
99 * PARAMS
100 * hinstDLL [I] handle to the 'dlls' instance
101 * fdwReason [I]
102 * lpvReserved [I] reserverd, must be NULL
104 * RETURNS
105 * Success: TRUE
106 * Failure: FALSE
109 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
111 TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
113 switch (fdwReason) {
114 case DLL_PROCESS_ATTACH:
115 DisableThreadLibraryCalls(hinstDLL);
117 COMCTL32_hModule = (HMODULE)hinstDLL;
119 /* add global subclassing atom (used by 'tooltip' and 'updown') */
120 COMCTL32_wSubclass = (LPWSTR)(DWORD_PTR)GlobalAddAtomW (strCC32SubclassInfo);
121 TRACE("Subclassing atom added: %p\n", COMCTL32_wSubclass);
123 /* create local pattern brush */
124 COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA);
125 COMCTL32_hPattern55AABrush = CreatePatternBrush (COMCTL32_hPattern55AABitmap);
127 /* Get all the colors at DLL load */
128 COMCTL32_RefreshSysColors();
130 /* like comctl32 5.82+ register all the common control classes */
131 ANIMATE_Register ();
132 COMBOEX_Register ();
133 DATETIME_Register ();
134 FLATSB_Register ();
135 HEADER_Register ();
136 HOTKEY_Register ();
137 IPADDRESS_Register ();
138 LISTVIEW_Register ();
139 MONTHCAL_Register ();
140 NATIVEFONT_Register ();
141 PAGER_Register ();
142 PROGRESS_Register ();
143 REBAR_Register ();
144 STATUS_Register ();
145 SYSLINK_Register ();
146 TAB_Register ();
147 TOOLBAR_Register ();
148 TOOLTIPS_Register ();
149 TRACKBAR_Register ();
150 TREEVIEW_Register ();
151 UPDOWN_Register ();
153 /* subclass user32 controls */
154 THEMING_Initialize ();
155 break;
157 case DLL_PROCESS_DETACH:
158 /* clean up subclassing */
159 THEMING_Uninitialize();
161 /* unregister all common control classes */
162 ANIMATE_Unregister ();
163 COMBOEX_Unregister ();
164 DATETIME_Unregister ();
165 FLATSB_Unregister ();
166 HEADER_Unregister ();
167 HOTKEY_Unregister ();
168 IPADDRESS_Unregister ();
169 LISTVIEW_Unregister ();
170 MONTHCAL_Unregister ();
171 NATIVEFONT_Unregister ();
172 PAGER_Unregister ();
173 PROGRESS_Unregister ();
174 REBAR_Unregister ();
175 STATUS_Unregister ();
176 SYSLINK_Unregister ();
177 TAB_Unregister ();
178 TOOLBAR_Unregister ();
179 TOOLTIPS_Unregister ();
180 TRACKBAR_Unregister ();
181 TREEVIEW_Unregister ();
182 UPDOWN_Unregister ();
184 /* delete local pattern brush */
185 DeleteObject (COMCTL32_hPattern55AABrush);
186 COMCTL32_hPattern55AABrush = NULL;
187 DeleteObject (COMCTL32_hPattern55AABitmap);
188 COMCTL32_hPattern55AABitmap = NULL;
190 /* delete global subclassing atom */
191 GlobalDeleteAtom (LOWORD(COMCTL32_wSubclass));
192 TRACE("Subclassing atom deleted: %p\n", COMCTL32_wSubclass);
193 COMCTL32_wSubclass = NULL;
194 break;
197 return TRUE;
201 /***********************************************************************
202 * MenuHelp [COMCTL32.2]
204 * Handles the setting of status bar help messages when the user
205 * selects menu items.
207 * PARAMS
208 * uMsg [I] message (WM_MENUSELECT) (see NOTES)
209 * wParam [I] wParam of the message uMsg
210 * lParam [I] lParam of the message uMsg
211 * hMainMenu [I] handle to the application's main menu
212 * hInst [I] handle to the module that contains string resources
213 * hwndStatus [I] handle to the status bar window
214 * lpwIDs [I] pointer to an array of integers (see NOTES)
216 * RETURNS
217 * No return value
219 * NOTES
220 * The official documentation is incomplete!
221 * This is the correct documentation:
223 * uMsg:
224 * MenuHelp() does NOT handle WM_COMMAND messages! It only handles
225 * WM_MENUSELECT messages.
227 * lpwIDs:
228 * (will be written ...)
231 VOID WINAPI
232 MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
233 HINSTANCE hInst, HWND hwndStatus, UINT* lpwIDs)
235 UINT uMenuID = 0;
237 if (!IsWindow (hwndStatus))
238 return;
240 switch (uMsg) {
241 case WM_MENUSELECT:
242 TRACE("WM_MENUSELECT wParam=0x%lX lParam=0x%lX\n",
243 wParam, lParam);
245 if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
246 /* menu was closed */
247 TRACE("menu was closed!\n");
248 SendMessageW (hwndStatus, SB_SIMPLE, FALSE, 0);
250 else {
251 /* menu item was selected */
252 if (HIWORD(wParam) & MF_POPUP)
253 uMenuID = (UINT)*(lpwIDs+1);
254 else
255 uMenuID = (UINT)LOWORD(wParam);
256 TRACE("uMenuID = %u\n", uMenuID);
258 if (uMenuID) {
259 WCHAR szText[256];
261 if (!LoadStringW (hInst, uMenuID, szText, sizeof(szText)/sizeof(szText[0])))
262 szText[0] = '\0';
264 SendMessageW (hwndStatus, SB_SETTEXTW,
265 255 | SBT_NOBORDERS, (LPARAM)szText);
266 SendMessageW (hwndStatus, SB_SIMPLE, TRUE, 0);
269 break;
271 case WM_COMMAND :
272 TRACE("WM_COMMAND wParam=0x%lX lParam=0x%lX\n",
273 wParam, lParam);
274 /* WM_COMMAND is not invalid since it is documented
275 * in the windows api reference. So don't output
276 * any FIXME for WM_COMMAND
278 WARN("We don't care about the WM_COMMAND\n");
279 break;
281 default:
282 FIXME("Invalid Message 0x%x!\n", uMsg);
283 break;
288 /***********************************************************************
289 * ShowHideMenuCtl [COMCTL32.3]
291 * Shows or hides controls and updates the corresponding menu item.
293 * PARAMS
294 * hwnd [I] handle to the client window.
295 * uFlags [I] menu command id.
296 * lpInfo [I] pointer to an array of integers. (See NOTES.)
298 * RETURNS
299 * Success: TRUE
300 * Failure: FALSE
302 * NOTES
303 * The official documentation is incomplete!
304 * This is the correct documentation:
306 * hwnd
307 * Handle to the window that contains the menu and controls.
309 * uFlags
310 * Identifier of the menu item to receive or lose a check mark.
312 * lpInfo
313 * The array of integers contains pairs of values. BOTH values of
314 * the first pair must be the handles to the application's main menu.
315 * Each subsequent pair consists of a menu id and control id.
318 BOOL WINAPI
319 ShowHideMenuCtl (HWND hwnd, UINT_PTR uFlags, LPINT lpInfo)
321 LPINT lpMenuId;
323 TRACE("%p, %lx, %p\n", hwnd, uFlags, lpInfo);
325 if (lpInfo == NULL)
326 return FALSE;
328 if (!(lpInfo[0]) || !(lpInfo[1]))
329 return FALSE;
331 /* search for control */
332 lpMenuId = &lpInfo[2];
333 while (*lpMenuId != uFlags)
334 lpMenuId += 2;
336 if (GetMenuState ((HMENU)(DWORD_PTR)lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
337 /* uncheck menu item */
338 CheckMenuItem ((HMENU)(DWORD_PTR)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
340 /* hide control */
341 lpMenuId++;
342 SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
343 SWP_HIDEWINDOW);
345 else {
346 /* check menu item */
347 CheckMenuItem ((HMENU)(DWORD_PTR)lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
349 /* show control */
350 lpMenuId++;
351 SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
352 SWP_SHOWWINDOW);
355 return TRUE;
359 /***********************************************************************
360 * GetEffectiveClientRect [COMCTL32.4]
362 * Calculates the coordinates of a rectangle in the client area.
364 * PARAMS
365 * hwnd [I] handle to the client window.
366 * lpRect [O] pointer to the rectangle of the client window
367 * lpInfo [I] pointer to an array of integers (see NOTES)
369 * RETURNS
370 * No return value.
372 * NOTES
373 * The official documentation is incomplete!
374 * This is the correct documentation:
376 * lpInfo
377 * (will be written ...)
380 VOID WINAPI
381 GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, const INT *lpInfo)
383 RECT rcCtrl;
384 const INT *lpRun;
385 HWND hwndCtrl;
387 TRACE("(%p %p %p)\n",
388 hwnd, lpRect, lpInfo);
390 GetClientRect (hwnd, lpRect);
391 lpRun = lpInfo;
393 do {
394 lpRun += 2;
395 if (*lpRun == 0)
396 return;
397 lpRun++;
398 hwndCtrl = GetDlgItem (hwnd, *lpRun);
399 if (GetWindowLongW (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
400 TRACE("control id 0x%x\n", *lpRun);
401 GetWindowRect (hwndCtrl, &rcCtrl);
402 MapWindowPoints (NULL, hwnd, (LPPOINT)&rcCtrl, 2);
403 SubtractRect (lpRect, lpRect, &rcCtrl);
405 lpRun++;
406 } while (*lpRun);
410 /***********************************************************************
411 * DrawStatusTextW [COMCTL32.@]
413 * Draws text with borders, like in a status bar.
415 * PARAMS
416 * hdc [I] handle to the window's display context
417 * lprc [I] pointer to a rectangle
418 * text [I] pointer to the text
419 * style [I] drawing style
421 * RETURNS
422 * No return value.
424 * NOTES
425 * The style variable can have one of the following values:
426 * (will be written ...)
429 void WINAPI DrawStatusTextW (HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style)
431 RECT r = *lprc;
432 UINT border = BDR_SUNKENOUTER;
434 if (style & SBT_POPOUT)
435 border = BDR_RAISEDOUTER;
436 else if (style & SBT_NOBORDERS)
437 border = 0;
439 DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST);
441 /* now draw text */
442 if (text) {
443 int oldbkmode = SetBkMode (hdc, TRANSPARENT);
444 UINT align = DT_LEFT;
445 if (*text == '\t') {
446 text++;
447 align = DT_CENTER;
448 if (*text == '\t') {
449 text++;
450 align = DT_RIGHT;
453 r.left += 3;
454 if (style & SBT_RTLREADING)
455 FIXME("Unsupported RTL style!\n");
456 DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX);
457 SetBkMode(hdc, oldbkmode);
462 /***********************************************************************
463 * DrawStatusText [COMCTL32.@]
464 * DrawStatusTextA [COMCTL32.5]
466 * Draws text with borders, like in a status bar.
468 * PARAMS
469 * hdc [I] handle to the window's display context
470 * lprc [I] pointer to a rectangle
471 * text [I] pointer to the text
472 * style [I] drawing style
474 * RETURNS
475 * No return value.
478 void WINAPI DrawStatusTextA (HDC hdc, LPCRECT lprc, LPCSTR text, UINT style)
480 INT len;
481 LPWSTR textW = NULL;
483 if ( text ) {
484 if ( (len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 )) ) {
485 if ( (textW = Alloc( len * sizeof(WCHAR) )) )
486 MultiByteToWideChar( CP_ACP, 0, text, -1, textW, len );
489 DrawStatusTextW( hdc, lprc, textW, style );
490 Free( textW );
494 /***********************************************************************
495 * CreateStatusWindow [COMCTL32.@]
496 * CreateStatusWindowA [COMCTL32.6]
498 * Creates a status bar
500 * PARAMS
501 * style [I] window style
502 * text [I] pointer to the window text
503 * parent [I] handle to the parent window
504 * wid [I] control id of the status bar
506 * RETURNS
507 * Success: handle to the status window
508 * Failure: 0
511 HWND WINAPI
512 CreateStatusWindowA (LONG style, LPCSTR text, HWND parent, UINT wid)
514 return CreateWindowA(STATUSCLASSNAMEA, text, style,
515 CW_USEDEFAULT, CW_USEDEFAULT,
516 CW_USEDEFAULT, CW_USEDEFAULT,
517 parent, (HMENU)(DWORD_PTR)wid, 0, 0);
521 /***********************************************************************
522 * CreateStatusWindowW [COMCTL32.@]
524 * Creates a status bar control
526 * PARAMS
527 * style [I] window style
528 * text [I] pointer to the window text
529 * parent [I] handle to the parent window
530 * wid [I] control id of the status bar
532 * RETURNS
533 * Success: handle to the status window
534 * Failure: 0
537 HWND WINAPI
538 CreateStatusWindowW (LONG style, LPCWSTR text, HWND parent, UINT wid)
540 return CreateWindowW(STATUSCLASSNAMEW, text, style,
541 CW_USEDEFAULT, CW_USEDEFAULT,
542 CW_USEDEFAULT, CW_USEDEFAULT,
543 parent, (HMENU)(DWORD_PTR)wid, 0, 0);
547 /***********************************************************************
548 * CreateUpDownControl [COMCTL32.16]
550 * Creates an up-down control
552 * PARAMS
553 * style [I] window styles
554 * x [I] horizontal position of the control
555 * y [I] vertical position of the control
556 * cx [I] with of the control
557 * cy [I] height of the control
558 * parent [I] handle to the parent window
559 * id [I] the control's identifier
560 * inst [I] handle to the application's module instance
561 * buddy [I] handle to the buddy window, can be NULL
562 * maxVal [I] upper limit of the control
563 * minVal [I] lower limit of the control
564 * curVal [I] current value of the control
566 * RETURNS
567 * Success: handle to the updown control
568 * Failure: 0
571 HWND WINAPI
572 CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
573 HWND parent, INT id, HINSTANCE inst,
574 HWND buddy, INT maxVal, INT minVal, INT curVal)
576 HWND hUD =
577 CreateWindowW (UPDOWN_CLASSW, 0, style, x, y, cx, cy,
578 parent, (HMENU)(DWORD_PTR)id, inst, 0);
579 if (hUD) {
580 SendMessageW (hUD, UDM_SETBUDDY, (WPARAM)buddy, 0);
581 SendMessageW (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
582 SendMessageW (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
585 return hUD;
589 /***********************************************************************
590 * InitCommonControls [COMCTL32.17]
592 * Registers the common controls.
594 * PARAMS
595 * No parameters.
597 * RETURNS
598 * No return values.
600 * NOTES
601 * This function is just a dummy - all the controls are registered at
602 * the DLL's initialization. See InitCommonContolsEx for details.
605 VOID WINAPI
606 InitCommonControls (void)
611 /***********************************************************************
612 * InitCommonControlsEx [COMCTL32.@]
614 * Registers the common controls.
616 * PARAMS
617 * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
619 * RETURNS
620 * Success: TRUE
621 * Failure: FALSE
623 * NOTES
624 * Probaly all versions of comctl32 initializes the Win95 controls in DllMain
625 * during DLL initializaiton. Starting from comctl32 v5.82 all the controls
626 * are initialized there. We follow this behaviour and this function is just
627 * a dummy.
629 * Note: when writing programs under Windows, if you don't call any function
630 * from comctl32 the linker may not link this DLL. If InitCommonControlsEx
631 * was the only comctl32 function you were calling and you remove it you may
632 * have a false impression that InitCommonControlsEx actually did something.
635 BOOL WINAPI
636 InitCommonControlsEx (const INITCOMMONCONTROLSEX *lpInitCtrls)
638 if (!lpInitCtrls || lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
639 return FALSE;
641 TRACE("(0x%08x)\n", lpInitCtrls->dwICC);
642 return TRUE;
646 /***********************************************************************
647 * CreateToolbarEx [COMCTL32.@]
649 * Creates a toolbar window.
651 * PARAMS
652 * hwnd
653 * style
654 * wID
655 * nBitmaps
656 * hBMInst
657 * wBMID
658 * lpButtons
659 * iNumButtons
660 * dxButton
661 * dyButton
662 * dxBitmap
663 * dyBitmap
664 * uStructSize
666 * RETURNS
667 * Success: handle to the tool bar control
668 * Failure: 0
671 HWND WINAPI
672 CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
673 HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
674 INT iNumButtons, INT dxButton, INT dyButton,
675 INT dxBitmap, INT dyBitmap, UINT uStructSize)
677 HWND hwndTB;
679 hwndTB =
680 CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL, style|WS_CHILD, 0,0,100,30,
681 hwnd, (HMENU)(DWORD_PTR)wID, COMCTL32_hModule, NULL);
682 if(hwndTB) {
683 TBADDBITMAP tbab;
685 SendMessageW (hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM)uStructSize, 0);
687 /* set bitmap and button size */
688 /*If CreateToolbarEx receives 0, windows sets default values*/
689 if (dxBitmap < 0)
690 dxBitmap = 16;
691 if (dyBitmap < 0)
692 dyBitmap = 16;
693 if (dxBitmap == 0 || dyBitmap == 0)
694 dxBitmap = dyBitmap = 16;
695 SendMessageW(hwndTB, TB_SETBITMAPSIZE, 0, MAKELPARAM(dxBitmap, dyBitmap));
697 if (dxButton < 0)
698 dxButton = dxBitmap;
699 if (dyButton < 0)
700 dyButton = dyBitmap;
701 /* TB_SETBUTTONSIZE -> TB_SETBITMAPSIZE bug introduced for Windows compatibility */
702 if (dxButton != 0 && dyButton != 0)
703 SendMessageW(hwndTB, TB_SETBITMAPSIZE, 0, MAKELPARAM(dxButton, dyButton));
706 /* add bitmaps */
707 if (nBitmaps > 0 || hBMInst == HINST_COMMCTRL)
709 tbab.hInst = hBMInst;
710 tbab.nID = wBMID;
712 SendMessageW (hwndTB, TB_ADDBITMAP, (WPARAM)nBitmaps, (LPARAM)&tbab);
714 /* add buttons */
715 if(iNumButtons > 0)
716 SendMessageW (hwndTB, TB_ADDBUTTONSW,
717 (WPARAM)iNumButtons, (LPARAM)lpButtons);
720 return hwndTB;
724 /***********************************************************************
725 * CreateMappedBitmap [COMCTL32.8]
727 * Loads a bitmap resource using a colour map.
729 * PARAMS
730 * hInstance [I] Handle to the module containing the bitmap.
731 * idBitmap [I] The bitmap resource ID.
732 * wFlags [I] CMB_MASKED for using bitmap as a mask or 0 for normal.
733 * lpColorMap [I] Colour information needed for the bitmap or NULL (uses system colours).
734 * iNumMaps [I] Number of COLORMAP's pointed to by lpColorMap.
736 * RETURNS
737 * Success: handle to the new bitmap
738 * Failure: 0
741 HBITMAP WINAPI
742 CreateMappedBitmap (HINSTANCE hInstance, INT_PTR idBitmap, UINT wFlags,
743 LPCOLORMAP lpColorMap, INT iNumMaps)
745 HGLOBAL hglb;
746 HRSRC hRsrc;
747 const BITMAPINFOHEADER *lpBitmap;
748 LPBITMAPINFOHEADER lpBitmapInfo;
749 UINT nSize, nColorTableSize, iColor;
750 RGBQUAD *pColorTable;
751 INT i, iMaps, nWidth, nHeight;
752 HDC hdcScreen;
753 HBITMAP hbm;
754 LPCOLORMAP sysColorMap;
755 COLORREF cRef;
756 COLORMAP internalColorMap[4] =
757 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
759 /* initialize pointer to colortable and default color table */
760 if (lpColorMap) {
761 iMaps = iNumMaps;
762 sysColorMap = lpColorMap;
764 else {
765 internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
766 internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
767 internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
768 internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
769 iMaps = 4;
770 sysColorMap = (LPCOLORMAP)internalColorMap;
773 hRsrc = FindResourceW (hInstance, (LPWSTR)idBitmap, (LPWSTR)RT_BITMAP);
774 if (hRsrc == 0)
775 return 0;
776 hglb = LoadResource (hInstance, hRsrc);
777 if (hglb == 0)
778 return 0;
779 lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
780 if (lpBitmap == NULL)
781 return 0;
783 if (lpBitmap->biSize >= sizeof(BITMAPINFOHEADER) && lpBitmap->biClrUsed)
784 nColorTableSize = lpBitmap->biClrUsed;
785 else if (lpBitmap->biBitCount <= 8)
786 nColorTableSize = (1 << lpBitmap->biBitCount);
787 else
788 nColorTableSize = 0;
789 nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
790 lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
791 if (lpBitmapInfo == NULL)
792 return 0;
793 RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
795 pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
797 for (iColor = 0; iColor < nColorTableSize; iColor++) {
798 for (i = 0; i < iMaps; i++) {
799 cRef = RGB(pColorTable[iColor].rgbRed,
800 pColorTable[iColor].rgbGreen,
801 pColorTable[iColor].rgbBlue);
802 if ( cRef == sysColorMap[i].from) {
803 #if 0
804 if (wFlags & CBS_MASKED) {
805 if (sysColorMap[i].to != COLOR_BTNTEXT)
806 pColorTable[iColor] = RGB(255, 255, 255);
808 else
809 #endif
810 pColorTable[iColor].rgbBlue = GetBValue(sysColorMap[i].to);
811 pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
812 pColorTable[iColor].rgbRed = GetRValue(sysColorMap[i].to);
813 break;
817 nWidth = (INT)lpBitmapInfo->biWidth;
818 nHeight = (INT)lpBitmapInfo->biHeight;
819 hdcScreen = GetDC (NULL);
820 hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
821 if (hbm) {
822 HDC hdcDst = CreateCompatibleDC (hdcScreen);
823 HBITMAP hbmOld = SelectObject (hdcDst, hbm);
824 const BYTE *lpBits = (const BYTE *)(lpBitmap + 1);
825 lpBits += nColorTableSize * sizeof(RGBQUAD);
826 StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
827 lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
828 SRCCOPY);
829 SelectObject (hdcDst, hbmOld);
830 DeleteDC (hdcDst);
832 ReleaseDC (NULL, hdcScreen);
833 GlobalFree ((HGLOBAL)lpBitmapInfo);
834 FreeResource (hglb);
836 return hbm;
840 /***********************************************************************
841 * CreateToolbar [COMCTL32.7]
843 * Creates a toolbar control.
845 * PARAMS
846 * hwnd
847 * style
848 * wID
849 * nBitmaps
850 * hBMInst
851 * wBMID
852 * lpButtons
853 * iNumButtons
855 * RETURNS
856 * Success: handle to the tool bar control
857 * Failure: 0
859 * NOTES
860 * Do not use this functions anymore. Use CreateToolbarEx instead.
863 HWND WINAPI
864 CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
865 HINSTANCE hBMInst, UINT wBMID,
866 LPCTBBUTTON lpButtons,INT iNumButtons)
868 return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
869 hBMInst, wBMID, lpButtons,
870 iNumButtons, 0, 0, 0, 0, CCSIZEOF_STRUCT(TBBUTTON, dwData));
874 /***********************************************************************
875 * DllGetVersion [COMCTL32.@]
877 * Retrieves version information of the 'COMCTL32.DLL'
879 * PARAMS
880 * pdvi [O] pointer to version information structure.
882 * RETURNS
883 * Success: S_OK
884 * Failure: E_INVALIDARG
886 * NOTES
887 * Returns version of a comctl32.dll from IE4.01 SP1.
890 HRESULT WINAPI DllGetVersion (DLLVERSIONINFO *pdvi)
892 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
893 WARN("wrong DLLVERSIONINFO size from app\n");
894 return E_INVALIDARG;
897 pdvi->dwMajorVersion = COMCTL32_VERSION;
898 pdvi->dwMinorVersion = COMCTL32_VERSION_MINOR;
899 pdvi->dwBuildNumber = 2919;
900 pdvi->dwPlatformID = 6304;
902 TRACE("%u.%u.%u.%u\n",
903 pdvi->dwMajorVersion, pdvi->dwMinorVersion,
904 pdvi->dwBuildNumber, pdvi->dwPlatformID);
906 return S_OK;
909 /***********************************************************************
910 * DllInstall (COMCTL32.@)
912 * Installs the ComCtl32 DLL.
914 * RETURNS
915 * Success: S_OK
916 * Failure: A HRESULT error
918 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
920 FIXME("(%s, %s): stub\n", bInstall?"TRUE":"FALSE",
921 debugstr_w(cmdline));
923 return S_OK;
926 /***********************************************************************
927 * _TrackMouseEvent [COMCTL32.@]
929 * Requests notification of mouse events
931 * During mouse tracking WM_MOUSEHOVER or WM_MOUSELEAVE events are posted
932 * to the hwnd specified in the ptme structure. After the event message
933 * is posted to the hwnd, the entry in the queue is removed.
935 * If the current hwnd isn't ptme->hwndTrack the TME_HOVER flag is completely
936 * ignored. The TME_LEAVE flag results in a WM_MOUSELEAVE message being posted
937 * immediately and the TME_LEAVE flag being ignored.
939 * PARAMS
940 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
942 * RETURNS
943 * Success: non-zero
944 * Failure: zero
946 * IMPLEMENTATION moved to USER32.TrackMouseEvent
950 BOOL WINAPI
951 _TrackMouseEvent (TRACKMOUSEEVENT *ptme)
953 return TrackMouseEvent (ptme);
956 /*************************************************************************
957 * GetMUILanguage [COMCTL32.@]
959 * Returns the user interface language in use by the current process.
961 * RETURNS
962 * Language ID in use by the current process.
964 LANGID WINAPI GetMUILanguage (VOID)
966 return COMCTL32_uiLang;
970 /*************************************************************************
971 * InitMUILanguage [COMCTL32.@]
973 * Sets the user interface language to be used by the current process.
975 * RETURNS
976 * Nothing.
978 VOID WINAPI InitMUILanguage (LANGID uiLang)
980 COMCTL32_uiLang = uiLang;
984 /***********************************************************************
985 * SetWindowSubclass [COMCTL32.410]
987 * Starts a window subclass
989 * PARAMS
990 * hWnd [in] handle to window subclass.
991 * pfnSubclass [in] Pointer to new window procedure.
992 * uIDSubclass [in] Unique identifier of sublass together with pfnSubclass.
993 * dwRef [in] Reference data to pass to window procedure.
995 * RETURNS
996 * Success: non-zero
997 * Failure: zero
999 * BUGS
1000 * If an application manually subclasses a window after subclassing it with
1001 * this API and then with this API again, then none of the previous
1002 * subclasses get called or the origional window procedure.
1005 BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
1006 UINT_PTR uIDSubclass, DWORD_PTR dwRef)
1008 LPSUBCLASS_INFO stack;
1009 LPSUBCLASSPROCS proc;
1011 TRACE ("(%p, %p, %lx, %lx)\n", hWnd, pfnSubclass, uIDSubclass, dwRef);
1013 /* Since the window procedure that we set here has two additional arguments,
1014 * we can't simply set it as the new window procedure of the window. So we
1015 * set our own window procedure and then calculate the other two arguments
1016 * from there. */
1018 /* See if we have been called for this window */
1019 stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
1020 if (!stack) {
1021 /* allocate stack */
1022 stack = Alloc (sizeof(SUBCLASS_INFO));
1023 if (!stack) {
1024 ERR ("Failed to allocate our Subclassing stack\n");
1025 return FALSE;
1027 SetPropW (hWnd, COMCTL32_wSubclass, (HANDLE)stack);
1029 /* set window procedure to our own and save the current one */
1030 if (IsWindowUnicode (hWnd))
1031 stack->origproc = (WNDPROC)SetWindowLongPtrW (hWnd, GWLP_WNDPROC,
1032 (DWORD_PTR)COMCTL32_SubclassProc);
1033 else
1034 stack->origproc = (WNDPROC)SetWindowLongPtrA (hWnd, GWLP_WNDPROC,
1035 (DWORD_PTR)COMCTL32_SubclassProc);
1037 else {
1038 /* Check to see if we have called this function with the same uIDSubClass
1039 * and pfnSubclass */
1040 proc = stack->SubclassProcs;
1041 while (proc) {
1042 if ((proc->id == uIDSubclass) &&
1043 (proc->subproc == pfnSubclass)) {
1044 proc->ref = dwRef;
1045 return TRUE;
1047 proc = proc->next;
1051 proc = Alloc(sizeof(SUBCLASSPROCS));
1052 if (!proc) {
1053 ERR ("Failed to allocate subclass entry in stack\n");
1054 if (IsWindowUnicode (hWnd))
1055 SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
1056 else
1057 SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
1058 Free (stack);
1059 RemovePropW( hWnd, COMCTL32_wSubclass );
1060 return FALSE;
1063 proc->subproc = pfnSubclass;
1064 proc->ref = dwRef;
1065 proc->id = uIDSubclass;
1066 proc->next = stack->SubclassProcs;
1067 stack->SubclassProcs = proc;
1069 return TRUE;
1073 /***********************************************************************
1074 * GetWindowSubclass [COMCTL32.411]
1076 * Gets the Reference data from a subclass.
1078 * PARAMS
1079 * hWnd [in] Handle to window which were subclassing
1080 * pfnSubclass [in] Pointer to the subclass procedure
1081 * uID [in] Unique indentifier of the subclassing procedure
1082 * pdwRef [out] Pointer to the reference data
1084 * RETURNS
1085 * Success: Non-zero
1086 * Failure: 0
1089 BOOL WINAPI GetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass,
1090 UINT_PTR uID, DWORD_PTR *pdwRef)
1092 const SUBCLASS_INFO *stack;
1093 const SUBCLASSPROCS *proc;
1095 TRACE ("(%p, %p, %lx, %p)\n", hWnd, pfnSubclass, uID, pdwRef);
1097 /* See if we have been called for this window */
1098 stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
1099 if (!stack)
1100 return FALSE;
1102 proc = stack->SubclassProcs;
1103 while (proc) {
1104 if ((proc->id == uID) &&
1105 (proc->subproc == pfnSubclass)) {
1106 *pdwRef = proc->ref;
1107 return TRUE;
1109 proc = proc->next;
1112 return FALSE;
1116 /***********************************************************************
1117 * RemoveWindowSubclass [COMCTL32.412]
1119 * Removes a window subclass.
1121 * PARAMS
1122 * hWnd [in] Handle to the window were subclassing
1123 * pfnSubclass [in] Pointer to the subclass procedure
1124 * uID [in] Unique identifier of this subclass
1126 * RETURNS
1127 * Success: non-zero
1128 * Failure: zero
1131 BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
1133 LPSUBCLASS_INFO stack;
1134 LPSUBCLASSPROCS prevproc = NULL;
1135 LPSUBCLASSPROCS proc;
1136 BOOL ret = FALSE;
1138 TRACE ("(%p, %p, %lx)\n", hWnd, pfnSubclass, uID);
1140 /* Find the Subclass to remove */
1141 stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
1142 if (!stack)
1143 return FALSE;
1145 proc = stack->SubclassProcs;
1146 while (proc) {
1147 if ((proc->id == uID) &&
1148 (proc->subproc == pfnSubclass)) {
1150 if (!prevproc)
1151 stack->SubclassProcs = proc->next;
1152 else
1153 prevproc->next = proc->next;
1155 if (stack->stackpos == proc)
1156 stack->stackpos = stack->stackpos->next;
1158 Free (proc);
1159 ret = TRUE;
1160 break;
1162 prevproc = proc;
1163 proc = proc->next;
1166 if (!stack->SubclassProcs && !stack->running) {
1167 TRACE("Last Subclass removed, cleaning up\n");
1168 /* clean up our heap and reset the origional window procedure */
1169 if (IsWindowUnicode (hWnd))
1170 SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
1171 else
1172 SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
1173 Free (stack);
1174 RemovePropW( hWnd, COMCTL32_wSubclass );
1177 return ret;
1180 /***********************************************************************
1181 * COMCTL32_SubclassProc (internal)
1183 * Window procedure for all subclassed windows.
1184 * Saves the current subclassing stack position to support nested messages
1186 LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1188 LPSUBCLASS_INFO stack;
1189 LPSUBCLASSPROCS proc;
1190 LRESULT ret;
1192 TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);
1194 stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
1195 if (!stack) {
1196 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
1197 return 0;
1200 /* Save our old stackpos to properly handle nested messages */
1201 proc = stack->stackpos;
1202 stack->stackpos = stack->SubclassProcs;
1203 stack->running++;
1204 ret = DefSubclassProc(hWnd, uMsg, wParam, lParam);
1205 stack->running--;
1206 stack->stackpos = proc;
1208 if (!stack->SubclassProcs && !stack->running) {
1209 TRACE("Last Subclass removed, cleaning up\n");
1210 /* clean up our heap and reset the origional window procedure */
1211 if (IsWindowUnicode (hWnd))
1212 SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
1213 else
1214 SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc);
1215 Free (stack);
1216 RemovePropW( hWnd, COMCTL32_wSubclass );
1218 return ret;
1221 /***********************************************************************
1222 * DefSubclassProc [COMCTL32.413]
1224 * Calls the next window procedure (ie. the one before this subclass)
1226 * PARAMS
1227 * hWnd [in] The window that we're subclassing
1228 * uMsg [in] Message
1229 * wParam [in] WPARAM
1230 * lParam [in] LPARAM
1232 * RETURNS
1233 * Success: non-zero
1234 * Failure: zero
1237 LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1239 LPSUBCLASS_INFO stack;
1240 LRESULT ret;
1242 TRACE ("(%p, 0x%08x, 0x%08lx, 0x%08lx)\n", hWnd, uMsg, wParam, lParam);
1244 /* retrieve our little stack from the Properties */
1245 stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass);
1246 if (!stack) {
1247 ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd);
1248 return 0;
1251 /* If we are at the end of stack then we have to call the original
1252 * window procedure */
1253 if (!stack->stackpos) {
1254 if (IsWindowUnicode (hWnd))
1255 ret = CallWindowProcW (stack->origproc, hWnd, uMsg, wParam, lParam);
1256 else
1257 ret = CallWindowProcA (stack->origproc, hWnd, uMsg, wParam, lParam);
1258 } else {
1259 const SUBCLASSPROCS *proc = stack->stackpos;
1260 stack->stackpos = stack->stackpos->next;
1261 /* call the Subclass procedure from the stack */
1262 ret = proc->subproc (hWnd, uMsg, wParam, lParam,
1263 proc->id, proc->ref);
1266 return ret;
1270 /***********************************************************************
1271 * COMCTL32_CreateToolTip [NOT AN API]
1273 * Creates a tooltip for the control specified in hwnd and does all
1274 * necessary setup and notifications.
1276 * PARAMS
1277 * hwndOwner [I] Handle to the window that will own the tool tip.
1279 * RETURNS
1280 * Success: Handle of tool tip window.
1281 * Failure: NULL
1284 HWND
1285 COMCTL32_CreateToolTip(HWND hwndOwner)
1287 HWND hwndToolTip;
1289 hwndToolTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, WS_POPUP,
1290 CW_USEDEFAULT, CW_USEDEFAULT,
1291 CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner,
1292 0, 0, 0);
1294 /* Send NM_TOOLTIPSCREATED notification */
1295 if (hwndToolTip)
1297 NMTOOLTIPSCREATED nmttc;
1298 /* true owner can be different if hwndOwner is a child window */
1299 HWND hwndTrueOwner = GetWindow(hwndToolTip, GW_OWNER);
1300 nmttc.hdr.hwndFrom = hwndTrueOwner;
1301 nmttc.hdr.idFrom = GetWindowLongPtrW(hwndTrueOwner, GWLP_ID);
1302 nmttc.hdr.code = NM_TOOLTIPSCREATED;
1303 nmttc.hwndToolTips = hwndToolTip;
1305 SendMessageW(GetParent(hwndTrueOwner), WM_NOTIFY,
1306 (WPARAM)GetWindowLongPtrW(hwndTrueOwner, GWLP_ID),
1307 (LPARAM)&nmttc);
1310 return hwndToolTip;
1314 /***********************************************************************
1315 * COMCTL32_RefreshSysColors [NOT AN API]
1317 * Invoked on any control recognizing a WM_SYSCOLORCHANGE message to
1318 * refresh the color values in the color structure
1320 * PARAMS
1321 * none
1323 * RETURNS
1324 * none
1327 VOID
1328 COMCTL32_RefreshSysColors(void)
1330 comctl32_color.clrBtnHighlight = GetSysColor (COLOR_BTNHIGHLIGHT);
1331 comctl32_color.clrBtnShadow = GetSysColor (COLOR_BTNSHADOW);
1332 comctl32_color.clrBtnText = GetSysColor (COLOR_BTNTEXT);
1333 comctl32_color.clrBtnFace = GetSysColor (COLOR_BTNFACE);
1334 comctl32_color.clrHighlight = GetSysColor (COLOR_HIGHLIGHT);
1335 comctl32_color.clrHighlightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
1336 comctl32_color.clr3dHilight = GetSysColor (COLOR_3DHILIGHT);
1337 comctl32_color.clr3dShadow = GetSysColor (COLOR_3DSHADOW);
1338 comctl32_color.clr3dDkShadow = GetSysColor (COLOR_3DDKSHADOW);
1339 comctl32_color.clr3dFace = GetSysColor (COLOR_3DFACE);
1340 comctl32_color.clrWindow = GetSysColor (COLOR_WINDOW);
1341 comctl32_color.clrWindowText = GetSysColor (COLOR_WINDOWTEXT);
1342 comctl32_color.clrGrayText = GetSysColor (COLOR_GRAYTEXT);
1343 comctl32_color.clrActiveCaption = GetSysColor (COLOR_ACTIVECAPTION);
1344 comctl32_color.clrInfoBk = GetSysColor (COLOR_INFOBK);
1345 comctl32_color.clrInfoText = GetSysColor (COLOR_INFOTEXT);
1348 /***********************************************************************
1349 * COMCTL32_DrawInsertMark [NOT AN API]
1351 * Draws an insertion mark (which looks similar to an 'I').
1353 * PARAMS
1354 * hDC [I] Device context to draw onto.
1355 * lpRect [I] Co-ordinates of insertion mark.
1356 * clrInsertMark [I] Colour of the insertion mark.
1357 * bHorizontal [I] True if insert mark should be drawn horizontally,
1358 * vertical otherwise.
1360 * RETURNS
1361 * none
1363 * NOTES
1364 * Draws up to but not including the bottom co-ordinate when drawing
1365 * vertically or the right co-ordinate when horizontal.
1367 void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal)
1369 HPEN hPen = CreatePen(PS_SOLID, 1, clrInsertMark);
1370 HPEN hOldPen;
1371 static const DWORD adwPolyPoints[] = {4,4,4};
1372 LONG lCentre = (bHorizontal ?
1373 lpRect->top + (lpRect->bottom - lpRect->top)/2 :
1374 lpRect->left + (lpRect->right - lpRect->left)/2);
1375 LONG l1 = (bHorizontal ? lpRect->left : lpRect->top);
1376 LONG l2 = (bHorizontal ? lpRect->right : lpRect->bottom);
1377 const POINT aptInsertMark[] =
1379 /* top (V) or left (H) arrow */
1380 {lCentre , l1 + 2},
1381 {lCentre - 2, l1 },
1382 {lCentre + 3, l1 },
1383 {lCentre + 1, l1 + 2},
1384 /* middle line */
1385 {lCentre , l2 - 2},
1386 {lCentre , l1 - 1},
1387 {lCentre + 1, l1 - 1},
1388 {lCentre + 1, l2 - 2},
1389 /* bottom (V) or right (H) arrow */
1390 {lCentre , l2 - 3},
1391 {lCentre - 2, l2 - 1},
1392 {lCentre + 3, l2 - 1},
1393 {lCentre + 1, l2 - 3},
1395 hOldPen = SelectObject(hDC, hPen);
1396 PolyPolyline(hDC, aptInsertMark, adwPolyPoints, sizeof(adwPolyPoints)/sizeof(adwPolyPoints[0]));
1397 SelectObject(hDC, hOldPen);
1398 DeleteObject(hPen);
1401 /***********************************************************************
1402 * COMCTL32_EnsureBitmapSize [internal]
1404 * If needed, enlarge the bitmap so that the width is at least cxMinWidth and
1405 * the height is at least cyMinHeight. If the bitmap already has these
1406 * dimensions nothing changes.
1408 * PARAMS
1409 * hBitmap [I/O] Bitmap to modify. The handle may change
1410 * cxMinWidth [I] If the width of the bitmap is smaller, then it will
1411 * be enlarged to this value
1412 * cyMinHeight [I] If the height of the bitmap is smaller, then it will
1413 * be enlarged to this value
1414 * cyBackground [I] The color with which the new area will be filled
1416 * RETURNS
1417 * none
1419 void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight, COLORREF crBackground)
1421 int cxNew, cyNew;
1422 BITMAP bmp;
1423 HBITMAP hNewBitmap;
1424 HBITMAP hNewDCBitmap, hOldDCBitmap;
1425 HBRUSH hNewDCBrush;
1426 HDC hdcNew, hdcOld;
1428 if (!GetObjectW(*pBitmap, sizeof(BITMAP), &bmp))
1429 return;
1430 cxNew = (cxMinWidth > bmp.bmWidth ? cxMinWidth : bmp.bmWidth);
1431 cyNew = (cyMinHeight > bmp.bmHeight ? cyMinHeight : bmp.bmHeight);
1432 if (cxNew == bmp.bmWidth && cyNew == bmp.bmHeight)
1433 return;
1435 hdcNew = CreateCompatibleDC(NULL);
1436 hNewBitmap = CreateBitmap(cxNew, cyNew, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
1437 hNewDCBitmap = SelectObject(hdcNew, hNewBitmap);
1438 hNewDCBrush = SelectObject(hdcNew, CreateSolidBrush(crBackground));
1440 hdcOld = CreateCompatibleDC(NULL);
1441 hOldDCBitmap = SelectObject(hdcOld, *pBitmap);
1443 BitBlt(hdcNew, 0, 0, bmp.bmWidth, bmp.bmHeight, hdcOld, 0, 0, SRCCOPY);
1444 if (bmp.bmWidth < cxMinWidth)
1445 PatBlt(hdcNew, bmp.bmWidth, 0, cxNew, bmp.bmHeight, PATCOPY);
1446 if (bmp.bmHeight < cyMinHeight)
1447 PatBlt(hdcNew, 0, bmp.bmHeight, bmp.bmWidth, cyNew, PATCOPY);
1448 if (bmp.bmWidth < cxMinWidth && bmp.bmHeight < cyMinHeight)
1449 PatBlt(hdcNew, bmp.bmWidth, bmp.bmHeight, cxNew, cyNew, PATCOPY);
1451 SelectObject(hdcNew, hNewDCBitmap);
1452 DeleteObject(SelectObject(hdcNew, hNewDCBrush));
1453 DeleteDC(hdcNew);
1454 SelectObject(hdcOld, hOldDCBitmap);
1455 DeleteDC(hdcOld);
1457 DeleteObject(*pBitmap);
1458 *pBitmap = hNewBitmap;
1459 return;
1462 /***********************************************************************
1463 * MirrorIcon [COMCTL32.414]
1465 * Mirrors an icon so that it will appear correctly on a mirrored DC.
1467 * PARAMS
1468 * phicon1 [I/O] Icon.
1469 * phicon2 [I/O] Icon.
1471 * RETURNS
1472 * Success: TRUE.
1473 * Failure: FALSE.
1475 BOOL WINAPI MirrorIcon(HICON *phicon1, HICON *phicon2)
1477 FIXME("(%p, %p): stub\n", phicon1, phicon2);
1478 return FALSE;
1481 static inline int IsDelimiter(WCHAR c)
1483 switch(c)
1485 case '/':
1486 case '\\':
1487 case '.':
1488 case ' ':
1489 return TRUE;
1491 return FALSE;
1494 static int CALLBACK PathWordBreakProc(LPCWSTR lpch, int ichCurrent, int cch, int code)
1496 if (code == WB_ISDELIMITER)
1497 return IsDelimiter(lpch[ichCurrent]);
1498 else
1500 int dir = (code == WB_LEFT) ? -1 : 1;
1501 for(; 0 <= ichCurrent && ichCurrent < cch; ichCurrent += dir)
1502 if (IsDelimiter(lpch[ichCurrent])) return ichCurrent;
1504 return ichCurrent;
1507 /***********************************************************************
1508 * SetPathWordBreakProc [COMCTL32.384]
1510 * Sets the word break procedure for an edit control to one that understands
1511 * paths so that the user can jump over directories.
1513 * PARAMS
1514 * hwnd [I] Handle to edit control.
1515 * bSet [I] If this is TRUE then the word break proc is set, otherwise it is removed.
1517 * RETURNS
1518 * Result from EM_SETWORDBREAKPROC message.
1520 LRESULT WINAPI SetPathWordBreakProc(HWND hwnd, BOOL bSet)
1522 return SendMessageW(hwnd, EM_SETWORDBREAKPROC, 0,
1523 (LPARAM)(bSet ? PathWordBreakProc : NULL));
1526 /***********************************************************************
1527 * DrawShadowText [COMCTL32.@]
1529 * Draw text with shadow.
1531 int WINAPI DrawShadowText(HDC hdc, LPCWSTR pszText, UINT cch, const RECT *pRect, DWORD dwFlags,
1532 COLORREF crText, COLORREF crShadow, int ixOffset, int iyOffset)
1534 RECT rect = *pRect;
1536 FIXME("(%p, %s, %d, %p, %d, 0x%08x, 0x%08x, %d, %d): stub\n", hdc, debugstr_w(pszText), cch, pRect, dwFlags,
1537 crText, crShadow, ixOffset, iyOffset);
1538 return DrawTextW(hdc, pszText, cch, &rect, DT_LEFT);