4 * Copyright 1998,1999 Eric Kohl
7 * - A little bug in TOOLBAR_DrawMasked()
8 * - Button wrapping (under construction).
10 * - Notifications (under construction).
12 * - Tooltip support (almost complete).
13 * - Unicode suppport (under construction).
14 * - Fix TOOLBAR_SetButtonInfo32A/W.
15 * - Customize dialog (under construction).
18 * - Run tests using Waite Group Windows95 API Bible Volume 2.
19 * The second cdrom contains executables addstr.exe, btncount.exe,
20 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
21 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
22 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
23 * setparnt.exe, setrows.exe, toolwnd.exe.
24 * - Microsofts controlspy examples.
37 #include "debugtools.h"
39 DEFAULT_DEBUG_CHANNEL(toolbar)
41 #define SEPARATOR_WIDTH 8
43 #define BOTTOM_BORDER 2
45 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
49 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
51 INT x = (lpRect->left + lpRect->right) / 2 - 1;
52 INT yBottom = lpRect->bottom - 3;
53 INT yTop = lpRect->top + 1;
55 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
56 MoveToEx (hdc, x, yBottom, NULL);
57 LineTo (hdc, x, yTop);
59 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
60 MoveToEx (hdc, x, yBottom, NULL);
61 LineTo (hdc, x, yTop);
65 * Draw the text string for this button.
66 * note: himl is not used, except to determine whether this button has
67 * an associated bitmap. If so, the text is drawn below it, otherwise
68 * the text is drawn within the rectangle of the button itself.
71 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
72 HDC hdc, INT nState, DWORD dwStyle, HIMAGELIST himl)
74 RECT rcText = btnPtr->rect;
80 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
82 InflateRect (&rcText, -3, -3);
84 if (himl && btnPtr->iBitmap>=0) {
85 if (dwStyle & TBSTYLE_LIST) {
86 rcText.left += infoPtr->nBitmapWidth;
89 rcText.top += infoPtr->nBitmapHeight;
93 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
94 OffsetRect (&rcText, 1, 1);
96 hOldFont = SelectObject (hdc, infoPtr->hFont);
97 nOldBkMode = SetBkMode (hdc, TRANSPARENT);
98 if (!(nState & TBSTATE_ENABLED)) {
99 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
100 OffsetRect (&rcText, 1, 1);
101 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
102 &rcText, infoPtr->dwDTFlags);
103 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
104 OffsetRect (&rcText, -1, -1);
105 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
106 &rcText, infoPtr->dwDTFlags);
108 else if (nState & TBSTATE_INDETERMINATE) {
109 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
110 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
111 &rcText, infoPtr->dwDTFlags);
114 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
115 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
116 &rcText, infoPtr->dwDTFlags);
119 SetTextColor (hdc, clrOld);
120 SelectObject (hdc, hOldFont);
121 if (nOldBkMode != TRANSPARENT)
122 SetBkMode (hdc, nOldBkMode);
128 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
130 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
131 INT cx = lpRect->right - lpRect->left;
132 INT cy = lpRect->bottom - lpRect->top;
133 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
134 SelectObject (hdc, hbr);
139 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
140 HDC hdc, INT x, INT y)
142 /* FIXME: this function is a hack since it uses image list
143 internals directly */
145 HIMAGELIST himl = infoPtr->himlDef;
153 /* create new dc's */
154 hdcImageList = CreateCompatibleDC (0);
155 hdcMask = CreateCompatibleDC (0);
157 /* create new bitmap */
158 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
159 SelectObject (hdcMask, hbmMask);
161 /* copy the mask bitmap */
162 SelectObject (hdcImageList, himl->hbmMask);
163 SetBkColor (hdcImageList, RGB(255, 255, 255));
164 SetTextColor (hdcImageList, RGB(0, 0, 0));
165 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
166 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
169 /* add white mask from image */
170 SelectObject (hdcImageList, himl->hbmImage);
171 SetBkColor (hdcImageList, RGB(0, 0, 0));
172 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
173 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
176 /* draw the new mask */
177 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
178 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
179 hdcMask, 0, 0, 0xB8074A);
181 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
182 BitBlt (hdc, x, y, himl->cx, himl->cy,
183 hdcMask, 0, 0, 0xB8074A);
185 DeleteObject (hbmMask);
187 DeleteDC (hdcImageList);
192 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
194 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
195 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
198 if (btnPtr->fsState & TBSTATE_HIDDEN)
204 if (btnPtr->fsStyle & TBSTYLE_SEP) {
205 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0))
206 TOOLBAR_DrawFlatSeparator (&rc, hdc);
211 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
212 if (!(dwStyle & TBSTYLE_FLAT))
213 DrawEdge (hdc, &rc, EDGE_RAISED,
214 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
216 if (infoPtr->himlDis && btnPtr->iBitmap>=0)
217 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
218 rc.left+1, rc.top+1, ILD_NORMAL);
220 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
222 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle,
227 /* pressed TBSTYLE_BUTTON */
228 if (btnPtr->fsState & TBSTATE_PRESSED) {
229 if (dwStyle & TBSTYLE_FLAT)
230 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
232 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
233 if (btnPtr->iBitmap>=0)
234 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
235 rc.left+2, rc.top+2, ILD_NORMAL);
236 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle,
241 /* checked TBSTYLE_CHECK */
242 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
243 (btnPtr->fsState & TBSTATE_CHECKED)) {
244 if (dwStyle & TBSTYLE_FLAT)
245 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
246 BF_RECT | BF_MIDDLE | BF_ADJUST);
248 DrawEdge (hdc, &rc, EDGE_SUNKEN,
249 BF_RECT | BF_MIDDLE | BF_ADJUST);
251 TOOLBAR_DrawPattern (hdc, &rc);
253 if (btnPtr->iBitmap>=0)
254 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
255 rc.left+2, rc.top+2, ILD_NORMAL);
257 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle,
263 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
264 DrawEdge (hdc, &rc, EDGE_RAISED,
265 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
267 TOOLBAR_DrawPattern (hdc, &rc);
268 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
269 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle,
275 if (dwStyle & TBSTYLE_FLAT)
278 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
279 if (btnPtr->bHot && infoPtr->himlHot && btnPtr->iBitmap>=0)
280 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
281 rc.left +2, rc.top +2, ILD_NORMAL);
282 else if (btnPtr->iBitmap>=0)
283 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
284 rc.left +2, rc.top +2, ILD_NORMAL);
288 DrawEdge (hdc, &rc, EDGE_RAISED,
289 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
291 if (btnPtr->iBitmap>=0)
292 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
293 rc.left+1, rc.top+1, ILD_NORMAL);
296 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle,
302 TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
304 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
305 TBUTTON_INFO *btnPtr;
309 /* redraw necessary buttons */
310 btnPtr = infoPtr->buttons;
311 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
313 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
314 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
320 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
322 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
323 TBUTTON_INFO *btnPtr;
333 hOldFont = SelectObject (hdc, infoPtr->hFont);
335 btnPtr = infoPtr->buttons;
336 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
337 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
338 (btnPtr->iString > -1) &&
339 (btnPtr->iString < infoPtr->nNumStrings)) {
340 LPWSTR lpText = infoPtr->strings[btnPtr->iString];
341 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
342 if (sz.cx > lpSize->cx)
344 if (sz.cy > lpSize->cy)
349 SelectObject (hdc, hOldFont);
352 TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy);
355 /***********************************************************************
356 * TOOLBAR_WrapToolbar
358 * This function walks through the buttons and seperators in the
359 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
360 * wrapping should occur based on the width of the toolbar window.
361 * It does *not* calculate button placement itself. That task
362 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
363 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
364 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
368 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
370 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
371 TBUTTON_INFO *btnPtr;
374 BOOL bWrap, bButtonWrap;
376 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
377 /* no layout is necessary. Applications may use this style */
378 /* to perform their own layout on the toolbar. */
379 if( !(dwStyle & TBSTYLE_WRAPABLE) )
382 btnPtr = infoPtr->buttons;
383 x = infoPtr->nIndent;
385 /* this can get the parents width, to know how far we can extend
386 * this toolbar. We cannot use its height, as there may be multiple
387 * toolbars in a rebar control
389 GetClientRect( GetParent(hwnd), &rc );
390 infoPtr->nWidth = rc.right - rc.left;
393 for (i = 0; i < infoPtr->nNumButtons; i++ )
396 btnPtr[i].fsState &= ~TBSTATE_WRAP;
398 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
401 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
402 /* it is the actual width of the separator. This is used for */
403 /* custom controls in toolbars. */
404 if (btnPtr[i].fsStyle & TBSTYLE_SEP)
405 cx = (btnPtr[i].iBitmap > 0) ?
406 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
408 cx = infoPtr->nButtonWidth;
410 /* Two or more adjacent separators form a separator group. */
411 /* The first separator in a group should be wrapped to the */
412 /* next row if the previous wrapping is on a button. */
414 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
415 (i + 1 < infoPtr->nNumButtons ) &&
416 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
418 btnPtr[i].fsState |= TBSTATE_WRAP;
419 x = infoPtr->nIndent;
425 /* The layout makes sure the bitmap is visible, but not the button. */
426 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
431 /* If the current button is a separator and not hidden, */
432 /* go to the next until it reaches a non separator. */
433 /* Wrap the last separator if it is before a button. */
434 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
435 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
436 i < infoPtr->nNumButtons )
442 if( bFound && i < infoPtr->nNumButtons )
445 btnPtr[i].fsState |= TBSTATE_WRAP;
446 x = infoPtr->nIndent;
450 else if ( i >= infoPtr->nNumButtons)
453 /* If the current button is not a separator, find the last */
454 /* separator and wrap it. */
455 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
457 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
458 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
462 x = infoPtr->nIndent;
463 btnPtr[j].fsState |= TBSTATE_WRAP;
469 /* If no separator available for wrapping, wrap one of */
470 /* non-hidden previous button. */
474 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
476 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
481 x = infoPtr->nIndent;
482 btnPtr[j].fsState |= TBSTATE_WRAP;
488 /* If all above failed, wrap the current button. */
491 btnPtr[i].fsState |= TBSTATE_WRAP;
493 x = infoPtr->nIndent;
494 if (btnPtr[i].fsState & TBSTYLE_SEP )
505 /***********************************************************************
506 * TOOLBAR_CalcToolbar
508 * This function calculates button and separator placement. It first
509 * calculates the button sizes, gets the toolbar window width and then
510 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
511 * on. It assigns a new location to each item and sends this location to
512 * the tooltip window if appropriate. Finally, it updates the rcBound
513 * rect and calculates the new required toolbar window height.
517 TOOLBAR_CalcToolbar (HWND hwnd)
519 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
520 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
521 TBUTTON_INFO *btnPtr;
522 INT i, nRows, nSepRows;
527 TOOLBAR_CalcStrings (hwnd, &sizeString);
529 if (dwStyle & TBSTYLE_LIST) {
530 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
531 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
534 BOOL usesBitmaps = FALSE;
537 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
538 if (infoPtr->buttons[i].iBitmap >=0)
541 if (sizeString.cy > 0)
543 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
545 infoPtr->nButtonHeight = sizeString.cy + 6;
546 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
547 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
549 if (sizeString.cx > infoPtr->nBitmapWidth)
550 infoPtr->nButtonWidth = sizeString.cx + 6;
551 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
552 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
555 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
556 infoPtr->nButtonWidth = infoPtr->cxMin;
557 if ( infoPtr->cxMax >= 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
558 infoPtr->nButtonWidth = infoPtr->cxMax;
560 TOOLBAR_WrapToolbar( hwnd, dwStyle );
562 x = infoPtr->nIndent;
563 y = (dwStyle & TBSTYLE_FLAT) ? 0 : TOP_BORDER;
566 * We wills et the height below, and we set the width on entry
567 * so we do not reset them here..
570 GetClientRect( hwnd, &rc );
571 /* get initial values for toolbar */
572 infoPtr->nWidth = rc.right - rc.left;
573 infoPtr->nHeight = rc.bottom - rc.top;
576 /* from above, minimum is a button, and possible text */
577 cx = infoPtr->nButtonWidth;
578 /* cannot use just ButtonHeight, we may have no buttons! */
579 if (infoPtr->nNumButtons > 0)
580 infoPtr->nHeight = infoPtr->nButtonHeight;
581 cy = infoPtr->nHeight;
583 nRows = nSepRows = 0;
585 infoPtr->rcBound.top = y;
586 infoPtr->rcBound.left = x;
587 infoPtr->rcBound.bottom = y + cy;
588 infoPtr->rcBound.right = x;
590 btnPtr = infoPtr->buttons;
592 /* do not base height/width on parent, if the parent is a */
593 /* rebar control it could have multiple rows of toolbars */
594 /* GetClientRect( GetParent(hwnd), &rc ); */
595 /* cx = rc.right - rc.left; */
596 /* cy = rc.bottom - rc.top; */
598 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
601 if (btnPtr->fsState & TBSTATE_HIDDEN)
603 SetRectEmpty (&btnPtr->rect);
607 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
608 /* it is the actual width of the separator. This is used for */
609 /* custom controls in toolbars. */
610 if (btnPtr->fsStyle & TBSTYLE_SEP)
611 cx = (btnPtr->iBitmap > 0) ?
612 btnPtr->iBitmap : SEPARATOR_WIDTH;
614 cx = infoPtr->nButtonWidth;
616 cy = infoPtr->nHeight;
618 if (btnPtr->fsState & TBSTATE_WRAP )
621 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
623 if (infoPtr->rcBound.left > x)
624 infoPtr->rcBound.left = x;
625 if (infoPtr->rcBound.right < x + cx)
626 infoPtr->rcBound.right = x + cx;
627 if (infoPtr->rcBound.bottom < y + cy)
628 infoPtr->rcBound.bottom = y + cy;
630 /* Set the toolTip only for non-hidden, non-separator button */
631 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
635 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
636 ti.cbSize = sizeof(TTTOOLINFOA);
638 ti.uId = btnPtr->idCommand;
639 ti.rect = btnPtr->rect;
640 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
644 /* btnPtr->nRow is zero based. The space between the rows is */
645 /* also considered as a row. */
646 btnPtr->nRow = nRows + nSepRows;
649 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
653 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
654 /* it is the actual width of the separator. This is used for */
655 /* custom controls in toolbars. */
656 y += cy + ( (btnPtr->iBitmap > 0 ) ?
657 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
659 /* nSepRows is used to calculate the extra height follwoing */
663 x = infoPtr->nIndent;
670 /* infoPtr->nRows is the number of rows on the toolbar */
671 infoPtr->nRows = nRows + nSepRows + 1;
673 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
675 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
676 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
677 nSepRows * (infoPtr->nBitmapHeight + 1) +
679 TRACE("toolbar height %d\n", infoPtr->nHeight);
684 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
686 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
687 TBUTTON_INFO *btnPtr;
690 btnPtr = infoPtr->buttons;
691 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
692 if (btnPtr->fsState & TBSTATE_HIDDEN)
695 if (btnPtr->fsStyle & TBSTYLE_SEP) {
696 if (PtInRect (&btnPtr->rect, *lpPt)) {
697 TRACE(" ON SEPARATOR %d!\n", i);
702 if (PtInRect (&btnPtr->rect, *lpPt)) {
703 TRACE(" ON BUTTON %d!\n", i);
709 TRACE(" NOWHERE!\n");
715 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
717 TBUTTON_INFO *btnPtr;
720 btnPtr = infoPtr->buttons;
721 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
722 if (btnPtr->idCommand == idCommand) {
723 TRACE("command=%d index=%d\n", idCommand, i);
727 TRACE("no index found for command=%d\n", idCommand);
733 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
735 TBUTTON_INFO *btnPtr;
738 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
741 /* check index button */
742 btnPtr = &infoPtr->buttons[nIndex];
743 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
744 if (btnPtr->fsState & TBSTATE_CHECKED)
748 /* check previous buttons */
749 nRunIndex = nIndex - 1;
750 while (nRunIndex >= 0) {
751 btnPtr = &infoPtr->buttons[nRunIndex];
752 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
753 if (btnPtr->fsState & TBSTATE_CHECKED)
761 /* check next buttons */
762 nRunIndex = nIndex + 1;
763 while (nRunIndex < infoPtr->nNumButtons) {
764 btnPtr = &infoPtr->buttons[nRunIndex];
765 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
766 if (btnPtr->fsState & TBSTATE_CHECKED)
779 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
780 WPARAM wParam, LPARAM lParam)
788 msg.time = GetMessageTime ();
789 msg.pt.x = LOWORD(GetMessagePos ());
790 msg.pt.y = HIWORD(GetMessagePos ());
792 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
796 /***********************************************************************
797 * TOOLBAR_CustomizeDialogProc
798 * This function implements the toolbar customization dialog.
801 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
803 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
804 static HDSA hDsa = NULL;
809 infoPtr = (TOOLBAR_INFO *)lParam;
810 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
812 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
816 TBUTTON_INFO *btnPtr;
819 /* insert 'virtual' separator button into 'available buttons' list */
820 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
822 /* copy all buttons and append them to the right listbox */
823 btnPtr = infoPtr->buttons;
824 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
826 DSA_InsertItem (hDsa, i, btnPtr);
828 /* FIXME: hidden buttons appear in the 'toolbar buttons' list too */
829 if (btnPtr->fsState & TBSTATE_HIDDEN)
831 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
835 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
839 /* append 'virtual' separator button to the 'toolbar buttons' list */
845 EndDialog(hwnd, FALSE);
849 switch (LOWORD(wParam))
852 EndDialog(hwnd, FALSE);
863 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
865 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
871 COLORREF oldText = 0;
874 FIXME("action: %x itemState: %x\n",
875 lpdis->itemAction, lpdis->itemState);
877 DSA_GetItem (hDsa, 0 /*lpdis->itemID*/, &btnPtr);
879 if (lpdis->itemState & ODS_FOCUS)
881 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
882 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
885 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
886 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
888 /* fill background rectangle */
889 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
890 lpdis->rcItem.right, lpdis->rcItem.bottom);
892 /* calculate button and text rectangles */
893 CopyRect (&rcButton, &lpdis->rcItem);
894 InflateRect (&rcButton, -1, -1);
895 CopyRect (&rcText, &rcButton);
896 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
897 rcText.left = rcButton.right + 2;
899 /* draw focus rectangle */
900 if (lpdis->itemState & ODS_FOCUS)
901 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
904 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
906 /* draw image and text */
907 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
909 /* virtual separator in the 'available' list */
910 DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
911 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
917 ImageList_Draw (infoPtr->himlDef, btnPtr.iBitmap, lpdis->hDC,
918 rcButton.left+1, rcButton.top+1, ILD_NORMAL);
920 DrawTextW (lpdis->hDC, infoPtr->strings[btnPtr.iString], -1, &rcText,
921 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
925 if (lpdis->itemState & ODS_FOCUS)
927 SetBkColor (lpdis->hDC, oldBk);
928 SetTextColor (lpdis->hDC, oldText);
931 SelectObject (lpdis->hDC, hOldBrush);
932 SelectObject (lpdis->hDC, hOldPen);
939 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
941 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
944 lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
946 lpmis->itemHeight = 15 + 8; /* default height */
958 /***********************************************************************
959 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
963 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
965 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
966 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
967 INT nIndex = 0, nButtons;
973 if (lpAddBmp->hInst == HINST_COMMCTRL)
975 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
977 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
979 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
984 TRACE ("adding %d internal bitmaps!\n", nButtons);
986 /* Windows resize all the buttons to the size of a newly added standard image */
987 if (lpAddBmp->nID & 1)
990 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
991 MAKELPARAM((WORD)26, (WORD)26));
992 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
993 MAKELPARAM((WORD)33, (WORD)33));
998 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
999 MAKELPARAM((WORD)16, (WORD)16));
1000 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
1001 MAKELPARAM((WORD)22, (WORD)22));
1004 TOOLBAR_CalcToolbar (hwnd);
1008 nButtons = (INT)wParam;
1012 TRACE ("adding %d bitmaps!\n", nButtons);
1015 if (!(infoPtr->himlDef)) {
1016 /* create new default image list */
1017 TRACE ("creating default image list!\n");
1020 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
1021 ILC_COLOR | ILC_MASK, nButtons, 2);
1022 infoPtr->himlInt = infoPtr->himlDef;
1025 /* Add bitmaps to the default image list */
1026 if (lpAddBmp->hInst == (HINSTANCE)0)
1029 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
1032 else if (lpAddBmp->hInst == HINST_COMMCTRL)
1034 /* Add system bitmaps */
1035 switch (lpAddBmp->nID)
1037 case IDB_STD_SMALL_COLOR:
1038 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1039 MAKEINTRESOURCEA(IDB_STD_SMALL));
1040 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1041 hbmLoad, CLR_DEFAULT);
1042 DeleteObject (hbmLoad);
1045 case IDB_STD_LARGE_COLOR:
1046 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1047 MAKEINTRESOURCEA(IDB_STD_LARGE));
1048 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1049 hbmLoad, CLR_DEFAULT);
1050 DeleteObject (hbmLoad);
1053 case IDB_VIEW_SMALL_COLOR:
1054 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1055 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
1056 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1057 hbmLoad, CLR_DEFAULT);
1058 DeleteObject (hbmLoad);
1061 case IDB_VIEW_LARGE_COLOR:
1062 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1063 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
1064 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1065 hbmLoad, CLR_DEFAULT);
1066 DeleteObject (hbmLoad);
1069 case IDB_HIST_SMALL_COLOR:
1070 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1071 MAKEINTRESOURCEA(IDB_HIST_SMALL));
1072 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1073 hbmLoad, CLR_DEFAULT);
1074 DeleteObject (hbmLoad);
1077 case IDB_HIST_LARGE_COLOR:
1078 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1079 MAKEINTRESOURCEA(IDB_HIST_LARGE));
1080 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1081 hbmLoad, CLR_DEFAULT);
1082 DeleteObject (hbmLoad);
1086 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
1087 ERR ("invalid imagelist!\n");
1093 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
1094 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
1095 DeleteObject (hbmLoad);
1098 infoPtr->nNumBitmaps += nButtons;
1105 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1107 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1108 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1109 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1111 TRACE("adding %d buttons!\n", wParam);
1113 nAddButtons = (UINT)wParam;
1114 nOldButtons = infoPtr->nNumButtons;
1115 nNewButtons = nOldButtons + nAddButtons;
1117 if (infoPtr->nNumButtons == 0) {
1119 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1122 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1124 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1125 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1126 nOldButtons * sizeof(TBUTTON_INFO));
1127 COMCTL32_Free (oldButtons);
1130 infoPtr->nNumButtons = nNewButtons;
1132 /* insert new button data */
1133 for (nCount = 0; nCount < nAddButtons; nCount++) {
1134 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1135 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1136 btnPtr->idCommand = lpTbb[nCount].idCommand;
1137 btnPtr->fsState = lpTbb[nCount].fsState;
1138 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1139 btnPtr->dwData = lpTbb[nCount].dwData;
1140 btnPtr->iString = lpTbb[nCount].iString;
1141 btnPtr->bHot = FALSE;
1143 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1146 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1147 ti.cbSize = sizeof (TTTOOLINFOA);
1149 ti.uId = btnPtr->idCommand;
1151 ti.lpszText = LPSTR_TEXTCALLBACKA;
1153 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1158 TOOLBAR_CalcToolbar (hwnd);
1160 InvalidateRect(hwnd, NULL, FALSE);
1167 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1169 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1170 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1171 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1173 TRACE("adding %d buttons!\n", wParam);
1175 nAddButtons = (UINT)wParam;
1176 nOldButtons = infoPtr->nNumButtons;
1177 nNewButtons = nOldButtons + nAddButtons;
1179 if (infoPtr->nNumButtons == 0) {
1181 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1184 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1186 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1187 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1188 nOldButtons * sizeof(TBUTTON_INFO));
1189 COMCTL32_Free (oldButtons);
1192 infoPtr->nNumButtons = nNewButtons;
1194 /* insert new button data */
1195 for (nCount = 0; nCount < nAddButtons; nCount++) {
1196 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1197 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1198 btnPtr->idCommand = lpTbb[nCount].idCommand;
1199 btnPtr->fsState = lpTbb[nCount].fsState;
1200 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1201 btnPtr->dwData = lpTbb[nCount].dwData;
1202 btnPtr->iString = lpTbb[nCount].iString;
1203 btnPtr->bHot = FALSE;
1205 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1208 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
1209 ti.cbSize = sizeof (TTTOOLINFOW);
1211 ti.uId = btnPtr->idCommand;
1213 ti.lpszText = LPSTR_TEXTCALLBACKW;
1215 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
1220 TOOLBAR_CalcToolbar (hwnd);
1222 InvalidateRect(hwnd, NULL, FALSE);
1229 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1231 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1234 if ((wParam) && (HIWORD(lParam) == 0)) {
1237 TRACE("adding string from resource!\n");
1239 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
1242 TRACE("len=%d \"%s\"\n", len, szString);
1243 nIndex = infoPtr->nNumStrings;
1244 if (infoPtr->nNumStrings == 0) {
1246 COMCTL32_Alloc (sizeof(LPWSTR));
1249 LPWSTR *oldStrings = infoPtr->strings;
1251 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1252 memcpy (&infoPtr->strings[0], &oldStrings[0],
1253 sizeof(LPWSTR) * infoPtr->nNumStrings);
1254 COMCTL32_Free (oldStrings);
1257 infoPtr->strings[infoPtr->nNumStrings] =
1258 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1259 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
1260 infoPtr->nNumStrings++;
1263 LPSTR p = (LPSTR)lParam;
1268 TRACE("adding string(s) from array!\n");
1269 nIndex = infoPtr->nNumStrings;
1272 TRACE("len=%d \"%s\"\n", len, p);
1274 if (infoPtr->nNumStrings == 0) {
1276 COMCTL32_Alloc (sizeof(LPWSTR));
1279 LPWSTR *oldStrings = infoPtr->strings;
1281 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1282 memcpy (&infoPtr->strings[0], &oldStrings[0],
1283 sizeof(LPWSTR) * infoPtr->nNumStrings);
1284 COMCTL32_Free (oldStrings);
1287 infoPtr->strings[infoPtr->nNumStrings] =
1288 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1289 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
1290 infoPtr->nNumStrings++;
1301 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1303 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1306 if ((wParam) && (HIWORD(lParam) == 0)) {
1307 WCHAR szString[256];
1309 TRACE("adding string from resource!\n");
1311 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
1314 TRACE("len=%d \"%s\"\n", len, debugstr_w(szString));
1315 nIndex = infoPtr->nNumStrings;
1316 if (infoPtr->nNumStrings == 0) {
1318 COMCTL32_Alloc (sizeof(LPWSTR));
1321 LPWSTR *oldStrings = infoPtr->strings;
1323 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1324 memcpy (&infoPtr->strings[0], &oldStrings[0],
1325 sizeof(LPWSTR) * infoPtr->nNumStrings);
1326 COMCTL32_Free (oldStrings);
1329 infoPtr->strings[infoPtr->nNumStrings] =
1330 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1331 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
1332 infoPtr->nNumStrings++;
1335 LPWSTR p = (LPWSTR)lParam;
1340 TRACE("adding string(s) from array!\n");
1341 nIndex = infoPtr->nNumStrings;
1344 TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
1346 if (infoPtr->nNumStrings == 0) {
1348 COMCTL32_Alloc (sizeof(LPWSTR));
1351 LPWSTR *oldStrings = infoPtr->strings;
1353 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1354 memcpy (&infoPtr->strings[0], &oldStrings[0],
1355 sizeof(LPWSTR) * infoPtr->nNumStrings);
1356 COMCTL32_Free (oldStrings);
1359 infoPtr->strings[infoPtr->nNumStrings] =
1360 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1361 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1362 infoPtr->nNumStrings++;
1373 TOOLBAR_AutoSize (HWND hwnd)
1375 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1376 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1384 TRACE("resize forced!\n");
1386 parent = GetParent (hwnd);
1387 GetClientRect(parent, &parent_rect);
1389 x = parent_rect.left;
1390 y = parent_rect.top;
1392 if (dwStyle & CCS_NORESIZE) {
1393 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1398 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1399 TOOLBAR_CalcToolbar (hwnd);
1400 InvalidateRect( hwnd, NULL, TRUE );
1401 cy = infoPtr->nHeight;
1402 cx = infoPtr->nWidth;
1404 if (dwStyle & CCS_NOMOVEY) {
1405 GetWindowRect(hwnd, &window_rect);
1406 ScreenToClient(parent, (LPPOINT)&window_rect.left);
1407 y = window_rect.top;
1411 if (dwStyle & CCS_NOPARENTALIGN)
1412 uPosFlags |= SWP_NOMOVE;
1414 if (!(dwStyle & CCS_NODIVIDER))
1415 cy += GetSystemMetrics(SM_CYEDGE);
1417 if (dwStyle & WS_BORDER)
1420 cy += GetSystemMetrics(SM_CYEDGE);
1421 cx += GetSystemMetrics(SM_CYEDGE);
1424 infoPtr->bAutoSize = TRUE;
1425 SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
1427 /* The following line makes sure that the infoPtr->bAutoSize is turned off after
1428 * the setwindowpos calls */
1429 infoPtr->bAutoSize = FALSE;
1436 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1438 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1440 return infoPtr->nNumButtons;
1445 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1447 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1449 if (infoPtr == NULL) {
1450 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1451 ERR("infoPtr == NULL!\n");
1455 infoPtr->dwStructSize = (DWORD)wParam;
1462 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1464 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1465 TBUTTON_INFO *btnPtr;
1468 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1472 btnPtr = &infoPtr->buttons[nIndex];
1473 btnPtr->iBitmap = LOWORD(lParam);
1475 RedrawWindow(hwnd,&btnPtr->rect,NULL,RDW_ERASE|RDW_INVALIDATE);
1482 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1484 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1485 TBUTTON_INFO *btnPtr;
1488 BOOL bChecked = FALSE;
1490 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1494 btnPtr = &infoPtr->buttons[nIndex];
1496 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1499 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
1501 if (LOWORD(lParam) == FALSE)
1502 btnPtr->fsState &= ~TBSTATE_CHECKED;
1504 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1506 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1507 if (nOldIndex == nIndex)
1509 if (nOldIndex != -1)
1510 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1512 btnPtr->fsState |= TBSTATE_CHECKED;
1515 if( bChecked != LOWORD(lParam) )
1517 if (nOldIndex != -1)
1518 RedrawWindow(hwnd,&infoPtr->buttons[nOldIndex].rect,NULL,
1519 RDW_ERASE|RDW_INVALIDATE);
1520 RedrawWindow(hwnd,&btnPtr->rect,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
1523 /* FIXME: Send a WM_NOTIFY?? */
1530 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1532 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1534 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1539 TOOLBAR_Customize (HWND hwnd)
1541 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1547 /* send TBN_BEGINADJUST notification */
1548 nmhdr.hwndFrom = hwnd;
1549 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1550 nmhdr.code = TBN_BEGINADJUST;
1552 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1553 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1555 if (!(hRes = FindResourceA (COMCTL32_hModule,
1556 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1560 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1563 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1564 (LPDLGTEMPLATEA)template,
1566 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1569 /* send TBN_ENDADJUST notification */
1570 nmhdr.code = TBN_ENDADJUST;
1572 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1573 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1580 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1582 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1583 INT nIndex = (INT)wParam;
1585 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1588 if ((infoPtr->hwndToolTip) &&
1589 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1592 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1593 ti.cbSize = sizeof (TTTOOLINFOA);
1595 ti.uId = infoPtr->buttons[nIndex].idCommand;
1597 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1600 if (infoPtr->nNumButtons == 1) {
1601 TRACE(" simple delete!\n");
1602 COMCTL32_Free (infoPtr->buttons);
1603 infoPtr->buttons = NULL;
1604 infoPtr->nNumButtons = 0;
1607 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1608 TRACE("complex delete! [nIndex=%d]\n", nIndex);
1610 infoPtr->nNumButtons--;
1611 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1613 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1614 nIndex * sizeof(TBUTTON_INFO));
1617 if (nIndex < infoPtr->nNumButtons) {
1618 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1619 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1622 COMCTL32_Free (oldButtons);
1625 TOOLBAR_CalcToolbar (hwnd);
1627 InvalidateRect (hwnd, NULL, TRUE);
1634 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1636 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1637 TBUTTON_INFO *btnPtr;
1641 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1645 btnPtr = &infoPtr->buttons[nIndex];
1647 bState = btnPtr->fsState & TBSTATE_ENABLED;
1649 /* update the toolbar button state */
1650 if(LOWORD(lParam) == FALSE) {
1651 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1653 btnPtr->fsState |= TBSTATE_ENABLED;
1656 /* redraw the button only if the state of the button changed */
1657 if(bState != (btnPtr->fsState & TBSTATE_ENABLED)) {
1658 RedrawWindow(hwnd,&btnPtr->rect,NULL,RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
1665 static inline LRESULT
1666 TOOLBAR_GetAnchorHighlight (HWND hwnd)
1668 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1670 return infoPtr->bAnchor;
1675 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1677 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1680 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1684 return infoPtr->buttons[nIndex].iBitmap;
1688 static inline LRESULT
1689 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1691 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1696 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1698 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1699 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1700 INT nIndex = (INT)wParam;
1701 TBUTTON_INFO *btnPtr;
1703 if (infoPtr == NULL)
1709 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1712 btnPtr = &infoPtr->buttons[nIndex];
1713 lpTbb->iBitmap = btnPtr->iBitmap;
1714 lpTbb->idCommand = btnPtr->idCommand;
1715 lpTbb->fsState = btnPtr->fsState;
1716 lpTbb->fsStyle = btnPtr->fsStyle;
1717 lpTbb->dwData = btnPtr->dwData;
1718 lpTbb->iString = btnPtr->iString;
1725 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1727 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1728 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1729 TBUTTON_INFO *btnPtr;
1732 if (infoPtr == NULL)
1734 if (lpTbInfo == NULL)
1736 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1739 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1743 btnPtr = &infoPtr->buttons[nIndex];
1745 if (lpTbInfo->dwMask & TBIF_COMMAND)
1746 lpTbInfo->idCommand = btnPtr->idCommand;
1747 if (lpTbInfo->dwMask & TBIF_IMAGE)
1748 lpTbInfo->iImage = btnPtr->iBitmap;
1749 if (lpTbInfo->dwMask & TBIF_LPARAM)
1750 lpTbInfo->lParam = btnPtr->dwData;
1751 if (lpTbInfo->dwMask & TBIF_SIZE)
1752 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1753 if (lpTbInfo->dwMask & TBIF_STATE)
1754 lpTbInfo->fsState = btnPtr->fsState;
1755 if (lpTbInfo->dwMask & TBIF_STYLE)
1756 lpTbInfo->fsStyle = btnPtr->fsStyle;
1757 if (lpTbInfo->dwMask & TBIF_TEXT) {
1758 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1759 lstrcpynWtoA (lpTbInfo->pszText,
1760 (LPWSTR)infoPtr->strings[btnPtr->iString],
1769 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1771 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1772 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
1773 TBUTTON_INFO *btnPtr;
1776 if (infoPtr == NULL)
1778 if (lpTbInfo == NULL)
1780 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
1783 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1787 btnPtr = &infoPtr->buttons[nIndex];
1789 if (lpTbInfo->dwMask & TBIF_COMMAND)
1790 lpTbInfo->idCommand = btnPtr->idCommand;
1791 if (lpTbInfo->dwMask & TBIF_IMAGE)
1792 lpTbInfo->iImage = btnPtr->iBitmap;
1793 if (lpTbInfo->dwMask & TBIF_LPARAM)
1794 lpTbInfo->lParam = btnPtr->dwData;
1795 if (lpTbInfo->dwMask & TBIF_SIZE)
1796 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1797 if (lpTbInfo->dwMask & TBIF_STATE)
1798 lpTbInfo->fsState = btnPtr->fsState;
1799 if (lpTbInfo->dwMask & TBIF_STYLE)
1800 lpTbInfo->fsStyle = btnPtr->fsStyle;
1801 if (lpTbInfo->dwMask & TBIF_TEXT) {
1802 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1803 lstrcpynW (lpTbInfo->pszText,
1804 (LPWSTR)infoPtr->strings[btnPtr->iString],
1813 TOOLBAR_GetButtonSize (HWND hwnd)
1815 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1817 return MAKELONG((WORD)infoPtr->nButtonWidth,
1818 (WORD)infoPtr->nButtonHeight);
1823 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1825 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1826 INT nIndex, nStringIndex;
1828 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1832 nStringIndex = infoPtr->buttons[nIndex].iString;
1834 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1836 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1842 lstrcpyWtoA ((LPSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1844 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1849 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1851 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1852 INT nIndex, nStringIndex;
1854 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1858 nStringIndex = infoPtr->buttons[nIndex].iString;
1860 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1862 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1868 lstrcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1870 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1874 /* << TOOLBAR_GetColorScheme >> */
1878 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1880 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1882 return (LRESULT)infoPtr->himlDis;
1886 inline static LRESULT
1887 TOOLBAR_GetExtendedStyle (HWND hwnd)
1889 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1891 return infoPtr->dwExStyle;
1896 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1898 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1900 return (LRESULT)infoPtr->himlHot;
1905 TOOLBAR_GetHotItem (HWND hwnd)
1907 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1909 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
1912 if (infoPtr->nHotItem < 0)
1915 return (LRESULT)infoPtr->nHotItem;
1920 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1922 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1924 return (LRESULT)infoPtr->himlDef;
1928 /* << TOOLBAR_GetInsertMark >> */
1929 /* << TOOLBAR_GetInsertMarkColor >> */
1933 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1935 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1936 TBUTTON_INFO *btnPtr;
1940 if (infoPtr == NULL)
1942 nIndex = (INT)wParam;
1943 btnPtr = &infoPtr->buttons[nIndex];
1944 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1946 lpRect = (LPRECT)lParam;
1949 if (btnPtr->fsState & TBSTATE_HIDDEN)
1952 TOOLBAR_CalcToolbar( hwnd );
1954 lpRect->left = btnPtr->rect.left;
1955 lpRect->right = btnPtr->rect.right;
1956 lpRect->bottom = btnPtr->rect.bottom;
1957 lpRect->top = btnPtr->rect.top;
1964 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1966 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1967 LPSIZE lpSize = (LPSIZE)lParam;
1972 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1973 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1975 TRACE("maximum size %d x %d\n",
1976 infoPtr->rcBound.right - infoPtr->rcBound.left,
1977 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1983 /* << TOOLBAR_GetObject >> */
1984 /* << TOOLBAR_GetPadding >> */
1988 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1990 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1991 TBUTTON_INFO *btnPtr;
1995 if (infoPtr == NULL)
1997 nIndex = (INT)wParam;
1998 btnPtr = &infoPtr->buttons[nIndex];
1999 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2001 lpRect = (LPRECT)lParam;
2005 lpRect->left = btnPtr->rect.left;
2006 lpRect->right = btnPtr->rect.right;
2007 lpRect->bottom = btnPtr->rect.bottom;
2008 lpRect->top = btnPtr->rect.top;
2015 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2017 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2019 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
2020 return infoPtr->nRows;
2027 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2029 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2032 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2036 return infoPtr->buttons[nIndex].fsState;
2041 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2043 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2046 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2050 return infoPtr->buttons[nIndex].fsStyle;
2055 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2057 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2059 if (infoPtr == NULL)
2062 return infoPtr->nMaxTextRows;
2067 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2069 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2071 if (infoPtr == NULL)
2073 return infoPtr->hwndToolTip;
2078 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2080 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2082 TRACE("%s hwnd=0x%x stub!\n",
2083 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
2085 return infoPtr->bUnicode;
2089 inline static LRESULT
2090 TOOLBAR_GetVersion (HWND hwnd)
2092 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2093 return infoPtr->iVersion;
2098 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2100 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2101 TBUTTON_INFO *btnPtr;
2104 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2108 btnPtr = &infoPtr->buttons[nIndex];
2109 if (LOWORD(lParam) == FALSE)
2110 btnPtr->fsState &= ~TBSTATE_HIDDEN;
2112 btnPtr->fsState |= TBSTATE_HIDDEN;
2114 TOOLBAR_CalcToolbar (hwnd);
2116 InvalidateRect (hwnd, NULL, TRUE);
2122 inline static LRESULT
2123 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2125 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
2130 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2132 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2133 TBUTTON_INFO *btnPtr;
2136 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2140 btnPtr = &infoPtr->buttons[nIndex];
2141 if (LOWORD(lParam) == FALSE)
2142 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
2144 btnPtr->fsState |= TBSTATE_INDETERMINATE;
2146 RedrawWindow(hwnd,&btnPtr->rect,NULL,
2147 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
2154 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2156 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2157 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2158 INT nIndex = (INT)wParam;
2159 TBUTTON_INFO *oldButtons;
2165 /* EPP: this seems to be an undocumented call (from my IE4)
2166 * I assume in that case that:
2167 * - lpTbb->iString is a string pointer (not a string index in strings[] table
2168 * - index of insertion is at the end of existing buttons
2169 * I only see this happen with nIndex == -1, but it could have a special
2170 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
2172 int len = lstrlenA((char*)lpTbb->iString) + 2;
2173 LPSTR ptr = COMCTL32_Alloc(len);
2175 nIndex = infoPtr->nNumButtons;
2176 strcpy(ptr, (char*)lpTbb->iString);
2177 ptr[len - 1] = 0; /* ended by two '\0' */
2178 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
2181 } else if (nIndex < 0)
2184 TRACE("inserting button index=%d\n", nIndex);
2185 if (nIndex > infoPtr->nNumButtons) {
2186 nIndex = infoPtr->nNumButtons;
2187 TRACE("adjust index=%d\n", nIndex);
2190 oldButtons = infoPtr->buttons;
2191 infoPtr->nNumButtons++;
2192 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2193 /* pre insert copy */
2195 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2196 nIndex * sizeof(TBUTTON_INFO));
2199 /* insert new button */
2200 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2201 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2202 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2203 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2204 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2205 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2207 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2210 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2211 ti.cbSize = sizeof (TTTOOLINFOA);
2213 ti.uId = lpTbb->idCommand;
2215 ti.lpszText = LPSTR_TEXTCALLBACKA;
2217 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2221 /* post insert copy */
2222 if (nIndex < infoPtr->nNumButtons - 1) {
2223 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2224 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2227 COMCTL32_Free (oldButtons);
2229 TOOLBAR_CalcToolbar (hwnd);
2231 InvalidateRect (hwnd, NULL, FALSE);
2238 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2240 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2241 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2242 INT nIndex = (INT)wParam;
2243 TBUTTON_INFO *oldButtons;
2250 TRACE("inserting button index=%d\n", nIndex);
2251 if (nIndex > infoPtr->nNumButtons) {
2252 nIndex = infoPtr->nNumButtons;
2253 TRACE("adjust index=%d\n", nIndex);
2256 oldButtons = infoPtr->buttons;
2257 infoPtr->nNumButtons++;
2258 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2259 /* pre insert copy */
2261 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2262 nIndex * sizeof(TBUTTON_INFO));
2265 /* insert new button */
2266 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2267 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2268 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2269 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2270 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2271 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2273 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2276 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2277 ti.cbSize = sizeof (TTTOOLINFOW);
2279 ti.uId = lpTbb->idCommand;
2281 ti.lpszText = LPSTR_TEXTCALLBACKW;
2283 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2287 /* post insert copy */
2288 if (nIndex < infoPtr->nNumButtons - 1) {
2289 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2290 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2293 COMCTL32_Free (oldButtons);
2295 TOOLBAR_CalcToolbar (hwnd);
2297 InvalidateRect (hwnd, NULL, FALSE);
2303 /* << TOOLBAR_InsertMarkHitTest >> */
2307 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
2309 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2312 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2316 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
2321 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
2323 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2326 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2330 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
2335 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
2337 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2340 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2344 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
2349 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
2351 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2354 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2358 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
2363 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2365 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2368 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2372 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
2377 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
2379 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2382 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2386 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
2390 /* << TOOLBAR_LoadImages >> */
2391 /* << TOOLBAR_MapAccelerator >> */
2392 /* << TOOLBAR_MarkButton >> */
2393 /* << TOOLBAR_MoveButton >> */
2397 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2399 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2400 TBUTTON_INFO *btnPtr;
2403 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2407 btnPtr = &infoPtr->buttons[nIndex];
2408 if (LOWORD(lParam) == FALSE)
2409 btnPtr->fsState &= ~TBSTATE_PRESSED;
2411 btnPtr->fsState |= TBSTATE_PRESSED;
2413 RedrawWindow(hwnd,&btnPtr->rect,NULL,
2414 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
2420 /* << TOOLBAR_ReplaceBitmap >> */
2424 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2427 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2428 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2430 if (lpSave == NULL) return 0;
2433 /* save toolbar information */
2434 FIXME("save to \"%s\" \"%s\"\n",
2435 lpSave->pszSubKey, lpSave->pszValueName);
2440 /* restore toolbar information */
2442 FIXME("restore from \"%s\" \"%s\"\n",
2443 lpSave->pszSubKey, lpSave->pszValueName);
2454 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2457 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2458 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
2464 /* save toolbar information */
2465 FIXME("save to \"%s\" \"%s\"\n",
2466 lpSave->pszSubKey, lpSave->pszValueName);
2471 /* restore toolbar information */
2473 FIXME("restore from \"%s\" \"%s\"\n",
2474 lpSave->pszSubKey, lpSave->pszValueName);
2485 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
2487 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2488 BOOL bOldAnchor = infoPtr->bAnchor;
2490 infoPtr->bAnchor = (BOOL)wParam;
2492 return (LRESULT)bOldAnchor;
2497 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2499 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2501 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2504 /* Bitmap size can only be set before adding any button to the toolbar
2505 according to the documentation. */
2506 if( infoPtr->nNumButtons != 0 )
2509 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2510 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2517 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2519 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2520 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2521 TBUTTON_INFO *btnPtr;
2526 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2529 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2533 btnPtr = &infoPtr->buttons[nIndex];
2534 if (lptbbi->dwMask & TBIF_COMMAND)
2535 btnPtr->idCommand = lptbbi->idCommand;
2536 if (lptbbi->dwMask & TBIF_IMAGE)
2537 btnPtr->iBitmap = lptbbi->iImage;
2538 if (lptbbi->dwMask & TBIF_LPARAM)
2539 btnPtr->dwData = lptbbi->lParam;
2540 /* if (lptbbi->dwMask & TBIF_SIZE) */
2541 /* btnPtr->cx = lptbbi->cx; */
2542 if (lptbbi->dwMask & TBIF_STATE)
2543 btnPtr->fsState = lptbbi->fsState;
2544 if (lptbbi->dwMask & TBIF_STYLE)
2545 btnPtr->fsStyle = lptbbi->fsStyle;
2547 if (lptbbi->dwMask & TBIF_TEXT) {
2548 if ((btnPtr->iString >= 0) ||
2549 (btnPtr->iString < infoPtr->nNumStrings)) {
2550 TRACE("Ooooooch\n");
2552 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2553 INT len = lstrlenA (lptbbi->pszText);
2554 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2557 /* this is the ultimate sollution */
2558 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2567 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2569 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2570 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
2571 TBUTTON_INFO *btnPtr;
2576 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
2579 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2583 btnPtr = &infoPtr->buttons[nIndex];
2584 if (lptbbi->dwMask & TBIF_COMMAND)
2585 btnPtr->idCommand = lptbbi->idCommand;
2586 if (lptbbi->dwMask & TBIF_IMAGE)
2587 btnPtr->iBitmap = lptbbi->iImage;
2588 if (lptbbi->dwMask & TBIF_LPARAM)
2589 btnPtr->dwData = lptbbi->lParam;
2590 /* if (lptbbi->dwMask & TBIF_SIZE) */
2591 /* btnPtr->cx = lptbbi->cx; */
2592 if (lptbbi->dwMask & TBIF_STATE)
2593 btnPtr->fsState = lptbbi->fsState;
2594 if (lptbbi->dwMask & TBIF_STYLE)
2595 btnPtr->fsStyle = lptbbi->fsStyle;
2597 if (lptbbi->dwMask & TBIF_TEXT) {
2598 if ((btnPtr->iString >= 0) ||
2599 (btnPtr->iString < infoPtr->nNumStrings)) {
2601 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2602 INT len = lstrlenW (lptbbi->pszText);
2603 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2606 /* this is the ultimate sollution */
2607 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2616 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2618 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2620 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2623 /* Button size can only be set before adding any button to the toolbar
2624 according to the documentation. */
2625 if( infoPtr->nNumButtons != 0 )
2628 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2629 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2635 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2637 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2639 if (infoPtr == NULL)
2642 infoPtr->cxMin = (INT)LOWORD(lParam);
2643 infoPtr->cxMax = (INT)HIWORD(lParam);
2650 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2652 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2653 INT nIndex = (INT)wParam;
2655 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2658 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2660 if (infoPtr->hwndToolTip) {
2662 FIXME("change tool tip!\n");
2670 /* << TOOLBAR_SetColorScheme >> */
2674 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2676 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2677 HIMAGELIST himlTemp;
2680 himlTemp = infoPtr->himlDis;
2681 infoPtr->himlDis = (HIMAGELIST)lParam;
2683 /* FIXME: redraw ? */
2685 return (LRESULT)himlTemp;
2690 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2692 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2695 dwTemp = infoPtr->dwDTFlags;
2696 infoPtr->dwDTFlags =
2697 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2699 return (LRESULT)dwTemp;
2704 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2706 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2709 dwTemp = infoPtr->dwExStyle;
2710 infoPtr->dwExStyle = (DWORD)lParam;
2712 return (LRESULT)dwTemp;
2717 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2719 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2720 HIMAGELIST himlTemp;
2722 himlTemp = infoPtr->himlHot;
2723 infoPtr->himlHot = (HIMAGELIST)lParam;
2725 /* FIXME: redraw ? */
2727 return (LRESULT)himlTemp;
2732 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
2734 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2735 INT nOldHotItem = infoPtr->nHotItem;
2737 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
2739 infoPtr->nHotItem = (INT)wParam;
2741 /* FIXME: What else must be done ??? */
2745 if (nOldHotItem < 0)
2748 return (LRESULT)nOldHotItem;
2753 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2755 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2756 HIMAGELIST himlTemp;
2758 himlTemp = infoPtr->himlDef;
2759 infoPtr->himlDef = (HIMAGELIST)lParam;
2761 /* FIXME: redraw ? */
2763 return (LRESULT)himlTemp;
2768 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2770 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2772 infoPtr->nIndent = (INT)wParam;
2774 TOOLBAR_CalcToolbar (hwnd);
2776 InvalidateRect(hwnd, NULL, FALSE);
2782 /* << TOOLBAR_SetInsertMark >> */
2786 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2788 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2790 infoPtr->clrInsertMark = (COLORREF)lParam;
2792 /* FIXME : redraw ??*/
2799 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2801 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2803 if (infoPtr == NULL)
2806 infoPtr->nMaxTextRows = (INT)wParam;
2812 /* << TOOLBAR_SetPadding >> */
2816 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2818 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2821 if (infoPtr == NULL)
2823 hwndOldNotify = infoPtr->hwndNotify;
2824 infoPtr->hwndNotify = (HWND)wParam;
2826 return hwndOldNotify;
2831 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2833 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2834 LPRECT lprc = (LPRECT)lParam;
2836 if (LOWORD(wParam) > 1) {
2838 FIXME("multiple rows not supported!\n");
2842 /* recalculate toolbar */
2843 TOOLBAR_CalcToolbar (hwnd);
2845 /* return bounding rectangle */
2847 lprc->left = infoPtr->rcBound.left;
2848 lprc->right = infoPtr->rcBound.right;
2849 lprc->top = infoPtr->rcBound.top;
2850 lprc->bottom = infoPtr->rcBound.bottom;
2853 /* repaint toolbar */
2854 InvalidateRect(hwnd, NULL, FALSE);
2861 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2863 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2864 TBUTTON_INFO *btnPtr;
2867 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2871 btnPtr = &infoPtr->buttons[nIndex];
2872 btnPtr->fsState = LOWORD(lParam);
2874 RedrawWindow(hwnd,&btnPtr->rect,NULL,
2875 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
2882 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2884 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2885 TBUTTON_INFO *btnPtr;
2888 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2892 btnPtr = &infoPtr->buttons[nIndex];
2893 btnPtr->fsStyle = LOWORD(lParam);
2895 RedrawWindow(hwnd,&btnPtr->rect,NULL,
2896 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
2898 if (infoPtr->hwndToolTip) {
2900 FIXME("change tool tip!\n");
2908 inline static LRESULT
2909 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2911 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2913 if (infoPtr == NULL)
2915 infoPtr->hwndToolTip = (HWND)wParam;
2921 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2923 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2926 TRACE("%s hwnd=0x%04x stub!\n",
2927 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2929 bTemp = infoPtr->bUnicode;
2930 infoPtr->bUnicode = (BOOL)wParam;
2937 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
2939 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2940 INT iOldVersion = infoPtr->iVersion;
2942 infoPtr->iVersion = iVersion;
2949 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2951 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2952 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2955 /* initialize info structure */
2956 infoPtr->nButtonHeight = 22;
2957 infoPtr->nButtonWidth = 24;
2958 infoPtr->nBitmapHeight = 15;
2959 infoPtr->nBitmapWidth = 16;
2961 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2963 infoPtr->nMaxTextRows = 1;
2964 infoPtr->cxMin = -1;
2965 infoPtr->cxMax = -1;
2967 infoPtr->bCaptured = FALSE;
2968 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2969 infoPtr->nButtonDown = -1;
2970 infoPtr->nOldHit = -1;
2971 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2972 infoPtr->hwndNotify = GetParent (hwnd);
2973 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2974 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
2975 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
2976 infoPtr->iVersion = 0;
2978 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2979 infoPtr->hFont = CreateFontIndirectA (&logFont);
2981 if (dwStyle & TBSTYLE_TOOLTIPS) {
2982 /* Create tooltip control */
2983 infoPtr->hwndToolTip =
2984 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2985 CW_USEDEFAULT, CW_USEDEFAULT,
2986 CW_USEDEFAULT, CW_USEDEFAULT,
2989 /* Send NM_TOOLTIPSCREATED notification */
2990 if (infoPtr->hwndToolTip) {
2991 NMTOOLTIPSCREATED nmttc;
2993 nmttc.hdr.hwndFrom = hwnd;
2994 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2995 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2996 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2998 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2999 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
3008 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
3010 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3012 /* delete tooltip control */
3013 if (infoPtr->hwndToolTip)
3014 DestroyWindow (infoPtr->hwndToolTip);
3016 /* delete button data */
3017 if (infoPtr->buttons)
3018 COMCTL32_Free (infoPtr->buttons);
3020 /* delete strings */
3021 if (infoPtr->strings) {
3023 for (i = 0; i < infoPtr->nNumStrings; i++)
3024 if (infoPtr->strings[i])
3025 COMCTL32_Free (infoPtr->strings[i]);
3027 COMCTL32_Free (infoPtr->strings);
3030 /* destroy internal image list */
3031 if (infoPtr->himlInt)
3032 ImageList_Destroy (infoPtr->himlInt);
3034 /* delete default font */
3036 DeleteObject (infoPtr->hFont);
3038 /* free toolbar info data */
3039 COMCTL32_Free (infoPtr);
3040 SetWindowLongA (hwnd, 0, 0);
3047 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
3049 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3051 if (infoPtr->bTransparent)
3052 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
3054 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
3059 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
3061 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3063 return infoPtr->hFont;
3068 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
3070 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3071 TBUTTON_INFO *btnPtr;
3075 pt.x = (INT)LOWORD(lParam);
3076 pt.y = (INT)HIWORD(lParam);
3077 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3080 btnPtr = &infoPtr->buttons[nHit];
3081 if (!(btnPtr->fsState & TBSTATE_ENABLED))
3084 infoPtr->bCaptured = TRUE;
3085 infoPtr->nButtonDown = nHit;
3087 btnPtr->fsState |= TBSTATE_PRESSED;
3089 RedrawWindow(hwnd,&btnPtr->rect,NULL,
3090 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3092 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
3093 TOOLBAR_Customize (hwnd);
3100 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
3102 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3103 TBUTTON_INFO *btnPtr;
3107 if (infoPtr->hwndToolTip)
3108 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3109 WM_LBUTTONDOWN, wParam, lParam);
3111 pt.x = (INT)LOWORD(lParam);
3112 pt.y = (INT)HIWORD(lParam);
3113 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3116 btnPtr = &infoPtr->buttons[nHit];
3117 if (!(btnPtr->fsState & TBSTATE_ENABLED))
3120 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
3124 nmtb.hdr.hwndFrom = hwnd;
3125 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3126 nmtb.hdr.code = TBN_DROPDOWN;
3127 nmtb.iItem = btnPtr->idCommand;
3129 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
3130 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3134 infoPtr->bCaptured = TRUE;
3135 infoPtr->nButtonDown = nHit;
3136 infoPtr->nOldHit = nHit;
3138 btnPtr->fsState |= TBSTATE_PRESSED;
3139 btnPtr->bHot = FALSE;
3141 RedrawWindow(hwnd,&btnPtr->rect,NULL,
3142 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3149 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
3151 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3152 TBUTTON_INFO *btnPtr;
3156 BOOL bSendMessage = TRUE;
3158 if (infoPtr->hwndToolTip)
3159 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3160 WM_LBUTTONUP, wParam, lParam);
3162 pt.x = (INT)LOWORD(lParam);
3163 pt.y = (INT)HIWORD(lParam);
3164 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3166 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
3167 if(infoPtr->nHotItem >= 0)
3168 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
3170 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
3171 infoPtr->bCaptured = FALSE;
3173 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3174 btnPtr->fsState &= ~TBSTATE_PRESSED;
3176 if (nHit == infoPtr->nButtonDown) {
3177 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
3178 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
3179 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
3180 infoPtr->nButtonDown);
3181 if (nOldIndex == infoPtr->nButtonDown)
3182 bSendMessage = FALSE;
3183 if ((nOldIndex != infoPtr->nButtonDown) &&
3185 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
3186 btnPtr->fsState |= TBSTATE_CHECKED;
3189 if (btnPtr->fsState & TBSTATE_CHECKED)
3190 btnPtr->fsState &= ~TBSTATE_CHECKED;
3192 btnPtr->fsState |= TBSTATE_CHECKED;
3197 bSendMessage = FALSE;
3199 if (nOldIndex != -1)
3200 RedrawWindow(hwnd,&infoPtr->buttons[nOldIndex].rect,NULL,
3201 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3202 RedrawWindow(hwnd,&btnPtr->rect,NULL,
3203 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3206 SendMessageA (GetParent(hwnd), WM_COMMAND,
3207 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
3209 // if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) ||
3210 // (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) {
3212 * This appears to be an error. Instead of checking the style of the
3213 * button in question wine was checking the style of the toolbar
3214 * itself. This caused a number of strange behaviors. In my
3215 * invistigation i think the whole dropdown thing is still fairly
3216 * broken. but this helps fix some of the problems.
3219 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
3222 nmtb.hdr.hwndFrom = hwnd;
3223 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3224 nmtb.hdr.code = TBN_DROPDOWN;
3226 /* nmtb.tbButton not used with TBN_DROPDOWN */
3227 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) {
3228 nmtb.pszText = infoPtr->strings[btnPtr->iString];
3229 nmtb.cchText = lstrlenW(nmtb.pszText);
3231 nmtb.pszText = NULL;
3234 nmtb.rcButton = btnPtr->rect;
3236 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
3237 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3240 infoPtr->nButtonDown = -1;
3241 infoPtr->nOldHit = -1;
3248 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
3250 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3251 TBUTTON_INFO *hotBtnPtr;
3253 if (infoPtr->nOldHit < 0)
3256 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
3258 /* Redraw the button if the last button we were over is the hot button and it
3260 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
3262 hotBtnPtr->bHot = FALSE;
3264 InvalidateRect (hwnd, &hotBtnPtr->rect, TRUE);
3267 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
3268 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
3274 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
3276 TBUTTON_INFO *btnPtr, *oldBtnPtr;
3277 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3280 TRACKMOUSEEVENT trackinfo;
3282 /* fill in the TRACKMOUSEEVENT struct */
3283 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
3284 trackinfo.dwFlags = TME_QUERY;
3285 trackinfo.hwndTrack = hwnd;
3286 trackinfo.dwHoverTime = HOVER_DEFAULT;
3288 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3289 _TrackMouseEvent(&trackinfo);
3291 /* Make sure tracking is enabled so we recieve a WM_MOUSELEAVE message */
3292 if(!(trackinfo.dwFlags & TME_LEAVE)) {
3293 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
3295 /* call TRACKMOUSEEVENT so we recieve a WM_MOUSELEAVE message */
3296 /* and can properly deactivate the hot toolbar button */
3297 _TrackMouseEvent(&trackinfo);
3300 if (infoPtr->hwndToolTip)
3301 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3302 WM_MOUSEMOVE, wParam, lParam);
3304 pt.x = (INT)LOWORD(lParam);
3305 pt.y = (INT)HIWORD(lParam);
3307 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3309 if (infoPtr->nOldHit != nHit)
3311 /* Remove the effect of an old hot button if the button was enabled and was
3312 drawn with the hot button effect */
3313 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
3314 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
3316 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
3317 oldBtnPtr->bHot = FALSE;
3319 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
3322 /* It's not a separator or in nowhere. It's a hot button. */
3325 btnPtr = &infoPtr->buttons[nHit];
3326 btnPtr->bHot = TRUE;
3328 infoPtr->nHotItem = nHit;
3330 /* only enabled buttons show hot effect */
3331 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
3333 RedrawWindow(hwnd,&btnPtr->rect,NULL,
3334 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3338 if (infoPtr->bCaptured) {
3339 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3340 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
3341 btnPtr->fsState &= ~TBSTATE_PRESSED;
3342 RedrawWindow(hwnd,&btnPtr->rect,NULL,
3343 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3345 else if (nHit == infoPtr->nButtonDown) {
3346 btnPtr->fsState |= TBSTATE_PRESSED;
3347 RedrawWindow(hwnd,&btnPtr->rect,NULL,
3348 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
3351 infoPtr->nOldHit = nHit;
3357 inline static LRESULT
3358 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3360 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
3361 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
3363 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
3367 inline static LRESULT
3368 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3370 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
3371 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
3373 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
3378 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3380 TOOLBAR_INFO *infoPtr;
3382 /* allocate memory for info structure */
3383 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
3384 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3387 infoPtr->dwStructSize = sizeof(TBBUTTON);
3389 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
3390 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
3391 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
3392 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
3395 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
3400 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
3402 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3406 if (dwStyle & WS_MINIMIZE)
3407 return 0; /* Nothing to do */
3409 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
3411 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
3414 if (!(dwStyle & CCS_NODIVIDER))
3416 GetWindowRect (hwnd, &rcWindow);
3417 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3418 if( dwStyle & WS_BORDER )
3419 OffsetRect (&rcWindow, 1, 1);
3420 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
3423 ReleaseDC( hwnd, hdc );
3429 inline static LRESULT
3430 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
3432 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3433 LPNMHDR lpnmh = (LPNMHDR)lParam;
3435 TRACE("passing WM_NOTIFY!\n");
3437 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
3438 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
3441 if (lpnmh->code == TTN_GETDISPINFOA) {
3442 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
3444 FIXME("retrieving ASCII string\n");
3447 else if (lpnmh->code == TTN_GETDISPINFOW) {
3448 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
3450 FIXME("retrieving UNICODE string\n");
3461 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
3463 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3467 /* fill ps.rcPaint with a default rect */
3468 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
3470 TOOLBAR_CalcToolbar( hwnd );
3471 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
3472 TOOLBAR_Refresh (hwnd, hdc, &ps);
3473 if (!wParam) EndPaint (hwnd, &ps);
3480 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
3482 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3483 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3492 /* Resize deadlock check */
3493 if (infoPtr->bAutoSize) {
3494 infoPtr->bAutoSize = FALSE;
3498 flags = (INT) wParam;
3500 /* FIXME for flags =
3501 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
3504 TRACE("sizing toolbar!\n");
3506 if (flags == SIZE_RESTORED) {
3507 /* width and height don't apply */
3508 parent = GetParent (hwnd);
3509 GetClientRect(parent, &parent_rect);
3510 x = parent_rect.left;
3511 y = parent_rect.top;
3513 if (dwStyle & CCS_NORESIZE) {
3514 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
3517 * this sets the working width of the toolbar, and
3518 * Calc Toolbar will not adjust it, only the height
3520 infoPtr->nWidth = parent_rect.right - parent_rect.left;
3521 cy = infoPtr->nHeight;
3522 cx = infoPtr->nWidth;
3523 TOOLBAR_CalcToolbar (hwnd);
3524 infoPtr->nWidth = cx;
3525 infoPtr->nHeight = cy;
3528 infoPtr->nWidth = parent_rect.right - parent_rect.left;
3529 TOOLBAR_CalcToolbar (hwnd);
3530 cy = infoPtr->nHeight;
3531 cx = infoPtr->nWidth;
3533 if (dwStyle & CCS_NOMOVEY) {
3534 GetWindowRect(hwnd, &window_rect);
3535 ScreenToClient(parent, (LPPOINT)&window_rect.left);
3536 y = window_rect.top;
3540 if (dwStyle & CCS_NOPARENTALIGN) {
3541 uPosFlags |= SWP_NOMOVE;
3542 cy = infoPtr->nHeight;
3543 cx = infoPtr->nWidth;
3546 if (!(dwStyle & CCS_NODIVIDER))
3547 cy += GetSystemMetrics(SM_CYEDGE);
3549 if (dwStyle & WS_BORDER)
3552 cy += GetSystemMetrics(SM_CYEDGE);
3553 cx += GetSystemMetrics(SM_CYEDGE);
3556 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
3557 cx, cy, uPosFlags | SWP_NOZORDER);
3564 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
3566 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3568 if (nType == GWL_STYLE) {
3569 if (lpStyle->styleNew & TBSTYLE_LIST) {
3570 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
3573 infoPtr->dwDTFlags = DT_CENTER;
3577 TOOLBAR_AutoSize (hwnd);
3579 InvalidateRect(hwnd, NULL, FALSE);
3586 static LRESULT WINAPI
3587 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3593 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3596 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3599 if (!TOOLBAR_GetInfoPtr (hwnd))
3601 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3607 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
3609 case TB_ADDBUTTONSA:
3610 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
3612 case TB_ADDBUTTONSW:
3613 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
3616 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
3619 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
3622 return TOOLBAR_AutoSize (hwnd);
3624 case TB_BUTTONCOUNT:
3625 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
3627 case TB_BUTTONSTRUCTSIZE:
3628 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
3630 case TB_CHANGEBITMAP:
3631 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
3633 case TB_CHECKBUTTON:
3634 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
3636 case TB_COMMANDTOINDEX:
3637 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
3640 return TOOLBAR_Customize (hwnd);
3642 case TB_DELETEBUTTON:
3643 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
3645 case TB_ENABLEBUTTON:
3646 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
3648 case TB_GETANCHORHIGHLIGHT:
3649 return TOOLBAR_GetAnchorHighlight (hwnd);
3652 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
3654 case TB_GETBITMAPFLAGS:
3655 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
3658 return TOOLBAR_GetButton (hwnd, wParam, lParam);
3660 case TB_GETBUTTONINFOA:
3661 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
3663 case TB_GETBUTTONINFOW:
3664 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
3666 case TB_GETBUTTONSIZE:
3667 return TOOLBAR_GetButtonSize (hwnd);
3669 case TB_GETBUTTONTEXTA:
3670 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3672 case TB_GETBUTTONTEXTW:
3673 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
3675 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
3677 case TB_GETDISABLEDIMAGELIST:
3678 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3680 case TB_GETEXTENDEDSTYLE:
3681 return TOOLBAR_GetExtendedStyle (hwnd);
3683 case TB_GETHOTIMAGELIST:
3684 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3687 return TOOLBAR_GetHotItem (hwnd);
3689 case TB_GETIMAGELIST:
3690 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3692 /* case TB_GETINSERTMARK: */ /* 4.71 */
3693 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3695 case TB_GETITEMRECT:
3696 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3699 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3701 /* case TB_GETOBJECT: */ /* 4.71 */
3702 /* case TB_GETPADDING: */ /* 4.71 */
3705 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3708 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3711 return TOOLBAR_GetState (hwnd, wParam, lParam);
3714 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3716 case TB_GETTEXTROWS:
3717 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3719 case TB_GETTOOLTIPS:
3720 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3722 case TB_GETUNICODEFORMAT:
3723 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3725 case CCM_GETVERSION:
3726 return TOOLBAR_GetVersion (hwnd);
3729 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3732 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3734 case TB_INDETERMINATE:
3735 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3737 case TB_INSERTBUTTONA:
3738 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3740 case TB_INSERTBUTTONW:
3741 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
3743 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3745 case TB_ISBUTTONCHECKED:
3746 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3748 case TB_ISBUTTONENABLED:
3749 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3751 case TB_ISBUTTONHIDDEN:
3752 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3754 case TB_ISBUTTONHIGHLIGHTED:
3755 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3757 case TB_ISBUTTONINDETERMINATE:
3758 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3760 case TB_ISBUTTONPRESSED:
3761 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3763 case TB_LOADIMAGES: /* 4.70 */
3764 FIXME("missing standard imagelists\n");
3767 /* case TB_MAPACCELERATORA: */ /* 4.71 */
3768 /* case TB_MAPACCELERATORW: */ /* 4.71 */
3769 /* case TB_MARKBUTTON: */ /* 4.71 */
3770 /* case TB_MOVEBUTTON: */ /* 4.71 */
3772 case TB_PRESSBUTTON:
3773 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3775 /* case TB_REPLACEBITMAP: */
3777 case TB_SAVERESTOREA:
3778 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3780 case TB_SAVERESTOREW:
3781 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
3783 case TB_SETANCHORHIGHLIGHT:
3784 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
3786 case TB_SETBITMAPSIZE:
3787 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3789 case TB_SETBUTTONINFOA:
3790 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3792 case TB_SETBUTTONINFOW:
3793 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
3795 case TB_SETBUTTONSIZE:
3796 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3798 case TB_SETBUTTONWIDTH:
3799 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3802 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3804 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
3806 case TB_SETDISABLEDIMAGELIST:
3807 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3809 case TB_SETDRAWTEXTFLAGS:
3810 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3812 case TB_SETEXTENDEDSTYLE:
3813 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3815 case TB_SETHOTIMAGELIST:
3816 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3819 return TOOLBAR_SetHotItem (hwnd, wParam);
3821 case TB_SETIMAGELIST:
3822 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3825 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3827 /* case TB_SETINSERTMARK: */ /* 4.71 */
3829 case TB_SETINSERTMARKCOLOR:
3830 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3832 case TB_SETMAXTEXTROWS:
3833 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3835 /* case TB_SETPADDING: */ /* 4.71 */
3838 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3841 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3844 return TOOLBAR_SetState (hwnd, wParam, lParam);
3847 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3849 case TB_SETTOOLTIPS:
3850 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3852 case TB_SETUNICODEFORMAT:
3853 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3855 case CCM_SETVERSION:
3856 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
3862 return TOOLBAR_Create (hwnd, wParam, lParam);
3865 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3868 return TOOLBAR_GetFont (hwnd, wParam, lParam);
3870 /* case WM_KEYDOWN: */
3871 /* case WM_KILLFOCUS: */
3873 case WM_LBUTTONDBLCLK:
3874 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3876 case WM_LBUTTONDOWN:
3877 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3880 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3883 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3886 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
3889 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3892 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3895 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3898 return TOOLBAR_Notify (hwnd, wParam, lParam);
3900 /* case WM_NOTIFYFORMAT: */
3903 return TOOLBAR_Paint (hwnd, wParam);
3906 return TOOLBAR_Size (hwnd, wParam, lParam);
3908 case WM_STYLECHANGED:
3909 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
3911 /* case WM_SYSCOLORCHANGE: */
3913 /* case WM_WININICHANGE: */
3918 case WM_MEASUREITEM:
3920 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3923 if (uMsg >= WM_USER)
3924 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
3925 uMsg, wParam, lParam);
3926 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3933 TOOLBAR_Register (void)
3937 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3938 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3939 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3940 wndClass.cbClsExtra = 0;
3941 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3942 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3943 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3944 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3946 RegisterClassA (&wndClass);
3951 TOOLBAR_Unregister (void)
3953 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);