source: trunk/src/comctl32/comctl32.cpp@ 3409

Last change on this file since 3409 was 3409, checked in by cbratschi, 25 years ago

new listview messages and styles, new resources

File size: 25.4 KB
Line 
1/* $Id: comctl32.cpp,v 1.2 2000-04-16 18:26:57 cbratschi Exp $ */
2/*
3 * Win32 common controls implementation
4 *
5 * Copyright (C) 1999 Achim Hasenmueller
6 *
7 * Based on the work of the WINE group (www.winehq.com)
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13
14/*
15 - Corel 20000212 level
16 - WINE 20000130 level (commctrl.c)
17*/
18
19#include "comctl32.h"
20#include "ccbase.h"
21#include "winerror.h"
22#include "progress.h"
23#include "comboex.h"
24#include "animate.h"
25#include "datetime.h"
26#include "flatsb.h"
27#include "hotkey.h"
28#include "ipaddress.h"
29#include "monthcal.h"
30#include "nativefont.h"
31#include "pager.h"
32#include "tab.h"
33#include "status.h"
34#include "header.h"
35#include "updown.h"
36#include "rebar.h"
37#include "trackbar.h"
38#include "tooltips.h"
39#include "toolbar.h"
40#include "treeview.h"
41#include "listview.h"
42
43HANDLE COMCTL32_hHeap = (HANDLE)NULL;
44HMODULE COMCTL32_hModule = 0;
45LPSTR COMCTL32_aSubclass = (LPSTR)NULL;
46
47void CDECL RegisterCOMCTL32WindowClasses(unsigned long hinstDLL)
48{
49 /* create private heap */
50 COMCTL32_hHeap = HeapCreate(0, 0x10000, 0);
51 /* add global subclassing atom (used by 'tooltip' and 'updown') */
52 COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo");
53 /* This will be wrong for any other process attching in this address-space! */
54 COMCTL32_hModule = (HMODULE)hinstDLL;
55
56 /* register controls */
57 PROGRESS_Register();
58 COMBOEX_Register();
59 ANIMATE_Register();
60 DATETIME_Register();
61 FLATSB_Register();
62 HOTKEY_Register();
63 IPADDRESS_Register();
64 MONTHCAL_Register();
65 NATIVEFONT_Register();
66 PAGER_Register();
67 TAB_Register();
68 STATUS_Register();
69 HEADER_Register();
70 UPDOWN_Register();
71 REBAR_Register();
72 TRACKBAR_Register();
73 TOOLTIPS_Register();
74 TOOLBAR_Register();
75 TREEVIEW_Register();
76 LISTVIEW_Register();
77}
78
79void CDECL UnregisterCOMCTL32WindowClasses(void)
80{
81 /* unregister controls */
82 PROGRESS_Unregister();
83 COMBOEX_Unregister();
84 ANIMATE_Unregister();
85 DATETIME_Unregister();
86 FLATSB_Unregister();
87 HOTKEY_Unregister();
88 IPADDRESS_Unregister();
89 MONTHCAL_Unregister();
90 NATIVEFONT_Unregister();
91 PAGER_Unregister();
92 TAB_Unregister();
93 STATUS_Unregister();
94 HEADER_Unregister();
95 UPDOWN_Unregister();
96 REBAR_Unregister();
97 TRACKBAR_Unregister();
98 TOOLTIPS_Unregister();
99 TOOLBAR_Unregister();
100 TREEVIEW_Unregister();
101 LISTVIEW_Unregister();
102
103 /* destroy private heap */
104 HeapDestroy(COMCTL32_hHeap);
105 COMCTL32_hHeap = (HANDLE)NULL;
106}
107
108/***********************************************************************
109 * MenuHelp [COMCTL32.2]
110 *
111 * PARAMS
112 * uMsg [I] message (WM_MENUSELECT) (see NOTES)
113 * wParam [I] wParam of the message uMsg
114 * lParam [I] lParam of the message uMsg
115 * hMainMenu [I] handle to the application's main menu
116 * hInst [I] handle to the module that contains string resources
117 * hwndStatus [I] handle to the status bar window
118 * lpwIDs [I] pointer to an array of intergers (see NOTES)
119 *
120 * RETURNS
121 * No return value
122 *
123 * NOTES
124 * The official documentation is incomplete!
125 * This is the correct documentation:
126 *
127 * uMsg:
128 * MenuHelp() does NOT handle WM_COMMAND messages! It only handes
129 * WM_MENUSELECT messages.
130 *
131 * lpwIDs:
132 * (will be written ...)
133 */
134
135VOID WINAPI
136MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu,
137 HINSTANCE hInst, HWND hwndStatus, LPUINT lpwIDs)
138{
139 UINT uMenuID = 0;
140
141 dprintf(("COMCTL32: MenuHelp"));
142
143 if (!IsWindow (hwndStatus))
144 return;
145
146 switch (uMsg) {
147 case WM_MENUSELECT:
148// TRACE (commctrl, "WM_MENUSELECT wParam=0x%X lParam=0x%lX\n",
149// wParam, lParam);
150
151 if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) {
152 /* menu was closed */
153// TRACE (commctrl, "menu was closed!\n");
154 SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0);
155 }
156 else {
157 /* menu item was selected */
158 if (HIWORD(wParam) & MF_POPUP)
159 uMenuID = (UINT)*(lpwIDs+1);
160 else
161 uMenuID = (UINT)LOWORD(wParam);
162// TRACE (commctrl, "uMenuID = %u\n", uMenuID);
163
164 if (uMenuID) {
165 CHAR szText[256];
166
167 if (!LoadStringA (hInst, uMenuID, szText, 256))
168 szText[0] = '\0';
169
170 SendMessageA (hwndStatus, SB_SETTEXTA,
171 255 | SBT_NOBORDERS, (LPARAM)szText);
172 SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0);
173 }
174 }
175 break;
176
177 case WM_COMMAND :
178// TRACE("WM_COMMAND wParam=0x%X lParam=0x%lX\n",
179// wParam, lParam);
180 /* WM_COMMAND is not invalid since it is documented
181 * in the windows api reference. So don't output
182 * any FIXME for WM_COMMAND
183 */
184// WARN("We don't care about the WM_COMMAND\n");
185 break;
186
187 default:
188// FIXME (commctrl, "Invalid Message 0x%x!\n", uMsg);
189 break;
190 }
191}
192
193/***********************************************************************
194 * ShowHideMenuCtl [COMCTL32.3]
195 *
196 * Shows or hides controls and updates the corresponding menu item.
197 *
198 * PARAMS
199 * hwnd [I] handle to the client window.
200 * uFlags [I] menu command id.
201 * lpInfo [I] pointer to an array of integers. (See NOTES.)
202 *
203 * RETURNS
204 * Success: TRUE
205 * Failure: FALSE
206 *
207 * NOTES
208 * The official documentation is incomplete!
209 * This is the correct documentation:
210 *
211 * hwnd
212 * Handle to the window that contains the menu and controls.
213 *
214 * uFlags
215 * Identifier of the menu item to receive or loose a check mark.
216 *
217 * lpInfo
218 * The array of integers contains pairs of values. BOTH values of
219 * the first pair must be the handles to the application's main menu.
220 * Each subsequent pair consists of a menu id and control id.
221 */
222
223BOOL WINAPI
224ShowHideMenuCtl (HWND hwnd, UINT uFlags, LPINT lpInfo)
225{
226 LPINT lpMenuId;
227
228 dprintf(("COMCTL32: ShowHideMenuCtl"));
229
230 if (lpInfo == NULL)
231 return FALSE;
232
233 if (!(lpInfo[0]) || !(lpInfo[1]))
234 return FALSE;
235
236 /* search for control */
237 lpMenuId = &lpInfo[2];
238 while (*lpMenuId != uFlags)
239 lpMenuId += 2;
240
241 if (GetMenuState (lpInfo[1], uFlags, MF_BYCOMMAND) & MFS_CHECKED) {
242 /* uncheck menu item */
243 CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_UNCHECKED);
244
245 /* hide control */
246 lpMenuId++;
247 SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
248 SWP_HIDEWINDOW);
249 }
250 else {
251 /* check menu item */
252 CheckMenuItem (lpInfo[0], *lpMenuId, MF_BYCOMMAND | MF_CHECKED);
253
254 /* show control */
255 lpMenuId++;
256 SetWindowPos (GetDlgItem (hwnd, *lpMenuId), 0, 0, 0, 0, 0,
257 SWP_SHOWWINDOW);
258 }
259
260 return TRUE;
261}
262
263/***********************************************************************
264 * GetEffectiveClientRect [COMCTL32.4]
265 *
266 * PARAMS
267 * hwnd [I] handle to the client window.
268 * lpRect [O] pointer to the rectangle of the client window
269 * lpInfo [I] pointer to an array of integers (see NOTES)
270 *
271 * RETURNS
272 * No return value.
273 *
274 * NOTES
275 * The official documentation is incomplete!
276 * This is the correct documentation:
277 *
278 * lpInfo
279 * (will be written...)
280 */
281
282VOID WINAPI
283GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo)
284{
285 RECT rcCtrl;
286 INT *lpRun;
287 HWND hwndCtrl;
288
289 dprintf(("COMCTL32: GetEffectiveClientRect"));
290
291 GetClientRect (hwnd, lpRect);
292 lpRun = lpInfo;
293
294 do {
295 lpRun += 2;
296 if (*lpRun == 0)
297 return;
298 lpRun++;
299 hwndCtrl = GetDlgItem (hwnd, *lpRun);
300 if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) {
301// TRACE (commctrl, "control id 0x%x\n", *lpRun);
302 GetWindowRect (hwndCtrl, &rcCtrl);
303 MapWindowPoints ((HWND)0, hwnd, (LPPOINT)&rcCtrl, 2);
304 SubtractRect (lpRect, lpRect, &rcCtrl);
305 }
306 lpRun++;
307 } while (*lpRun);
308}
309
310/***********************************************************************
311 * DrawStatusText32A [COMCTL32.5][COMCTL32.27]
312 *
313 * Draws text with borders, like in a status bar.
314 *
315 * PARAMS
316 * hdc [I] handle to the window's display context
317 * lprc [I] pointer to a rectangle
318 * text [I] pointer to the text
319 * style [I] drawing style
320 *
321 * RETURNS
322 * No return value.
323 *
324 * NOTES
325 * The style variable can have one of the following values:
326 * (will be written ...)
327 */
328
329VOID WINAPI
330DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style)
331{
332 RECT r = *lprc;
333 UINT border = BDR_SUNKENOUTER;
334
335 dprintf(("COMCTL32: DrawStatusTextA"));
336
337 if (style & SBT_POPOUT)
338 border = BDR_RAISEDOUTER;
339 else if (style & SBT_NOBORDERS)
340 border = 0;
341
342 DrawEdge (hdc, &r, border, BF_RECT|BF_ADJUST|BF_MIDDLE);
343
344 /* now draw text */
345 if (text) {
346 int oldbkmode = SetBkMode (hdc, TRANSPARENT);
347 r.left += 3;
348 DrawTextA (hdc, text, lstrlenA(text),
349 &r, DT_LEFT|DT_VCENTER|DT_SINGLELINE);
350 if (oldbkmode != TRANSPARENT)
351 SetBkMode(hdc, oldbkmode);
352 }
353}
354
355
356/***********************************************************************
357 * DrawStatusText32W [COMCTL32.28]
358 *
359 * Draws text with borders, like in a status bar.
360 *
361 * PARAMS
362 * hdc [I] handle to the window's display context
363 * lprc [I] pointer to a rectangle
364 * text [I] pointer to the text
365 * style [I] drawing style
366 *
367 * RETURNS
368 * No return value.
369 */
370
371VOID WINAPI
372DrawStatusTextW (HDC hdc, LPRECT lprc, LPCWSTR text, UINT style)
373{
374 LPSTR p = HEAP_strdupWtoA (GetProcessHeap (), 0, text);
375
376 dprintf(("COMCTL32: DrawStatusTextW"));
377
378 DrawStatusTextA (hdc, lprc, p, style);
379 HeapFree (GetProcessHeap (), 0, p );
380}
381
382
383/***********************************************************************
384 * CreateStatusWindow32A [COMCTL32.6][COMCTL32.21]
385 *
386 * Creates a status bar
387 *
388 * PARAMS
389 * style [I] window style
390 * text [I] pointer to the window text
391 * parent [I] handle to the parent window
392 * wid [I] control id of the status bar
393 *
394 * RETURNS
395 * Success: handle to the status window
396 * Failure: 0
397 */
398
399HWND WINAPI
400CreateStatusWindowA (INT style, LPCSTR text, HWND parent, UINT wid)
401{
402 dprintf(("COMCTL32: CreateStatusWindowA"));
403
404 return CreateWindowA(STATUSCLASSNAMEA, text, style,
405 CW_USEDEFAULT, CW_USEDEFAULT,
406 CW_USEDEFAULT, CW_USEDEFAULT,
407 parent, wid, 0, 0);
408}
409
410
411/***********************************************************************
412 * CreateStatusWindow32W [COMCTL32.22] Creates a status bar control
413 *
414 * PARAMS
415 * style [I] window style
416 * text [I] pointer to the window text
417 * parent [I] handle to the parent window
418 * wid [I] control id of the status bar
419 *
420 * RETURNS
421 * Success: handle to the status window
422 * Failure: 0
423 */
424
425HWND WINAPI
426CreateStatusWindowW (INT style, LPCWSTR text, HWND parent, UINT wid)
427{
428 dprintf(("COMCTL32: CreateStatusWindowW"));
429
430 return CreateWindowW(STATUSCLASSNAMEW, text, style,
431 CW_USEDEFAULT, CW_USEDEFAULT,
432 CW_USEDEFAULT, CW_USEDEFAULT,
433 parent, wid, 0, 0);
434}
435
436
437/***********************************************************************
438 * CreateUpDownControl [COMCTL32.16] Creates an up-down control
439 *
440 * PARAMS
441 * style [I] window styles
442 * x [I] horizontal position of the control
443 * y [I] vertical position of the control
444 * cx [I] with of the control
445 * cy [I] height of the control
446 * parent [I] handle to the parent window
447 * id [I] the control's identifier
448 * inst [I] handle to the application's module instance
449 * buddy [I] handle to the buddy window, can be NULL
450 * maxVal [I] upper limit of the control
451 * minVal [I] lower limit of the control
452 * curVal [I] current value of the control
453 *
454 * RETURNS
455 * Success: handle to the updown control
456 * Failure: 0
457 */
458
459HWND WINAPI
460CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy,
461 HWND parent, INT id, HINSTANCE inst,
462 HWND buddy, INT maxVal, INT minVal, INT curVal)
463{
464 HWND hUD;
465
466 dprintf(("COMCTL32: CreateUpDownControl"));
467
468 hUD = CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy,
469 parent, id, inst, 0);
470 if (hUD) {
471 SendMessageA (hUD, UDM_SETBUDDY, buddy, 0);
472 SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal));
473 SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0));
474 }
475
476 return hUD;
477}
478
479/***********************************************************************
480 * InitCommonControls [COMCTL32.17]
481 *
482 * Registers the common controls.
483 *
484 * PARAMS
485 * No parameters.
486 *
487 * RETURNS
488 * No return values.
489 *
490 * NOTES
491 * This function is just a dummy.
492 * The Win95 controls are registered at the DLL's initialization.
493 * To register other controls InitCommonControlsEx() must be used.
494 */
495
496VOID WINAPI InitCommonControls(VOID)
497{
498 dprintf(("COMCTL32: InitCommonControls"));
499}
500
501/***********************************************************************
502 * InitCommonControlsEx [COMCTL32.81]
503 *
504 * Registers the common controls.
505 *
506 * PARAMS
507 * lpInitCtrls [I] pointer to an INITCOMMONCONTROLS structure.
508 *
509 * RETURNS
510 * Success: TRUE
511 * Failure: FALSE
512 *
513 * NOTES
514 * Only the additinal common controls are registered by this function.
515 * The Win95 controls are registered at the DLL's initialization.
516 */
517
518BOOL WINAPI
519InitCommonControlsEx (LPINITCOMMONCONTROLSEX lpInitCtrls)
520{
521 INT cCount;
522 DWORD dwMask;
523
524 dprintf(("COMCTL32: InitCommonControlsEx"));
525
526 if (!lpInitCtrls)
527 return FALSE;
528 if (lpInitCtrls->dwSize != sizeof(INITCOMMONCONTROLSEX))
529 return FALSE;
530
531// TRACE(commctrl,"(0x%08lx)\n", lpInitCtrls->dwICC);
532
533 for (cCount = 0; cCount < 32; cCount++) {
534 dwMask = 1 << cCount;
535 if (!(lpInitCtrls->dwICC & dwMask))
536 continue;
537
538 switch (lpInitCtrls->dwICC & dwMask) {
539 /* dummy initialization */
540 case ICC_ANIMATE_CLASS:
541 case ICC_BAR_CLASSES:
542 case ICC_LISTVIEW_CLASSES:
543 case ICC_TREEVIEW_CLASSES:
544 case ICC_TAB_CLASSES:
545 case ICC_UPDOWN_CLASS:
546 case ICC_PROGRESS_CLASS:
547 case ICC_HOTKEY_CLASS:
548 break;
549
550 /* advanced classes - not included in Win95 */
551 case ICC_DATE_CLASSES:
552 MONTHCAL_Register ();
553 DATETIME_Register ();
554 break;
555
556 case ICC_USEREX_CLASSES:
557 COMBOEX_Register ();
558 break;
559
560 case ICC_COOL_CLASSES:
561 REBAR_Register ();
562 break;
563
564 case ICC_INTERNET_CLASSES:
565 IPADDRESS_Register ();
566 break;
567
568 case ICC_PAGESCROLLER_CLASS:
569 PAGER_Register ();
570 break;
571
572 case ICC_NATIVEFNTCTL_CLASS:
573 NATIVEFONT_Register ();
574 break;
575
576 default:
577// FIXME (commctrl, "Unknown class! dwICC=0x%lX\n", dwMask);
578 break;
579 }
580 }
581
582 return TRUE;
583}
584
585/***********************************************************************
586 * CreateToolbarEx [COMCTL32.32] Creates a tool bar window
587 *
588 * PARAMS
589 * hwnd
590 * style
591 * wID
592 * nBitmaps
593 * hBMInst
594 * wBMID
595 * lpButtons
596 * iNumButtons
597 * dxButton
598 * dyButton
599 * dxBitmap
600 * dyBitmap
601 * uStructSize
602 *
603 * RETURNS
604 * Success: handle to the tool bar control
605 * Failure: 0
606 */
607
608HWND WINAPI
609CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
610 HINSTANCE hBMInst, UINT wBMID, LPCTBBUTTON lpButtons,
611 INT iNumButtons, INT dxButton, INT dyButton,
612 INT dxBitmap, INT dyBitmap, UINT uStructSize)
613{
614 HWND hwndTB;
615
616 dprintf(("COMCTL32: CreateToolbarEx"));
617
618 hwndTB = CreateWindowExA (0, TOOLBARCLASSNAMEA, "", style, 0, 0, 0, 0,
619 hwnd, (HMENU)wID, 0, NULL);
620 if(hwndTB) {
621 TBADDBITMAP tbab;
622
623 SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE,
624 (WPARAM)uStructSize, 0);
625
626 /* set bitmap and button size */
627 /*If CreateToolbarEx receive 0, windows set default values*/
628 if (dyBitmap <= 0)
629 dyBitmap = 16;
630 if (dxBitmap <= 0)
631 dxBitmap = 16;
632
633 SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
634 MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap));
635 SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
636 MAKELPARAM((WORD)dxButton, (WORD)dyButton));
637
638
639 /* add bitmaps */
640 if (nBitmaps > 0)
641 {
642 tbab.hInst = hBMInst;
643 tbab.nID = wBMID;
644
645 SendMessageA (hwndTB, TB_ADDBITMAP,
646 (WPARAM)nBitmaps, (LPARAM)&tbab);
647 }
648 /* add buttons */
649 if(iNumButtons > 0)
650 SendMessageA (hwndTB, TB_ADDBUTTONSA,
651 (WPARAM)iNumButtons, (LPARAM)lpButtons);
652 }
653
654 return hwndTB;
655}
656
657
658/***********************************************************************
659 * CreateMappedBitmap [COMCTL32.8]
660 *
661 * PARAMS
662 * hInstance [I]
663 * idBitmap [I]
664 * wFlags [I]
665 * lpColorMap [I]
666 * iNumMaps [I]
667 *
668 * RETURNS
669 * Success: handle to the new bitmap
670 * Failure: 0
671 */
672
673HBITMAP WINAPI
674CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags,
675 LPCOLORMAP lpColorMap, INT iNumMaps)
676{
677 HGLOBAL hglb;
678 HRSRC hRsrc;
679 LPBITMAPINFOHEADER lpBitmap, lpBitmapInfo;
680 UINT nSize, nColorTableSize;
681 RGBQUAD *pColorTable;
682 INT iColor, i, iMaps, nWidth, nHeight;
683 HDC hdcScreen;
684 HBITMAP hbm;
685 LPCOLORMAP sysColorMap;
686 COLORREF cRef;
687 COLORMAP internalColorMap[4] =
688 {{0x000000, 0}, {0x808080, 0}, {0xC0C0C0, 0}, {0xFFFFFF, 0}};
689
690 dprintf(("COMCTL32: CreateMappedBitmap"));
691
692 /* initialize pointer to colortable and default color table */
693 if (lpColorMap) {
694 iMaps = iNumMaps;
695 sysColorMap = lpColorMap;
696 }
697 else {
698 internalColorMap[0].to = GetSysColor (COLOR_BTNTEXT);
699 internalColorMap[1].to = GetSysColor (COLOR_BTNSHADOW);
700 internalColorMap[2].to = GetSysColor (COLOR_BTNFACE);
701 internalColorMap[3].to = GetSysColor (COLOR_BTNHIGHLIGHT);
702 iMaps = 4;
703 sysColorMap = (LPCOLORMAP)internalColorMap;
704 }
705
706 hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, RT_BITMAPA);
707 if (hRsrc == 0)
708 return 0;
709 hglb = LoadResource (hInstance, hRsrc);
710 if (hglb == 0)
711 return 0;
712 lpBitmap = (LPBITMAPINFOHEADER)LockResource (hglb);
713 if (lpBitmap == NULL)
714 return 0;
715
716 nColorTableSize = (1 << lpBitmap->biBitCount);
717 nSize = lpBitmap->biSize + nColorTableSize * sizeof(RGBQUAD);
718 lpBitmapInfo = (LPBITMAPINFOHEADER)GlobalAlloc (GMEM_FIXED, nSize);
719 if (lpBitmapInfo == NULL)
720 return 0;
721 RtlMoveMemory (lpBitmapInfo, lpBitmap, nSize);
722
723 pColorTable = (RGBQUAD*)(((LPBYTE)lpBitmapInfo)+(UINT)lpBitmapInfo->biSize);
724
725 for (iColor = 0; iColor < nColorTableSize; iColor++) {
726 for (i = 0; i < iMaps; i++) {
727 cRef = RGB(pColorTable[iColor].rgbRed,
728 pColorTable[iColor].rgbGreen,
729 pColorTable[iColor].rgbBlue);
730 if ( cRef == sysColorMap[i].from) {
731#if 0
732 if (wFlags & CBS_MASKED) {
733 if (sysColorMap[i].to != COLOR_BTNTEXT)
734 pColorTable[iColor] = RGB(255, 255, 255);
735 }
736 else
737#endif
738 pColorTable[iColor].rgbBlue = GetBValue(sysColorMap[i].to);
739 pColorTable[iColor].rgbGreen = GetGValue(sysColorMap[i].to);
740 pColorTable[iColor].rgbRed = GetRValue(sysColorMap[i].to);
741 break;
742 }
743 }
744 }
745 nWidth = (INT)lpBitmapInfo->biWidth;
746 nHeight = (INT)lpBitmapInfo->biHeight;
747 hdcScreen = GetDC ((HWND)0);
748 hbm = CreateCompatibleBitmap (hdcScreen, nWidth, nHeight);
749 if (hbm) {
750 HDC hdcDst = CreateCompatibleDC (hdcScreen);
751 HBITMAP hbmOld = SelectObject (hdcDst, hbm);
752 LPBYTE lpBits = (LPBYTE)(lpBitmap + 1);
753 lpBits += (1 << (lpBitmapInfo->biBitCount)) * sizeof(RGBQUAD);
754 StretchDIBits (hdcDst, 0, 0, nWidth, nHeight, 0, 0, nWidth, nHeight,
755 lpBits, (LPBITMAPINFO)lpBitmapInfo, DIB_RGB_COLORS,
756 SRCCOPY);
757 SelectObject (hdcDst, hbmOld);
758 DeleteDC (hdcDst);
759 }
760 ReleaseDC ((HWND)0, hdcScreen);
761 GlobalFree ((HGLOBAL)lpBitmapInfo);
762 FreeResource (hglb);
763
764 return hbm;
765}
766
767
768/***********************************************************************
769 * CreateToolbar [COMCTL32.7] Creates a tool bar control
770 *
771 * PARAMS
772 * hwnd
773 * style
774 * wID
775 * nBitmaps
776 * hBMInst
777 * wBMID
778 * lpButtons
779 * iNumButtons
780 *
781 * RETURNS
782 * Success: handle to the tool bar control
783 * Failure: 0
784 *
785 * NOTES
786 * Do not use this functions anymore. Use CreateToolbarEx instead.
787 */
788
789HWND WINAPI
790CreateToolbar (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
791 HINSTANCE hBMInst, UINT wBMID,
792 LPCOLDTBBUTTON lpButtons,INT iNumButtons)
793{
794 dprintf(("COMCTL32: CreateToolbar"));
795
796 return CreateToolbarEx (hwnd, style | CCS_NODIVIDER, wID, nBitmaps,
797 hBMInst, wBMID, (LPCTBBUTTON)lpButtons,
798 iNumButtons, 0, 0, 0, 0, sizeof (OLDTBBUTTON));
799}
800
801
802/***********************************************************************
803 * DllGetVersion [COMCTL32.25]
804 *
805 * Retrieves version information of the 'COMCTL32.DLL'
806 *
807 * PARAMS
808 * pdvi [O] pointer to version information structure.
809 *
810 * RETURNS
811 * Success: S_OK
812 * Failure: E_INVALIDARG
813 *
814 * NOTES
815 * IE4.01 SP1:
816 * 4-72-3110-1
817 *
818 * IE5:
819 * 5-80-2014-1
820 */
821
822HRESULT WINAPI
823COMCTL32_DllGetVersion (DLLVERSIONINFO *pdvi)
824{
825 dprintf(("COMCTL32: COMCTL32_DllGetVersion"));
826
827 if (pdvi->cbSize != sizeof(DLLVERSIONINFO)) {
828// WARN (commctrl, "wrong DLLVERSIONINFO size from app");
829 return E_INVALIDARG;
830 }
831
832 pdvi->dwMajorVersion = 5;
833 pdvi->dwMinorVersion = 80;
834 pdvi->dwBuildNumber = 2014;
835 pdvi->dwPlatformID = 1;
836
837// TRACE (commctrl, "%lu.%lu.%lu.%lu\n",
838// pdvi->dwMajorVersion, pdvi->dwMinorVersion,
839// pdvi->dwBuildNumber, pdvi->dwPlatformID);
840
841 return S_OK;
842}
843
844static int iTrackMax = 0;
845static HWND TrackingList[10];
846static UINT timer;
847
848static void CALLBACK TrackMouseEventProc(HWND hwndUnused, UINT uMsg, UINT idEvent, DWORD dwTime) {
849 int i = 0;
850 POINT pos;
851 HWND hwnd;
852 BOOL keepTracking = FALSE;
853 GetCursorPos(&pos);
854 hwnd = WindowFromPoint(pos);
855 /* Loop through the list of windows waiting on mouse exit */
856 while (i < iTrackMax) {
857 if (TrackingList[i] != hwnd)
858 PostMessageA(TrackingList[i], WM_MOUSELEAVE, 0, 0);
859 else
860 keepTracking = TRUE;
861
862
863 i++;
864 }
865
866 if (keepTracking) {
867 iTrackMax = 1;
868 TrackingList[0] = hwnd;
869 }
870 else
871 KillTimer(0, timer);
872}
873
874/***********************************************************************
875 * _TrackMouseEvent [COMCTL32.25]
876 *
877 * Requests notification of mouse events
878 *
879 * PARAMS
880 * ptme [I,O] pointer to TRACKMOUSEEVENT information structure.
881 *
882 * RETURNS
883 * Success: non-zero
884 * Failure: zero
885 *
886 */
887
888BOOL WINAPI
889_TrackMouseEvent (TRACKMOUSEEVENT *ptme)
890{
891 DWORD flags = 0;
892 int i;
893 BOOL cancel = 0, hover = 0, leave = 0, query = 0;
894
895 dprintf(("COMCTL32: _TrackMouseEvent"));
896
897 if (ptme->cbSize != sizeof(TRACKMOUSEEVENT)) {
898 //WARN("wrong TRACKMOUSEEVENT size from app");
899 return E_INVALIDARG;
900 }
901
902 flags = ptme->dwFlags;
903 if ( flags & TME_CANCEL ) {
904 cancel = 1;
905 flags &= ~ TME_CANCEL;
906 }
907 if ( flags & TME_HOVER ) {
908 hover = 1;
909 flags &= ~ TME_HOVER;
910 //FIXME("TME_HOVER unimplemented\n" );
911 }
912 if ( flags & TME_LEAVE ) {
913 leave = 1;
914 flags &= ~ TME_LEAVE;
915 }
916 if ( flags & TME_QUERY ) {
917 query = 1;
918 flags &= ~ TME_QUERY;
919 //FIXME("TME_QUERY unimplemented\n" );
920 }
921
922 //if ( flags )
923 // FIXME("Unknown flag(s) %ld\n", flags & ~(TME_CANCEL | TME_HOVER | TME_LEAVE | TME_QUERY) );
924
925 if (leave) {
926 if (cancel) {
927 for (i = 0; i < iTrackMax; i++)
928 if (TrackingList[i] == ptme->hwndTrack)
929 TrackingList[i] = TrackingList[--iTrackMax];
930 }
931 else {
932 if (iTrackMax == sizeof (TrackingList) / sizeof *TrackingList)
933 return FALSE;
934
935 /* Add hwndTrack to the track list */
936 TrackingList[iTrackMax++] = ptme->hwndTrack;
937 if (!timer)
938 timer = SetTimer(0, 0, 50, TrackMouseEventProc);
939 }
940 }
941
942 return TRUE;
943}
944
945
Note: See TracBrowser for help on using the repository browser.