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 = 16 + 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);
1324 TRACE("resize forced!\n");
1326 parent = GetParent (hwnd);
1327 GetClientRect(parent, &parent_rect);
1329 if (dwStyle & CCS_NORESIZE) {
1330 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1335 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1336 TOOLBAR_CalcToolbar (hwnd);
1337 InvalidateRect( hwnd, NULL, TRUE );
1338 cy = infoPtr->nHeight;
1339 cx = infoPtr->nWidth;
1342 if (dwStyle & CCS_NOPARENTALIGN)
1343 uPosFlags |= SWP_NOMOVE;
1345 if (!(dwStyle & CCS_NODIVIDER))
1346 cy += GetSystemMetrics(SM_CYEDGE);
1348 infoPtr->bAutoSize = TRUE;
1349 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
1357 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1359 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1361 return infoPtr->nNumButtons;
1366 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1368 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1370 if (infoPtr == NULL) {
1371 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1372 ERR("infoPtr == NULL!\n");
1376 infoPtr->dwStructSize = (DWORD)wParam;
1383 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1385 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1386 TBUTTON_INFO *btnPtr;
1390 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1394 btnPtr = &infoPtr->buttons[nIndex];
1395 btnPtr->iBitmap = LOWORD(lParam);
1398 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1399 ReleaseDC (hwnd, hdc);
1406 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1408 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1409 TBUTTON_INFO *btnPtr;
1414 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1418 btnPtr = &infoPtr->buttons[nIndex];
1420 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1423 if (LOWORD(lParam) == FALSE)
1424 btnPtr->fsState &= ~TBSTATE_CHECKED;
1426 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1428 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1429 if (nOldIndex == nIndex)
1431 if (nOldIndex != -1)
1432 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1434 btnPtr->fsState |= TBSTATE_CHECKED;
1438 if (nOldIndex != -1)
1439 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1440 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1441 ReleaseDC (hwnd, hdc);
1443 /* FIXME: Send a WM_NOTIFY?? */
1450 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1452 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1454 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1459 TOOLBAR_Customize (HWND hwnd)
1461 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1467 /* send TBN_BEGINADJUST notification */
1468 nmhdr.hwndFrom = hwnd;
1469 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1470 nmhdr.code = TBN_BEGINADJUST;
1472 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1473 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1475 if (!(hRes = FindResourceA (COMCTL32_hModule,
1476 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1480 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1483 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1484 (LPDLGTEMPLATEA)template,
1486 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1489 /* send TBN_ENDADJUST notification */
1490 nmhdr.code = TBN_ENDADJUST;
1492 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1493 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1500 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1502 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1503 INT nIndex = (INT)wParam;
1505 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1508 if ((infoPtr->hwndToolTip) &&
1509 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1512 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1513 ti.cbSize = sizeof (TTTOOLINFOA);
1515 ti.uId = infoPtr->buttons[nIndex].idCommand;
1517 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1520 if (infoPtr->nNumButtons == 1) {
1521 TRACE(" simple delete!\n");
1522 COMCTL32_Free (infoPtr->buttons);
1523 infoPtr->buttons = NULL;
1524 infoPtr->nNumButtons = 0;
1527 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1528 TRACE("complex delete! [nIndex=%d]\n", nIndex);
1530 infoPtr->nNumButtons--;
1531 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1533 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1534 nIndex * sizeof(TBUTTON_INFO));
1537 if (nIndex < infoPtr->nNumButtons) {
1538 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1539 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1542 COMCTL32_Free (oldButtons);
1545 TOOLBAR_CalcToolbar (hwnd);
1547 InvalidateRect (hwnd, NULL, TRUE);
1554 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1556 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1557 TBUTTON_INFO *btnPtr;
1561 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1565 btnPtr = &infoPtr->buttons[nIndex];
1566 if (LOWORD(lParam) == FALSE)
1567 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1569 btnPtr->fsState |= TBSTATE_ENABLED;
1572 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1573 ReleaseDC (hwnd, hdc);
1579 static inline LRESULT
1580 TOOLBAR_GetAnchorHighlight (HWND hwnd)
1582 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1584 return infoPtr->bAnchor;
1589 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1591 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1594 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1598 return infoPtr->buttons[nIndex].iBitmap;
1602 static inline LRESULT
1603 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1605 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1610 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1612 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1613 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1614 INT nIndex = (INT)wParam;
1615 TBUTTON_INFO *btnPtr;
1617 if (infoPtr == NULL)
1623 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1626 btnPtr = &infoPtr->buttons[nIndex];
1627 lpTbb->iBitmap = btnPtr->iBitmap;
1628 lpTbb->idCommand = btnPtr->idCommand;
1629 lpTbb->fsState = btnPtr->fsState;
1630 lpTbb->fsStyle = btnPtr->fsStyle;
1631 lpTbb->dwData = btnPtr->dwData;
1632 lpTbb->iString = btnPtr->iString;
1639 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1641 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1642 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1643 TBUTTON_INFO *btnPtr;
1646 if (infoPtr == NULL)
1648 if (lpTbInfo == NULL)
1650 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1653 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1657 btnPtr = &infoPtr->buttons[nIndex];
1659 if (lpTbInfo->dwMask & TBIF_COMMAND)
1660 lpTbInfo->idCommand = btnPtr->idCommand;
1661 if (lpTbInfo->dwMask & TBIF_IMAGE)
1662 lpTbInfo->iImage = btnPtr->iBitmap;
1663 if (lpTbInfo->dwMask & TBIF_LPARAM)
1664 lpTbInfo->lParam = btnPtr->dwData;
1665 if (lpTbInfo->dwMask & TBIF_SIZE)
1666 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1667 if (lpTbInfo->dwMask & TBIF_STATE)
1668 lpTbInfo->fsState = btnPtr->fsState;
1669 if (lpTbInfo->dwMask & TBIF_STYLE)
1670 lpTbInfo->fsStyle = btnPtr->fsStyle;
1671 if (lpTbInfo->dwMask & TBIF_TEXT) {
1672 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1673 lstrcpynWtoA (lpTbInfo->pszText,
1674 (LPWSTR)infoPtr->strings[btnPtr->iString],
1683 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1685 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1686 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
1687 TBUTTON_INFO *btnPtr;
1690 if (infoPtr == NULL)
1692 if (lpTbInfo == NULL)
1694 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
1697 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1701 btnPtr = &infoPtr->buttons[nIndex];
1703 if (lpTbInfo->dwMask & TBIF_COMMAND)
1704 lpTbInfo->idCommand = btnPtr->idCommand;
1705 if (lpTbInfo->dwMask & TBIF_IMAGE)
1706 lpTbInfo->iImage = btnPtr->iBitmap;
1707 if (lpTbInfo->dwMask & TBIF_LPARAM)
1708 lpTbInfo->lParam = btnPtr->dwData;
1709 if (lpTbInfo->dwMask & TBIF_SIZE)
1710 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1711 if (lpTbInfo->dwMask & TBIF_STATE)
1712 lpTbInfo->fsState = btnPtr->fsState;
1713 if (lpTbInfo->dwMask & TBIF_STYLE)
1714 lpTbInfo->fsStyle = btnPtr->fsStyle;
1715 if (lpTbInfo->dwMask & TBIF_TEXT) {
1716 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1717 lstrcpynW (lpTbInfo->pszText,
1718 (LPWSTR)infoPtr->strings[btnPtr->iString],
1727 TOOLBAR_GetButtonSize (HWND hwnd)
1729 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1731 return MAKELONG((WORD)infoPtr->nButtonWidth,
1732 (WORD)infoPtr->nButtonHeight);
1737 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1739 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1740 INT nIndex, nStringIndex;
1742 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1746 nStringIndex = infoPtr->buttons[nIndex].iString;
1748 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1750 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1756 lstrcpyWtoA ((LPSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1758 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1763 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1765 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1766 INT nIndex, nStringIndex;
1768 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1772 nStringIndex = infoPtr->buttons[nIndex].iString;
1774 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1776 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1782 lstrcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1784 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1788 /* << TOOLBAR_GetColorScheme >> */
1792 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1794 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1796 return (LRESULT)infoPtr->himlDis;
1800 inline static LRESULT
1801 TOOLBAR_GetExtendedStyle (HWND hwnd)
1803 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1805 return infoPtr->dwExStyle;
1810 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1812 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1814 return (LRESULT)infoPtr->himlHot;
1819 TOOLBAR_GetHotItem (HWND hwnd)
1821 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1823 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
1826 if (infoPtr->nHotItem < 0)
1829 return (LRESULT)infoPtr->nHotItem;
1834 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1836 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1838 return (LRESULT)infoPtr->himlDef;
1842 /* << TOOLBAR_GetInsertMark >> */
1843 /* << TOOLBAR_GetInsertMarkColor >> */
1847 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1849 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1850 TBUTTON_INFO *btnPtr;
1854 if (infoPtr == NULL)
1856 nIndex = (INT)wParam;
1857 btnPtr = &infoPtr->buttons[nIndex];
1858 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1860 lpRect = (LPRECT)lParam;
1863 if (btnPtr->fsState & TBSTATE_HIDDEN)
1866 TOOLBAR_CalcToolbar( hwnd );
1868 lpRect->left = btnPtr->rect.left;
1869 lpRect->right = btnPtr->rect.right;
1870 lpRect->bottom = btnPtr->rect.bottom;
1871 lpRect->top = btnPtr->rect.top;
1878 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1880 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1881 LPSIZE lpSize = (LPSIZE)lParam;
1886 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1887 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1889 TRACE("maximum size %d x %d\n",
1890 infoPtr->rcBound.right - infoPtr->rcBound.left,
1891 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1897 /* << TOOLBAR_GetObject >> */
1898 /* << TOOLBAR_GetPadding >> */
1902 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1904 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1905 TBUTTON_INFO *btnPtr;
1909 if (infoPtr == NULL)
1911 nIndex = (INT)wParam;
1912 btnPtr = &infoPtr->buttons[nIndex];
1913 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1915 lpRect = (LPRECT)lParam;
1919 lpRect->left = btnPtr->rect.left;
1920 lpRect->right = btnPtr->rect.right;
1921 lpRect->bottom = btnPtr->rect.bottom;
1922 lpRect->top = btnPtr->rect.top;
1929 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1931 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1933 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1934 return infoPtr->nRows;
1941 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1943 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1946 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1950 return infoPtr->buttons[nIndex].fsState;
1955 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1957 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1960 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1964 return infoPtr->buttons[nIndex].fsStyle;
1969 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1971 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1973 if (infoPtr == NULL)
1976 return infoPtr->nMaxTextRows;
1981 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1983 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1985 if (infoPtr == NULL)
1987 return infoPtr->hwndToolTip;
1992 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1994 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1996 TRACE("%s hwnd=0x%x stub!\n",
1997 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
1999 return infoPtr->bUnicode;
2003 inline static LRESULT
2004 TOOLBAR_GetVersion (HWND hwnd)
2006 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2007 return infoPtr->iVersion;
2012 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2014 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2015 TBUTTON_INFO *btnPtr;
2018 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2022 btnPtr = &infoPtr->buttons[nIndex];
2023 if (LOWORD(lParam) == FALSE)
2024 btnPtr->fsState &= ~TBSTATE_HIDDEN;
2026 btnPtr->fsState |= TBSTATE_HIDDEN;
2028 TOOLBAR_CalcToolbar (hwnd);
2030 InvalidateRect (hwnd, NULL, TRUE);
2036 inline static LRESULT
2037 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2039 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
2044 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2046 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2047 TBUTTON_INFO *btnPtr;
2051 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2055 btnPtr = &infoPtr->buttons[nIndex];
2056 if (LOWORD(lParam) == FALSE)
2057 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
2059 btnPtr->fsState |= TBSTATE_INDETERMINATE;
2062 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2063 ReleaseDC (hwnd, hdc);
2070 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2072 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2073 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2074 INT nIndex = (INT)wParam;
2075 TBUTTON_INFO *oldButtons;
2081 /* EPP: this seems to be an undocumented call (from my IE4)
2082 * I assume in that case that:
2083 * - lpTbb->iString is a string pointer (not a string index in strings[] table
2084 * - index of insertion is at the end of existing buttons
2085 * I only see this happen with nIndex == -1, but it could have a special
2086 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
2088 int len = lstrlenA((char*)lpTbb->iString) + 2;
2089 LPSTR ptr = COMCTL32_Alloc(len);
2091 nIndex = infoPtr->nNumButtons;
2092 strcpy(ptr, (char*)lpTbb->iString);
2093 ptr[len - 1] = 0; /* ended by two '\0' */
2094 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
2097 } else if (nIndex < 0)
2100 TRACE("inserting button index=%d\n", nIndex);
2101 if (nIndex > infoPtr->nNumButtons) {
2102 nIndex = infoPtr->nNumButtons;
2103 TRACE("adjust index=%d\n", nIndex);
2106 oldButtons = infoPtr->buttons;
2107 infoPtr->nNumButtons++;
2108 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2109 /* pre insert copy */
2111 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2112 nIndex * sizeof(TBUTTON_INFO));
2115 /* insert new button */
2116 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2117 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2118 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2119 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2120 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2121 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2123 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2126 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2127 ti.cbSize = sizeof (TTTOOLINFOA);
2129 ti.uId = lpTbb->idCommand;
2131 ti.lpszText = LPSTR_TEXTCALLBACKA;
2133 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2137 /* post insert copy */
2138 if (nIndex < infoPtr->nNumButtons - 1) {
2139 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2140 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2143 COMCTL32_Free (oldButtons);
2145 TOOLBAR_CalcToolbar (hwnd);
2147 InvalidateRect (hwnd, NULL, FALSE);
2154 TOOLBAR_InsertButtonW (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;
2166 TRACE("inserting button index=%d\n", nIndex);
2167 if (nIndex > infoPtr->nNumButtons) {
2168 nIndex = infoPtr->nNumButtons;
2169 TRACE("adjust index=%d\n", nIndex);
2172 oldButtons = infoPtr->buttons;
2173 infoPtr->nNumButtons++;
2174 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2175 /* pre insert copy */
2177 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2178 nIndex * sizeof(TBUTTON_INFO));
2181 /* insert new button */
2182 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2183 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2184 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2185 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2186 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2187 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2189 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2192 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2193 ti.cbSize = sizeof (TTTOOLINFOW);
2195 ti.uId = lpTbb->idCommand;
2197 ti.lpszText = LPSTR_TEXTCALLBACKW;
2199 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2203 /* post insert copy */
2204 if (nIndex < infoPtr->nNumButtons - 1) {
2205 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2206 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2209 COMCTL32_Free (oldButtons);
2211 TOOLBAR_CalcToolbar (hwnd);
2213 InvalidateRect (hwnd, NULL, FALSE);
2219 /* << TOOLBAR_InsertMarkHitTest >> */
2223 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
2225 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2228 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2232 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
2237 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
2239 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2242 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2246 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
2251 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
2253 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2256 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2260 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
2265 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
2267 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2270 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2274 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
2279 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2281 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2284 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2288 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
2293 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
2295 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2298 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2302 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
2306 /* << TOOLBAR_LoadImages >> */
2307 /* << TOOLBAR_MapAccelerator >> */
2308 /* << TOOLBAR_MarkButton >> */
2309 /* << TOOLBAR_MoveButton >> */
2313 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2315 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2316 TBUTTON_INFO *btnPtr;
2320 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2324 btnPtr = &infoPtr->buttons[nIndex];
2325 if (LOWORD(lParam) == FALSE)
2326 btnPtr->fsState &= ~TBSTATE_PRESSED;
2328 btnPtr->fsState |= TBSTATE_PRESSED;
2331 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2332 ReleaseDC (hwnd, hdc);
2338 /* << TOOLBAR_ReplaceBitmap >> */
2342 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2345 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2346 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2348 if (lpSave == NULL) return 0;
2351 /* save toolbar information */
2352 FIXME("save to \"%s\" \"%s\"\n",
2353 lpSave->pszSubKey, lpSave->pszValueName);
2358 /* restore toolbar information */
2360 FIXME("restore from \"%s\" \"%s\"\n",
2361 lpSave->pszSubKey, lpSave->pszValueName);
2372 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2375 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2376 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
2382 /* save toolbar information */
2383 FIXME("save to \"%s\" \"%s\"\n",
2384 lpSave->pszSubKey, lpSave->pszValueName);
2389 /* restore toolbar information */
2391 FIXME("restore from \"%s\" \"%s\"\n",
2392 lpSave->pszSubKey, lpSave->pszValueName);
2403 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
2405 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2406 BOOL bOldAnchor = infoPtr->bAnchor;
2408 infoPtr->bAnchor = (BOOL)wParam;
2410 return (LRESULT)bOldAnchor;
2415 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2417 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2419 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2422 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2423 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2430 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2432 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2433 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2434 TBUTTON_INFO *btnPtr;
2439 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2442 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2446 btnPtr = &infoPtr->buttons[nIndex];
2447 if (lptbbi->dwMask & TBIF_COMMAND)
2448 btnPtr->idCommand = lptbbi->idCommand;
2449 if (lptbbi->dwMask & TBIF_IMAGE)
2450 btnPtr->iBitmap = lptbbi->iImage;
2451 if (lptbbi->dwMask & TBIF_LPARAM)
2452 btnPtr->dwData = lptbbi->lParam;
2453 /* if (lptbbi->dwMask & TBIF_SIZE) */
2454 /* btnPtr->cx = lptbbi->cx; */
2455 if (lptbbi->dwMask & TBIF_STATE)
2456 btnPtr->fsState = lptbbi->fsState;
2457 if (lptbbi->dwMask & TBIF_STYLE)
2458 btnPtr->fsStyle = lptbbi->fsStyle;
2460 if (lptbbi->dwMask & TBIF_TEXT) {
2461 if ((btnPtr->iString >= 0) ||
2462 (btnPtr->iString < infoPtr->nNumStrings)) {
2463 TRACE("Ooooooch\n");
2465 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2466 INT len = lstrlenA (lptbbi->pszText);
2467 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2470 /* this is the ultimate sollution */
2471 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2480 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2482 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2483 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
2484 TBUTTON_INFO *btnPtr;
2489 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
2492 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2496 btnPtr = &infoPtr->buttons[nIndex];
2497 if (lptbbi->dwMask & TBIF_COMMAND)
2498 btnPtr->idCommand = lptbbi->idCommand;
2499 if (lptbbi->dwMask & TBIF_IMAGE)
2500 btnPtr->iBitmap = lptbbi->iImage;
2501 if (lptbbi->dwMask & TBIF_LPARAM)
2502 btnPtr->dwData = lptbbi->lParam;
2503 /* if (lptbbi->dwMask & TBIF_SIZE) */
2504 /* btnPtr->cx = lptbbi->cx; */
2505 if (lptbbi->dwMask & TBIF_STATE)
2506 btnPtr->fsState = lptbbi->fsState;
2507 if (lptbbi->dwMask & TBIF_STYLE)
2508 btnPtr->fsStyle = lptbbi->fsStyle;
2510 if (lptbbi->dwMask & TBIF_TEXT) {
2511 if ((btnPtr->iString >= 0) ||
2512 (btnPtr->iString < infoPtr->nNumStrings)) {
2514 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2515 INT len = lstrlenW (lptbbi->pszText);
2516 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2519 /* this is the ultimate sollution */
2520 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2529 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2531 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2533 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2536 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2537 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2544 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2546 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2548 if (infoPtr == NULL)
2551 infoPtr->cxMin = (INT)LOWORD(lParam);
2552 infoPtr->cxMax = (INT)HIWORD(lParam);
2559 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2561 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2562 INT nIndex = (INT)wParam;
2564 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2567 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2569 if (infoPtr->hwndToolTip) {
2571 FIXME("change tool tip!\n");
2579 /* << TOOLBAR_SetColorScheme >> */
2583 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2585 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2586 HIMAGELIST himlTemp;
2588 himlTemp = infoPtr->himlDis;
2589 infoPtr->himlDis = (HIMAGELIST)lParam;
2591 /* FIXME: redraw ? */
2593 return (LRESULT)himlTemp;
2598 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2600 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2603 dwTemp = infoPtr->dwDTFlags;
2604 infoPtr->dwDTFlags =
2605 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2607 return (LRESULT)dwTemp;
2612 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2614 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2617 dwTemp = infoPtr->dwExStyle;
2618 infoPtr->dwExStyle = (DWORD)lParam;
2620 return (LRESULT)dwTemp;
2625 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2627 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2628 HIMAGELIST himlTemp;
2630 himlTemp = infoPtr->himlHot;
2631 infoPtr->himlHot = (HIMAGELIST)lParam;
2633 /* FIXME: redraw ? */
2635 return (LRESULT)himlTemp;
2640 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
2642 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2643 INT nOldHotItem = infoPtr->nHotItem;
2645 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
2647 infoPtr->nHotItem = (INT)wParam;
2649 /* FIXME: What else must be done ??? */
2653 if (nOldHotItem < 0)
2656 return (LRESULT)nOldHotItem;
2661 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2663 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2664 HIMAGELIST himlTemp;
2666 himlTemp = infoPtr->himlDef;
2667 infoPtr->himlDef = (HIMAGELIST)lParam;
2669 /* FIXME: redraw ? */
2671 return (LRESULT)himlTemp;
2676 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2678 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2680 infoPtr->nIndent = (INT)wParam;
2682 TOOLBAR_CalcToolbar (hwnd);
2684 InvalidateRect(hwnd, NULL, FALSE);
2690 /* << TOOLBAR_SetInsertMark >> */
2694 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2696 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2698 infoPtr->clrInsertMark = (COLORREF)lParam;
2700 /* FIXME : redraw ??*/
2707 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2709 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2711 if (infoPtr == NULL)
2714 infoPtr->nMaxTextRows = (INT)wParam;
2720 /* << TOOLBAR_SetPadding >> */
2724 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2726 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2729 if (infoPtr == NULL)
2731 hwndOldNotify = infoPtr->hwndNotify;
2732 infoPtr->hwndNotify = (HWND)wParam;
2734 return hwndOldNotify;
2739 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2741 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2742 LPRECT lprc = (LPRECT)lParam;
2744 if (LOWORD(wParam) > 1) {
2746 FIXME("multiple rows not supported!\n");
2750 /* recalculate toolbar */
2751 TOOLBAR_CalcToolbar (hwnd);
2753 /* return bounding rectangle */
2755 lprc->left = infoPtr->rcBound.left;
2756 lprc->right = infoPtr->rcBound.right;
2757 lprc->top = infoPtr->rcBound.top;
2758 lprc->bottom = infoPtr->rcBound.bottom;
2761 /* repaint toolbar */
2762 InvalidateRect(hwnd, NULL, FALSE);
2769 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2771 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2772 TBUTTON_INFO *btnPtr;
2776 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2780 btnPtr = &infoPtr->buttons[nIndex];
2781 btnPtr->fsState = LOWORD(lParam);
2784 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2785 ReleaseDC (hwnd, hdc);
2792 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2794 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2795 TBUTTON_INFO *btnPtr;
2799 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2803 btnPtr = &infoPtr->buttons[nIndex];
2804 btnPtr->fsStyle = LOWORD(lParam);
2807 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2808 ReleaseDC (hwnd, hdc);
2810 if (infoPtr->hwndToolTip) {
2812 FIXME("change tool tip!\n");
2820 inline static LRESULT
2821 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2823 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2825 if (infoPtr == NULL)
2827 infoPtr->hwndToolTip = (HWND)wParam;
2833 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2835 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2838 TRACE("%s hwnd=0x%04x stub!\n",
2839 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2841 bTemp = infoPtr->bUnicode;
2842 infoPtr->bUnicode = (BOOL)wParam;
2849 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
2851 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2852 INT iOldVersion = infoPtr->iVersion;
2854 infoPtr->iVersion = iVersion;
2861 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2863 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2864 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2867 /* initialize info structure */
2868 infoPtr->nButtonHeight = 22;
2869 infoPtr->nButtonWidth = 23;
2870 infoPtr->nBitmapHeight = 15;
2871 infoPtr->nBitmapWidth = 16;
2873 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2875 infoPtr->nMaxTextRows = 1;
2876 infoPtr->cxMin = -1;
2877 infoPtr->cxMax = -1;
2879 infoPtr->bCaptured = FALSE;
2880 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2881 infoPtr->nButtonDown = -1;
2882 infoPtr->nOldHit = -1;
2883 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2884 infoPtr->hwndNotify = GetParent (hwnd);
2885 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2886 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
2887 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
2888 infoPtr->iVersion = 0;
2890 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2891 infoPtr->hFont = CreateFontIndirectA (&logFont);
2893 if (dwStyle & TBSTYLE_TOOLTIPS) {
2894 /* Create tooltip control */
2895 infoPtr->hwndToolTip =
2896 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2897 CW_USEDEFAULT, CW_USEDEFAULT,
2898 CW_USEDEFAULT, CW_USEDEFAULT,
2901 /* Send NM_TOOLTIPSCREATED notification */
2902 if (infoPtr->hwndToolTip) {
2903 NMTOOLTIPSCREATED nmttc;
2905 nmttc.hdr.hwndFrom = hwnd;
2906 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2907 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2908 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2910 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2911 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2920 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2922 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2924 /* delete tooltip control */
2925 if (infoPtr->hwndToolTip)
2926 DestroyWindow (infoPtr->hwndToolTip);
2928 /* delete button data */
2929 if (infoPtr->buttons)
2930 COMCTL32_Free (infoPtr->buttons);
2932 /* delete strings */
2933 if (infoPtr->strings) {
2935 for (i = 0; i < infoPtr->nNumStrings; i++)
2936 if (infoPtr->strings[i])
2937 COMCTL32_Free (infoPtr->strings[i]);
2939 COMCTL32_Free (infoPtr->strings);
2942 /* destroy internal image list */
2943 if (infoPtr->himlInt)
2944 ImageList_Destroy (infoPtr->himlInt);
2946 /* delete default font */
2948 DeleteObject (infoPtr->hFont);
2950 /* free toolbar info data */
2951 COMCTL32_Free (infoPtr);
2952 SetWindowLongA (hwnd, 0, 0);
2959 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2961 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2963 if (infoPtr->bTransparent)
2964 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2966 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2971 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2973 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2975 return infoPtr->hFont;
2980 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
2982 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2983 TBUTTON_INFO *btnPtr;
2988 pt.x = (INT)LOWORD(lParam);
2989 pt.y = (INT)HIWORD(lParam);
2990 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2993 btnPtr = &infoPtr->buttons[nHit];
2994 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2997 infoPtr->bCaptured = TRUE;
2998 infoPtr->nButtonDown = nHit;
3000 btnPtr->fsState |= TBSTATE_PRESSED;
3003 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3004 ReleaseDC (hwnd, hdc);
3006 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
3007 TOOLBAR_Customize (hwnd);
3014 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
3016 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3017 TBUTTON_INFO *btnPtr;
3022 if (infoPtr->hwndToolTip)
3023 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3024 WM_LBUTTONDOWN, wParam, lParam);
3026 pt.x = (INT)LOWORD(lParam);
3027 pt.y = (INT)HIWORD(lParam);
3028 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3031 btnPtr = &infoPtr->buttons[nHit];
3032 if (!(btnPtr->fsState & TBSTATE_ENABLED))
3035 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
3039 nmtb.hdr.hwndFrom = hwnd;
3040 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3041 nmtb.hdr.code = TBN_DROPDOWN;
3042 nmtb.iItem = btnPtr->idCommand;
3044 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
3045 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3049 infoPtr->bCaptured = TRUE;
3050 infoPtr->nButtonDown = nHit;
3051 infoPtr->nOldHit = nHit;
3053 btnPtr->fsState |= TBSTATE_PRESSED;
3056 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3057 ReleaseDC (hwnd, hdc);
3064 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
3066 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3067 TBUTTON_INFO *btnPtr;
3072 BOOL bSendMessage = TRUE;
3074 if (infoPtr->hwndToolTip)
3075 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3076 WM_LBUTTONUP, wParam, lParam);
3078 pt.x = (INT)LOWORD(lParam);
3079 pt.y = (INT)HIWORD(lParam);
3080 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3082 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
3083 infoPtr->bCaptured = FALSE;
3085 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3086 btnPtr->fsState &= ~TBSTATE_PRESSED;
3088 if (nHit == infoPtr->nButtonDown) {
3089 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
3090 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
3091 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
3092 infoPtr->nButtonDown);
3093 if (nOldIndex == infoPtr->nButtonDown)
3094 bSendMessage = FALSE;
3095 if ((nOldIndex != infoPtr->nButtonDown) &&
3097 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
3098 btnPtr->fsState |= TBSTATE_CHECKED;
3101 if (btnPtr->fsState & TBSTATE_CHECKED)
3102 btnPtr->fsState &= ~TBSTATE_CHECKED;
3104 btnPtr->fsState |= TBSTATE_CHECKED;
3109 bSendMessage = FALSE;
3112 if (nOldIndex != -1)
3113 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
3114 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3115 ReleaseDC (hwnd, hdc);
3118 SendMessageA (GetParent(hwnd), WM_COMMAND,
3119 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
3121 if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) ||
3122 (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) {
3125 nmtb.hdr.hwndFrom = hwnd;
3126 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3127 nmtb.hdr.code = TBN_DROPDOWN;
3129 /* nmtb.tbButton not used with TBN_DROPDOWN */
3130 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) {
3131 nmtb.pszText = infoPtr->strings[btnPtr->iString];
3132 nmtb.cchText = lstrlenW(nmtb.pszText);
3134 nmtb.pszText = NULL;
3137 nmtb.rcButton = btnPtr->rect;
3139 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
3140 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3143 infoPtr->nButtonDown = -1;
3144 infoPtr->nOldHit = -1;
3152 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
3154 TBUTTON_INFO *btnPtr, *oldBtnPtr;
3155 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3160 if (infoPtr->hwndToolTip)
3161 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3162 WM_MOUSEMOVE, wParam, lParam);
3164 pt.x = (INT)LOWORD(lParam);
3165 pt.y = (INT)HIWORD(lParam);
3167 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3169 if (infoPtr->nOldHit != nHit)
3171 /* Remove the effect of an old hot button */
3172 if(infoPtr->nOldHit == infoPtr->nHotItem)
3174 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
3175 oldBtnPtr->bHot = FALSE;
3177 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
3180 /* It's not a separator or in nowhere. It's a hot button. */
3183 btnPtr = &infoPtr->buttons[nHit];
3184 btnPtr->bHot = TRUE;
3187 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3188 ReleaseDC (hwnd, hdc);
3190 infoPtr->nHotItem = nHit;
3193 if (infoPtr->bCaptured) {
3194 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3195 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
3196 btnPtr->fsState &= ~TBSTATE_PRESSED;
3198 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3199 ReleaseDC (hwnd, hdc);
3201 else if (nHit == infoPtr->nButtonDown) {
3202 btnPtr->fsState |= TBSTATE_PRESSED;
3204 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3205 ReleaseDC (hwnd, hdc);
3208 infoPtr->nOldHit = nHit;
3214 inline static LRESULT
3215 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3217 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
3218 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
3220 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
3224 inline static LRESULT
3225 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3227 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
3228 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
3230 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
3235 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3237 TOOLBAR_INFO *infoPtr;
3239 /* allocate memory for info structure */
3240 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
3241 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3244 infoPtr->dwStructSize = sizeof(TBBUTTON);
3246 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
3247 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
3248 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
3249 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
3252 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
3257 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
3259 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3263 if (dwStyle & WS_MINIMIZE)
3264 return 0; /* Nothing to do */
3266 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
3268 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
3271 if (!(dwStyle & CCS_NODIVIDER))
3273 GetWindowRect (hwnd, &rcWindow);
3274 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3275 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
3278 ReleaseDC( hwnd, hdc );
3284 inline static LRESULT
3285 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
3287 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3288 LPNMHDR lpnmh = (LPNMHDR)lParam;
3290 TRACE("passing WM_NOTIFY!\n");
3292 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
3293 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
3296 if (lpnmh->code == TTN_GETDISPINFOA) {
3297 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
3299 FIXME("retrieving ASCII string\n");
3302 else if (lpnmh->code == TTN_GETDISPINFOW) {
3303 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
3305 FIXME("retrieving UNICODE string\n");
3316 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
3321 TOOLBAR_CalcToolbar( hwnd );
3322 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
3323 TOOLBAR_Refresh (hwnd, hdc);
3325 EndPaint (hwnd, &ps);
3331 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
3333 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3334 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3342 /* Resize deadlock check */
3343 if (infoPtr->bAutoSize) {
3344 infoPtr->bAutoSize = FALSE;
3348 flags = (INT) wParam;
3350 /* FIXME for flags =
3351 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
3354 TRACE("sizing toolbar!\n");
3356 if (flags == SIZE_RESTORED) {
3357 /* width and height don't apply */
3358 parent = GetParent (hwnd);
3359 GetClientRect(parent, &parent_rect);
3361 if (dwStyle & CCS_NORESIZE) {
3362 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
3365 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
3366 cy = infoPtr->nHeight;
3367 cx = infoPtr->nWidth;
3368 TOOLBAR_CalcToolbar (hwnd);
3369 infoPtr->nWidth = cx;
3370 infoPtr->nHeight = cy;
3373 infoPtr->nWidth = parent_rect.right - parent_rect.left;
3374 TOOLBAR_CalcToolbar (hwnd);
3375 cy = infoPtr->nHeight;
3376 cx = infoPtr->nWidth;
3379 if (dwStyle & CCS_NOPARENTALIGN) {
3380 uPosFlags |= SWP_NOMOVE;
3381 cy = infoPtr->nHeight;
3382 cx = infoPtr->nWidth;
3385 if (!(dwStyle & CCS_NODIVIDER))
3386 cy += GetSystemMetrics(SM_CYEDGE);
3388 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
3389 cx, cy, uPosFlags | SWP_NOZORDER);
3396 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
3398 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3400 if (nType == GWL_STYLE) {
3401 if (lpStyle->styleNew & TBSTYLE_LIST) {
3402 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
3405 infoPtr->dwDTFlags = DT_CENTER;
3409 TOOLBAR_AutoSize (hwnd);
3411 InvalidateRect(hwnd, NULL, FALSE);
3418 static LRESULT WINAPI
3419 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3425 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3428 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3431 if (!TOOLBAR_GetInfoPtr (hwnd))
3433 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3439 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
3441 case TB_ADDBUTTONSA:
3442 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
3444 case TB_ADDBUTTONSW:
3445 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
3448 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
3451 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
3454 return TOOLBAR_AutoSize (hwnd);
3456 case TB_BUTTONCOUNT:
3457 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
3459 case TB_BUTTONSTRUCTSIZE:
3460 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
3462 case TB_CHANGEBITMAP:
3463 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
3465 case TB_CHECKBUTTON:
3466 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
3468 case TB_COMMANDTOINDEX:
3469 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
3472 return TOOLBAR_Customize (hwnd);
3474 case TB_DELETEBUTTON:
3475 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
3477 case TB_ENABLEBUTTON:
3478 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
3480 case TB_GETANCHORHIGHLIGHT:
3481 return TOOLBAR_GetAnchorHighlight (hwnd);
3484 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
3486 case TB_GETBITMAPFLAGS:
3487 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
3490 return TOOLBAR_GetButton (hwnd, wParam, lParam);
3492 case TB_GETBUTTONINFOA:
3493 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
3495 case TB_GETBUTTONINFOW:
3496 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
3498 case TB_GETBUTTONSIZE:
3499 return TOOLBAR_GetButtonSize (hwnd);
3501 case TB_GETBUTTONTEXTA:
3502 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3504 case TB_GETBUTTONTEXTW:
3505 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
3507 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
3509 case TB_GETDISABLEDIMAGELIST:
3510 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3512 case TB_GETEXTENDEDSTYLE:
3513 return TOOLBAR_GetExtendedStyle (hwnd);
3515 case TB_GETHOTIMAGELIST:
3516 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3519 return TOOLBAR_GetHotItem (hwnd);
3521 case TB_GETIMAGELIST:
3522 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3524 /* case TB_GETINSERTMARK: */ /* 4.71 */
3525 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3527 case TB_GETITEMRECT:
3528 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3531 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3533 /* case TB_GETOBJECT: */ /* 4.71 */
3534 /* case TB_GETPADDING: */ /* 4.71 */
3537 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3540 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3543 return TOOLBAR_GetState (hwnd, wParam, lParam);
3546 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3548 case TB_GETTEXTROWS:
3549 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3551 case TB_GETTOOLTIPS:
3552 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3554 case TB_GETUNICODEFORMAT:
3555 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3557 case CCM_GETVERSION:
3558 return TOOLBAR_GetVersion (hwnd);
3561 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3564 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3566 case TB_INDETERMINATE:
3567 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3569 case TB_INSERTBUTTONA:
3570 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3572 case TB_INSERTBUTTONW:
3573 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
3575 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3577 case TB_ISBUTTONCHECKED:
3578 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3580 case TB_ISBUTTONENABLED:
3581 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3583 case TB_ISBUTTONHIDDEN:
3584 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3586 case TB_ISBUTTONHIGHLIGHTED:
3587 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3589 case TB_ISBUTTONINDETERMINATE:
3590 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3592 case TB_ISBUTTONPRESSED:
3593 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3595 case TB_LOADIMAGES: /* 4.70 */
3596 FIXME("missing standard imagelists\n");
3599 /* case TB_MAPACCELERATORA: */ /* 4.71 */
3600 /* case TB_MAPACCELERATORW: */ /* 4.71 */
3601 /* case TB_MARKBUTTON: */ /* 4.71 */
3602 /* case TB_MOVEBUTTON: */ /* 4.71 */
3604 case TB_PRESSBUTTON:
3605 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3607 /* case TB_REPLACEBITMAP: */
3609 case TB_SAVERESTOREA:
3610 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3612 case TB_SAVERESTOREW:
3613 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
3615 case TB_SETANCHORHIGHLIGHT:
3616 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
3618 case TB_SETBITMAPSIZE:
3619 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3621 case TB_SETBUTTONINFOA:
3622 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3624 case TB_SETBUTTONINFOW:
3625 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
3627 case TB_SETBUTTONSIZE:
3628 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3630 case TB_SETBUTTONWIDTH:
3631 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3634 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3636 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
3638 case TB_SETDISABLEDIMAGELIST:
3639 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3641 case TB_SETDRAWTEXTFLAGS:
3642 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3644 case TB_SETEXTENDEDSTYLE:
3645 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3647 case TB_SETHOTIMAGELIST:
3648 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3651 return TOOLBAR_SetHotItem (hwnd, wParam);
3653 case TB_SETIMAGELIST:
3654 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3657 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3659 /* case TB_SETINSERTMARK: */ /* 4.71 */
3661 case TB_SETINSERTMARKCOLOR:
3662 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3664 case TB_SETMAXTEXTROWS:
3665 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3667 /* case TB_SETPADDING: */ /* 4.71 */
3670 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3673 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3676 return TOOLBAR_SetState (hwnd, wParam, lParam);
3679 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3681 case TB_SETTOOLTIPS:
3682 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3684 case TB_SETUNICODEFORMAT:
3685 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3687 case CCM_SETVERSION:
3688 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
3694 return TOOLBAR_Create (hwnd, wParam, lParam);
3697 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3700 return TOOLBAR_GetFont (hwnd, wParam, lParam);
3702 /* case WM_KEYDOWN: */
3703 /* case WM_KILLFOCUS: */
3705 case WM_LBUTTONDBLCLK:
3706 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3708 case WM_LBUTTONDOWN:
3709 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3712 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3715 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3718 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3721 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3724 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3727 return TOOLBAR_Notify (hwnd, wParam, lParam);
3729 /* case WM_NOTIFYFORMAT: */
3732 return TOOLBAR_Paint (hwnd, wParam);
3735 return TOOLBAR_Size (hwnd, wParam, lParam);
3737 case WM_STYLECHANGED:
3738 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
3740 /* case WM_SYSCOLORCHANGE: */
3742 /* case WM_WININICHANGE: */
3747 case WM_MEASUREITEM:
3749 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3752 if (uMsg >= WM_USER)
3753 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
3754 uMsg, wParam, lParam);
3755 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3762 TOOLBAR_Register (void)
3766 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3767 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3768 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3769 wndClass.cbClsExtra = 0;
3770 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3771 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3772 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3773 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3775 RegisterClassA (&wndClass);
3780 TOOLBAR_Unregister (void)
3782 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);