5 * Copyright 1998 Eric Kohl
8 * - A little bug in TOOLBAR_DrawMasked()
9 * - Button wrapping (under construction).
13 * - Tooltip support (almost complete).
15 * - Internal COMMCTL32 bitmaps.
16 * - Fix TOOLBAR_SetButtonInfo32A.
17 * - Fix TOOLBAR_Customize. (Customize dialog.)
20 * - Run tests using Waite Group Windows95 API Bible Volume 2.
21 * The second cdrom contains executables addstr.exe, btncount.exe,
22 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
23 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
24 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
25 * setparnt.exe, setrows.exe, toolwnd.exe.
26 * - Microsofts controlspy examples.
33 #include "sysmetrics.h"
38 DEFAULT_DEBUG_CHANNEL(toolbar)
40 #define SEPARATOR_WIDTH 8
42 #define BOTTOM_BORDER 2
45 #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
48 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
50 INT x = (lpRect->left + lpRect->right) / 2 - 1;
51 INT yBottom = lpRect->bottom - 3;
52 INT yTop = lpRect->top + 1;
54 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
55 MoveToEx (hdc, x, yBottom, NULL);
56 LineTo (hdc, x, yTop);
58 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
59 MoveToEx (hdc, x, yBottom, NULL);
60 LineTo (hdc, x, yTop);
65 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
68 RECT rcText = btnPtr->rect;
74 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
75 InflateRect (&rcText, -3, -3);
76 rcText.top += infoPtr->nBitmapHeight;
77 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
78 OffsetRect (&rcText, 1, 1);
80 hOldFont = SelectObject (hdc, infoPtr->hFont);
81 nOldBkMode = SetBkMode (hdc, TRANSPARENT);
82 if (!(nState & TBSTATE_ENABLED)) {
83 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
84 OffsetRect (&rcText, 1, 1);
85 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
86 &rcText, infoPtr->dwDTFlags);
87 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
88 OffsetRect (&rcText, -1, -1);
89 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
90 &rcText, infoPtr->dwDTFlags);
92 else if (nState & TBSTATE_INDETERMINATE) {
93 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
94 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
95 &rcText, infoPtr->dwDTFlags);
98 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
99 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
100 &rcText, infoPtr->dwDTFlags);
103 SetTextColor (hdc, clrOld);
104 SelectObject (hdc, hOldFont);
105 if (nOldBkMode != TRANSPARENT)
106 SetBkMode (hdc, nOldBkMode);
112 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
114 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
115 INT cx = lpRect->right - lpRect->left;
116 INT cy = lpRect->bottom - lpRect->top;
117 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
118 SelectObject (hdc, hbr);
123 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
124 HDC hdc, INT x, INT y)
126 /* FIXME: this function is a hack since it uses image list
127 internals directly */
129 HDC hdcImageList = CreateCompatibleDC (0);
130 HDC hdcMask = CreateCompatibleDC (0);
131 HIMAGELIST himl = infoPtr->himlStd;
134 /* create new bitmap */
135 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
136 SelectObject (hdcMask, hbmMask);
138 /* copy the mask bitmap */
139 SelectObject (hdcImageList, himl->hbmMask);
140 SetBkColor (hdcImageList, RGB(255, 255, 255));
141 SetTextColor (hdcImageList, RGB(0, 0, 0));
142 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
143 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
146 /* add white mask from image */
147 SelectObject (hdcImageList, himl->hbmImage);
148 SetBkColor (hdcImageList, RGB(0, 0, 0));
149 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
150 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
153 /* draw the new mask */
154 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
155 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
156 hdcMask, 0, 0, 0xB8074A);
158 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
159 BitBlt (hdc, x, y, himl->cx, himl->cy,
160 hdcMask, 0, 0, 0xB8074A);
162 DeleteObject (hbmMask);
164 DeleteDC (hdcImageList);
169 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
171 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
172 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
175 if (btnPtr->fsState & TBSTATE_HIDDEN)
179 if (btnPtr->fsStyle & TBSTYLE_SEP) {
180 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
181 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
186 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
187 DrawEdge (hdc, &rc, EDGE_RAISED,
188 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
190 if (dwStyle & TBSTYLE_FLAT) {
191 /* if (infoPtr->himlDis) */
192 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
193 rc.left+1, rc.top+1, ILD_NORMAL);
195 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */
198 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
200 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
204 /* pressed TBSTYLE_BUTTON */
205 if (btnPtr->fsState & TBSTATE_PRESSED) {
206 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
207 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
208 rc.left+2, rc.top+2, ILD_NORMAL);
209 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
213 /* checked TBSTYLE_CHECK*/
214 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
215 (btnPtr->fsState & TBSTATE_CHECKED)) {
216 if (dwStyle & TBSTYLE_FLAT)
217 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
218 BF_RECT | BF_MIDDLE | BF_ADJUST);
220 DrawEdge (hdc, &rc, EDGE_SUNKEN,
221 BF_RECT | BF_MIDDLE | BF_ADJUST);
223 TOOLBAR_DrawPattern (hdc, &rc);
224 if (dwStyle & TBSTYLE_FLAT)
226 if (infoPtr->himlDef != NULL)
227 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
228 rc.left+2, rc.top+2, ILD_NORMAL);
230 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
231 rc.left+2, rc.top+2, ILD_NORMAL);
234 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
235 rc.left+2, rc.top+2, ILD_NORMAL);
236 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
241 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
242 DrawEdge (hdc, &rc, EDGE_RAISED,
243 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
245 TOOLBAR_DrawPattern (hdc, &rc);
246 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
247 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
251 if (dwStyle & TBSTYLE_FLAT)
254 DrawEdge (hdc, &rc, BDR_RAISEDINNER,
255 BF_RECT | BF_MIDDLE | BF_SOFT);
257 if(infoPtr->himlDef != NULL)
258 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
259 rc.left +2, rc.top +2, ILD_NORMAL);
261 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
262 rc.left +2, rc.top +2, ILD_NORMAL);
266 DrawEdge (hdc, &rc, EDGE_RAISED,
267 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
269 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
270 rc.left+1, rc.top+1, ILD_NORMAL);
273 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
278 TOOLBAR_Refresh (HWND hwnd, HDC hdc)
280 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
281 TBUTTON_INFO *btnPtr;
285 btnPtr = infoPtr->buttons;
286 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
287 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
292 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
294 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
295 TBUTTON_INFO *btnPtr;
304 hOldFont = SelectObject (hdc, infoPtr->hFont);
306 btnPtr = infoPtr->buttons;
307 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
308 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
309 (btnPtr->iString > -1) &&
310 (btnPtr->iString < infoPtr->nNumStrings)) {
311 LPWSTR lpText = infoPtr->strings[btnPtr->iString];
312 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
313 if (sz.cx > lpSize->cx)
315 if (sz.cy > lpSize->cy)
320 SelectObject (hdc, hOldFont);
323 TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy);
326 /***********************************************************************
327 * TOOLBAR_WrapToolbar
329 * This function walks through the buttons and seperators in the
330 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
331 * wrapping should occur based on the width of the toolbar window.
332 * It does *not* calculate button placement itself. That task
333 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
334 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
335 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
339 TOOLBAR_WrapToolbar( HWND hwnd )
341 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
342 TBUTTON_INFO *btnPtr;
343 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
346 BOOL bWrap, bButtonWrap;
348 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
349 /* no layout is necessary. Applications may use this style */
350 /* to perform their own layout on the toolbar. */
351 if( !(dwStyle & TBSTYLE_WRAPABLE) )
354 btnPtr = infoPtr->buttons;
355 x = infoPtr->nIndent;
357 GetClientRect( GetParent(hwnd), &rc );
358 infoPtr->nWidth = rc.right - rc.left;
361 for (i = 0; i < infoPtr->nNumButtons; i++ )
364 btnPtr[i].fsState &= ~TBSTATE_WRAP;
366 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
369 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
370 /* it is the actual width of the separator. This is used for */
371 /* custom controls in toolbars. */
372 if (btnPtr[i].fsStyle & TBSTYLE_SEP)
373 cx = (btnPtr[i].iBitmap > 0) ?
374 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
376 cx = infoPtr->nButtonWidth;
378 /* Two or more adjacent separators form a separator group. */
379 /* The first separator in a group should be wrapped to the */
380 /* next row if the previous wrapping is on a button. */
382 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
383 (i + 1 < infoPtr->nNumButtons ) &&
384 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
386 btnPtr[i].fsState |= TBSTATE_WRAP;
387 x = infoPtr->nIndent;
393 /* The layout makes sure the bitmap is visible, but not the button. */
394 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
399 /* If the current button is a separator and not hidden, */
400 /* go to the next until it reaches a non separator. */
401 /* Wrap the last separator if it is before a button. */
402 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
403 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
404 i < infoPtr->nNumButtons )
410 if( bFound && i < infoPtr->nNumButtons )
413 btnPtr[i].fsState |= TBSTATE_WRAP;
414 x = infoPtr->nIndent;
418 else if ( i >= infoPtr->nNumButtons)
421 /* If the current button is not a separator, find the last */
422 /* separator and wrap it. */
423 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
425 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
426 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
430 x = infoPtr->nIndent;
431 btnPtr[j].fsState |= TBSTATE_WRAP;
437 /* If no separator available for wrapping, wrap one of */
438 /* non-hidden previous button. */
442 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
444 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
449 x = infoPtr->nIndent;
450 btnPtr[j].fsState |= TBSTATE_WRAP;
456 /* If all above failed, wrap the current button. */
459 btnPtr[i].fsState |= TBSTATE_WRAP;
461 x = infoPtr->nIndent;
462 if (btnPtr[i].fsState & TBSTYLE_SEP )
473 /***********************************************************************
474 * TOOLBAR_CalcToolbar
476 * This function calculates button and separator placement. It first
477 * calculates the button sizes, gets the toolbar window width and then
478 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
479 * on. It assigns a new location to each item and sends this location to
480 * the tooltip window if appropriate. Finally, it updates the rcBound
481 * rect and calculates the new required toolbar window height.
485 TOOLBAR_CalcToolbar (HWND hwnd)
487 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
488 TBUTTON_INFO *btnPtr;
489 INT i, nRows, nSepRows;
495 TOOLBAR_CalcStrings (hwnd, &sizeString);
497 if (sizeString.cy > 0)
498 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
499 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
500 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
502 if (sizeString.cx > infoPtr->nBitmapWidth)
503 infoPtr->nButtonWidth = sizeString.cx + 6;
504 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
505 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
507 TOOLBAR_WrapToolbar( hwnd );
509 x = infoPtr->nIndent;
511 cx = infoPtr->nButtonWidth;
512 cy = infoPtr->nButtonHeight;
513 nRows = nSepRows = 0;
515 infoPtr->rcBound.top = y;
516 infoPtr->rcBound.left = x;
517 infoPtr->rcBound.bottom = y + cy;
518 infoPtr->rcBound.right = x;
520 btnPtr = infoPtr->buttons;
521 GetClientRect( GetParent(hwnd), &rc );
522 infoPtr->nWidth = rc.right - rc.left;
524 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
527 if (btnPtr->fsState & TBSTATE_HIDDEN)
529 SetRectEmpty (&btnPtr->rect);
533 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
534 /* it is the actual width of the separator. This is used for */
535 /* custom controls in toolbars. */
536 if (btnPtr->fsStyle & TBSTYLE_SEP)
537 cx = (btnPtr->iBitmap > 0) ?
538 btnPtr->iBitmap : SEPARATOR_WIDTH;
540 cx = infoPtr->nButtonWidth;
542 if (btnPtr->fsState & TBSTATE_WRAP )
545 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
547 if (infoPtr->rcBound.left > x)
548 infoPtr->rcBound.left = x;
549 if (infoPtr->rcBound.right < x + cx)
550 infoPtr->rcBound.right = x + cx;
551 if (infoPtr->rcBound.bottom < y + cy)
552 infoPtr->rcBound.bottom = y + cy;
554 /* Set the toolTip only for non-hidden, non-separator button */
555 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
559 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
560 ti.cbSize = sizeof(TTTOOLINFOA);
562 ti.uId = btnPtr->idCommand;
563 ti.rect = btnPtr->rect;
564 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
568 /* btnPtr->nRow is zero based. The space between the rows is */
569 /* also considered as a row. */
570 btnPtr->nRow = nRows + nSepRows;
573 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
577 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
578 /* it is the actual width of the separator. This is used for */
579 /* custom controls in toolbars. */
580 y += cy + ( (btnPtr->iBitmap > 0 ) ?
581 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
583 /* nSepRows is used to calculate the extra height follwoing */
587 x = infoPtr->nIndent;
594 /* infoPtr->nRows is the number of rows on the toolbar */
595 infoPtr->nRows = nRows + nSepRows + 1;
597 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
599 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
600 nSepRows * SEPARATOR_WIDTH * 2 / 3 +
601 nSepRows * (infoPtr->nBitmapHeight + 1) +
603 TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
608 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
610 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
611 TBUTTON_INFO *btnPtr;
614 btnPtr = infoPtr->buttons;
615 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
616 if (btnPtr->fsState & TBSTATE_HIDDEN)
619 if (btnPtr->fsStyle & TBSTYLE_SEP) {
620 if (PtInRect (&btnPtr->rect, *lpPt)) {
621 TRACE (toolbar, " ON SEPARATOR %d!\n", i);
626 if (PtInRect (&btnPtr->rect, *lpPt)) {
627 TRACE (toolbar, " ON BUTTON %d!\n", i);
633 TRACE (toolbar, " NOWHERE!\n");
639 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
641 TBUTTON_INFO *btnPtr;
644 btnPtr = infoPtr->buttons;
645 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
646 if (btnPtr->idCommand == idCommand) {
647 TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
651 TRACE (toolbar, "no index found for command=%d\n", idCommand);
657 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
659 TBUTTON_INFO *btnPtr;
662 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
665 /* check index button */
666 btnPtr = &infoPtr->buttons[nIndex];
667 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
668 if (btnPtr->fsState & TBSTATE_CHECKED)
672 /* check previous buttons */
673 nRunIndex = nIndex - 1;
674 while (nRunIndex >= 0) {
675 btnPtr = &infoPtr->buttons[nRunIndex];
676 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
677 if (btnPtr->fsState & TBSTATE_CHECKED)
685 /* check next buttons */
686 nRunIndex = nIndex + 1;
687 while (nRunIndex < infoPtr->nNumButtons) {
688 btnPtr = &infoPtr->buttons[nRunIndex];
689 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
690 if (btnPtr->fsState & TBSTATE_CHECKED)
703 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
704 WPARAM wParam, LPARAM lParam)
712 msg.time = GetMessageTime ();
713 msg.pt.x = LOWORD(GetMessagePos ());
714 msg.pt.y = HIWORD(GetMessagePos ());
716 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
719 /***********************************************************************
720 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
724 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
726 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
727 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
730 if ((!lpAddBmp) || ((INT)wParam <= 0))
733 TRACE (toolbar, "adding %d bitmaps!\n", wParam);
735 if (!(infoPtr->himlStd)) {
736 /* create new standard image list */
738 TRACE (toolbar, "creating standard image list!\n");
741 /* Windows resize all the buttons to the size of a newly added STandard Image*/
742 /* TODO: The resizing should be done each time a standard image is added*/
743 if (lpAddBmp->hInst == HINST_COMMCTRL)
746 if (lpAddBmp->nID & 1)
748 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
749 MAKELPARAM((WORD)26, (WORD)26));
750 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
751 MAKELPARAM((WORD)33, (WORD)33));
755 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
756 MAKELPARAM((WORD)16, (WORD)16));
758 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
759 MAKELPARAM((WORD)22, (WORD)22));
762 TOOLBAR_CalcToolbar (hwnd);
766 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
767 ILC_COLOR | ILC_MASK, (INT)wParam, 2);
770 /* Add bitmaps to the standard image list */
771 if (lpAddBmp->hInst == (HINSTANCE)0) {
773 ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
776 else if (lpAddBmp->hInst == HINST_COMMCTRL) {
777 /* add internal bitmaps */
779 FIXME (toolbar, "internal bitmaps not supported!\n");
780 /* TODO: Resize all the buttons when a new standard image is added */
782 /* Hack to "add" some reserved images within the image list
783 to get the right image indices */
784 nIndex = ImageList_GetImageCount (infoPtr->himlStd);
785 ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
790 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
791 nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
796 infoPtr->nNumBitmaps += (INT)wParam;
803 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
805 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
806 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
807 INT nOldButtons, nNewButtons, nAddButtons, nCount;
809 TRACE (toolbar, "adding %d buttons!\n", wParam);
811 nAddButtons = (UINT)wParam;
812 nOldButtons = infoPtr->nNumButtons;
813 nNewButtons = nOldButtons + nAddButtons;
815 if (infoPtr->nNumButtons == 0) {
817 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
820 TBUTTON_INFO *oldButtons = infoPtr->buttons;
822 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
823 memcpy (&infoPtr->buttons[0], &oldButtons[0],
824 nOldButtons * sizeof(TBUTTON_INFO));
825 COMCTL32_Free (oldButtons);
828 infoPtr->nNumButtons = nNewButtons;
830 /* insert new button data */
831 for (nCount = 0; nCount < nAddButtons; nCount++) {
832 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
833 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
834 btnPtr->idCommand = lpTbb[nCount].idCommand;
835 btnPtr->fsState = lpTbb[nCount].fsState;
836 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
837 btnPtr->dwData = lpTbb[nCount].dwData;
838 btnPtr->iString = lpTbb[nCount].iString;
839 btnPtr->bHot = FALSE;
841 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
844 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
845 ti.cbSize = sizeof (TTTOOLINFOA);
847 ti.uId = btnPtr->idCommand;
849 ti.lpszText = LPSTR_TEXTCALLBACKA;
851 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
856 TOOLBAR_CalcToolbar (hwnd);
858 InvalidateRect(hwnd, NULL, FALSE);
864 /* << TOOLBAR_AddButtons32W >> */
868 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
870 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
873 if ((wParam) && (HIWORD(lParam) == 0)) {
876 TRACE (toolbar, "adding string from resource!\n");
878 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
881 TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
882 nIndex = infoPtr->nNumStrings;
883 if (infoPtr->nNumStrings == 0) {
885 COMCTL32_Alloc (sizeof(LPWSTR));
888 LPWSTR *oldStrings = infoPtr->strings;
890 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
891 memcpy (&infoPtr->strings[0], &oldStrings[0],
892 sizeof(LPWSTR) * infoPtr->nNumStrings);
893 COMCTL32_Free (oldStrings);
896 infoPtr->strings[infoPtr->nNumStrings] =
897 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
898 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
899 infoPtr->nNumStrings++;
902 LPSTR p = (LPSTR)lParam;
907 TRACE (toolbar, "adding string(s) from array!\n");
908 nIndex = infoPtr->nNumStrings;
911 TRACE (toolbar, "len=%d \"%s\"\n", len, p);
913 if (infoPtr->nNumStrings == 0) {
915 COMCTL32_Alloc (sizeof(LPWSTR));
918 LPWSTR *oldStrings = infoPtr->strings;
920 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
921 memcpy (&infoPtr->strings[0], &oldStrings[0],
922 sizeof(LPWSTR) * infoPtr->nNumStrings);
923 COMCTL32_Free (oldStrings);
926 infoPtr->strings[infoPtr->nNumStrings] =
927 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
928 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
929 infoPtr->nNumStrings++;
940 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
942 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
945 if ((wParam) && (HIWORD(lParam) == 0)) {
948 TRACE (toolbar, "adding string from resource!\n");
950 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
953 TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(szString));
954 nIndex = infoPtr->nNumStrings;
955 if (infoPtr->nNumStrings == 0) {
957 COMCTL32_Alloc (sizeof(LPWSTR));
960 LPWSTR *oldStrings = infoPtr->strings;
962 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
963 memcpy (&infoPtr->strings[0], &oldStrings[0],
964 sizeof(LPWSTR) * infoPtr->nNumStrings);
965 COMCTL32_Free (oldStrings);
968 infoPtr->strings[infoPtr->nNumStrings] =
969 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
970 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
971 infoPtr->nNumStrings++;
974 LPWSTR p = (LPWSTR)lParam;
979 TRACE (toolbar, "adding string(s) from array!\n");
980 nIndex = infoPtr->nNumStrings;
983 TRACE (toolbar, "len=%d \"%s\"\n", len, debugstr_w(p));
985 if (infoPtr->nNumStrings == 0) {
987 COMCTL32_Alloc (sizeof(LPWSTR));
990 LPWSTR *oldStrings = infoPtr->strings;
992 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
993 memcpy (&infoPtr->strings[0], &oldStrings[0],
994 sizeof(LPWSTR) * infoPtr->nNumStrings);
995 COMCTL32_Free (oldStrings);
998 infoPtr->strings[infoPtr->nNumStrings] =
999 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1000 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1001 infoPtr->nNumStrings++;
1012 TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1014 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1015 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1022 TRACE (toolbar, "resize forced!\n");
1024 parent = GetParent (hwnd);
1025 GetClientRect(parent, &parent_rect);
1027 if (dwStyle & CCS_NORESIZE) {
1028 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1033 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1034 TOOLBAR_CalcToolbar (hwnd);
1035 InvalidateRect( hwnd, NULL, TRUE );
1036 cy = infoPtr->nHeight;
1037 cx = infoPtr->nWidth;
1040 if (dwStyle & CCS_NOPARENTALIGN)
1041 uPosFlags |= SWP_NOMOVE;
1043 if (!(dwStyle & CCS_NODIVIDER))
1044 cy += sysMetrics[SM_CYEDGE];
1046 infoPtr->bAutoSize = TRUE;
1047 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
1055 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1057 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1059 return infoPtr->nNumButtons;
1064 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1066 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1068 if (infoPtr == NULL) {
1069 ERR (toolbar, "(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1070 ERR (toolbar, "infoPtr == NULL!\n");
1074 infoPtr->dwStructSize = (DWORD)wParam;
1081 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1083 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1084 TBUTTON_INFO *btnPtr;
1088 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1092 btnPtr = &infoPtr->buttons[nIndex];
1093 btnPtr->iBitmap = LOWORD(lParam);
1096 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1097 ReleaseDC (hwnd, hdc);
1104 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1106 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1107 TBUTTON_INFO *btnPtr;
1112 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1116 btnPtr = &infoPtr->buttons[nIndex];
1118 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1121 if (LOWORD(lParam) == FALSE)
1122 btnPtr->fsState &= ~TBSTATE_CHECKED;
1124 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1126 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1127 if (nOldIndex == nIndex)
1129 if (nOldIndex != -1)
1130 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1132 btnPtr->fsState |= TBSTATE_CHECKED;
1136 if (nOldIndex != -1)
1137 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1138 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1139 ReleaseDC (hwnd, hdc);
1141 /* FIXME: Send a WM_NOTIFY?? */
1148 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1150 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1152 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1157 TOOLBAR_Customize (HWND hwnd)
1159 FIXME (toolbar, "customization not implemented!\n");
1166 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1168 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1169 INT nIndex = (INT)wParam;
1171 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1174 if ((infoPtr->hwndToolTip) &&
1175 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1178 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1179 ti.cbSize = sizeof (TTTOOLINFOA);
1181 ti.uId = infoPtr->buttons[nIndex].idCommand;
1183 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1186 if (infoPtr->nNumButtons == 1) {
1187 TRACE (toolbar, " simple delete!\n");
1188 COMCTL32_Free (infoPtr->buttons);
1189 infoPtr->buttons = NULL;
1190 infoPtr->nNumButtons = 0;
1193 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1194 TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
1196 infoPtr->nNumButtons--;
1197 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1199 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1200 nIndex * sizeof(TBUTTON_INFO));
1203 if (nIndex < infoPtr->nNumButtons) {
1204 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1205 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1208 COMCTL32_Free (oldButtons);
1211 TOOLBAR_CalcToolbar (hwnd);
1213 InvalidateRect (hwnd, NULL, TRUE);
1220 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1222 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1223 TBUTTON_INFO *btnPtr;
1227 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1231 btnPtr = &infoPtr->buttons[nIndex];
1232 if (LOWORD(lParam) == FALSE)
1233 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1235 btnPtr->fsState |= TBSTATE_ENABLED;
1238 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1239 ReleaseDC (hwnd, hdc);
1245 /* << TOOLBAR_GetAnchorHighlight >> */
1249 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1251 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1254 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1258 return infoPtr->buttons[nIndex].iBitmap;
1262 static __inline__ LRESULT
1263 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1265 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1270 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1272 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1273 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1274 INT nIndex = (INT)wParam;
1275 TBUTTON_INFO *btnPtr;
1277 if (infoPtr == NULL)
1283 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1286 btnPtr = &infoPtr->buttons[nIndex];
1287 lpTbb->iBitmap = btnPtr->iBitmap;
1288 lpTbb->idCommand = btnPtr->idCommand;
1289 lpTbb->fsState = btnPtr->fsState;
1290 lpTbb->fsStyle = btnPtr->fsStyle;
1291 lpTbb->dwData = btnPtr->dwData;
1292 lpTbb->iString = btnPtr->iString;
1299 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1301 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1302 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1303 TBUTTON_INFO *btnPtr;
1306 if (infoPtr == NULL)
1308 if (lpTbInfo == NULL)
1310 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1313 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1317 btnPtr = &infoPtr->buttons[nIndex];
1319 if (lpTbInfo->dwMask & TBIF_COMMAND)
1320 lpTbInfo->idCommand = btnPtr->idCommand;
1321 if (lpTbInfo->dwMask & TBIF_IMAGE)
1322 lpTbInfo->iImage = btnPtr->iBitmap;
1323 if (lpTbInfo->dwMask & TBIF_LPARAM)
1324 lpTbInfo->lParam = btnPtr->dwData;
1325 if (lpTbInfo->dwMask & TBIF_SIZE)
1326 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1327 if (lpTbInfo->dwMask & TBIF_STATE)
1328 lpTbInfo->fsState = btnPtr->fsState;
1329 if (lpTbInfo->dwMask & TBIF_STYLE)
1330 lpTbInfo->fsStyle = btnPtr->fsStyle;
1331 if (lpTbInfo->dwMask & TBIF_TEXT) {
1332 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1333 lstrcpynA (lpTbInfo->pszText,
1334 (LPSTR)infoPtr->strings[btnPtr->iString],
1342 /* << TOOLBAR_GetButtonInfo32W >> */
1346 TOOLBAR_GetButtonSize (HWND hwnd)
1348 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1350 return MAKELONG((WORD)infoPtr->nButtonWidth,
1351 (WORD)infoPtr->nButtonHeight);
1356 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1358 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1359 INT nIndex, nStringIndex;
1361 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1365 nStringIndex = infoPtr->buttons[nIndex].iString;
1367 TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
1369 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1372 if (lParam == 0) return -1;
1374 lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
1376 return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]);
1380 /* << TOOLBAR_GetButtonText32W >> */
1381 /* << TOOLBAR_GetColorScheme >> */
1385 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1387 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1389 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1390 return (LRESULT)infoPtr->himlDis;
1396 __inline__ static LRESULT
1397 TOOLBAR_GetExtendedStyle (HWND hwnd)
1399 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1401 return infoPtr->dwExStyle;
1406 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1408 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1410 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1411 return (LRESULT)infoPtr->himlHot;
1417 /* << TOOLBAR_GetHotItem >> */
1421 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1423 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1425 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1426 return (LRESULT)infoPtr->himlDef;
1432 /* << TOOLBAR_GetInsertMark >> */
1433 /* << TOOLBAR_GetInsertMarkColor >> */
1437 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1439 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1440 TBUTTON_INFO *btnPtr;
1444 if (infoPtr == NULL)
1446 nIndex = (INT)wParam;
1447 btnPtr = &infoPtr->buttons[nIndex];
1448 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1450 lpRect = (LPRECT)lParam;
1453 if (btnPtr->fsState & TBSTATE_HIDDEN)
1456 TOOLBAR_CalcToolbar( hwnd );
1458 lpRect->left = btnPtr->rect.left;
1459 lpRect->right = btnPtr->rect.right;
1460 lpRect->bottom = btnPtr->rect.bottom;
1461 lpRect->top = btnPtr->rect.top;
1468 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1470 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1471 LPSIZE lpSize = (LPSIZE)lParam;
1476 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1477 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1479 TRACE (toolbar, "maximum size %d x %d\n",
1480 infoPtr->rcBound.right - infoPtr->rcBound.left,
1481 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1487 /* << TOOLBAR_GetObject >> */
1488 /* << TOOLBAR_GetPadding >> */
1492 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1494 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1495 TBUTTON_INFO *btnPtr;
1499 if (infoPtr == NULL)
1501 nIndex = (INT)wParam;
1502 btnPtr = &infoPtr->buttons[nIndex];
1503 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1505 lpRect = (LPRECT)lParam;
1509 lpRect->left = btnPtr->rect.left;
1510 lpRect->right = btnPtr->rect.right;
1511 lpRect->bottom = btnPtr->rect.bottom;
1512 lpRect->top = btnPtr->rect.top;
1519 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1521 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1523 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1524 return infoPtr->nRows;
1531 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1533 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1536 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1540 return infoPtr->buttons[nIndex].fsState;
1545 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1547 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1550 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1554 return infoPtr->buttons[nIndex].fsStyle;
1559 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1561 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1563 if (infoPtr == NULL)
1566 return infoPtr->nMaxTextRows;
1571 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1573 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1575 if (infoPtr == NULL)
1577 return infoPtr->hwndToolTip;
1582 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1584 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1586 TRACE (toolbar, "%s hwnd=0x%x stub!\n",
1587 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
1589 return infoPtr->bUnicode;
1594 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1596 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1597 TBUTTON_INFO *btnPtr;
1600 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1604 btnPtr = &infoPtr->buttons[nIndex];
1605 if (LOWORD(lParam) == FALSE)
1606 btnPtr->fsState &= ~TBSTATE_HIDDEN;
1608 btnPtr->fsState |= TBSTATE_HIDDEN;
1610 TOOLBAR_CalcToolbar (hwnd);
1612 InvalidateRect (hwnd, NULL, TRUE);
1618 __inline__ static LRESULT
1619 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
1621 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
1626 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1628 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1629 TBUTTON_INFO *btnPtr;
1633 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1637 btnPtr = &infoPtr->buttons[nIndex];
1638 if (LOWORD(lParam) == FALSE)
1639 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
1641 btnPtr->fsState |= TBSTATE_INDETERMINATE;
1644 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1645 ReleaseDC (hwnd, hdc);
1652 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1654 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1655 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1656 INT nIndex = (INT)wParam;
1657 TBUTTON_INFO *oldButtons;
1664 TRACE (toolbar, "inserting button index=%d\n", nIndex);
1665 if (nIndex > infoPtr->nNumButtons) {
1666 nIndex = infoPtr->nNumButtons;
1667 TRACE (toolbar, "adjust index=%d\n", nIndex);
1670 oldButtons = infoPtr->buttons;
1671 infoPtr->nNumButtons++;
1672 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1673 /* pre insert copy */
1675 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1676 nIndex * sizeof(TBUTTON_INFO));
1679 /* insert new button */
1680 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
1681 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
1682 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
1683 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
1684 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
1685 infoPtr->buttons[nIndex].iString = lpTbb->iString;
1687 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
1690 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1691 ti.cbSize = sizeof (TTTOOLINFOA);
1693 ti.uId = lpTbb->idCommand;
1695 ti.lpszText = LPSTR_TEXTCALLBACKA;
1697 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1701 /* post insert copy */
1702 if (nIndex < infoPtr->nNumButtons - 1) {
1703 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
1704 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
1707 COMCTL32_Free (oldButtons);
1709 TOOLBAR_CalcToolbar (hwnd);
1711 InvalidateRect (hwnd, NULL, FALSE);
1717 /* << TOOLBAR_InsertButton32W >> */
1718 /* << TOOLBAR_InsertMarkHitTest >> */
1722 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
1724 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1727 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1731 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
1736 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
1738 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1741 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1745 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
1750 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
1752 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1755 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1759 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
1764 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
1766 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1769 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1773 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
1778 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1780 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1783 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1787 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
1792 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
1794 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1797 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1801 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
1805 /* << TOOLBAR_LoadImages >> */
1806 /* << TOOLBAR_MapAccelerator >> */
1807 /* << TOOLBAR_MarkButton >> */
1808 /* << TOOLBAR_MoveButton >> */
1812 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1814 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1815 TBUTTON_INFO *btnPtr;
1819 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1823 btnPtr = &infoPtr->buttons[nIndex];
1824 if (LOWORD(lParam) == FALSE)
1825 btnPtr->fsState &= ~TBSTATE_PRESSED;
1827 btnPtr->fsState |= TBSTATE_PRESSED;
1830 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1831 ReleaseDC (hwnd, hdc);
1837 /* << TOOLBAR_ReplaceBitmap >> */
1841 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1844 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1845 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
1847 if (lpSave == NULL) return 0;
1850 /* save toolbar information */
1851 FIXME (toolbar, "save to \"%s\" \"%s\"\n",
1852 lpSave->pszSubKey, lpSave->pszValueName);
1857 /* restore toolbar information */
1859 FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
1860 lpSave->pszSubKey, lpSave->pszValueName);
1870 /* << TOOLBAR_SaveRestore32W >> */
1871 /* << TOOLBAR_SetAnchorHighlight >> */
1875 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1877 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1879 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
1882 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
1883 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
1890 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1892 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1893 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
1894 TBUTTON_INFO *btnPtr;
1899 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
1902 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1906 btnPtr = &infoPtr->buttons[nIndex];
1907 if (lptbbi->dwMask & TBIF_COMMAND)
1908 btnPtr->idCommand = lptbbi->idCommand;
1909 if (lptbbi->dwMask & TBIF_IMAGE)
1910 btnPtr->iBitmap = lptbbi->iImage;
1911 if (lptbbi->dwMask & TBIF_LPARAM)
1912 btnPtr->dwData = lptbbi->lParam;
1913 /* if (lptbbi->dwMask & TBIF_SIZE) */
1914 /* btnPtr->cx = lptbbi->cx; */
1915 if (lptbbi->dwMask & TBIF_STATE)
1916 btnPtr->fsState = lptbbi->fsState;
1917 if (lptbbi->dwMask & TBIF_STYLE)
1918 btnPtr->fsStyle = lptbbi->fsStyle;
1920 if (lptbbi->dwMask & TBIF_TEXT) {
1921 if ((btnPtr->iString >= 0) ||
1922 (btnPtr->iString < infoPtr->nNumStrings)) {
1924 CHAR **lpString = &infoPtr->strings[btnPtr->iString];
1925 INT len = lstrlenA (lptbbi->pszText);
1926 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
1929 /* this is the ultimate sollution */
1930 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
1938 /* << TOOLBAR_SetButtonInfo32W >> */
1942 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1944 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1946 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
1949 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
1950 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
1957 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
1959 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1961 if (infoPtr == NULL)
1964 infoPtr->cxMin = (INT)LOWORD(lParam);
1965 infoPtr->cxMax = (INT)HIWORD(lParam);
1972 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
1974 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1975 INT nIndex = (INT)wParam;
1977 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1980 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
1982 if (infoPtr->hwndToolTip) {
1984 FIXME (toolbar, "change tool tip!\n");
1992 /* << TOOLBAR_SetColorScheme >> */
1996 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1998 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1999 HIMAGELIST himlTemp;
2001 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2004 himlTemp = infoPtr->himlDis;
2005 infoPtr->himlDis = (HIMAGELIST)lParam;
2007 /* FIXME: redraw ? */
2009 return (LRESULT)himlTemp;
2014 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2016 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2019 dwTemp = infoPtr->dwDTFlags;
2020 infoPtr->dwDTFlags =
2021 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2023 return (LRESULT)dwTemp;
2028 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2030 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2033 dwTemp = infoPtr->dwExStyle;
2034 infoPtr->dwExStyle = (DWORD)lParam;
2036 return (LRESULT)dwTemp;
2041 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2043 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2044 HIMAGELIST himlTemp;
2046 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2049 himlTemp = infoPtr->himlHot;
2050 infoPtr->himlHot = (HIMAGELIST)lParam;
2052 /* FIXME: redraw ? */
2054 return (LRESULT)himlTemp;
2058 /* << TOOLBAR_SetHotItem >> */
2062 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2064 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2065 HIMAGELIST himlTemp;
2067 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2070 himlTemp = infoPtr->himlDef;
2071 infoPtr->himlDef = (HIMAGELIST)lParam;
2073 /* FIXME: redraw ? */
2075 return (LRESULT)himlTemp;
2080 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2082 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2084 infoPtr->nIndent = (INT)wParam;
2086 TOOLBAR_CalcToolbar (hwnd);
2088 InvalidateRect(hwnd, NULL, FALSE);
2094 /* << TOOLBAR_SetInsertMark >> */
2098 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2100 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2102 infoPtr->clrInsertMark = (COLORREF)lParam;
2104 /* FIXME : redraw ??*/
2111 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2113 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2115 if (infoPtr == NULL)
2118 infoPtr->nMaxTextRows = (INT)wParam;
2124 /* << TOOLBAR_SetPadding >> */
2128 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2130 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2133 if (infoPtr == NULL)
2135 hwndOldNotify = infoPtr->hwndNotify;
2136 infoPtr->hwndNotify = (HWND)wParam;
2138 return hwndOldNotify;
2143 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2145 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2146 LPRECT lprc = (LPRECT)lParam;
2148 if (LOWORD(wParam) > 1) {
2150 FIXME (toolbar, "multiple rows not supported!\n");
2154 /* recalculate toolbar */
2155 TOOLBAR_CalcToolbar (hwnd);
2157 /* return bounding rectangle */
2159 lprc->left = infoPtr->rcBound.left;
2160 lprc->right = infoPtr->rcBound.right;
2161 lprc->top = infoPtr->rcBound.top;
2162 lprc->bottom = infoPtr->rcBound.bottom;
2165 /* repaint toolbar */
2166 InvalidateRect(hwnd, NULL, FALSE);
2173 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2175 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2176 TBUTTON_INFO *btnPtr;
2180 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2184 btnPtr = &infoPtr->buttons[nIndex];
2185 btnPtr->fsState = LOWORD(lParam);
2188 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2189 ReleaseDC (hwnd, hdc);
2196 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2198 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2199 TBUTTON_INFO *btnPtr;
2203 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2207 btnPtr = &infoPtr->buttons[nIndex];
2208 btnPtr->fsStyle = LOWORD(lParam);
2211 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2212 ReleaseDC (hwnd, hdc);
2214 if (infoPtr->hwndToolTip) {
2216 FIXME (toolbar, "change tool tip!\n");
2224 __inline__ static LRESULT
2225 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2227 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2229 if (infoPtr == NULL)
2231 infoPtr->hwndToolTip = (HWND)wParam;
2237 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2239 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2242 TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
2243 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2245 bTemp = infoPtr->bUnicode;
2246 infoPtr->bUnicode = (BOOL)wParam;
2253 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2255 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2256 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2259 /* initialize info structure */
2260 infoPtr->nButtonHeight = 22;
2261 infoPtr->nButtonWidth = 23;
2262 infoPtr->nBitmapHeight = 15;
2263 infoPtr->nBitmapWidth = 16;
2265 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2267 infoPtr->nMaxTextRows = 1;
2268 infoPtr->cxMin = -1;
2269 infoPtr->cxMax = -1;
2271 infoPtr->bCaptured = FALSE;
2272 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2273 infoPtr->nButtonDown = -1;
2274 infoPtr->nOldHit = -1;
2275 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2276 infoPtr->hwndNotify = GetParent (hwnd);
2277 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2278 infoPtr->dwDTFlags = DT_CENTER;
2280 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2281 infoPtr->hFont = CreateFontIndirectA (&logFont);
2283 if (dwStyle & TBSTYLE_TOOLTIPS) {
2284 /* Create tooltip control */
2285 infoPtr->hwndToolTip =
2286 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2287 CW_USEDEFAULT, CW_USEDEFAULT,
2288 CW_USEDEFAULT, CW_USEDEFAULT,
2291 /* Send NM_TOOLTIPSCREATED notification */
2292 if (infoPtr->hwndToolTip) {
2293 NMTOOLTIPSCREATED nmttc;
2295 nmttc.hdr.hwndFrom = hwnd;
2296 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2297 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2298 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2300 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2301 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2310 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2312 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2314 /* delete tooltip control */
2315 if (infoPtr->hwndToolTip)
2316 DestroyWindow (infoPtr->hwndToolTip);
2318 /* delete button data */
2319 if (infoPtr->buttons)
2320 COMCTL32_Free (infoPtr->buttons);
2322 /* delete strings */
2323 if (infoPtr->strings) {
2325 for (i = 0; i < infoPtr->nNumStrings; i++)
2326 if (infoPtr->strings[i])
2327 COMCTL32_Free (infoPtr->strings[i]);
2329 COMCTL32_Free (infoPtr->strings);
2332 /* destroy default image list */
2333 if (infoPtr->himlDef)
2334 ImageList_Destroy (infoPtr->himlDef);
2336 /* destroy disabled image list */
2337 if (infoPtr->himlDis)
2338 ImageList_Destroy (infoPtr->himlDis);
2340 /* destroy hot image list */
2341 if (infoPtr->himlHot)
2342 ImageList_Destroy (infoPtr->himlHot);
2344 /* delete default font */
2346 DeleteObject (infoPtr->hFont);
2348 /* free toolbar info data */
2349 COMCTL32_Free (infoPtr);
2356 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2358 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2360 if (infoPtr->bTransparent)
2361 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2363 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2368 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
2370 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2371 TBUTTON_INFO *btnPtr;
2376 pt.x = (INT)LOWORD(lParam);
2377 pt.y = (INT)HIWORD(lParam);
2378 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2381 btnPtr = &infoPtr->buttons[nHit];
2382 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2385 infoPtr->bCaptured = TRUE;
2386 infoPtr->nButtonDown = nHit;
2388 btnPtr->fsState |= TBSTATE_PRESSED;
2391 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2392 ReleaseDC (hwnd, hdc);
2394 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
2395 TOOLBAR_Customize (hwnd);
2402 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
2404 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2405 TBUTTON_INFO *btnPtr;
2410 if (infoPtr->hwndToolTip)
2411 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2412 WM_LBUTTONDOWN, wParam, lParam);
2414 pt.x = (INT)LOWORD(lParam);
2415 pt.y = (INT)HIWORD(lParam);
2416 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2419 btnPtr = &infoPtr->buttons[nHit];
2420 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2424 infoPtr->bCaptured = TRUE;
2425 infoPtr->nButtonDown = nHit;
2426 infoPtr->nOldHit = nHit;
2428 btnPtr->fsState |= TBSTATE_PRESSED;
2431 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2432 ReleaseDC (hwnd, hdc);
2440 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
2442 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2443 TBUTTON_INFO *btnPtr;
2448 BOOL bSendMessage = TRUE;
2450 if (infoPtr->hwndToolTip)
2451 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2452 WM_LBUTTONUP, wParam, lParam);
2454 pt.x = (INT)LOWORD(lParam);
2455 pt.y = (INT)HIWORD(lParam);
2456 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2458 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
2459 infoPtr->bCaptured = FALSE;
2461 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2462 btnPtr->fsState &= ~TBSTATE_PRESSED;
2464 if (nHit == infoPtr->nButtonDown) {
2465 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
2466 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2467 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
2468 infoPtr->nButtonDown);
2469 if (nOldIndex == infoPtr->nButtonDown)
2470 bSendMessage = FALSE;
2471 if ((nOldIndex != infoPtr->nButtonDown) &&
2473 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2474 btnPtr->fsState |= TBSTATE_CHECKED;
2477 if (btnPtr->fsState & TBSTATE_CHECKED)
2478 btnPtr->fsState &= ~TBSTATE_CHECKED;
2480 btnPtr->fsState |= TBSTATE_CHECKED;
2485 bSendMessage = FALSE;
2488 if (nOldIndex != -1)
2489 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
2490 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2491 ReleaseDC (hwnd, hdc);
2494 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
2495 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
2497 infoPtr->nButtonDown = -1;
2498 infoPtr->nOldHit = -1;
2506 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
2508 TBUTTON_INFO *btnPtr, *oldBtnPtr;
2509 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2514 if (infoPtr->hwndToolTip)
2515 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2516 WM_MOUSEMOVE, wParam, lParam);
2518 pt.x = (INT)LOWORD(lParam);
2519 pt.y = (INT)HIWORD(lParam);
2521 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2523 if (infoPtr->nOldHit != nHit)
2525 /* Remove the effect of an old hot button */
2526 if(infoPtr->nOldHit == infoPtr->nHotItem)
2528 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
2529 oldBtnPtr->bHot = FALSE;
2531 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
2534 /* It's not a separator or in nowhere. It's a hot button. */
2537 btnPtr = &infoPtr->buttons[nHit];
2538 btnPtr->bHot = TRUE;
2541 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2542 ReleaseDC (hwnd, hdc);
2544 infoPtr->nHotItem = nHit;
2547 if (infoPtr->bCaptured) {
2548 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2549 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
2550 btnPtr->fsState &= ~TBSTATE_PRESSED;
2552 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2553 ReleaseDC (hwnd, hdc);
2555 else if (nHit == infoPtr->nButtonDown) {
2556 btnPtr->fsState |= TBSTATE_PRESSED;
2558 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2559 ReleaseDC (hwnd, hdc);
2562 infoPtr->nOldHit = nHit;
2568 __inline__ static LRESULT
2569 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2571 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
2572 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
2574 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
2578 __inline__ static LRESULT
2579 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2581 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
2582 ((LPRECT)lParam)->top += sysMetrics[SM_CYEDGE];
2584 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
2589 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2591 TOOLBAR_INFO *infoPtr;
2593 /* allocate memory for info structure */
2594 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
2595 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
2598 infoPtr->dwStructSize = sizeof(TBBUTTON);
2600 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
2601 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
2602 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
2603 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
2606 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
2611 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2613 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2617 if (dwStyle & WS_MINIMIZE)
2618 return 0; /* Nothing to do */
2620 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
2622 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
2625 if (!(dwStyle & CCS_NODIVIDER))
2627 GetWindowRect (hwnd, &rcWindow);
2628 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
2629 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
2632 ReleaseDC( hwnd, hdc );
2638 __inline__ static LRESULT
2639 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
2641 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2642 LPNMHDR lpnmh = (LPNMHDR)lParam;
2644 TRACE (toolbar, "passing WM_NOTIFY!\n");
2646 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
2647 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
2650 if (lpnmh->code == TTN_GETDISPINFOA) {
2651 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
2653 FIXME (toolbar, "retrieving ASCII string\n");
2656 else if (lpnmh->code == TTN_GETDISPINFOW) {
2657 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
2659 FIXME (toolbar, "retrieving UNICODE string\n");
2670 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
2675 TOOLBAR_CalcToolbar( hwnd );
2676 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2677 TOOLBAR_Refresh (hwnd, hdc);
2679 EndPaint (hwnd, &ps);
2685 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
2687 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2688 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2696 /* Resize deadlock check */
2697 if (infoPtr->bAutoSize) {
2698 infoPtr->bAutoSize = FALSE;
2702 flags = (INT) wParam;
2704 /* FIXME for flags =
2705 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
2708 TRACE (toolbar, "sizing toolbar!\n");
2710 if (flags == SIZE_RESTORED) {
2711 /* width and height don't apply */
2712 parent = GetParent (hwnd);
2713 GetClientRect(parent, &parent_rect);
2715 if (dwStyle & CCS_NORESIZE) {
2716 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2719 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
2720 cy = infoPtr->nHeight;
2721 cx = infoPtr->nWidth;
2722 TOOLBAR_CalcToolbar (hwnd);
2723 infoPtr->nWidth = cx;
2724 infoPtr->nHeight = cy;
2727 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2728 TOOLBAR_CalcToolbar (hwnd);
2729 cy = infoPtr->nHeight;
2730 cx = infoPtr->nWidth;
2733 if (dwStyle & CCS_NOPARENTALIGN) {
2734 uPosFlags |= SWP_NOMOVE;
2735 cy = infoPtr->nHeight;
2736 cx = infoPtr->nWidth;
2739 if (!(dwStyle & CCS_NODIVIDER))
2740 cy += sysMetrics[SM_CYEDGE];
2742 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
2743 cx, cy, uPosFlags | SWP_NOZORDER);
2750 TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
2752 TOOLBAR_AutoSize (hwnd, wParam, lParam);
2754 InvalidateRect(hwnd, NULL, FALSE);
2762 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2767 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
2769 case TB_ADDBUTTONSA:
2770 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
2772 /* case TB_ADDBUTTONS32W: */
2775 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
2778 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
2781 return TOOLBAR_AutoSize (hwnd, wParam, lParam);
2783 case TB_BUTTONCOUNT:
2784 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
2786 case TB_BUTTONSTRUCTSIZE:
2787 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
2789 case TB_CHANGEBITMAP:
2790 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
2792 case TB_CHECKBUTTON:
2793 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
2795 case TB_COMMANDTOINDEX:
2796 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
2799 return TOOLBAR_Customize (hwnd);
2801 case TB_DELETEBUTTON:
2802 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
2804 case TB_ENABLEBUTTON:
2805 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
2807 /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
2810 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
2812 case TB_GETBITMAPFLAGS:
2813 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
2816 return TOOLBAR_GetButton (hwnd, wParam, lParam);
2818 case TB_GETBUTTONINFOA:
2819 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
2821 /* case TB_GETBUTTONINFO32W: */ /* 4.71 */
2823 case TB_GETBUTTONSIZE:
2824 return TOOLBAR_GetButtonSize (hwnd);
2826 case TB_GETBUTTONTEXTA:
2827 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
2829 /* case TB_GETBUTTONTEXT32W: */
2830 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
2832 case TB_GETDISABLEDIMAGELIST:
2833 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
2835 case TB_GETEXTENDEDSTYLE:
2836 return TOOLBAR_GetExtendedStyle (hwnd);
2838 case TB_GETHOTIMAGELIST:
2839 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
2841 /* case TB_GETHOTITEM: */ /* 4.71 */
2843 case TB_GETIMAGELIST:
2844 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
2846 /* case TB_GETINSERTMARK: */ /* 4.71 */
2847 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
2849 case TB_GETITEMRECT:
2850 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
2853 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
2855 /* case TB_GETOBJECT: */ /* 4.71 */
2856 /* case TB_GETPADDING: */ /* 4.71 */
2859 return TOOLBAR_GetRect (hwnd, wParam, lParam);
2862 return TOOLBAR_GetRows (hwnd, wParam, lParam);
2865 return TOOLBAR_GetState (hwnd, wParam, lParam);
2868 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
2870 case TB_GETTEXTROWS:
2871 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
2873 case TB_GETTOOLTIPS:
2874 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
2876 case TB_GETUNICODEFORMAT:
2877 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
2880 return TOOLBAR_HideButton (hwnd, wParam, lParam);
2883 return TOOLBAR_HitTest (hwnd, wParam, lParam);
2885 case TB_INDETERMINATE:
2886 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
2888 case TB_INSERTBUTTONA:
2889 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
2891 /* case TB_INSERTBUTTON32W: */
2892 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
2894 case TB_ISBUTTONCHECKED:
2895 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
2897 case TB_ISBUTTONENABLED:
2898 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
2900 case TB_ISBUTTONHIDDEN:
2901 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
2903 case TB_ISBUTTONHIGHLIGHTED:
2904 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
2906 case TB_ISBUTTONINDETERMINATE:
2907 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
2909 case TB_ISBUTTONPRESSED:
2910 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
2912 /* case TB_LOADIMAGES: */ /* 4.70 */
2913 /* case TB_MAPACCELERATOR32A: */ /* 4.71 */
2914 /* case TB_MAPACCELERATOR32W: */ /* 4.71 */
2915 /* case TB_MARKBUTTON: */ /* 4.71 */
2916 /* case TB_MOVEBUTTON: */ /* 4.71 */
2918 case TB_PRESSBUTTON:
2919 return TOOLBAR_PressButton (hwnd, wParam, lParam);
2921 /* case TB_REPLACEBITMAP: */
2923 case TB_SAVERESTOREA:
2924 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
2926 /* case TB_SAVERESTORE32W: */
2927 /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
2929 case TB_SETBITMAPSIZE:
2930 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
2932 case TB_SETBUTTONINFOA:
2933 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
2935 /* case TB_SETBUTTONINFO32W: */ /* 4.71 */
2937 case TB_SETBUTTONSIZE:
2938 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
2940 case TB_SETBUTTONWIDTH:
2941 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
2944 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
2946 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
2948 case TB_SETDISABLEDIMAGELIST:
2949 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
2951 case TB_SETDRAWTEXTFLAGS:
2952 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
2954 case TB_SETEXTENDEDSTYLE:
2955 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
2957 case TB_SETHOTIMAGELIST:
2958 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
2960 /* case TB_SETHOTITEM: */ /* 4.71 */
2962 case TB_SETIMAGELIST:
2963 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
2966 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
2968 /* case TB_SETINSERTMARK: */ /* 4.71 */
2970 case TB_SETINSERTMARKCOLOR:
2971 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
2973 case TB_SETMAXTEXTROWS:
2974 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
2976 /* case TB_SETPADDING: */ /* 4.71 */
2979 return TOOLBAR_SetParent (hwnd, wParam, lParam);
2982 return TOOLBAR_SetRows (hwnd, wParam, lParam);
2985 return TOOLBAR_SetState (hwnd, wParam, lParam);
2988 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
2990 case TB_SETTOOLTIPS:
2991 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
2993 case TB_SETUNICODEFORMAT:
2994 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3000 return TOOLBAR_Create (hwnd, wParam, lParam);
3003 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3006 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3008 /* case WM_GETFONT: */
3009 /* case WM_KEYDOWN: */
3010 /* case WM_KILLFOCUS: */
3012 case WM_LBUTTONDBLCLK:
3013 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3015 case WM_LBUTTONDOWN:
3016 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3019 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3022 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3025 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3028 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3031 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3034 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3037 return TOOLBAR_Notify (hwnd, wParam, lParam);
3039 /* case WM_NOTIFYFORMAT: */
3042 return TOOLBAR_Paint (hwnd, wParam);
3045 return TOOLBAR_Size (hwnd, wParam, lParam);
3047 case WM_STYLECHANGED:
3048 return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
3050 /* case WM_SYSCOLORCHANGE: */
3052 /* case WM_WININICHANGE: */
3057 case WM_MEASUREITEM:
3059 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3062 if (uMsg >= WM_USER)
3063 ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
3064 uMsg, wParam, lParam);
3065 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3072 TOOLBAR_Register (VOID)
3076 if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
3078 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3079 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3080 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3081 wndClass.cbClsExtra = 0;
3082 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3083 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3084 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3085 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3087 RegisterClassA (&wndClass);
3092 TOOLBAR_Unregister (VOID)
3094 if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
3095 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);