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);
66 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
67 HDC hdc, INT nState, DWORD dwStyle)
69 RECT rcText = btnPtr->rect;
75 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
76 InflateRect (&rcText, -3, -3);
77 if (dwStyle & TBSTYLE_LIST) {
78 rcText.left += infoPtr->nBitmapWidth;
81 rcText.top += infoPtr->nBitmapHeight;
83 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
84 OffsetRect (&rcText, 1, 1);
86 hOldFont = SelectObject (hdc, infoPtr->hFont);
87 nOldBkMode = SetBkMode (hdc, TRANSPARENT);
88 if (!(nState & TBSTATE_ENABLED)) {
89 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
90 OffsetRect (&rcText, 1, 1);
91 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
92 &rcText, infoPtr->dwDTFlags);
93 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
94 OffsetRect (&rcText, -1, -1);
95 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
96 &rcText, infoPtr->dwDTFlags);
98 else if (nState & TBSTATE_INDETERMINATE) {
99 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
100 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
101 &rcText, infoPtr->dwDTFlags);
104 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
105 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
106 &rcText, infoPtr->dwDTFlags);
109 SetTextColor (hdc, clrOld);
110 SelectObject (hdc, hOldFont);
111 if (nOldBkMode != TRANSPARENT)
112 SetBkMode (hdc, nOldBkMode);
118 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
120 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
121 INT cx = lpRect->right - lpRect->left;
122 INT cy = lpRect->bottom - lpRect->top;
123 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
124 SelectObject (hdc, hbr);
129 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
130 HDC hdc, INT x, INT y)
132 /* FIXME: this function is a hack since it uses image list
133 internals directly */
135 HIMAGELIST himl = infoPtr->himlDef;
143 /* create new dc's */
144 hdcImageList = CreateCompatibleDC (0);
145 hdcMask = CreateCompatibleDC (0);
147 /* create new bitmap */
148 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
149 SelectObject (hdcMask, hbmMask);
151 /* copy the mask bitmap */
152 SelectObject (hdcImageList, himl->hbmMask);
153 SetBkColor (hdcImageList, RGB(255, 255, 255));
154 SetTextColor (hdcImageList, RGB(0, 0, 0));
155 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
156 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
159 /* add white mask from image */
160 SelectObject (hdcImageList, himl->hbmImage);
161 SetBkColor (hdcImageList, RGB(0, 0, 0));
162 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
163 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
166 /* draw the new mask */
167 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
168 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
169 hdcMask, 0, 0, 0xB8074A);
171 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
172 BitBlt (hdc, x, y, himl->cx, himl->cy,
173 hdcMask, 0, 0, 0xB8074A);
175 DeleteObject (hbmMask);
177 DeleteDC (hdcImageList);
182 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
184 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
185 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
188 if (btnPtr->fsState & TBSTATE_HIDDEN)
194 if (btnPtr->fsStyle & TBSTYLE_SEP) {
195 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0))
196 TOOLBAR_DrawFlatSeparator (&rc, hdc);
201 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
202 if (!(dwStyle & TBSTYLE_FLAT))
203 DrawEdge (hdc, &rc, EDGE_RAISED,
204 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
206 if (infoPtr->himlDis)
207 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
208 rc.left+1, rc.top+1, ILD_NORMAL);
210 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
212 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
216 /* pressed TBSTYLE_BUTTON */
217 if (btnPtr->fsState & TBSTATE_PRESSED) {
218 if (dwStyle & TBSTYLE_FLAT)
219 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_MIDDLE | BF_ADJUST);
221 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
222 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
223 rc.left+2, rc.top+2, ILD_NORMAL);
224 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
228 /* checked TBSTYLE_CHECK */
229 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
230 (btnPtr->fsState & TBSTATE_CHECKED)) {
231 if (dwStyle & TBSTYLE_FLAT)
232 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
233 BF_RECT | BF_MIDDLE | BF_ADJUST);
235 DrawEdge (hdc, &rc, EDGE_SUNKEN,
236 BF_RECT | BF_MIDDLE | BF_ADJUST);
238 TOOLBAR_DrawPattern (hdc, &rc);
240 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
241 rc.left+2, rc.top+2, ILD_NORMAL);
243 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
248 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
249 DrawEdge (hdc, &rc, EDGE_RAISED,
250 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
252 TOOLBAR_DrawPattern (hdc, &rc);
253 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
254 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
259 if (dwStyle & TBSTYLE_FLAT)
262 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
263 if (btnPtr->bHot && infoPtr->himlHot)
264 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
265 rc.left +2, rc.top +2, ILD_NORMAL);
267 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
268 rc.left +2, rc.top +2, ILD_NORMAL);
272 DrawEdge (hdc, &rc, EDGE_RAISED,
273 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
275 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
276 rc.left+1, rc.top+1, ILD_NORMAL);
279 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
284 TOOLBAR_Refresh (HWND hwnd, HDC hdc)
286 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
287 TBUTTON_INFO *btnPtr;
291 btnPtr = infoPtr->buttons;
292 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
293 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
298 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
300 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
301 TBUTTON_INFO *btnPtr;
310 hOldFont = SelectObject (hdc, infoPtr->hFont);
312 btnPtr = infoPtr->buttons;
313 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
314 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
315 (btnPtr->iString > -1) &&
316 (btnPtr->iString < infoPtr->nNumStrings)) {
317 LPWSTR lpText = infoPtr->strings[btnPtr->iString];
318 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
319 if (sz.cx > lpSize->cx)
321 if (sz.cy > lpSize->cy)
326 SelectObject (hdc, hOldFont);
329 TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy);
332 /***********************************************************************
333 * TOOLBAR_WrapToolbar
335 * This function walks through the buttons and seperators in the
336 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
337 * wrapping should occur based on the width of the toolbar window.
338 * It does *not* calculate button placement itself. That task
339 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
340 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
341 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
345 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
347 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
348 TBUTTON_INFO *btnPtr;
351 BOOL bWrap, bButtonWrap;
353 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
354 /* no layout is necessary. Applications may use this style */
355 /* to perform their own layout on the toolbar. */
356 if( !(dwStyle & TBSTYLE_WRAPABLE) )
359 btnPtr = infoPtr->buttons;
360 x = infoPtr->nIndent;
362 GetClientRect( GetParent(hwnd), &rc );
363 infoPtr->nWidth = rc.right - rc.left;
366 for (i = 0; i < infoPtr->nNumButtons; i++ )
369 btnPtr[i].fsState &= ~TBSTATE_WRAP;
371 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
374 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
375 /* it is the actual width of the separator. This is used for */
376 /* custom controls in toolbars. */
377 if (btnPtr[i].fsStyle & TBSTYLE_SEP)
378 cx = (btnPtr[i].iBitmap > 0) ?
379 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
381 cx = infoPtr->nButtonWidth;
383 /* Two or more adjacent separators form a separator group. */
384 /* The first separator in a group should be wrapped to the */
385 /* next row if the previous wrapping is on a button. */
387 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
388 (i + 1 < infoPtr->nNumButtons ) &&
389 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
391 btnPtr[i].fsState |= TBSTATE_WRAP;
392 x = infoPtr->nIndent;
398 /* The layout makes sure the bitmap is visible, but not the button. */
399 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
404 /* If the current button is a separator and not hidden, */
405 /* go to the next until it reaches a non separator. */
406 /* Wrap the last separator if it is before a button. */
407 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
408 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
409 i < infoPtr->nNumButtons )
415 if( bFound && i < infoPtr->nNumButtons )
418 btnPtr[i].fsState |= TBSTATE_WRAP;
419 x = infoPtr->nIndent;
423 else if ( i >= infoPtr->nNumButtons)
426 /* If the current button is not a separator, find the last */
427 /* separator and wrap it. */
428 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
430 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
431 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
435 x = infoPtr->nIndent;
436 btnPtr[j].fsState |= TBSTATE_WRAP;
442 /* If no separator available for wrapping, wrap one of */
443 /* non-hidden previous button. */
447 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
449 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
454 x = infoPtr->nIndent;
455 btnPtr[j].fsState |= TBSTATE_WRAP;
461 /* If all above failed, wrap the current button. */
464 btnPtr[i].fsState |= TBSTATE_WRAP;
466 x = infoPtr->nIndent;
467 if (btnPtr[i].fsState & TBSTYLE_SEP )
478 /***********************************************************************
479 * TOOLBAR_CalcToolbar
481 * This function calculates button and separator placement. It first
482 * calculates the button sizes, gets the toolbar window width and then
483 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
484 * on. It assigns a new location to each item and sends this location to
485 * the tooltip window if appropriate. Finally, it updates the rcBound
486 * rect and calculates the new required toolbar window height.
490 TOOLBAR_CalcToolbar (HWND hwnd)
492 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
493 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
494 TBUTTON_INFO *btnPtr;
495 INT i, nRows, nSepRows;
501 TOOLBAR_CalcStrings (hwnd, &sizeString);
503 if (dwStyle & TBSTYLE_LIST) {
504 infoPtr->nButtonHeight = max(infoPtr->nBitmapHeight, sizeString.cy) + 6;
505 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + sizeString.cx + 6;
508 if (sizeString.cy > 0)
509 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
510 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
511 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
513 if (sizeString.cx > infoPtr->nBitmapWidth)
514 infoPtr->nButtonWidth = sizeString.cx + 6;
515 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
516 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
519 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
520 infoPtr->nButtonWidth = infoPtr->cxMin;
521 if ( infoPtr->cxMax >= 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
522 infoPtr->nButtonWidth = infoPtr->cxMax;
524 TOOLBAR_WrapToolbar( hwnd, dwStyle );
526 x = infoPtr->nIndent;
527 y = (dwStyle & TBSTYLE_FLAT) ? 0 : TOP_BORDER;
528 cx = infoPtr->nButtonWidth;
529 cy = infoPtr->nButtonHeight;
530 nRows = nSepRows = 0;
532 infoPtr->rcBound.top = y;
533 infoPtr->rcBound.left = x;
534 infoPtr->rcBound.bottom = y + cy;
535 infoPtr->rcBound.right = x;
537 btnPtr = infoPtr->buttons;
538 GetClientRect( GetParent(hwnd), &rc );
539 infoPtr->nWidth = rc.right - rc.left;
541 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
544 if (btnPtr->fsState & TBSTATE_HIDDEN)
546 SetRectEmpty (&btnPtr->rect);
550 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
551 /* it is the actual width of the separator. This is used for */
552 /* custom controls in toolbars. */
553 if (btnPtr->fsStyle & TBSTYLE_SEP)
554 cx = (btnPtr->iBitmap > 0) ?
555 btnPtr->iBitmap : SEPARATOR_WIDTH;
557 cx = infoPtr->nButtonWidth;
559 if (btnPtr->fsState & TBSTATE_WRAP )
562 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
564 if (infoPtr->rcBound.left > x)
565 infoPtr->rcBound.left = x;
566 if (infoPtr->rcBound.right < x + cx)
567 infoPtr->rcBound.right = x + cx;
568 if (infoPtr->rcBound.bottom < y + cy)
569 infoPtr->rcBound.bottom = y + cy;
571 /* Set the toolTip only for non-hidden, non-separator button */
572 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
576 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
577 ti.cbSize = sizeof(TTTOOLINFOA);
579 ti.uId = btnPtr->idCommand;
580 ti.rect = btnPtr->rect;
581 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
585 /* btnPtr->nRow is zero based. The space between the rows is */
586 /* also considered as a row. */
587 btnPtr->nRow = nRows + nSepRows;
590 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
594 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
595 /* it is the actual width of the separator. This is used for */
596 /* custom controls in toolbars. */
597 y += cy + ( (btnPtr->iBitmap > 0 ) ?
598 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
600 /* nSepRows is used to calculate the extra height follwoing */
604 x = infoPtr->nIndent;
611 /* infoPtr->nRows is the number of rows on the toolbar */
612 infoPtr->nRows = nRows + nSepRows + 1;
614 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
616 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
617 nSepRows * SEPARATOR_WIDTH * 2 / 3 +
618 nSepRows * (infoPtr->nBitmapHeight + 1) +
620 TRACE("toolbar height %d\n", infoPtr->nHeight);
625 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
627 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
628 TBUTTON_INFO *btnPtr;
631 btnPtr = infoPtr->buttons;
632 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
633 if (btnPtr->fsState & TBSTATE_HIDDEN)
636 if (btnPtr->fsStyle & TBSTYLE_SEP) {
637 if (PtInRect (&btnPtr->rect, *lpPt)) {
638 TRACE(" ON SEPARATOR %d!\n", i);
643 if (PtInRect (&btnPtr->rect, *lpPt)) {
644 TRACE(" ON BUTTON %d!\n", i);
650 TRACE(" NOWHERE!\n");
656 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
658 TBUTTON_INFO *btnPtr;
661 btnPtr = infoPtr->buttons;
662 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
663 if (btnPtr->idCommand == idCommand) {
664 TRACE("command=%d index=%d\n", idCommand, i);
668 TRACE("no index found for command=%d\n", idCommand);
674 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
676 TBUTTON_INFO *btnPtr;
679 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
682 /* check index button */
683 btnPtr = &infoPtr->buttons[nIndex];
684 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
685 if (btnPtr->fsState & TBSTATE_CHECKED)
689 /* check previous buttons */
690 nRunIndex = nIndex - 1;
691 while (nRunIndex >= 0) {
692 btnPtr = &infoPtr->buttons[nRunIndex];
693 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
694 if (btnPtr->fsState & TBSTATE_CHECKED)
702 /* check next buttons */
703 nRunIndex = nIndex + 1;
704 while (nRunIndex < infoPtr->nNumButtons) {
705 btnPtr = &infoPtr->buttons[nRunIndex];
706 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
707 if (btnPtr->fsState & TBSTATE_CHECKED)
720 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
721 WPARAM wParam, LPARAM lParam)
729 msg.time = GetMessageTime ();
730 msg.pt.x = LOWORD(GetMessagePos ());
731 msg.pt.y = HIWORD(GetMessagePos ());
733 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
737 /***********************************************************************
738 * TOOLBAR_CustomizeDialogProc
739 * This function implements the toolbar customization dialog.
742 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
744 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
745 static HDSA hDsa = NULL;
750 infoPtr = (TOOLBAR_INFO *)lParam;
751 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
753 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
757 TBUTTON_INFO *btnPtr;
760 /* insert 'virtual' separator button into 'available buttons' list */
761 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
763 /* copy all buttons and append them to the right listbox */
764 btnPtr = infoPtr->buttons;
765 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
767 DSA_InsertItem (hDsa, i, btnPtr);
769 /* FIXME: hidden buttons appear in the 'toolbar buttons' list too */
770 if (btnPtr->fsState & TBSTATE_HIDDEN)
772 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
776 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
780 /* append 'virtual' separator button to the 'toolbar buttons' list */
786 EndDialog(hwnd, FALSE);
790 switch (LOWORD(wParam))
793 EndDialog(hwnd, FALSE);
804 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
806 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
812 COLORREF oldText = 0;
815 FIXME("action: %x itemState: %x\n",
816 lpdis->itemAction, lpdis->itemState);
818 DSA_GetItem (hDsa, 0 /*lpdis->itemID*/, &btnPtr);
820 if (lpdis->itemState & ODS_FOCUS)
822 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
823 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
826 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
827 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
829 /* fill background rectangle */
830 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
831 lpdis->rcItem.right, lpdis->rcItem.bottom);
833 /* calculate button and text rectangles */
834 CopyRect (&rcButton, &lpdis->rcItem);
835 InflateRect (&rcButton, -1, -1);
836 CopyRect (&rcText, &rcButton);
837 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
838 rcText.left = rcButton.right + 2;
840 /* draw focus rectangle */
841 if (lpdis->itemState & ODS_FOCUS)
842 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
845 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
847 /* draw image and text */
848 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
850 /* virtual separator in the 'available' list */
851 DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
852 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
858 ImageList_Draw (infoPtr->himlDef, btnPtr.iBitmap, lpdis->hDC,
859 rcButton.left+1, rcButton.top+1, ILD_NORMAL);
861 DrawTextW (lpdis->hDC, infoPtr->strings[btnPtr.iString], -1, &rcText,
862 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
866 if (lpdis->itemState & ODS_FOCUS)
868 SetBkColor (lpdis->hDC, oldBk);
869 SetTextColor (lpdis->hDC, oldText);
872 SelectObject (lpdis->hDC, hOldBrush);
873 SelectObject (lpdis->hDC, hOldPen);
880 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
882 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
885 lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
887 lpmis->itemHeight = 15 + 8; /* default height */
899 /***********************************************************************
900 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
904 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
906 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
907 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
908 INT nIndex = 0, nButtons;
914 if (lpAddBmp->hInst == HINST_COMMCTRL)
916 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
918 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
920 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
925 TRACE ("adding %d internal bitmaps!\n", nButtons);
927 /* Windows resize all the buttons to the size of a newly added standard image */
928 if (lpAddBmp->nID & 1)
931 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
932 MAKELPARAM((WORD)26, (WORD)26));
933 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
934 MAKELPARAM((WORD)33, (WORD)33));
939 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
940 MAKELPARAM((WORD)16, (WORD)16));
941 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
942 MAKELPARAM((WORD)22, (WORD)22));
945 TOOLBAR_CalcToolbar (hwnd);
949 nButtons = (INT)wParam;
953 TRACE ("adding %d bitmaps!\n", nButtons);
956 if (!(infoPtr->himlDef)) {
957 /* create new default image list */
958 TRACE ("creating default image list!\n");
961 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
962 ILC_COLOR | ILC_MASK, nButtons, 2);
963 infoPtr->himlInt = infoPtr->himlDef;
966 /* Add bitmaps to the default image list */
967 if (lpAddBmp->hInst == (HINSTANCE)0)
970 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
973 else if (lpAddBmp->hInst == HINST_COMMCTRL)
975 /* Add system bitmaps */
976 switch (lpAddBmp->nID)
978 case IDB_STD_SMALL_COLOR:
979 hbmLoad = LoadBitmapA (COMCTL32_hModule,
980 MAKEINTRESOURCEA(IDB_STD_SMALL));
981 nIndex = ImageList_AddMasked (infoPtr->himlDef,
982 hbmLoad, CLR_DEFAULT);
983 DeleteObject (hbmLoad);
986 case IDB_STD_LARGE_COLOR:
987 hbmLoad = LoadBitmapA (COMCTL32_hModule,
988 MAKEINTRESOURCEA(IDB_STD_LARGE));
989 nIndex = ImageList_AddMasked (infoPtr->himlDef,
990 hbmLoad, CLR_DEFAULT);
991 DeleteObject (hbmLoad);
994 case IDB_VIEW_SMALL_COLOR:
995 hbmLoad = LoadBitmapA (COMCTL32_hModule,
996 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
997 nIndex = ImageList_AddMasked (infoPtr->himlDef,
998 hbmLoad, CLR_DEFAULT);
999 DeleteObject (hbmLoad);
1002 case IDB_VIEW_LARGE_COLOR:
1003 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1004 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
1005 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1006 hbmLoad, CLR_DEFAULT);
1007 DeleteObject (hbmLoad);
1010 case IDB_HIST_SMALL_COLOR:
1011 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1012 MAKEINTRESOURCEA(IDB_HIST_SMALL));
1013 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1014 hbmLoad, CLR_DEFAULT);
1015 DeleteObject (hbmLoad);
1018 case IDB_HIST_LARGE_COLOR:
1019 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1020 MAKEINTRESOURCEA(IDB_HIST_LARGE));
1021 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1022 hbmLoad, CLR_DEFAULT);
1023 DeleteObject (hbmLoad);
1027 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
1028 ERR ("invalid imagelist!\n");
1034 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
1035 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
1036 DeleteObject (hbmLoad);
1039 infoPtr->nNumBitmaps += nButtons;
1046 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1048 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1049 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1050 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1052 TRACE("adding %d buttons!\n", wParam);
1054 nAddButtons = (UINT)wParam;
1055 nOldButtons = infoPtr->nNumButtons;
1056 nNewButtons = nOldButtons + nAddButtons;
1058 if (infoPtr->nNumButtons == 0) {
1060 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1063 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1065 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1066 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1067 nOldButtons * sizeof(TBUTTON_INFO));
1068 COMCTL32_Free (oldButtons);
1071 infoPtr->nNumButtons = nNewButtons;
1073 /* insert new button data */
1074 for (nCount = 0; nCount < nAddButtons; nCount++) {
1075 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1076 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1077 btnPtr->idCommand = lpTbb[nCount].idCommand;
1078 btnPtr->fsState = lpTbb[nCount].fsState;
1079 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1080 btnPtr->dwData = lpTbb[nCount].dwData;
1081 btnPtr->iString = lpTbb[nCount].iString;
1082 btnPtr->bHot = FALSE;
1084 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1087 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1088 ti.cbSize = sizeof (TTTOOLINFOA);
1090 ti.uId = btnPtr->idCommand;
1092 ti.lpszText = LPSTR_TEXTCALLBACKA;
1094 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1099 TOOLBAR_CalcToolbar (hwnd);
1101 InvalidateRect(hwnd, NULL, FALSE);
1108 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1110 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1111 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1112 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1114 TRACE("adding %d buttons!\n", wParam);
1116 nAddButtons = (UINT)wParam;
1117 nOldButtons = infoPtr->nNumButtons;
1118 nNewButtons = nOldButtons + nAddButtons;
1120 if (infoPtr->nNumButtons == 0) {
1122 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1125 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1127 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1128 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1129 nOldButtons * sizeof(TBUTTON_INFO));
1130 COMCTL32_Free (oldButtons);
1133 infoPtr->nNumButtons = nNewButtons;
1135 /* insert new button data */
1136 for (nCount = 0; nCount < nAddButtons; nCount++) {
1137 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1138 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1139 btnPtr->idCommand = lpTbb[nCount].idCommand;
1140 btnPtr->fsState = lpTbb[nCount].fsState;
1141 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1142 btnPtr->dwData = lpTbb[nCount].dwData;
1143 btnPtr->iString = lpTbb[nCount].iString;
1144 btnPtr->bHot = FALSE;
1146 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1149 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
1150 ti.cbSize = sizeof (TTTOOLINFOW);
1152 ti.uId = btnPtr->idCommand;
1154 ti.lpszText = LPSTR_TEXTCALLBACKW;
1156 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
1161 TOOLBAR_CalcToolbar (hwnd);
1163 InvalidateRect(hwnd, NULL, FALSE);
1170 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1172 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1175 if ((wParam) && (HIWORD(lParam) == 0)) {
1178 TRACE("adding string from resource!\n");
1180 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
1183 TRACE("len=%d \"%s\"\n", len, szString);
1184 nIndex = infoPtr->nNumStrings;
1185 if (infoPtr->nNumStrings == 0) {
1187 COMCTL32_Alloc (sizeof(LPWSTR));
1190 LPWSTR *oldStrings = infoPtr->strings;
1192 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1193 memcpy (&infoPtr->strings[0], &oldStrings[0],
1194 sizeof(LPWSTR) * infoPtr->nNumStrings);
1195 COMCTL32_Free (oldStrings);
1198 infoPtr->strings[infoPtr->nNumStrings] =
1199 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1200 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
1201 infoPtr->nNumStrings++;
1204 LPSTR p = (LPSTR)lParam;
1209 TRACE("adding string(s) from array!\n");
1210 nIndex = infoPtr->nNumStrings;
1213 TRACE("len=%d \"%s\"\n", len, p);
1215 if (infoPtr->nNumStrings == 0) {
1217 COMCTL32_Alloc (sizeof(LPWSTR));
1220 LPWSTR *oldStrings = infoPtr->strings;
1222 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1223 memcpy (&infoPtr->strings[0], &oldStrings[0],
1224 sizeof(LPWSTR) * infoPtr->nNumStrings);
1225 COMCTL32_Free (oldStrings);
1228 infoPtr->strings[infoPtr->nNumStrings] =
1229 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1230 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
1231 infoPtr->nNumStrings++;
1242 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1244 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1247 if ((wParam) && (HIWORD(lParam) == 0)) {
1248 WCHAR szString[256];
1250 TRACE("adding string from resource!\n");
1252 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
1255 TRACE("len=%d \"%s\"\n", len, debugstr_w(szString));
1256 nIndex = infoPtr->nNumStrings;
1257 if (infoPtr->nNumStrings == 0) {
1259 COMCTL32_Alloc (sizeof(LPWSTR));
1262 LPWSTR *oldStrings = infoPtr->strings;
1264 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1265 memcpy (&infoPtr->strings[0], &oldStrings[0],
1266 sizeof(LPWSTR) * infoPtr->nNumStrings);
1267 COMCTL32_Free (oldStrings);
1270 infoPtr->strings[infoPtr->nNumStrings] =
1271 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1272 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
1273 infoPtr->nNumStrings++;
1276 LPWSTR p = (LPWSTR)lParam;
1281 TRACE("adding string(s) from array!\n");
1282 nIndex = infoPtr->nNumStrings;
1285 TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
1287 if (infoPtr->nNumStrings == 0) {
1289 COMCTL32_Alloc (sizeof(LPWSTR));
1292 LPWSTR *oldStrings = infoPtr->strings;
1294 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1295 memcpy (&infoPtr->strings[0], &oldStrings[0],
1296 sizeof(LPWSTR) * infoPtr->nNumStrings);
1297 COMCTL32_Free (oldStrings);
1300 infoPtr->strings[infoPtr->nNumStrings] =
1301 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1302 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1303 infoPtr->nNumStrings++;
1314 TOOLBAR_AutoSize (HWND hwnd)
1316 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1317 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1325 TRACE("resize forced!\n");
1327 parent = GetParent (hwnd);
1328 GetClientRect(parent, &parent_rect);
1330 x = parent_rect.left;
1331 y = parent_rect.top;
1333 if (dwStyle & CCS_NORESIZE) {
1334 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1339 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1340 TOOLBAR_CalcToolbar (hwnd);
1341 InvalidateRect( hwnd, NULL, TRUE );
1342 cy = infoPtr->nHeight;
1343 cx = infoPtr->nWidth;
1345 if (dwStyle & CCS_NOMOVEY) {
1346 GetWindowRect(hwnd, &window_rect);
1347 ScreenToClient(parent, (LPPOINT)&window_rect.left);
1348 y = window_rect.top;
1352 if (dwStyle & CCS_NOPARENTALIGN)
1353 uPosFlags |= SWP_NOMOVE;
1355 if (!(dwStyle & CCS_NODIVIDER))
1356 cy += GetSystemMetrics(SM_CYEDGE);
1358 infoPtr->bAutoSize = TRUE;
1359 SetWindowPos (hwnd, HWND_TOP, x, y, cx, cy, uPosFlags);
1366 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1368 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1370 return infoPtr->nNumButtons;
1375 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1377 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1379 if (infoPtr == NULL) {
1380 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1381 ERR("infoPtr == NULL!\n");
1385 infoPtr->dwStructSize = (DWORD)wParam;
1392 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1394 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1395 TBUTTON_INFO *btnPtr;
1399 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1403 btnPtr = &infoPtr->buttons[nIndex];
1404 btnPtr->iBitmap = LOWORD(lParam);
1407 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1408 ReleaseDC (hwnd, hdc);
1415 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1417 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1418 TBUTTON_INFO *btnPtr;
1423 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1427 btnPtr = &infoPtr->buttons[nIndex];
1429 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1432 if (LOWORD(lParam) == FALSE)
1433 btnPtr->fsState &= ~TBSTATE_CHECKED;
1435 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1437 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1438 if (nOldIndex == nIndex)
1440 if (nOldIndex != -1)
1441 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1443 btnPtr->fsState |= TBSTATE_CHECKED;
1447 if (nOldIndex != -1)
1448 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1449 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1450 ReleaseDC (hwnd, hdc);
1452 /* FIXME: Send a WM_NOTIFY?? */
1459 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1461 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1463 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1468 TOOLBAR_Customize (HWND hwnd)
1470 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1476 /* send TBN_BEGINADJUST notification */
1477 nmhdr.hwndFrom = hwnd;
1478 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1479 nmhdr.code = TBN_BEGINADJUST;
1481 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1482 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1484 if (!(hRes = FindResourceA (COMCTL32_hModule,
1485 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1489 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1492 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1493 (LPDLGTEMPLATEA)template,
1495 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1498 /* send TBN_ENDADJUST notification */
1499 nmhdr.code = TBN_ENDADJUST;
1501 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1502 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1509 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1511 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1512 INT nIndex = (INT)wParam;
1514 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1517 if ((infoPtr->hwndToolTip) &&
1518 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1521 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1522 ti.cbSize = sizeof (TTTOOLINFOA);
1524 ti.uId = infoPtr->buttons[nIndex].idCommand;
1526 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1529 if (infoPtr->nNumButtons == 1) {
1530 TRACE(" simple delete!\n");
1531 COMCTL32_Free (infoPtr->buttons);
1532 infoPtr->buttons = NULL;
1533 infoPtr->nNumButtons = 0;
1536 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1537 TRACE("complex delete! [nIndex=%d]\n", nIndex);
1539 infoPtr->nNumButtons--;
1540 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1542 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1543 nIndex * sizeof(TBUTTON_INFO));
1546 if (nIndex < infoPtr->nNumButtons) {
1547 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1548 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1551 COMCTL32_Free (oldButtons);
1554 TOOLBAR_CalcToolbar (hwnd);
1556 InvalidateRect (hwnd, NULL, TRUE);
1563 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1565 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1566 TBUTTON_INFO *btnPtr;
1571 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1575 btnPtr = &infoPtr->buttons[nIndex];
1577 bState = btnPtr->fsState & TBSTATE_ENABLED;
1579 /* update the toolbar button state */
1580 if(LOWORD(lParam) == FALSE) {
1581 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1583 btnPtr->fsState |= TBSTATE_ENABLED;
1586 /* redraw the button only if the state of the button changed */
1587 if(bState != (btnPtr->fsState & TBSTATE_ENABLED)) {
1589 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1590 ReleaseDC (hwnd, hdc);
1597 static inline LRESULT
1598 TOOLBAR_GetAnchorHighlight (HWND hwnd)
1600 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1602 return infoPtr->bAnchor;
1607 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1609 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1612 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1616 return infoPtr->buttons[nIndex].iBitmap;
1620 static inline LRESULT
1621 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1623 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1628 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1630 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1631 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1632 INT nIndex = (INT)wParam;
1633 TBUTTON_INFO *btnPtr;
1635 if (infoPtr == NULL)
1641 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1644 btnPtr = &infoPtr->buttons[nIndex];
1645 lpTbb->iBitmap = btnPtr->iBitmap;
1646 lpTbb->idCommand = btnPtr->idCommand;
1647 lpTbb->fsState = btnPtr->fsState;
1648 lpTbb->fsStyle = btnPtr->fsStyle;
1649 lpTbb->dwData = btnPtr->dwData;
1650 lpTbb->iString = btnPtr->iString;
1657 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1659 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1660 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1661 TBUTTON_INFO *btnPtr;
1664 if (infoPtr == NULL)
1666 if (lpTbInfo == NULL)
1668 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1671 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1675 btnPtr = &infoPtr->buttons[nIndex];
1677 if (lpTbInfo->dwMask & TBIF_COMMAND)
1678 lpTbInfo->idCommand = btnPtr->idCommand;
1679 if (lpTbInfo->dwMask & TBIF_IMAGE)
1680 lpTbInfo->iImage = btnPtr->iBitmap;
1681 if (lpTbInfo->dwMask & TBIF_LPARAM)
1682 lpTbInfo->lParam = btnPtr->dwData;
1683 if (lpTbInfo->dwMask & TBIF_SIZE)
1684 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1685 if (lpTbInfo->dwMask & TBIF_STATE)
1686 lpTbInfo->fsState = btnPtr->fsState;
1687 if (lpTbInfo->dwMask & TBIF_STYLE)
1688 lpTbInfo->fsStyle = btnPtr->fsStyle;
1689 if (lpTbInfo->dwMask & TBIF_TEXT) {
1690 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1691 lstrcpynWtoA (lpTbInfo->pszText,
1692 (LPWSTR)infoPtr->strings[btnPtr->iString],
1701 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1703 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1704 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
1705 TBUTTON_INFO *btnPtr;
1708 if (infoPtr == NULL)
1710 if (lpTbInfo == NULL)
1712 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
1715 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1719 btnPtr = &infoPtr->buttons[nIndex];
1721 if (lpTbInfo->dwMask & TBIF_COMMAND)
1722 lpTbInfo->idCommand = btnPtr->idCommand;
1723 if (lpTbInfo->dwMask & TBIF_IMAGE)
1724 lpTbInfo->iImage = btnPtr->iBitmap;
1725 if (lpTbInfo->dwMask & TBIF_LPARAM)
1726 lpTbInfo->lParam = btnPtr->dwData;
1727 if (lpTbInfo->dwMask & TBIF_SIZE)
1728 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1729 if (lpTbInfo->dwMask & TBIF_STATE)
1730 lpTbInfo->fsState = btnPtr->fsState;
1731 if (lpTbInfo->dwMask & TBIF_STYLE)
1732 lpTbInfo->fsStyle = btnPtr->fsStyle;
1733 if (lpTbInfo->dwMask & TBIF_TEXT) {
1734 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1735 lstrcpynW (lpTbInfo->pszText,
1736 (LPWSTR)infoPtr->strings[btnPtr->iString],
1745 TOOLBAR_GetButtonSize (HWND hwnd)
1747 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1749 return MAKELONG((WORD)infoPtr->nButtonWidth,
1750 (WORD)infoPtr->nButtonHeight);
1755 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1757 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1758 INT nIndex, nStringIndex;
1760 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1764 nStringIndex = infoPtr->buttons[nIndex].iString;
1766 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1768 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1774 lstrcpyWtoA ((LPSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1776 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1781 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1783 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1784 INT nIndex, nStringIndex;
1786 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1790 nStringIndex = infoPtr->buttons[nIndex].iString;
1792 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1794 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1800 lstrcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1802 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1806 /* << TOOLBAR_GetColorScheme >> */
1810 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1812 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1814 return (LRESULT)infoPtr->himlDis;
1818 inline static LRESULT
1819 TOOLBAR_GetExtendedStyle (HWND hwnd)
1821 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1823 return infoPtr->dwExStyle;
1828 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1830 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1832 return (LRESULT)infoPtr->himlHot;
1837 TOOLBAR_GetHotItem (HWND hwnd)
1839 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1841 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
1844 if (infoPtr->nHotItem < 0)
1847 return (LRESULT)infoPtr->nHotItem;
1852 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1854 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1856 return (LRESULT)infoPtr->himlDef;
1860 /* << TOOLBAR_GetInsertMark >> */
1861 /* << TOOLBAR_GetInsertMarkColor >> */
1865 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1867 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1868 TBUTTON_INFO *btnPtr;
1872 if (infoPtr == NULL)
1874 nIndex = (INT)wParam;
1875 btnPtr = &infoPtr->buttons[nIndex];
1876 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1878 lpRect = (LPRECT)lParam;
1881 if (btnPtr->fsState & TBSTATE_HIDDEN)
1884 TOOLBAR_CalcToolbar( hwnd );
1886 lpRect->left = btnPtr->rect.left;
1887 lpRect->right = btnPtr->rect.right;
1888 lpRect->bottom = btnPtr->rect.bottom;
1889 lpRect->top = btnPtr->rect.top;
1896 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1898 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1899 LPSIZE lpSize = (LPSIZE)lParam;
1904 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1905 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1907 TRACE("maximum size %d x %d\n",
1908 infoPtr->rcBound.right - infoPtr->rcBound.left,
1909 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1915 /* << TOOLBAR_GetObject >> */
1916 /* << TOOLBAR_GetPadding >> */
1920 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1922 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1923 TBUTTON_INFO *btnPtr;
1927 if (infoPtr == NULL)
1929 nIndex = (INT)wParam;
1930 btnPtr = &infoPtr->buttons[nIndex];
1931 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1933 lpRect = (LPRECT)lParam;
1937 lpRect->left = btnPtr->rect.left;
1938 lpRect->right = btnPtr->rect.right;
1939 lpRect->bottom = btnPtr->rect.bottom;
1940 lpRect->top = btnPtr->rect.top;
1947 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1949 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1951 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1952 return infoPtr->nRows;
1959 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1961 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1964 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1968 return infoPtr->buttons[nIndex].fsState;
1973 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1975 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1978 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1982 return infoPtr->buttons[nIndex].fsStyle;
1987 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1989 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1991 if (infoPtr == NULL)
1994 return infoPtr->nMaxTextRows;
1999 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2001 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2003 if (infoPtr == NULL)
2005 return infoPtr->hwndToolTip;
2010 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2012 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2014 TRACE("%s hwnd=0x%x stub!\n",
2015 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
2017 return infoPtr->bUnicode;
2021 inline static LRESULT
2022 TOOLBAR_GetVersion (HWND hwnd)
2024 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2025 return infoPtr->iVersion;
2030 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2032 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2033 TBUTTON_INFO *btnPtr;
2036 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2040 btnPtr = &infoPtr->buttons[nIndex];
2041 if (LOWORD(lParam) == FALSE)
2042 btnPtr->fsState &= ~TBSTATE_HIDDEN;
2044 btnPtr->fsState |= TBSTATE_HIDDEN;
2046 TOOLBAR_CalcToolbar (hwnd);
2048 InvalidateRect (hwnd, NULL, TRUE);
2054 inline static LRESULT
2055 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2057 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
2062 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2064 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2065 TBUTTON_INFO *btnPtr;
2069 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2073 btnPtr = &infoPtr->buttons[nIndex];
2074 if (LOWORD(lParam) == FALSE)
2075 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
2077 btnPtr->fsState |= TBSTATE_INDETERMINATE;
2080 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2081 ReleaseDC (hwnd, hdc);
2088 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2090 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2091 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2092 INT nIndex = (INT)wParam;
2093 TBUTTON_INFO *oldButtons;
2099 /* EPP: this seems to be an undocumented call (from my IE4)
2100 * I assume in that case that:
2101 * - lpTbb->iString is a string pointer (not a string index in strings[] table
2102 * - index of insertion is at the end of existing buttons
2103 * I only see this happen with nIndex == -1, but it could have a special
2104 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
2106 int len = lstrlenA((char*)lpTbb->iString) + 2;
2107 LPSTR ptr = COMCTL32_Alloc(len);
2109 nIndex = infoPtr->nNumButtons;
2110 strcpy(ptr, (char*)lpTbb->iString);
2111 ptr[len - 1] = 0; /* ended by two '\0' */
2112 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
2115 } else if (nIndex < 0)
2118 TRACE("inserting button index=%d\n", nIndex);
2119 if (nIndex > infoPtr->nNumButtons) {
2120 nIndex = infoPtr->nNumButtons;
2121 TRACE("adjust index=%d\n", nIndex);
2124 oldButtons = infoPtr->buttons;
2125 infoPtr->nNumButtons++;
2126 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2127 /* pre insert copy */
2129 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2130 nIndex * sizeof(TBUTTON_INFO));
2133 /* insert new button */
2134 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2135 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2136 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2137 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2138 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2139 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2141 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2144 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2145 ti.cbSize = sizeof (TTTOOLINFOA);
2147 ti.uId = lpTbb->idCommand;
2149 ti.lpszText = LPSTR_TEXTCALLBACKA;
2151 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2155 /* post insert copy */
2156 if (nIndex < infoPtr->nNumButtons - 1) {
2157 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2158 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2161 COMCTL32_Free (oldButtons);
2163 TOOLBAR_CalcToolbar (hwnd);
2165 InvalidateRect (hwnd, NULL, FALSE);
2172 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2174 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2175 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2176 INT nIndex = (INT)wParam;
2177 TBUTTON_INFO *oldButtons;
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(TTTOOLINFOW));
2211 ti.cbSize = sizeof (TTTOOLINFOW);
2213 ti.uId = lpTbb->idCommand;
2215 ti.lpszText = LPSTR_TEXTCALLBACKW;
2217 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
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);
2237 /* << TOOLBAR_InsertMarkHitTest >> */
2241 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
2243 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2246 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2250 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
2255 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
2257 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2260 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2264 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
2269 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
2271 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2274 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2278 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
2283 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
2285 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2288 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2292 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
2297 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2299 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2302 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2306 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
2311 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
2313 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2316 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2320 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
2324 /* << TOOLBAR_LoadImages >> */
2325 /* << TOOLBAR_MapAccelerator >> */
2326 /* << TOOLBAR_MarkButton >> */
2327 /* << TOOLBAR_MoveButton >> */
2331 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2333 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2334 TBUTTON_INFO *btnPtr;
2338 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2342 btnPtr = &infoPtr->buttons[nIndex];
2343 if (LOWORD(lParam) == FALSE)
2344 btnPtr->fsState &= ~TBSTATE_PRESSED;
2346 btnPtr->fsState |= TBSTATE_PRESSED;
2349 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2350 ReleaseDC (hwnd, hdc);
2356 /* << TOOLBAR_ReplaceBitmap >> */
2360 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2363 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2364 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2366 if (lpSave == NULL) return 0;
2369 /* save toolbar information */
2370 FIXME("save to \"%s\" \"%s\"\n",
2371 lpSave->pszSubKey, lpSave->pszValueName);
2376 /* restore toolbar information */
2378 FIXME("restore from \"%s\" \"%s\"\n",
2379 lpSave->pszSubKey, lpSave->pszValueName);
2390 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2393 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2394 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
2400 /* save toolbar information */
2401 FIXME("save to \"%s\" \"%s\"\n",
2402 lpSave->pszSubKey, lpSave->pszValueName);
2407 /* restore toolbar information */
2409 FIXME("restore from \"%s\" \"%s\"\n",
2410 lpSave->pszSubKey, lpSave->pszValueName);
2421 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
2423 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2424 BOOL bOldAnchor = infoPtr->bAnchor;
2426 infoPtr->bAnchor = (BOOL)wParam;
2428 return (LRESULT)bOldAnchor;
2433 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2435 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2437 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2440 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2441 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2448 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2450 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2451 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2452 TBUTTON_INFO *btnPtr;
2457 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2460 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2464 btnPtr = &infoPtr->buttons[nIndex];
2465 if (lptbbi->dwMask & TBIF_COMMAND)
2466 btnPtr->idCommand = lptbbi->idCommand;
2467 if (lptbbi->dwMask & TBIF_IMAGE)
2468 btnPtr->iBitmap = lptbbi->iImage;
2469 if (lptbbi->dwMask & TBIF_LPARAM)
2470 btnPtr->dwData = lptbbi->lParam;
2471 /* if (lptbbi->dwMask & TBIF_SIZE) */
2472 /* btnPtr->cx = lptbbi->cx; */
2473 if (lptbbi->dwMask & TBIF_STATE)
2474 btnPtr->fsState = lptbbi->fsState;
2475 if (lptbbi->dwMask & TBIF_STYLE)
2476 btnPtr->fsStyle = lptbbi->fsStyle;
2478 if (lptbbi->dwMask & TBIF_TEXT) {
2479 if ((btnPtr->iString >= 0) ||
2480 (btnPtr->iString < infoPtr->nNumStrings)) {
2481 TRACE("Ooooooch\n");
2483 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2484 INT len = lstrlenA (lptbbi->pszText);
2485 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2488 /* this is the ultimate sollution */
2489 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2498 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2500 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2501 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
2502 TBUTTON_INFO *btnPtr;
2507 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
2510 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2514 btnPtr = &infoPtr->buttons[nIndex];
2515 if (lptbbi->dwMask & TBIF_COMMAND)
2516 btnPtr->idCommand = lptbbi->idCommand;
2517 if (lptbbi->dwMask & TBIF_IMAGE)
2518 btnPtr->iBitmap = lptbbi->iImage;
2519 if (lptbbi->dwMask & TBIF_LPARAM)
2520 btnPtr->dwData = lptbbi->lParam;
2521 /* if (lptbbi->dwMask & TBIF_SIZE) */
2522 /* btnPtr->cx = lptbbi->cx; */
2523 if (lptbbi->dwMask & TBIF_STATE)
2524 btnPtr->fsState = lptbbi->fsState;
2525 if (lptbbi->dwMask & TBIF_STYLE)
2526 btnPtr->fsStyle = lptbbi->fsStyle;
2528 if (lptbbi->dwMask & TBIF_TEXT) {
2529 if ((btnPtr->iString >= 0) ||
2530 (btnPtr->iString < infoPtr->nNumStrings)) {
2532 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2533 INT len = lstrlenW (lptbbi->pszText);
2534 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2537 /* this is the ultimate sollution */
2538 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2547 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2549 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2551 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2554 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2555 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2562 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2564 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2566 if (infoPtr == NULL)
2569 infoPtr->cxMin = (INT)LOWORD(lParam);
2570 infoPtr->cxMax = (INT)HIWORD(lParam);
2577 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2579 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2580 INT nIndex = (INT)wParam;
2582 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2585 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2587 if (infoPtr->hwndToolTip) {
2589 FIXME("change tool tip!\n");
2597 /* << TOOLBAR_SetColorScheme >> */
2601 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2603 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2604 HIMAGELIST himlTemp;
2606 himlTemp = infoPtr->himlDis;
2607 infoPtr->himlDis = (HIMAGELIST)lParam;
2609 /* FIXME: redraw ? */
2611 return (LRESULT)himlTemp;
2616 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2618 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2621 dwTemp = infoPtr->dwDTFlags;
2622 infoPtr->dwDTFlags =
2623 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2625 return (LRESULT)dwTemp;
2630 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2632 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2635 dwTemp = infoPtr->dwExStyle;
2636 infoPtr->dwExStyle = (DWORD)lParam;
2638 return (LRESULT)dwTemp;
2643 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2645 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2646 HIMAGELIST himlTemp;
2648 himlTemp = infoPtr->himlHot;
2649 infoPtr->himlHot = (HIMAGELIST)lParam;
2651 /* FIXME: redraw ? */
2653 return (LRESULT)himlTemp;
2658 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
2660 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2661 INT nOldHotItem = infoPtr->nHotItem;
2663 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
2665 infoPtr->nHotItem = (INT)wParam;
2667 /* FIXME: What else must be done ??? */
2671 if (nOldHotItem < 0)
2674 return (LRESULT)nOldHotItem;
2679 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2681 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2682 HIMAGELIST himlTemp;
2684 himlTemp = infoPtr->himlDef;
2685 infoPtr->himlDef = (HIMAGELIST)lParam;
2687 /* FIXME: redraw ? */
2689 return (LRESULT)himlTemp;
2694 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2696 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2698 infoPtr->nIndent = (INT)wParam;
2700 TOOLBAR_CalcToolbar (hwnd);
2702 InvalidateRect(hwnd, NULL, FALSE);
2708 /* << TOOLBAR_SetInsertMark >> */
2712 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2714 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2716 infoPtr->clrInsertMark = (COLORREF)lParam;
2718 /* FIXME : redraw ??*/
2725 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2727 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2729 if (infoPtr == NULL)
2732 infoPtr->nMaxTextRows = (INT)wParam;
2738 /* << TOOLBAR_SetPadding >> */
2742 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2744 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2747 if (infoPtr == NULL)
2749 hwndOldNotify = infoPtr->hwndNotify;
2750 infoPtr->hwndNotify = (HWND)wParam;
2752 return hwndOldNotify;
2757 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2759 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2760 LPRECT lprc = (LPRECT)lParam;
2762 if (LOWORD(wParam) > 1) {
2764 FIXME("multiple rows not supported!\n");
2768 /* recalculate toolbar */
2769 TOOLBAR_CalcToolbar (hwnd);
2771 /* return bounding rectangle */
2773 lprc->left = infoPtr->rcBound.left;
2774 lprc->right = infoPtr->rcBound.right;
2775 lprc->top = infoPtr->rcBound.top;
2776 lprc->bottom = infoPtr->rcBound.bottom;
2779 /* repaint toolbar */
2780 InvalidateRect(hwnd, NULL, FALSE);
2787 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2789 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2790 TBUTTON_INFO *btnPtr;
2794 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2798 btnPtr = &infoPtr->buttons[nIndex];
2799 btnPtr->fsState = LOWORD(lParam);
2802 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2803 ReleaseDC (hwnd, hdc);
2810 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2812 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2813 TBUTTON_INFO *btnPtr;
2817 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2821 btnPtr = &infoPtr->buttons[nIndex];
2822 btnPtr->fsStyle = LOWORD(lParam);
2825 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2826 ReleaseDC (hwnd, hdc);
2828 if (infoPtr->hwndToolTip) {
2830 FIXME("change tool tip!\n");
2838 inline static LRESULT
2839 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2841 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2843 if (infoPtr == NULL)
2845 infoPtr->hwndToolTip = (HWND)wParam;
2851 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2853 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2856 TRACE("%s hwnd=0x%04x stub!\n",
2857 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2859 bTemp = infoPtr->bUnicode;
2860 infoPtr->bUnicode = (BOOL)wParam;
2867 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
2869 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2870 INT iOldVersion = infoPtr->iVersion;
2872 infoPtr->iVersion = iVersion;
2879 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2881 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2882 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2885 /* initialize info structure */
2886 infoPtr->nButtonHeight = 22;
2887 infoPtr->nButtonWidth = 23;
2888 infoPtr->nBitmapHeight = 15;
2889 infoPtr->nBitmapWidth = 16;
2891 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2893 infoPtr->nMaxTextRows = 1;
2894 infoPtr->cxMin = -1;
2895 infoPtr->cxMax = -1;
2897 infoPtr->bCaptured = FALSE;
2898 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2899 infoPtr->nButtonDown = -1;
2900 infoPtr->nOldHit = -1;
2901 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2902 infoPtr->hwndNotify = GetParent (hwnd);
2903 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2904 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
2905 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
2906 infoPtr->iVersion = 0;
2908 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2909 infoPtr->hFont = CreateFontIndirectA (&logFont);
2911 if (dwStyle & TBSTYLE_TOOLTIPS) {
2912 /* Create tooltip control */
2913 infoPtr->hwndToolTip =
2914 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2915 CW_USEDEFAULT, CW_USEDEFAULT,
2916 CW_USEDEFAULT, CW_USEDEFAULT,
2919 /* Send NM_TOOLTIPSCREATED notification */
2920 if (infoPtr->hwndToolTip) {
2921 NMTOOLTIPSCREATED nmttc;
2923 nmttc.hdr.hwndFrom = hwnd;
2924 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2925 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2926 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2928 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2929 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2938 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2940 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2942 /* delete tooltip control */
2943 if (infoPtr->hwndToolTip)
2944 DestroyWindow (infoPtr->hwndToolTip);
2946 /* delete button data */
2947 if (infoPtr->buttons)
2948 COMCTL32_Free (infoPtr->buttons);
2950 /* delete strings */
2951 if (infoPtr->strings) {
2953 for (i = 0; i < infoPtr->nNumStrings; i++)
2954 if (infoPtr->strings[i])
2955 COMCTL32_Free (infoPtr->strings[i]);
2957 COMCTL32_Free (infoPtr->strings);
2960 /* destroy internal image list */
2961 if (infoPtr->himlInt)
2962 ImageList_Destroy (infoPtr->himlInt);
2964 /* delete default font */
2966 DeleteObject (infoPtr->hFont);
2968 /* free toolbar info data */
2969 COMCTL32_Free (infoPtr);
2970 SetWindowLongA (hwnd, 0, 0);
2977 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2979 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2981 if (infoPtr->bTransparent)
2982 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2984 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2989 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2991 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2993 return infoPtr->hFont;
2998 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
3000 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3001 TBUTTON_INFO *btnPtr;
3006 pt.x = (INT)LOWORD(lParam);
3007 pt.y = (INT)HIWORD(lParam);
3008 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3011 btnPtr = &infoPtr->buttons[nHit];
3012 if (!(btnPtr->fsState & TBSTATE_ENABLED))
3015 infoPtr->bCaptured = TRUE;
3016 infoPtr->nButtonDown = nHit;
3018 btnPtr->fsState |= TBSTATE_PRESSED;
3021 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3022 ReleaseDC (hwnd, hdc);
3024 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
3025 TOOLBAR_Customize (hwnd);
3032 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
3034 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3035 TBUTTON_INFO *btnPtr;
3040 if (infoPtr->hwndToolTip)
3041 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3042 WM_LBUTTONDOWN, wParam, lParam);
3044 pt.x = (INT)LOWORD(lParam);
3045 pt.y = (INT)HIWORD(lParam);
3046 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3049 btnPtr = &infoPtr->buttons[nHit];
3050 if (!(btnPtr->fsState & TBSTATE_ENABLED))
3053 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
3057 nmtb.hdr.hwndFrom = hwnd;
3058 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3059 nmtb.hdr.code = TBN_DROPDOWN;
3060 nmtb.iItem = btnPtr->idCommand;
3062 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
3063 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3067 infoPtr->bCaptured = TRUE;
3068 infoPtr->nButtonDown = nHit;
3069 infoPtr->nOldHit = nHit;
3071 btnPtr->fsState |= TBSTATE_PRESSED;
3074 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3075 ReleaseDC (hwnd, hdc);
3082 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
3084 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3085 TBUTTON_INFO *btnPtr;
3090 BOOL bSendMessage = TRUE;
3092 if (infoPtr->hwndToolTip)
3093 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3094 WM_LBUTTONUP, wParam, lParam);
3096 pt.x = (INT)LOWORD(lParam);
3097 pt.y = (INT)HIWORD(lParam);
3098 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3100 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
3101 infoPtr->bCaptured = FALSE;
3103 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3104 btnPtr->fsState &= ~TBSTATE_PRESSED;
3106 if (nHit == infoPtr->nButtonDown) {
3107 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
3108 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
3109 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
3110 infoPtr->nButtonDown);
3111 if (nOldIndex == infoPtr->nButtonDown)
3112 bSendMessage = FALSE;
3113 if ((nOldIndex != infoPtr->nButtonDown) &&
3115 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
3116 btnPtr->fsState |= TBSTATE_CHECKED;
3119 if (btnPtr->fsState & TBSTATE_CHECKED)
3120 btnPtr->fsState &= ~TBSTATE_CHECKED;
3122 btnPtr->fsState |= TBSTATE_CHECKED;
3127 bSendMessage = FALSE;
3130 if (nOldIndex != -1)
3131 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
3132 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3133 ReleaseDC (hwnd, hdc);
3136 SendMessageA (GetParent(hwnd), WM_COMMAND,
3137 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
3139 if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) ||
3140 (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) {
3143 nmtb.hdr.hwndFrom = hwnd;
3144 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3145 nmtb.hdr.code = TBN_DROPDOWN;
3147 /* nmtb.tbButton not used with TBN_DROPDOWN */
3148 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) {
3149 nmtb.pszText = infoPtr->strings[btnPtr->iString];
3150 nmtb.cchText = lstrlenW(nmtb.pszText);
3152 nmtb.pszText = NULL;
3155 nmtb.rcButton = btnPtr->rect;
3157 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
3158 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3161 infoPtr->nButtonDown = -1;
3162 infoPtr->nOldHit = -1;
3169 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
3171 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3172 TBUTTON_INFO *hotBtnPtr;
3174 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
3176 /* Redraw the button if the last button we were over is the hot button and it
3178 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
3180 hotBtnPtr->bHot = FALSE;
3182 InvalidateRect (hwnd, &hotBtnPtr->rect, TRUE);
3185 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
3186 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
3192 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
3194 TBUTTON_INFO *btnPtr, *oldBtnPtr;
3195 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3199 TRACKMOUSEEVENT trackinfo;
3201 /* fill in the TRACKMOUSEEVENT struct */
3202 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
3203 trackinfo.dwFlags = TME_QUERY;
3204 trackinfo.hwndTrack = hwnd;
3205 trackinfo.dwHoverTime = HOVER_DEFAULT;
3207 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
3208 _TrackMouseEvent(&trackinfo);
3210 /* Make sure tracking is enabled so we recieve a WM_MOUSELEAVE message */
3211 if(!(trackinfo.dwFlags & TME_LEAVE)) {
3212 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
3214 /* call TRACKMOUSEEVENT so we recieve a WM_MOUSELEAVE message */
3215 /* and can properly deactivate the hot toolbar button */
3216 _TrackMouseEvent(&trackinfo);
3219 if (infoPtr->hwndToolTip)
3220 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3221 WM_MOUSEMOVE, wParam, lParam);
3223 pt.x = (INT)LOWORD(lParam);
3224 pt.y = (INT)HIWORD(lParam);
3226 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3228 if (infoPtr->nOldHit != nHit)
3230 /* Remove the effect of an old hot button if the button was enabled and was
3231 drawn with the hot button effect */
3232 if(infoPtr->nOldHit == infoPtr->nHotItem &&
3233 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
3235 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
3236 oldBtnPtr->bHot = FALSE;
3238 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
3241 /* It's not a separator or in nowhere. It's a hot button. */
3244 btnPtr = &infoPtr->buttons[nHit];
3245 btnPtr->bHot = TRUE;
3248 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3249 ReleaseDC (hwnd, hdc);
3251 infoPtr->nHotItem = nHit;
3254 if (infoPtr->bCaptured) {
3255 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3256 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
3257 btnPtr->fsState &= ~TBSTATE_PRESSED;
3259 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3260 ReleaseDC (hwnd, hdc);
3262 else if (nHit == infoPtr->nButtonDown) {
3263 btnPtr->fsState |= TBSTATE_PRESSED;
3265 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3266 ReleaseDC (hwnd, hdc);
3269 infoPtr->nOldHit = nHit;
3275 inline static LRESULT
3276 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3278 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
3279 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
3281 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
3285 inline static LRESULT
3286 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3288 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
3289 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
3291 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
3296 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3298 TOOLBAR_INFO *infoPtr;
3300 /* allocate memory for info structure */
3301 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
3302 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3305 infoPtr->dwStructSize = sizeof(TBBUTTON);
3307 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
3308 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
3309 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
3310 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
3313 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
3318 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
3320 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3324 if (dwStyle & WS_MINIMIZE)
3325 return 0; /* Nothing to do */
3327 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
3329 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
3332 if (!(dwStyle & CCS_NODIVIDER))
3334 GetWindowRect (hwnd, &rcWindow);
3335 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3336 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
3339 ReleaseDC( hwnd, hdc );
3345 inline static LRESULT
3346 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
3348 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3349 LPNMHDR lpnmh = (LPNMHDR)lParam;
3351 TRACE("passing WM_NOTIFY!\n");
3353 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
3354 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
3357 if (lpnmh->code == TTN_GETDISPINFOA) {
3358 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
3360 FIXME("retrieving ASCII string\n");
3363 else if (lpnmh->code == TTN_GETDISPINFOW) {
3364 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
3366 FIXME("retrieving UNICODE string\n");
3377 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
3382 TOOLBAR_CalcToolbar( hwnd );
3383 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
3384 TOOLBAR_Refresh (hwnd, hdc);
3386 EndPaint (hwnd, &ps);
3392 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
3394 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3395 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3404 /* Resize deadlock check */
3405 if (infoPtr->bAutoSize) {
3406 infoPtr->bAutoSize = FALSE;
3410 flags = (INT) wParam;
3412 /* FIXME for flags =
3413 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
3416 TRACE("sizing toolbar!\n");
3418 if (flags == SIZE_RESTORED) {
3419 /* width and height don't apply */
3420 parent = GetParent (hwnd);
3421 GetClientRect(parent, &parent_rect);
3422 x = parent_rect.left;
3423 y = parent_rect.top;
3425 if (dwStyle & CCS_NORESIZE) {
3426 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
3429 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
3430 cy = infoPtr->nHeight;
3431 cx = infoPtr->nWidth;
3432 TOOLBAR_CalcToolbar (hwnd);
3433 infoPtr->nWidth = cx;
3434 infoPtr->nHeight = cy;
3437 infoPtr->nWidth = parent_rect.right - parent_rect.left;
3438 TOOLBAR_CalcToolbar (hwnd);
3439 cy = infoPtr->nHeight;
3440 cx = infoPtr->nWidth;
3442 if (dwStyle & CCS_NOMOVEY) {
3443 GetWindowRect(hwnd, &window_rect);
3444 ScreenToClient(parent, (LPPOINT)&window_rect.left);
3445 y = window_rect.top;
3449 if (dwStyle & CCS_NOPARENTALIGN) {
3450 uPosFlags |= SWP_NOMOVE;
3451 cy = infoPtr->nHeight;
3452 cx = infoPtr->nWidth;
3455 if (!(dwStyle & CCS_NODIVIDER))
3456 cy += GetSystemMetrics(SM_CYEDGE);
3458 SetWindowPos (hwnd, 0, x, y, cx, cy, uPosFlags | SWP_NOZORDER);
3466 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
3468 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3470 if (nType == GWL_STYLE) {
3471 if (lpStyle->styleNew & TBSTYLE_LIST) {
3472 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
3475 infoPtr->dwDTFlags = DT_CENTER;
3479 TOOLBAR_AutoSize (hwnd);
3481 InvalidateRect(hwnd, NULL, FALSE);
3488 static LRESULT WINAPI
3489 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3495 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3498 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3501 if (!TOOLBAR_GetInfoPtr (hwnd))
3503 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3509 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
3511 case TB_ADDBUTTONSA:
3512 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
3514 case TB_ADDBUTTONSW:
3515 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
3518 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
3521 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
3524 return TOOLBAR_AutoSize (hwnd);
3526 case TB_BUTTONCOUNT:
3527 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
3529 case TB_BUTTONSTRUCTSIZE:
3530 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
3532 case TB_CHANGEBITMAP:
3533 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
3535 case TB_CHECKBUTTON:
3536 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
3538 case TB_COMMANDTOINDEX:
3539 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
3542 return TOOLBAR_Customize (hwnd);
3544 case TB_DELETEBUTTON:
3545 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
3547 case TB_ENABLEBUTTON:
3548 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
3550 case TB_GETANCHORHIGHLIGHT:
3551 return TOOLBAR_GetAnchorHighlight (hwnd);
3554 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
3556 case TB_GETBITMAPFLAGS:
3557 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
3560 return TOOLBAR_GetButton (hwnd, wParam, lParam);
3562 case TB_GETBUTTONINFOA:
3563 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
3565 case TB_GETBUTTONINFOW:
3566 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
3568 case TB_GETBUTTONSIZE:
3569 return TOOLBAR_GetButtonSize (hwnd);
3571 case TB_GETBUTTONTEXTA:
3572 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3574 case TB_GETBUTTONTEXTW:
3575 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
3577 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
3579 case TB_GETDISABLEDIMAGELIST:
3580 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3582 case TB_GETEXTENDEDSTYLE:
3583 return TOOLBAR_GetExtendedStyle (hwnd);
3585 case TB_GETHOTIMAGELIST:
3586 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3589 return TOOLBAR_GetHotItem (hwnd);
3591 case TB_GETIMAGELIST:
3592 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3594 /* case TB_GETINSERTMARK: */ /* 4.71 */
3595 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3597 case TB_GETITEMRECT:
3598 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3601 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3603 /* case TB_GETOBJECT: */ /* 4.71 */
3604 /* case TB_GETPADDING: */ /* 4.71 */
3607 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3610 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3613 return TOOLBAR_GetState (hwnd, wParam, lParam);
3616 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3618 case TB_GETTEXTROWS:
3619 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3621 case TB_GETTOOLTIPS:
3622 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3624 case TB_GETUNICODEFORMAT:
3625 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3627 case CCM_GETVERSION:
3628 return TOOLBAR_GetVersion (hwnd);
3631 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3634 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3636 case TB_INDETERMINATE:
3637 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3639 case TB_INSERTBUTTONA:
3640 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3642 case TB_INSERTBUTTONW:
3643 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
3645 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3647 case TB_ISBUTTONCHECKED:
3648 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3650 case TB_ISBUTTONENABLED:
3651 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3653 case TB_ISBUTTONHIDDEN:
3654 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3656 case TB_ISBUTTONHIGHLIGHTED:
3657 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3659 case TB_ISBUTTONINDETERMINATE:
3660 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3662 case TB_ISBUTTONPRESSED:
3663 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3665 case TB_LOADIMAGES: /* 4.70 */
3666 FIXME("missing standard imagelists\n");
3669 /* case TB_MAPACCELERATORA: */ /* 4.71 */
3670 /* case TB_MAPACCELERATORW: */ /* 4.71 */
3671 /* case TB_MARKBUTTON: */ /* 4.71 */
3672 /* case TB_MOVEBUTTON: */ /* 4.71 */
3674 case TB_PRESSBUTTON:
3675 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3677 /* case TB_REPLACEBITMAP: */
3679 case TB_SAVERESTOREA:
3680 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3682 case TB_SAVERESTOREW:
3683 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
3685 case TB_SETANCHORHIGHLIGHT:
3686 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
3688 case TB_SETBITMAPSIZE:
3689 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3691 case TB_SETBUTTONINFOA:
3692 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3694 case TB_SETBUTTONINFOW:
3695 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
3697 case TB_SETBUTTONSIZE:
3698 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3700 case TB_SETBUTTONWIDTH:
3701 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3704 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3706 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
3708 case TB_SETDISABLEDIMAGELIST:
3709 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3711 case TB_SETDRAWTEXTFLAGS:
3712 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3714 case TB_SETEXTENDEDSTYLE:
3715 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3717 case TB_SETHOTIMAGELIST:
3718 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3721 return TOOLBAR_SetHotItem (hwnd, wParam);
3723 case TB_SETIMAGELIST:
3724 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3727 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3729 /* case TB_SETINSERTMARK: */ /* 4.71 */
3731 case TB_SETINSERTMARKCOLOR:
3732 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3734 case TB_SETMAXTEXTROWS:
3735 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3737 /* case TB_SETPADDING: */ /* 4.71 */
3740 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3743 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3746 return TOOLBAR_SetState (hwnd, wParam, lParam);
3749 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3751 case TB_SETTOOLTIPS:
3752 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3754 case TB_SETUNICODEFORMAT:
3755 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3757 case CCM_SETVERSION:
3758 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
3764 return TOOLBAR_Create (hwnd, wParam, lParam);
3767 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3770 return TOOLBAR_GetFont (hwnd, wParam, lParam);
3772 /* case WM_KEYDOWN: */
3773 /* case WM_KILLFOCUS: */
3775 case WM_LBUTTONDBLCLK:
3776 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3778 case WM_LBUTTONDOWN:
3779 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3782 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3785 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3788 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
3791 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3794 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3797 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3800 return TOOLBAR_Notify (hwnd, wParam, lParam);
3802 /* case WM_NOTIFYFORMAT: */
3805 return TOOLBAR_Paint (hwnd, wParam);
3808 return TOOLBAR_Size (hwnd, wParam, lParam);
3810 case WM_STYLECHANGED:
3811 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
3813 /* case WM_SYSCOLORCHANGE: */
3815 /* case WM_WININICHANGE: */
3820 case WM_MEASUREITEM:
3822 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3825 if (uMsg >= WM_USER)
3826 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
3827 uMsg, wParam, lParam);
3828 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3835 TOOLBAR_Register (void)
3839 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3840 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3841 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3842 wndClass.cbClsExtra = 0;
3843 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3844 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3845 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3846 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3848 RegisterClassA (&wndClass);
3853 TOOLBAR_Unregister (void)
3855 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);