4 * Copyright 1998,1999 Eric Kohl
5 * Copyright 2000 Eric Kohl for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Differences between MSDN and actual native control operation:
22 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
23 * to the right of the bitmap. Otherwise, this style is
24 * identical to TBSTYLE_FLAT."
25 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
26 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
27 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
28 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
32 * - A little bug in TOOLBAR_DrawMasked()
33 * - Button wrapping (under construction).
35 * - Notifications (under construction).
37 * - Tooltip support (almost complete).
38 * - Unicode suppport (under construction).
39 * - Fix TOOLBAR_SetButtonInfo32A/W.
40 * - TBSTYLE_AUTOSIZE for toolbar and buttons.
41 * - I_IMAGECALLBACK support.
42 * - iString of -1 is undocumented
43 * - Customization dialog:
45 * - Minor buglet in 'available buttons' list:
46 * Buttons are not listed in M$-like order. M$ seems to use a single
47 * internal list to store the button information of both listboxes.
48 * - Drag list support.
49 * - Help and Reset button support.
52 * - Run tests using Waite Group Windows95 API Bible Volume 2.
53 * The second cdrom contains executables addstr.exe, btncount.exe,
54 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
55 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
56 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
57 * setparnt.exe, setrows.exe, toolwnd.exe.
58 * - Microsofts controlspy examples.
59 * - Charles Petzold's 'Programming Windows': gadgets.exe
68 #include "wine/unicode.h"
70 #include "imagelist.h"
72 #include "wine/debug.h"
74 WINE_DEFAULT_DEBUG_CHANNEL(toolbar);
92 DWORD dwStructSize; /* size of TBBUTTON struct */
93 INT nHeight; /* height of the toolbar */
94 INT nWidth; /* width of the toolbar */
100 INT nRows; /* number of button rows */
101 INT nMaxTextRows; /* maximum number of text rows */
102 INT cxMin; /* minimum button width */
103 INT cxMax; /* maximum button width */
104 INT nNumButtons; /* number of buttons */
105 INT nNumBitmaps; /* number of bitmaps */
106 INT nNumStrings; /* number of strings */
107 BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
108 BOOL bCaptured; /* mouse captured? */
111 INT nHotItem; /* index of the "hot" item */
112 SIZE szPadding; /* padding values around button */
114 HFONT hFont; /* text font */
115 HIMAGELIST himlInt; /* image list created internally */
116 HIMAGELIST himlDef; /* default image list */
117 HIMAGELIST himlHot; /* hot image list */
118 HIMAGELIST himlDis; /* disabled image list */
119 HWND hwndToolTip; /* handle to tool tip control */
120 HWND hwndNotify; /* handle to the window that gets notifications */
121 HWND hwndSelf; /* my own handle */
122 BOOL bTransparent; /* background transparency flag */
123 BOOL bBtnTranspnt; /* button transparency flag */
124 BOOL bAutoSize; /* auto size deadlock indicator */
125 BOOL bAnchor; /* anchor highlight enabled */
126 BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
127 BOOL bDoRedraw; /* Redraw status */
128 DWORD dwExStyle; /* extended toolbar style */
129 DWORD dwDTFlags; /* DrawText flags */
131 COLORREF clrInsertMark; /* insert mark color */
132 RECT rcBound; /* bounding rectangle */
135 TBUTTON_INFO *buttons; /* pointer to button array */
136 LPWSTR *strings; /* pointer to string array */
137 } TOOLBAR_INFO, *PTOOLBAR_INFO;
140 /* used by customization dialog */
143 PTOOLBAR_INFO tbInfo;
145 } CUSTDLG_INFO, *PCUSTDLG_INFO;
153 } CUSTOMBUTTON, *PCUSTOMBUTTON;
156 #define SEPARATOR_WIDTH 8
158 #define BOTTOM_BORDER 2
159 #define DDARROW_WIDTH 11
161 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
162 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
163 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
165 /* Used to find undocumented extended styles */
166 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
167 TBSTYLE_EX_UNDOC1 | \
168 TBSTYLE_EX_MIXEDBUTTONS | \
169 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
174 TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
176 LPWSTR lpText = NULL;
178 /* FIXME: iString == -1 is undocumented */
179 if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
180 lpText = (LPWSTR)btnPtr->iString;
181 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
182 lpText = infoPtr->strings[btnPtr->iString];
188 TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
190 if (TRACE_ON(toolbar)){
191 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
192 btn_num, bP->idCommand,
193 bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
194 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr,bP)));
196 TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
197 btn_num, bP->idCommand,
198 (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
199 bP->rect.left, bP->rect.top,
200 bP->rect.right, bP->rect.bottom);
206 TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
208 if (TRACE_ON(toolbar)) {
212 dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
213 TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
215 iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
216 iP->nNumStrings, dwStyle);
217 TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
219 iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
220 (iP->bDoRedraw) ? "TRUE" : "FALSE");
221 for(i=0; i<iP->nNumButtons; i++) {
222 TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
228 /***********************************************************************
231 * This function validates that the styles set are implemented and
232 * issues FIXME's warning of possible problems. In a perfect world this
233 * function should be null.
236 TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
238 if (dwStyle & TBSTYLE_ALTDRAG)
239 FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd);
240 if (dwStyle & TBSTYLE_REGISTERDROP)
241 FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
246 TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
248 if(!IsWindow(infoPtr->hwndSelf))
249 return 0; /* we have just been destroyed */
251 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
252 nmhdr->hwndFrom = infoPtr->hwndSelf;
255 TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code,
256 (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
258 if (infoPtr->bNtfUnicode)
259 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
260 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
262 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
263 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
266 /***********************************************************************
267 * TOOLBAR_GetBitmapIndex
269 * This function returns the bitmap index associated with a button.
270 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
271 * is issued to retrieve the index.
274 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
276 INT ret = btnPtr->iBitmap;
278 if (ret == I_IMAGECALLBACK) {
279 /* issue TBN_GETDISPINFO */
282 nmgd.idCommand = btnPtr->idCommand;
283 nmgd.lParam = btnPtr->dwData;
284 nmgd.dwMask = TBNF_IMAGE;
285 TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
286 (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
288 if (nmgd.dwMask & TBNF_DI_SETITEM) {
289 btnPtr->iBitmap = nmgd.iImage;
292 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
293 ret, nmgd.dwMask, infoPtr->nNumBitmaps);
300 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
302 if (((index>=0) && (index <= infoPtr->nNumBitmaps)) ||
303 (index == I_IMAGECALLBACK))
310 /***********************************************************************
311 * TOOLBAR_DrawImageList
313 * This function validates the bitmap index (including I_IMAGECALLBACK
314 * functionality). It then draws the image via the ImageList_Draw
315 * function. It returns TRUE if the image was drawn, FALSE otherwise.
318 TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
319 HDC hdc, UINT left, UINT top, UINT draw_flags)
323 if (!himl) return FALSE;
325 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
326 ERR("index %d is not valid, max %d\n",
327 btnPtr->iBitmap, infoPtr->nNumBitmaps);
331 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
332 if (index == -1) return FALSE;
333 ERR("TBN_GETDISPINFO returned invalid index %d\n",
337 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
338 index, himl, left, top, draw_flags);
340 ImageList_Draw (himl, index, hdc, left, top, draw_flags);
345 /***********************************************************************
346 * TOOLBAR_TestImageExist
348 * This function is similar to TOOLBAR_DrawImageList, except it does not
349 * draw the image. The I_IMAGECALLBACK functionality is implemented.
352 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
356 if (!himl) return FALSE;
358 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
359 ERR("index %d is not valid, max %d\n",
360 btnPtr->iBitmap, infoPtr->nNumBitmaps);
364 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
365 if (index == -1) return FALSE;
366 ERR("TBN_GETDISPINFO returned invalid index %d\n",
375 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
377 INT x = (lpRect->left + lpRect->right) / 2 - 1;
378 INT yBottom = lpRect->bottom - 3;
379 INT yTop = lpRect->top + 1;
381 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
382 MoveToEx (hdc, x, yBottom, NULL);
383 LineTo (hdc, x, yTop);
385 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
386 MoveToEx (hdc, x, yBottom, NULL);
387 LineTo (hdc, x, yTop);
391 /***********************************************************************
392 * TOOLBAR_DrawDDFlatSeparator
394 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
395 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
396 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
397 * are horizontal as opposed to the vertical separators for not dropdown
400 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
403 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr)
406 COLORREF oldcolor, newcolor;
408 myrect.left = lpRect->left;
409 myrect.right = lpRect->right;
410 myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
411 myrect.bottom = myrect.top + 1;
413 InflateRect (&myrect, -2, 0);
415 TRACE("rect=(%d,%d)-(%d,%d)\n",
416 myrect.left, myrect.top, myrect.right, myrect.bottom);
418 newcolor = GetSysColor (COLOR_BTNSHADOW);
419 oldcolor = SetBkColor (hdc, newcolor);
420 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
422 myrect.top = myrect.bottom;
423 myrect.bottom = myrect.top + 1;
425 newcolor = GetSysColor (COLOR_BTNHIGHLIGHT);
426 SetBkColor (hdc, newcolor);
427 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
429 SetBkColor (hdc, oldcolor);
434 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
437 SelectObject ( hdc, GetSysColorPen (colorRef));
440 MoveToEx (hdc, x, y, NULL);
441 LineTo (hdc, x+5, y++); x++;
442 MoveToEx (hdc, x, y, NULL);
443 LineTo (hdc, x+3, y++); x++;
444 MoveToEx (hdc, x, y, NULL);
445 LineTo (hdc, x+1, y++);
449 * Draw the text string for this button.
450 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
451 * is non-zero, so we can simply check himlDef to see if we have
455 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
456 HDC hdc, INT nState, DWORD dwStyle)
458 RECT rcText = btnPtr->rect;
461 LPWSTR lpText = NULL;
462 HIMAGELIST himl = infoPtr->himlDef;
464 TRACE ("iString: %x\n", btnPtr->iString);
466 /* get a pointer to the text */
467 lpText = TOOLBAR_GetText(infoPtr, btnPtr);
469 TRACE ("Stringtext: %s\n", debugstr_w(lpText));
474 InflateRect (&rcText, -3, -3);
476 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
477 /* The following test looked like this before
478 * I changed it. IE4 "Links" toolbar would not
479 * draw correctly with the original code. - GA 8/01
480 * ((dwStyle & TBSTYLE_LIST) &&
481 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
482 * (btnPtr->iBitmap != I_IMAGENONE))
484 if (dwStyle & TBSTYLE_LIST) {
485 /* LIST style w/ ICON offset is by matching native. */
486 /* Matches IE4 "Links" bar. - GA 8/01 */
487 rcText.left += (infoPtr->nBitmapWidth + 2);
490 rcText.top += infoPtr->nBitmapHeight + 1;
494 if (dwStyle & TBSTYLE_LIST) {
495 /* LIST style w/o ICON offset is by matching native. */
496 /* Matches IE4 "menu" bar. - GA 8/01 */
501 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
502 OffsetRect (&rcText, 1, 1);
504 TRACE("string rect=(%d,%d)-(%d,%d)\n",
505 rcText.left, rcText.top, rcText.right, rcText.bottom);
507 hOldFont = SelectObject (hdc, infoPtr->hFont);
508 if (!(nState & TBSTATE_ENABLED)) {
509 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
510 OffsetRect (&rcText, 1, 1);
511 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
512 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
513 OffsetRect (&rcText, -1, -1);
514 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
516 else if (nState & TBSTATE_INDETERMINATE) {
517 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
518 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
521 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
522 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
525 SetTextColor (hdc, clrOld);
526 SelectObject (hdc, hOldFont);
532 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
534 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
535 INT cx = lpRect->right - lpRect->left;
536 INT cy = lpRect->bottom - lpRect->top;
537 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
538 SelectObject (hdc, hbr);
543 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
544 HDC hdc, INT x, INT y)
546 /* FIXME: this function is a hack since it uses image list
547 internals directly */
549 HIMAGELIST himl = infoPtr->himlDef;
557 /* create new dc's */
558 hdcImageList = CreateCompatibleDC (0);
559 hdcMask = CreateCompatibleDC (0);
561 /* create new bitmap */
562 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
563 SelectObject (hdcMask, hbmMask);
565 /* copy the mask bitmap */
566 SelectObject (hdcImageList, himl->hbmMask);
567 SetBkColor (hdcImageList, RGB(255, 255, 255));
568 SetTextColor (hdcImageList, RGB(0, 0, 0));
569 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
570 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
572 /* draw the new mask */
573 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
574 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
575 hdcMask, 0, 0, 0xB8074A);
577 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
578 BitBlt (hdc, x, y, himl->cx, himl->cy,
579 hdcMask, 0, 0, 0xB8074A);
581 DeleteObject (hbmMask);
583 DeleteDC (hdcImageList);
588 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
590 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
591 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
592 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
593 (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
594 RECT rc, rcArrow, rcBitmap;
596 if (btnPtr->fsState & TBSTATE_HIDDEN)
600 CopyRect (&rcArrow, &rc);
601 CopyRect(&rcBitmap, &rc);
603 if (!infoPtr->bBtnTranspnt)
604 FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
606 if (hasDropDownArrow)
608 if (dwStyle & TBSTYLE_FLAT)
609 rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
611 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
612 rcArrow.left = rc.right;
615 /* Center the bitmap horizontally and vertically */
616 if (dwStyle & TBSTYLE_LIST)
619 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
621 if(TOOLBAR_HasText(infoPtr, btnPtr))
622 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
624 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
626 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
627 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
628 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
631 if (btnPtr->fsStyle & TBSTYLE_SEP) {
632 /* with the FLAT style, iBitmap is the width and has already */
633 /* been taken into consideration in calculating the width */
634 /* so now we need to draw the vertical separator */
635 /* empirical tests show that iBitmap can/will be non-zero */
636 /* when drawing the vertical bar... */
637 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
638 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
639 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr);
641 TOOLBAR_DrawFlatSeparator (&rc, hdc);
644 FIXME("Draw some kind of separator: fsStyle=%x\n",
651 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
652 if (!(dwStyle & TBSTYLE_FLAT))
654 DrawEdge (hdc, &rc, EDGE_RAISED,
655 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
656 if (hasDropDownArrow)
657 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
658 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
661 if (hasDropDownArrow)
663 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
664 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
667 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
668 hdc, rcBitmap.left, rcBitmap.top,
670 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
672 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
676 /* pressed TBSTYLE_BUTTON */
677 if (btnPtr->fsState & TBSTATE_PRESSED) {
678 if (dwStyle & TBSTYLE_FLAT)
680 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
681 if (hasDropDownArrow)
682 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
686 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
687 if (hasDropDownArrow)
688 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
691 if (hasDropDownArrow)
692 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
694 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
695 hdc, rcBitmap.left+1, rcBitmap.top+1,
698 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
702 /* checked TBSTYLE_CHECK */
703 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
704 (btnPtr->fsState & TBSTATE_CHECKED)) {
705 if (dwStyle & TBSTYLE_FLAT)
706 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
707 BF_RECT | BF_ADJUST);
709 DrawEdge (hdc, &rc, EDGE_SUNKEN,
710 BF_RECT | BF_MIDDLE | BF_ADJUST);
712 TOOLBAR_DrawPattern (hdc, &rc);
714 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
715 hdc, rcBitmap.left+1, rcBitmap.top+1,
718 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
723 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
724 DrawEdge (hdc, &rc, EDGE_RAISED,
725 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
727 TOOLBAR_DrawPattern (hdc, &rc);
728 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
729 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
734 if (dwStyle & TBSTYLE_FLAT)
738 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
739 if (hasDropDownArrow)
740 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
743 else /* The following code needs to be removed after
744 * "hot item" support has been implemented for the
745 * case where it is being de-selected.
748 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
749 if (hasDropDownArrow)
750 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
754 if (hasDropDownArrow)
755 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
758 /* if hot, attempt to draw with himlHot, if fails, use himlDef */
759 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
762 rcBitmap.top, ILD_NORMAL))
763 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
764 hdc, rcBitmap.left, rcBitmap.top,
768 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
769 hdc, rcBitmap.left, rcBitmap.top,
774 DrawEdge (hdc, &rc, EDGE_RAISED,
775 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
777 if (hasDropDownArrow)
779 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
780 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
781 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
784 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
785 hdc, rcBitmap.left, rcBitmap.top,
789 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
794 TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
796 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
797 TBUTTON_INFO *btnPtr;
798 INT i, oldBKmode = 0;
801 /* if imagelist belongs to the app, it can be changed
802 by the app after setting it */
803 if (infoPtr->himlDef != infoPtr->himlInt)
804 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
806 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
808 if (infoPtr->bBtnTranspnt)
809 oldBKmode = SetBkMode (hdc, TRANSPARENT);
811 /* redraw necessary buttons */
812 btnPtr = infoPtr->buttons;
813 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
815 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
816 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
819 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
820 SetBkMode (hdc, oldBKmode);
823 /***********************************************************************
824 * TOOLBAR_MeasureString
826 * This function gets the width and height of a string in pixels. This
827 * is done first by using GetTextExtentPoint to get the basic width
828 * and height. The DrawText is called with DT_CALCRECT to get the exact
829 * width. The reason is because the text may have more than one "&" (or
830 * prefix characters as M$ likes to call them). The prefix character
831 * indicates where the underline goes, except for the string "&&" which
832 * is reduced to a single "&". GetTextExtentPoint does not process these
833 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
836 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
837 HDC hdc, LPSIZE lpSize)
844 if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
846 LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
849 /* first get size of all the text */
850 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
852 /* feed above size into the rectangle for DrawText */
853 myrect.left = myrect.top = 0;
854 myrect.right = lpSize->cx;
855 myrect.bottom = lpSize->cy;
857 /* Use DrawText to get true size as drawn (less pesky "&") */
858 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
859 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
862 /* feed back to caller */
863 lpSize->cx = myrect.right;
864 lpSize->cy = myrect.bottom;
868 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
871 /***********************************************************************
872 * TOOLBAR_CalcStrings
874 * This function walks through each string and measures it and returns
875 * the largest height and width to caller.
878 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
880 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
881 TBUTTON_INFO *btnPtr;
891 hOldFont = SelectObject (hdc, infoPtr->hFont);
893 btnPtr = infoPtr->buttons;
894 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
895 if(TOOLBAR_HasText(infoPtr, btnPtr))
897 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
898 if (sz.cx > lpSize->cx)
900 if (sz.cy > lpSize->cy)
905 SelectObject (hdc, hOldFont);
906 ReleaseDC (hwnd, hdc);
908 TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
911 /***********************************************************************
912 * TOOLBAR_WrapToolbar
914 * This function walks through the buttons and seperators in the
915 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
916 * wrapping should occur based on the width of the toolbar window.
917 * It does *not* calculate button placement itself. That task
918 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
919 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
920 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
922 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
923 * vertical toolbar lists.
927 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
929 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
930 TBUTTON_INFO *btnPtr;
933 BOOL bWrap, bButtonWrap;
935 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
936 /* no layout is necessary. Applications may use this style */
937 /* to perform their own layout on the toolbar. */
938 if( !(dwStyle & TBSTYLE_WRAPABLE) &&
939 !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) ) return;
941 btnPtr = infoPtr->buttons;
942 x = infoPtr->nIndent;
944 /* this can get the parents width, to know how far we can extend
945 * this toolbar. We cannot use its height, as there may be multiple
946 * toolbars in a rebar control
948 GetClientRect( GetParent(hwnd), &rc );
949 infoPtr->nWidth = rc.right - rc.left;
952 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
953 infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
956 for (i = 0; i < infoPtr->nNumButtons; i++ )
959 btnPtr[i].fsState &= ~TBSTATE_WRAP;
961 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
964 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
965 /* it is the actual width of the separator. This is used for */
966 /* custom controls in toolbars. */
968 /* TBSTYLE_DROPDOWN separators are treated as buttons for */
969 /* width. - GA 8/01 */
970 if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
971 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
972 cx = (btnPtr[i].iBitmap > 0) ?
973 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
975 cx = infoPtr->nButtonWidth;
977 /* Two or more adjacent separators form a separator group. */
978 /* The first separator in a group should be wrapped to the */
979 /* next row if the previous wrapping is on a button. */
981 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
982 (i + 1 < infoPtr->nNumButtons ) &&
983 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
985 TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
986 btnPtr[i].fsState |= TBSTATE_WRAP;
987 x = infoPtr->nIndent;
993 /* The layout makes sure the bitmap is visible, but not the button. */
994 /* Test added to also wrap after a button that starts a row but */
995 /* is bigger than the area. - GA 8/01 */
996 if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
997 > infoPtr->nWidth ) ||
998 ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
1000 BOOL bFound = FALSE;
1002 /* If the current button is a separator and not hidden, */
1003 /* go to the next until it reaches a non separator. */
1004 /* Wrap the last separator if it is before a button. */
1005 while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1006 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
1007 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
1008 i < infoPtr->nNumButtons )
1014 if( bFound && i < infoPtr->nNumButtons )
1017 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1018 i, btnPtr[i].fsStyle, x, cx);
1019 btnPtr[i].fsState |= TBSTATE_WRAP;
1020 x = infoPtr->nIndent;
1021 bButtonWrap = FALSE;
1024 else if ( i >= infoPtr->nNumButtons)
1027 /* If the current button is not a separator, find the last */
1028 /* separator and wrap it. */
1029 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1031 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
1032 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
1036 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1037 i, btnPtr[i].fsStyle, x, cx);
1038 x = infoPtr->nIndent;
1039 btnPtr[j].fsState |= TBSTATE_WRAP;
1040 bButtonWrap = FALSE;
1045 /* If no separator available for wrapping, wrap one of */
1046 /* non-hidden previous button. */
1050 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1052 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
1057 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1058 i, btnPtr[i].fsStyle, x, cx);
1059 x = infoPtr->nIndent;
1060 btnPtr[j].fsState |= TBSTATE_WRAP;
1066 /* If all above failed, wrap the current button. */
1069 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1070 i, btnPtr[i].fsStyle, x, cx);
1071 btnPtr[i].fsState |= TBSTATE_WRAP;
1073 x = infoPtr->nIndent;
1074 if (btnPtr[i].fsStyle & TBSTYLE_SEP )
1075 bButtonWrap = FALSE;
1081 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1082 i, btnPtr[i].fsStyle, x, cx);
1089 /***********************************************************************
1090 * TOOLBAR_CalcToolbar
1092 * This function calculates button and separator placement. It first
1093 * calculates the button sizes, gets the toolbar window width and then
1094 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1095 * on. It assigns a new location to each item and sends this location to
1096 * the tooltip window if appropriate. Finally, it updates the rcBound
1097 * rect and calculates the new required toolbar window height.
1101 TOOLBAR_CalcToolbar (HWND hwnd)
1103 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
1104 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1105 TBUTTON_INFO *btnPtr;
1106 INT i, nRows, nSepRows;
1110 BOOL usesBitmaps = FALSE;
1111 BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
1113 TOOLBAR_CalcStrings (hwnd, &sizeString);
1115 if (dwStyle & TBSTYLE_LIST)
1117 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
1119 if (infoPtr->buttons[i].iBitmap >= 0)
1122 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
1123 0, sizeString.cy) + 6;
1124 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
1125 0) + sizeString.cx + 6;
1126 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1127 infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
1128 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
1129 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
1132 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
1134 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
1138 if (sizeString.cy > 0)
1141 infoPtr->nButtonHeight = sizeString.cy +
1142 2 + /* this is the space to separate text from bitmap */
1143 infoPtr->nBitmapHeight + 6;
1145 infoPtr->nButtonHeight = sizeString.cy + 6;
1147 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
1148 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
1150 if (sizeString.cx > infoPtr->nBitmapWidth)
1151 infoPtr->nButtonWidth = sizeString.cx + 6;
1152 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
1153 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
1156 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
1157 infoPtr->nButtonWidth = infoPtr->cxMin;
1158 if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
1159 infoPtr->nButtonWidth = infoPtr->cxMax;
1161 TOOLBAR_WrapToolbar( hwnd, dwStyle );
1163 x = infoPtr->nIndent;
1167 * We will set the height below, and we set the width on entry
1168 * so we do not reset them here..
1171 GetClientRect( hwnd, &rc );
1172 /* get initial values for toolbar */
1173 infoPtr->nWidth = rc.right - rc.left;
1174 infoPtr->nHeight = rc.bottom - rc.top;
1177 /* from above, minimum is a button, and possible text */
1178 cx = infoPtr->nButtonWidth;
1180 /* cannot use just ButtonHeight, we may have no buttons! */
1181 if (infoPtr->nNumButtons > 0)
1182 infoPtr->nHeight = infoPtr->nButtonHeight;
1184 cy = infoPtr->nHeight;
1186 nRows = nSepRows = 0;
1188 infoPtr->rcBound.top = y;
1189 infoPtr->rcBound.left = x;
1190 infoPtr->rcBound.bottom = y + cy;
1191 infoPtr->rcBound.right = x;
1193 btnPtr = infoPtr->buttons;
1195 /* do not base height/width on parent, if the parent is a */
1196 /* rebar control it could have multiple rows of toolbars */
1197 /* GetClientRect( GetParent(hwnd), &rc ); */
1198 /* cx = rc.right - rc.left; */
1199 /* cy = rc.bottom - rc.top; */
1201 TRACE("cy=%d\n", cy);
1203 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
1206 if (btnPtr->fsState & TBSTATE_HIDDEN)
1208 SetRectEmpty (&btnPtr->rect);
1212 cy = infoPtr->nHeight;
1214 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1215 /* it is the actual width of the separator. This is used for */
1216 /* custom controls in toolbars. */
1217 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1218 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
1219 cy = (btnPtr->iBitmap > 0) ?
1220 btnPtr->iBitmap : SEPARATOR_WIDTH;
1221 cx = infoPtr->nButtonWidth;
1224 cx = (btnPtr->iBitmap > 0) ?
1225 btnPtr->iBitmap : SEPARATOR_WIDTH;
1229 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
1236 hOldFont = SelectObject (hdc, infoPtr->hFont);
1238 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1240 SelectObject (hdc, hOldFont);
1241 ReleaseDC (hwnd, hdc);
1243 /* Fudge amount measured against IE4 "menu" and "Links" */
1244 /* toolbars with native control (v4.71). - GA 8/01 */
1245 cx = sz.cx + 6 + 5 + 5;
1246 if ((dwStyle & TBSTYLE_LIST) &&
1247 (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
1248 cx += infoPtr->nBitmapWidth;
1251 cx = infoPtr->nButtonWidth;
1253 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1254 cx += DDARROW_WIDTH;
1256 if (btnPtr->fsState & TBSTATE_WRAP )
1259 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
1261 if (infoPtr->rcBound.left > x)
1262 infoPtr->rcBound.left = x;
1263 if (infoPtr->rcBound.right < x + cx)
1264 infoPtr->rcBound.right = x + cx;
1265 if (infoPtr->rcBound.bottom < y + cy)
1266 infoPtr->rcBound.bottom = y + cy;
1268 /* Set the toolTip only for non-hidden, non-separator button */
1269 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
1273 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1274 ti.cbSize = sizeof(TTTOOLINFOA);
1276 ti.uId = btnPtr->idCommand;
1277 ti.rect = btnPtr->rect;
1278 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
1282 /* btnPtr->nRow is zero based. The space between the rows is */
1283 /* also considered as a row. */
1284 btnPtr->nRow = nRows + nSepRows;
1286 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d\n",
1287 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow);
1291 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
1295 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1296 /* it is the actual width of the separator. This is used for */
1297 /* custom controls in toolbars. */
1298 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1299 y += cy + ( (btnPtr->iBitmap > 0 ) ?
1300 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
1304 /* nSepRows is used to calculate the extra height follwoing */
1308 x = infoPtr->nIndent;
1315 /* infoPtr->nRows is the number of rows on the toolbar */
1316 infoPtr->nRows = nRows + nSepRows + 1;
1318 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1320 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
1321 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
1322 nSepRows * (infoPtr->nBitmapHeight + 1) +
1324 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
1329 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
1331 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1332 TBUTTON_INFO *btnPtr;
1335 btnPtr = infoPtr->buttons;
1336 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1337 if (btnPtr->fsState & TBSTATE_HIDDEN)
1340 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1341 if (PtInRect (&btnPtr->rect, *lpPt)) {
1342 TRACE(" ON SEPARATOR %d!\n", i);
1347 if (PtInRect (&btnPtr->rect, *lpPt)) {
1348 TRACE(" ON BUTTON %d!\n", i);
1354 TRACE(" NOWHERE!\n");
1360 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
1362 TBUTTON_INFO *btnPtr;
1365 if (CommandIsIndex) {
1366 TRACE("command is really index command=%d\n", idCommand);
1367 if (idCommand >= infoPtr->nNumButtons) return -1;
1370 btnPtr = infoPtr->buttons;
1371 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1372 if (btnPtr->idCommand == idCommand) {
1373 TRACE("command=%d index=%d\n", idCommand, i);
1377 TRACE("no index found for command=%d\n", idCommand);
1383 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
1385 TBUTTON_INFO *btnPtr;
1388 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
1391 /* check index button */
1392 btnPtr = &infoPtr->buttons[nIndex];
1393 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1394 if (btnPtr->fsState & TBSTATE_CHECKED)
1398 /* check previous buttons */
1399 nRunIndex = nIndex - 1;
1400 while (nRunIndex >= 0) {
1401 btnPtr = &infoPtr->buttons[nRunIndex];
1402 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1403 if (btnPtr->fsState & TBSTATE_CHECKED)
1411 /* check next buttons */
1412 nRunIndex = nIndex + 1;
1413 while (nRunIndex < infoPtr->nNumButtons) {
1414 btnPtr = &infoPtr->buttons[nRunIndex];
1415 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1416 if (btnPtr->fsState & TBSTATE_CHECKED)
1429 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
1430 WPARAM wParam, LPARAM lParam)
1436 msg.wParam = wParam;
1437 msg.lParam = lParam;
1438 msg.time = GetMessageTime ();
1439 msg.pt.x = LOWORD(GetMessagePos ());
1440 msg.pt.y = HIWORD(GetMessagePos ());
1442 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
1446 /***********************************************************************
1447 * TOOLBAR_CustomizeDialogProc
1448 * This function implements the toolbar customization dialog.
1451 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1453 PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
1454 PCUSTOMBUTTON btnInfo;
1456 TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
1461 custInfo = (PCUSTDLG_INFO)lParam;
1462 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
1470 infoPtr = custInfo->tbInfo;
1472 /* send TBN_QUERYINSERT notification */
1473 nmtb.iItem = custInfo->tbInfo->nNumButtons;
1475 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
1478 /* add items to 'toolbar buttons' list and check if removable */
1479 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
1481 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1482 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1483 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1484 btnInfo->bVirtual = FALSE;
1485 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1487 /* send TBN_QUERYDELETE notification */
1489 btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
1493 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
1494 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1497 /* insert separator button into 'available buttons' list */
1498 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1499 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1500 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1501 btnInfo->bVirtual = FALSE;
1502 btnInfo->bRemovable = TRUE;
1503 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1504 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1505 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1507 /* insert all buttons into dsa */
1510 /* send TBN_GETBUTTONINFO notification */
1512 nmtb.pszText = Buffer;
1515 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA))
1518 TRACE("style: %x\n", nmtb.tbButton.fsStyle);
1520 /* insert button into the apropriate list */
1521 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
1524 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1525 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1526 btnInfo->bVirtual = FALSE;
1527 btnInfo->bRemovable = TRUE;
1528 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1529 strcpy (btnInfo->text, nmtb.pszText);
1531 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1532 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1536 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1537 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1538 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1539 strcpy (btnInfo->text, nmtb.pszText);
1541 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1545 /* select first item in the 'available' list */
1546 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
1548 /* append 'virtual' separator button to the 'toolbar buttons' list */
1549 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1550 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1551 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1552 btnInfo->bVirtual = TRUE;
1553 btnInfo->bRemovable = FALSE;
1554 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1555 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1556 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1558 /* select last item in the 'toolbar' list */
1559 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
1560 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
1562 /* set focus and disable buttons */
1563 PostMessageA (hwnd, WM_USER, 0, 0);
1568 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1569 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1570 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
1571 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
1575 EndDialog(hwnd, FALSE);
1579 switch (LOWORD(wParam))
1581 case IDC_TOOLBARBTN_LBOX:
1582 if (HIWORD(wParam) == LBN_SELCHANGE)
1584 PCUSTOMBUTTON btnInfo;
1589 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1590 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1592 /* send TBN_QUERYINSERT notification */
1594 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1597 /* get list box item */
1598 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1600 if (index == (count - 1))
1602 /* last item (virtual separator) */
1603 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1604 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1606 else if (index == (count - 2))
1608 /* second last item (last non-virtual item) */
1609 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1610 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1612 else if (index == 0)
1615 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1616 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1620 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1621 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1624 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
1628 case IDC_MOVEUP_BTN:
1630 PCUSTOMBUTTON btnInfo;
1634 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1635 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1636 TRACE("Move up: index %d\n", index);
1638 /* send TBN_QUERYINSERT notification */
1641 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1644 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1646 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1647 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
1648 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
1649 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1652 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1653 else if (index >= (count - 3))
1654 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1656 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1657 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
1662 case IDC_MOVEDN_BTN: /* move down */
1664 PCUSTOMBUTTON btnInfo;
1668 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1669 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1670 TRACE("Move up: index %d\n", index);
1672 /* send TBN_QUERYINSERT notification */
1674 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1677 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1679 /* move button down */
1680 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1681 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
1682 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
1683 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
1686 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1687 else if (index >= (count - 3))
1688 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1690 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1691 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
1696 case IDC_REMOVE_BTN: /* remove button */
1698 PCUSTOMBUTTON btnInfo;
1701 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1702 TRACE("Remove: index %d\n", index);
1704 /* send TBN_QUERYDELETE notification */
1706 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1709 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1710 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1711 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
1713 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1715 /* insert into 'available button' list */
1716 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
1718 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1719 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1722 COMCTL32_Free (btnInfo);
1727 case IDOK: /* Add button */
1732 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1733 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
1734 TRACE("Add: index %d\n", index);
1736 /* send TBN_QUERYINSERT notification */
1738 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1741 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
1745 /* remove from 'available buttons' list */
1746 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
1747 if (index == count-1)
1748 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1750 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
1754 PCUSTOMBUTTON btnNew;
1756 /* duplicate 'separator' button */
1757 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
1758 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
1762 /* insert into 'toolbar button' list */
1763 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1764 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
1765 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1767 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
1773 EndDialog(hwnd, FALSE);
1783 /* delete items from 'toolbar buttons' listbox*/
1784 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1785 for (i = 0; i < count; i++)
1787 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
1788 COMCTL32_Free(btnInfo);
1789 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
1791 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
1794 /* delete items from 'available buttons' listbox*/
1795 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1796 for (i = 0; i < count; i++)
1798 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
1799 COMCTL32_Free(btnInfo);
1800 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
1802 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
1807 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
1809 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
1814 COLORREF oldText = 0;
1818 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
1819 if (btnInfo == NULL)
1821 FIXME("btnInfo invalid!\n");
1825 /* set colors and select objects */
1826 oldBk = SetBkColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1827 if (btnInfo->bVirtual)
1828 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_GRAYTEXT));
1830 oldText = SetTextColor (lpdis->hDC, GetSysColor((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHTTEXT:COLOR_WINDOWTEXT));
1831 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1832 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1834 /* fill background rectangle */
1835 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
1836 lpdis->rcItem.right, lpdis->rcItem.bottom);
1838 /* calculate button and text rectangles */
1839 CopyRect (&rcButton, &lpdis->rcItem);
1840 InflateRect (&rcButton, -1, -1);
1841 CopyRect (&rcText, &rcButton);
1842 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
1843 rcText.left = rcButton.right + 2;
1845 /* draw focus rectangle */
1846 if (lpdis->itemState & ODS_FOCUS)
1847 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
1850 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
1852 /* draw image and text */
1853 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
1854 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
1855 rcButton.left+3, rcButton.top+3, ILD_NORMAL);
1856 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText,
1857 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
1859 /* delete objects and reset colors */
1860 SelectObject (lpdis->hDC, hOldBrush);
1861 SelectObject (lpdis->hDC, hOldPen);
1862 SetBkColor (lpdis->hDC, oldBk);
1863 SetTextColor (lpdis->hDC, oldText);
1869 case WM_MEASUREITEM:
1870 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
1872 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
1874 if (custInfo && custInfo->tbInfo)
1875 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
1877 lpmis->itemHeight = 15 + 8; /* default height */
1889 /***********************************************************************
1890 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
1894 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1896 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1897 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
1898 INT nIndex = 0, nButtons, nCount;
1901 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
1905 if (lpAddBmp->hInst == HINST_COMMCTRL)
1907 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
1909 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
1911 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
1916 TRACE ("adding %d internal bitmaps!\n", nButtons);
1918 /* Windows resize all the buttons to the size of a newly added standard image */
1919 if (lpAddBmp->nID & 1)
1922 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
1923 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
1925 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
1926 MAKELPARAM((WORD)24, (WORD)24));
1927 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
1928 MAKELPARAM((WORD)31, (WORD)30));
1933 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
1934 MAKELPARAM((WORD)16, (WORD)16));
1935 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
1936 MAKELPARAM((WORD)22, (WORD)22));
1939 TOOLBAR_CalcToolbar (hwnd);
1943 nButtons = (INT)wParam;
1947 TRACE ("adding %d bitmaps!\n", nButtons);
1950 if (!(infoPtr->himlDef)) {
1951 /* create new default image list */
1952 TRACE ("creating default image list!\n");
1955 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
1956 ILC_COLOR | ILC_MASK, nButtons, 2);
1957 infoPtr->himlInt = infoPtr->himlDef;
1960 nCount = ImageList_GetImageCount(infoPtr->himlDef);
1962 /* Add bitmaps to the default image list */
1963 if (lpAddBmp->hInst == (HINSTANCE)0)
1966 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
1969 else if (lpAddBmp->hInst == HINST_COMMCTRL)
1971 /* Add system bitmaps */
1972 switch (lpAddBmp->nID)
1974 case IDB_STD_SMALL_COLOR:
1975 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1976 MAKEINTRESOURCEA(IDB_STD_SMALL));
1977 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1978 hbmLoad, CLR_DEFAULT);
1979 DeleteObject (hbmLoad);
1982 case IDB_STD_LARGE_COLOR:
1983 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1984 MAKEINTRESOURCEA(IDB_STD_LARGE));
1985 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1986 hbmLoad, CLR_DEFAULT);
1987 DeleteObject (hbmLoad);
1990 case IDB_VIEW_SMALL_COLOR:
1991 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1992 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
1993 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1994 hbmLoad, CLR_DEFAULT);
1995 DeleteObject (hbmLoad);
1998 case IDB_VIEW_LARGE_COLOR:
1999 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2000 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
2001 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2002 hbmLoad, CLR_DEFAULT);
2003 DeleteObject (hbmLoad);
2006 case IDB_HIST_SMALL_COLOR:
2007 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2008 MAKEINTRESOURCEA(IDB_HIST_SMALL));
2009 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2010 hbmLoad, CLR_DEFAULT);
2011 DeleteObject (hbmLoad);
2014 case IDB_HIST_LARGE_COLOR:
2015 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2016 MAKEINTRESOURCEA(IDB_HIST_LARGE));
2017 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2018 hbmLoad, CLR_DEFAULT);
2019 DeleteObject (hbmLoad);
2023 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
2024 ERR ("invalid imagelist!\n");
2030 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
2031 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
2032 DeleteObject (hbmLoad);
2037 INT imagecount = ImageList_GetImageCount(infoPtr->himlDef);
2039 if (infoPtr->nNumBitmaps + nButtons != imagecount)
2041 WARN("Desired images do not match received images : Previous image number %i Previous images in list %i added %i expecting total %i, Images in list %i\n",
2042 infoPtr->nNumBitmaps, nCount, imagecount - nCount,
2043 infoPtr->nNumBitmaps+nButtons,imagecount);
2045 infoPtr->nNumBitmaps = imagecount;
2048 infoPtr->nNumBitmaps += nButtons;
2051 InvalidateRect(hwnd, NULL, FALSE);
2058 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2060 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2061 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2062 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2064 TRACE("adding %d buttons!\n", wParam);
2066 nAddButtons = (UINT)wParam;
2067 nOldButtons = infoPtr->nNumButtons;
2068 nNewButtons = nOldButtons + nAddButtons;
2070 if (infoPtr->nNumButtons == 0) {
2072 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2075 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2077 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2078 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2079 nOldButtons * sizeof(TBUTTON_INFO));
2080 COMCTL32_Free (oldButtons);
2083 infoPtr->nNumButtons = nNewButtons;
2085 /* insert new button data */
2086 for (nCount = 0; nCount < nAddButtons; nCount++) {
2087 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2088 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2089 btnPtr->idCommand = lpTbb[nCount].idCommand;
2090 btnPtr->fsState = lpTbb[nCount].fsState;
2091 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2092 btnPtr->dwData = lpTbb[nCount].dwData;
2093 btnPtr->iString = lpTbb[nCount].iString;
2094 btnPtr->bHot = FALSE;
2096 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2099 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2100 ti.cbSize = sizeof (TTTOOLINFOA);
2102 ti.uId = btnPtr->idCommand;
2104 ti.lpszText = LPSTR_TEXTCALLBACKA;
2106 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2111 TOOLBAR_CalcToolbar (hwnd);
2113 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2115 InvalidateRect(hwnd, NULL, FALSE);
2122 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2124 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2125 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2126 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2128 TRACE("adding %d buttons!\n", wParam);
2130 nAddButtons = (UINT)wParam;
2131 nOldButtons = infoPtr->nNumButtons;
2132 nNewButtons = nOldButtons + nAddButtons;
2134 if (infoPtr->nNumButtons == 0) {
2136 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2139 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2141 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2142 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2143 nOldButtons * sizeof(TBUTTON_INFO));
2144 COMCTL32_Free (oldButtons);
2147 infoPtr->nNumButtons = nNewButtons;
2149 /* insert new button data */
2150 for (nCount = 0; nCount < nAddButtons; nCount++) {
2151 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2152 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2153 btnPtr->idCommand = lpTbb[nCount].idCommand;
2154 btnPtr->fsState = lpTbb[nCount].fsState;
2155 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2156 btnPtr->dwData = lpTbb[nCount].dwData;
2157 btnPtr->iString = lpTbb[nCount].iString;
2158 btnPtr->bHot = FALSE;
2160 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2163 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2164 ti.cbSize = sizeof (TTTOOLINFOW);
2166 ti.uId = btnPtr->idCommand;
2168 ti.lpszText = LPSTR_TEXTCALLBACKW;
2170 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2175 TOOLBAR_CalcToolbar (hwnd);
2177 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2179 InvalidateRect(hwnd, NULL, FALSE);
2186 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2188 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2191 if ((wParam) && (HIWORD(lParam) == 0)) {
2194 TRACE("adding string from resource!\n");
2196 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
2199 TRACE("len=%d \"%s\"\n", len, szString);
2200 nIndex = infoPtr->nNumStrings;
2201 if (infoPtr->nNumStrings == 0) {
2203 COMCTL32_Alloc (sizeof(LPWSTR));
2206 LPWSTR *oldStrings = infoPtr->strings;
2208 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2209 memcpy (&infoPtr->strings[0], &oldStrings[0],
2210 sizeof(LPWSTR) * infoPtr->nNumStrings);
2211 COMCTL32_Free (oldStrings);
2214 /*COMCTL32_Alloc zeros out the allocated memory*/
2215 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
2216 infoPtr->nNumStrings++;
2219 LPSTR p = (LPSTR)lParam;
2224 TRACE("adding string(s) from array!\n");
2226 nIndex = infoPtr->nNumStrings;
2229 TRACE("len=%d \"%s\"\n", len, p);
2231 if (infoPtr->nNumStrings == 0) {
2233 COMCTL32_Alloc (sizeof(LPWSTR));
2236 LPWSTR *oldStrings = infoPtr->strings;
2238 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2239 memcpy (&infoPtr->strings[0], &oldStrings[0],
2240 sizeof(LPWSTR) * infoPtr->nNumStrings);
2241 COMCTL32_Free (oldStrings);
2244 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
2245 infoPtr->nNumStrings++;
2256 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2258 #define MAX_RESOURCE_STRING_LENGTH 512
2259 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2262 if ((wParam) && (HIWORD(lParam) == 0)) {
2263 WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
2265 TRACE("adding string from resource!\n");
2267 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
2268 szString, MAX_RESOURCE_STRING_LENGTH);
2270 TRACE("len=%d %s\n", len, debugstr_w(szString));
2271 TRACE("First char: 0x%x\n", *szString);
2272 if (szString[0] == L'|')
2274 PWSTR p = szString + 1;
2276 nIndex = infoPtr->nNumStrings;
2277 while (*p != L'|') {
2279 if (infoPtr->nNumStrings == 0) {
2281 COMCTL32_Alloc (sizeof(LPWSTR));
2284 LPWSTR *oldStrings = infoPtr->strings;
2286 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2287 memcpy (&infoPtr->strings[0], &oldStrings[0],
2288 sizeof(LPWSTR) * infoPtr->nNumStrings);
2289 COMCTL32_Free (oldStrings);
2292 len = COMCTL32_StrChrW (p, L'|') - p;
2293 TRACE("len=%d %s\n", len, debugstr_w(p));
2294 infoPtr->strings[infoPtr->nNumStrings] =
2295 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
2296 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
2297 infoPtr->nNumStrings++;
2304 nIndex = infoPtr->nNumStrings;
2305 if (infoPtr->nNumStrings == 0) {
2307 COMCTL32_Alloc (sizeof(LPWSTR));
2310 LPWSTR *oldStrings = infoPtr->strings;
2312 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2313 memcpy (&infoPtr->strings[0], &oldStrings[0],
2314 sizeof(LPWSTR) * infoPtr->nNumStrings);
2315 COMCTL32_Free (oldStrings);
2318 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
2319 infoPtr->nNumStrings++;
2323 LPWSTR p = (LPWSTR)lParam;
2328 TRACE("adding string(s) from array!\n");
2329 nIndex = infoPtr->nNumStrings;
2333 TRACE("len=%d %s\n", len, debugstr_w(p));
2334 if (infoPtr->nNumStrings == 0) {
2336 COMCTL32_Alloc (sizeof(LPWSTR));
2339 LPWSTR *oldStrings = infoPtr->strings;
2341 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2342 memcpy (&infoPtr->strings[0], &oldStrings[0],
2343 sizeof(LPWSTR) * infoPtr->nNumStrings);
2344 COMCTL32_Free (oldStrings);
2347 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
2348 infoPtr->nNumStrings++;
2359 TOOLBAR_AutoSize (HWND hwnd)
2361 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2362 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2368 UINT uPosFlags = SWP_NOZORDER;
2370 TRACE("resize forced, style=%lx!\n", dwStyle);
2372 parent = GetParent (hwnd);
2373 GetClientRect(parent, &parent_rect);
2375 x = parent_rect.left;
2376 y = parent_rect.top;
2378 /* FIXME: we should be able to early out if nothing */
2379 /* has changed with nWidth != parent_rect width */
2381 if (dwStyle & CCS_NORESIZE) {
2382 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2385 TOOLBAR_CalcToolbar (hwnd);
2388 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2389 TOOLBAR_CalcToolbar (hwnd);
2390 InvalidateRect( hwnd, NULL, TRUE );
2391 cy = infoPtr->nHeight;
2392 cx = infoPtr->nWidth;
2394 if (dwStyle & CCS_NOMOVEY) {
2395 GetWindowRect(hwnd, &window_rect);
2396 ScreenToClient(parent, (LPPOINT)&window_rect.left);
2397 y = window_rect.top;
2401 if (dwStyle & CCS_NOPARENTALIGN)
2402 uPosFlags |= SWP_NOMOVE;
2404 if (!(dwStyle & CCS_NODIVIDER))
2405 cy += GetSystemMetrics(SM_CYEDGE);
2407 if (dwStyle & WS_BORDER)
2410 cy += GetSystemMetrics(SM_CYEDGE);
2411 cx += GetSystemMetrics(SM_CYEDGE);
2414 infoPtr->bAutoSize = TRUE;
2415 SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
2417 /* The following line makes sure that the infoPtr->bAutoSize is turned off after
2418 * the setwindowpos calls */
2419 infoPtr->bAutoSize = FALSE;
2426 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
2428 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2430 return infoPtr->nNumButtons;
2435 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2437 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2439 if (infoPtr == NULL) {
2440 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
2441 ERR("infoPtr == NULL!\n");
2445 infoPtr->dwStructSize = (DWORD)wParam;
2452 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2454 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2455 TBUTTON_INFO *btnPtr;
2458 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2462 btnPtr = &infoPtr->buttons[nIndex];
2463 btnPtr->iBitmap = LOWORD(lParam);
2465 /* we HAVE to erase the background, the new bitmap could be */
2467 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2474 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2476 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2477 TBUTTON_INFO *btnPtr;
2480 BOOL bChecked = FALSE;
2482 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2486 btnPtr = &infoPtr->buttons[nIndex];
2488 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
2491 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
2493 if (LOWORD(lParam) == FALSE)
2494 btnPtr->fsState &= ~TBSTATE_CHECKED;
2496 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2498 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
2499 if (nOldIndex == nIndex)
2501 if (nOldIndex != -1)
2502 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2504 btnPtr->fsState |= TBSTATE_CHECKED;
2507 if( bChecked != LOWORD(lParam) )
2509 if (nOldIndex != -1)
2511 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
2512 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
2514 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2517 /* FIXME: Send a WM_NOTIFY?? */
2524 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
2526 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2528 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2533 TOOLBAR_Customize (HWND hwnd)
2535 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2536 CUSTDLG_INFO custInfo;
2542 custInfo.tbInfo = infoPtr;
2543 custInfo.tbHwnd = hwnd;
2545 /* send TBN_BEGINADJUST notification */
2546 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2549 if (!(hRes = FindResourceA (COMCTL32_hModule,
2550 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
2554 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
2557 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
2558 (LPDLGTEMPLATEA)template,
2560 (DLGPROC)TOOLBAR_CustomizeDialogProc,
2563 /* send TBN_ENDADJUST notification */
2564 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2572 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2574 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2575 INT nIndex = (INT)wParam;
2577 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2580 if ((infoPtr->hwndToolTip) &&
2581 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
2584 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2585 ti.cbSize = sizeof (TTTOOLINFOA);
2587 ti.uId = infoPtr->buttons[nIndex].idCommand;
2589 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
2592 if (infoPtr->nNumButtons == 1) {
2593 TRACE(" simple delete!\n");
2594 COMCTL32_Free (infoPtr->buttons);
2595 infoPtr->buttons = NULL;
2596 infoPtr->nNumButtons = 0;
2599 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2600 TRACE("complex delete! [nIndex=%d]\n", nIndex);
2602 infoPtr->nNumButtons--;
2603 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2605 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2606 nIndex * sizeof(TBUTTON_INFO));
2609 if (nIndex < infoPtr->nNumButtons) {
2610 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
2611 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
2614 COMCTL32_Free (oldButtons);
2617 TOOLBAR_CalcToolbar (hwnd);
2619 InvalidateRect (hwnd, NULL, TRUE);
2626 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2628 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2629 TBUTTON_INFO *btnPtr;
2633 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2637 btnPtr = &infoPtr->buttons[nIndex];
2639 bState = btnPtr->fsState & TBSTATE_ENABLED;
2641 /* update the toolbar button state */
2642 if(LOWORD(lParam) == FALSE) {
2643 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
2645 btnPtr->fsState |= TBSTATE_ENABLED;
2648 /* redraw the button only if the state of the button changed */
2649 if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
2651 InvalidateRect(hwnd, &btnPtr->rect,
2652 TOOLBAR_HasText(infoPtr, btnPtr));
2659 static inline LRESULT
2660 TOOLBAR_GetAnchorHighlight (HWND hwnd)
2662 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2664 return infoPtr->bAnchor;
2669 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2671 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2674 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2678 return infoPtr->buttons[nIndex].iBitmap;
2682 static inline LRESULT
2683 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2685 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
2690 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2692 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2693 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2694 INT nIndex = (INT)wParam;
2695 TBUTTON_INFO *btnPtr;
2697 if (infoPtr == NULL)
2703 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2706 btnPtr = &infoPtr->buttons[nIndex];
2707 lpTbb->iBitmap = btnPtr->iBitmap;
2708 lpTbb->idCommand = btnPtr->idCommand;
2709 lpTbb->fsState = btnPtr->fsState;
2710 lpTbb->fsStyle = btnPtr->fsStyle;
2711 lpTbb->dwData = btnPtr->dwData;
2712 lpTbb->iString = btnPtr->iString;
2719 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2721 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2722 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
2723 TBUTTON_INFO *btnPtr;
2726 if (infoPtr == NULL)
2728 if (lpTbInfo == NULL)
2730 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
2733 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
2734 lpTbInfo->dwMask & 0x80000000);
2738 if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
2740 if (lpTbInfo->dwMask & TBIF_COMMAND)
2741 lpTbInfo->idCommand = btnPtr->idCommand;
2742 if (lpTbInfo->dwMask & TBIF_IMAGE)
2743 lpTbInfo->iImage = btnPtr->iBitmap;
2744 if (lpTbInfo->dwMask & TBIF_LPARAM)
2745 lpTbInfo->lParam = btnPtr->dwData;
2746 if (lpTbInfo->dwMask & TBIF_SIZE)
2747 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
2748 if (lpTbInfo->dwMask & TBIF_STATE)
2749 lpTbInfo->fsState = btnPtr->fsState;
2750 if (lpTbInfo->dwMask & TBIF_STYLE)
2751 lpTbInfo->fsStyle = btnPtr->fsStyle;
2752 if (lpTbInfo->dwMask & TBIF_TEXT) {
2753 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
2754 Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
2761 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2763 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2764 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
2765 TBUTTON_INFO *btnPtr;
2768 if (infoPtr == NULL)
2770 if (lpTbInfo == NULL)
2772 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
2775 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
2776 lpTbInfo->dwMask & 0x80000000);
2780 btnPtr = &infoPtr->buttons[nIndex];
2782 if (lpTbInfo->dwMask & TBIF_COMMAND)
2783 lpTbInfo->idCommand = btnPtr->idCommand;
2784 if (lpTbInfo->dwMask & TBIF_IMAGE)
2785 lpTbInfo->iImage = btnPtr->iBitmap;
2786 if (lpTbInfo->dwMask & TBIF_LPARAM)
2787 lpTbInfo->lParam = btnPtr->dwData;
2788 if (lpTbInfo->dwMask & TBIF_SIZE)
2789 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
2790 if (lpTbInfo->dwMask & TBIF_STATE)
2791 lpTbInfo->fsState = btnPtr->fsState;
2792 if (lpTbInfo->dwMask & TBIF_STYLE)
2793 lpTbInfo->fsStyle = btnPtr->fsStyle;
2794 if (lpTbInfo->dwMask & TBIF_TEXT) {
2795 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
2796 Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
2804 TOOLBAR_GetButtonSize (HWND hwnd)
2806 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2808 if (infoPtr->nNumButtons > 0)
2809 return MAKELONG((WORD)infoPtr->nButtonWidth,
2810 (WORD)infoPtr->nButtonHeight);
2812 return MAKELONG(8,7);
2817 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2819 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2826 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2830 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
2832 return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
2833 (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
2838 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2840 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2847 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2851 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
2853 strcpyW ((LPWSTR)lParam, lpText);
2855 return strlenW (lpText);
2859 /* << TOOLBAR_GetColorScheme >> */
2863 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2865 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2867 return (LRESULT)infoPtr->himlDis;
2871 inline static LRESULT
2872 TOOLBAR_GetExtendedStyle (HWND hwnd)
2874 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2876 return infoPtr->dwExStyle;
2881 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2883 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2885 return (LRESULT)infoPtr->himlHot;
2890 TOOLBAR_GetHotItem (HWND hwnd)
2892 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2894 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2897 if (infoPtr->nHotItem < 0)
2900 return (LRESULT)infoPtr->nHotItem;
2905 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2907 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2909 return (LRESULT)infoPtr->himlDef;
2913 /* << TOOLBAR_GetInsertMark >> */
2914 /* << TOOLBAR_GetInsertMarkColor >> */
2918 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
2920 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2921 TBUTTON_INFO *btnPtr;
2925 if (infoPtr == NULL)
2927 nIndex = (INT)wParam;
2928 btnPtr = &infoPtr->buttons[nIndex];
2929 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2931 lpRect = (LPRECT)lParam;
2934 if (btnPtr->fsState & TBSTATE_HIDDEN)
2937 lpRect->left = btnPtr->rect.left;
2938 lpRect->right = btnPtr->rect.right;
2939 lpRect->bottom = btnPtr->rect.bottom;
2940 lpRect->top = btnPtr->rect.top;
2947 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2949 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2950 LPSIZE lpSize = (LPSIZE)lParam;
2955 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
2956 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
2958 TRACE("maximum size %d x %d\n",
2959 infoPtr->rcBound.right - infoPtr->rcBound.left,
2960 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
2966 /* << TOOLBAR_GetObject >> */
2970 TOOLBAR_GetPadding (HWND hwnd)
2972 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2975 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
2976 return (LRESULT) oldPad;
2981 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
2983 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2984 TBUTTON_INFO *btnPtr;
2988 if (infoPtr == NULL)
2990 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2991 btnPtr = &infoPtr->buttons[nIndex];
2992 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2994 lpRect = (LPRECT)lParam;
2998 lpRect->left = btnPtr->rect.left;
2999 lpRect->right = btnPtr->rect.right;
3000 lpRect->bottom = btnPtr->rect.bottom;
3001 lpRect->top = btnPtr->rect.top;
3008 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3010 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3012 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
3013 return infoPtr->nRows;
3020 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
3022 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3025 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3029 return infoPtr->buttons[nIndex].fsState;
3034 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3036 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3039 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3043 return infoPtr->buttons[nIndex].fsStyle;
3048 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3050 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3052 if (infoPtr == NULL)
3055 return infoPtr->nMaxTextRows;
3060 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
3062 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3064 if (infoPtr == NULL)
3066 return infoPtr->hwndToolTip;
3071 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
3073 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3075 TRACE("%s hwnd=0x%x stub!\n",
3076 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
3078 return infoPtr->bUnicode;
3082 inline static LRESULT
3083 TOOLBAR_GetVersion (HWND hwnd)
3085 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3086 return infoPtr->iVersion;
3091 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3093 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3094 TBUTTON_INFO *btnPtr;
3099 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3103 btnPtr = &infoPtr->buttons[nIndex];
3104 if (LOWORD(lParam) == FALSE)
3105 btnPtr->fsState &= ~TBSTATE_HIDDEN;
3107 btnPtr->fsState |= TBSTATE_HIDDEN;
3109 TOOLBAR_CalcToolbar (hwnd);
3111 InvalidateRect (hwnd, NULL, TRUE);
3117 inline static LRESULT
3118 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
3120 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
3125 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3127 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3128 TBUTTON_INFO *btnPtr;
3131 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3135 btnPtr = &infoPtr->buttons[nIndex];
3136 if (LOWORD(lParam) == FALSE)
3137 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
3139 btnPtr->fsState |= TBSTATE_INDETERMINATE;
3141 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3148 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3150 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3151 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3152 INT nIndex = (INT)wParam;
3153 TBUTTON_INFO *oldButtons;
3158 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3161 /* EPP: this seems to be an undocumented call (from my IE4)
3162 * I assume in that case that:
3163 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3164 * - index of insertion is at the end of existing buttons
3165 * I only see this happen with nIndex == -1, but it could have a special
3166 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3168 nIndex = infoPtr->nNumButtons;
3170 } else if (nIndex < 0)
3173 /* If the string passed is not an index, assume address of string
3174 and do our own AddString */
3175 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3179 TRACE("string %s passed instead of index, adding string\n",
3180 debugstr_a((LPSTR)lpTbb->iString));
3181 len = strlen((LPSTR)lpTbb->iString) + 2;
3182 ptr = COMCTL32_Alloc(len);
3183 strcpy(ptr, (LPSTR)lpTbb->iString);
3184 ptr[len - 1] = 0; /* ended by two '\0' */
3185 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
3189 TRACE("inserting button index=%d\n", nIndex);
3190 if (nIndex > infoPtr->nNumButtons) {
3191 nIndex = infoPtr->nNumButtons;
3192 TRACE("adjust index=%d\n", nIndex);
3195 oldButtons = infoPtr->buttons;
3196 infoPtr->nNumButtons++;
3197 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3198 /* pre insert copy */
3200 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3201 nIndex * sizeof(TBUTTON_INFO));
3204 /* insert new button */
3205 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3206 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3207 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3208 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3209 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3210 /* if passed string and not index, then add string */
3211 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3212 Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
3215 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3217 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3220 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
3221 ti.cbSize = sizeof (TTTOOLINFOA);
3223 ti.uId = lpTbb->idCommand;
3225 ti.lpszText = LPSTR_TEXTCALLBACKA;
3227 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
3231 /* post insert copy */
3232 if (nIndex < infoPtr->nNumButtons - 1) {
3233 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3234 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3237 COMCTL32_Free (oldButtons);
3239 TOOLBAR_CalcToolbar (hwnd);
3241 InvalidateRect (hwnd, NULL, TRUE);
3248 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3250 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3251 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3252 INT nIndex = (INT)wParam;
3253 TBUTTON_INFO *oldButtons;
3258 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3261 /* EPP: this seems to be an undocumented call (from my IE4)
3262 * I assume in that case that:
3263 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3264 * - index of insertion is at the end of existing buttons
3265 * I only see this happen with nIndex == -1, but it could have a special
3266 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3268 nIndex = infoPtr->nNumButtons;
3270 } else if (nIndex < 0)
3273 /* If the string passed is not an index, assume address of string
3274 and do our own AddString */
3275 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3279 TRACE("string %s passed instead of index, adding string\n",
3280 debugstr_w((LPWSTR)lpTbb->iString));
3281 len = strlenW((LPWSTR)lpTbb->iString) + 2;
3282 ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
3283 strcpyW(ptr, (LPWSTR)lpTbb->iString);
3284 ptr[len - 1] = 0; /* ended by two '\0' */
3285 lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
3289 TRACE("inserting button index=%d\n", nIndex);
3290 if (nIndex > infoPtr->nNumButtons) {
3291 nIndex = infoPtr->nNumButtons;
3292 TRACE("adjust index=%d\n", nIndex);
3295 oldButtons = infoPtr->buttons;
3296 infoPtr->nNumButtons++;
3297 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3298 /* pre insert copy */
3300 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3301 nIndex * sizeof(TBUTTON_INFO));
3304 /* insert new button */
3305 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3306 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3307 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3308 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3309 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3310 /* if passed string and not index, then add string */
3311 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3312 Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
3315 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3317 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3320 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
3321 ti.cbSize = sizeof (TTTOOLINFOW);
3323 ti.uId = lpTbb->idCommand;
3325 ti.lpszText = LPSTR_TEXTCALLBACKW;
3327 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
3331 /* post insert copy */
3332 if (nIndex < infoPtr->nNumButtons - 1) {
3333 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3334 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3337 COMCTL32_Free (oldButtons);
3339 TOOLBAR_CalcToolbar (hwnd);
3341 InvalidateRect (hwnd, NULL, TRUE);
3347 /* << TOOLBAR_InsertMarkHitTest >> */
3351 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
3353 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3356 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3360 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
3365 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
3367 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3370 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3374 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
3379 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
3381 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3384 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3388 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
3393 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
3395 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3398 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3402 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
3407 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3409 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3412 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3416 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
3421 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
3423 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3426 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3430 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
3434 /* << TOOLBAR_LoadImages >> */
3435 /* << TOOLBAR_MapAccelerator >> */
3436 /* << TOOLBAR_MarkButton >> */
3437 /* << TOOLBAR_MoveButton >> */
3441 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3443 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3444 TBUTTON_INFO *btnPtr;
3447 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3451 btnPtr = &infoPtr->buttons[nIndex];
3452 if (LOWORD(lParam) == FALSE)
3453 btnPtr->fsState &= ~TBSTATE_PRESSED;
3455 btnPtr->fsState |= TBSTATE_PRESSED;
3457 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3463 /* << TOOLBAR_ReplaceBitmap >> */
3467 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3470 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3471 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
3473 if (lpSave == NULL) return 0;
3476 /* save toolbar information */
3477 FIXME("save to \"%s\" \"%s\"\n",
3478 lpSave->pszSubKey, lpSave->pszValueName);
3483 /* restore toolbar information */
3485 FIXME("restore from \"%s\" \"%s\"\n",
3486 lpSave->pszSubKey, lpSave->pszValueName);
3497 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3500 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3501 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
3507 /* save toolbar information */
3508 FIXME("save to \"%s\" \"%s\"\n",
3509 lpSave->pszSubKey, lpSave->pszValueName);
3514 /* restore toolbar information */
3516 FIXME("restore from \"%s\" \"%s\"\n",
3517 lpSave->pszSubKey, lpSave->pszValueName);
3528 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
3530 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3531 BOOL bOldAnchor = infoPtr->bAnchor;
3533 infoPtr->bAnchor = (BOOL)wParam;
3535 return (LRESULT)bOldAnchor;
3540 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3542 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3544 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
3547 if (infoPtr->nNumButtons > 0)
3548 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
3549 infoPtr->nNumButtons,
3550 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
3551 LOWORD(lParam), HIWORD(lParam));
3553 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
3554 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
3556 /* uses image list internals directly */
3557 if (infoPtr->himlDef) {
3558 infoPtr->himlDef->cx = infoPtr->nBitmapWidth;
3559 infoPtr->himlDef->cy = infoPtr->nBitmapHeight;
3567 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3569 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3570 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
3571 TBUTTON_INFO *btnPtr;
3576 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
3579 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3580 lptbbi->dwMask & 0x80000000);
3584 btnPtr = &infoPtr->buttons[nIndex];
3585 if (lptbbi->dwMask & TBIF_COMMAND)
3586 btnPtr->idCommand = lptbbi->idCommand;
3587 if (lptbbi->dwMask & TBIF_IMAGE)
3588 btnPtr->iBitmap = lptbbi->iImage;
3589 if (lptbbi->dwMask & TBIF_LPARAM)
3590 btnPtr->dwData = lptbbi->lParam;
3591 /* if (lptbbi->dwMask & TBIF_SIZE) */
3592 /* btnPtr->cx = lptbbi->cx; */
3593 if (lptbbi->dwMask & TBIF_STATE)
3594 btnPtr->fsState = lptbbi->fsState;
3595 if (lptbbi->dwMask & TBIF_STYLE)
3596 btnPtr->fsStyle = lptbbi->fsStyle;
3598 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3599 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3600 /* iString is index, zero it to make Str_SetPtr succeed */
3603 Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
3610 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3612 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3613 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
3614 TBUTTON_INFO *btnPtr;
3619 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
3622 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3623 lptbbi->dwMask & 0x80000000);
3627 btnPtr = &infoPtr->buttons[nIndex];
3628 if (lptbbi->dwMask & TBIF_COMMAND)
3629 btnPtr->idCommand = lptbbi->idCommand;
3630 if (lptbbi->dwMask & TBIF_IMAGE)
3631 btnPtr->iBitmap = lptbbi->iImage;
3632 if (lptbbi->dwMask & TBIF_LPARAM)
3633 btnPtr->dwData = lptbbi->lParam;
3634 /* if (lptbbi->dwMask & TBIF_SIZE) */
3635 /* btnPtr->cx = lptbbi->cx; */
3636 if (lptbbi->dwMask & TBIF_STATE)
3637 btnPtr->fsState = lptbbi->fsState;
3638 if (lptbbi->dwMask & TBIF_STYLE)
3639 btnPtr->fsStyle = lptbbi->fsStyle;
3641 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3642 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3643 /* iString is index, zero it to make Str_SetPtr succeed */
3645 Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
3652 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3654 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3655 INT cx = LOWORD(lParam), cy = HIWORD(lParam);
3657 if ((cx < 0) || (cy < 0))
3659 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
3663 /* The documentation claims you can only change the button size before
3664 * any button has been added. But this is wrong.
3665 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
3666 * it to the toolbar, and it checks that the return value is nonzero - mjm
3667 * Further testing shows that we must actually perform the change too.
3670 * The documentation also does not mention that if 0 is supplied for
3671 * either size, the system changes it to the default of 24 wide and
3672 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
3674 infoPtr->nButtonWidth = (cx) ? cx : 24;
3675 infoPtr->nButtonHeight = (cy) ? cy : 22;
3681 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
3683 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3685 if (infoPtr == NULL) {
3686 TRACE("Toolbar not initialized yet?????\n");
3690 /* if setting to current values, ignore */
3691 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
3692 (infoPtr->cxMax == (INT)HIWORD(lParam))) {
3693 TRACE("matches current width, min=%d, max=%d, no recalc\n",
3694 infoPtr->cxMin, infoPtr->cxMax);
3698 /* save new values */
3699 infoPtr->cxMin = (INT)LOWORD(lParam);
3700 infoPtr->cxMax = (INT)HIWORD(lParam);
3702 /* if both values are 0 then we are done */
3704 TRACE("setting both min and max to 0, norecalc\n");
3708 /* otherwise we need to recalc the toolbar and in some cases
3709 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
3710 which doesn't actually draw - GA). */
3711 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
3712 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
3714 TOOLBAR_CalcToolbar (hwnd);
3716 InvalidateRect (hwnd, NULL, TRUE);
3723 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
3725 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3726 INT nIndex = (INT)wParam;
3728 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3731 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
3733 if (infoPtr->hwndToolTip) {
3735 FIXME("change tool tip!\n");
3743 /* << TOOLBAR_SetColorScheme >> */
3747 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3749 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3750 HIMAGELIST himlTemp;
3754 FIXME("no support for multiple image lists\n");
3758 himlTemp = infoPtr->himlDis;
3759 infoPtr->himlDis = (HIMAGELIST)lParam;
3761 /* FIXME: redraw ? */
3763 return (LRESULT)himlTemp;
3768 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
3770 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3773 dwTemp = infoPtr->dwDTFlags;
3774 infoPtr->dwDTFlags =
3775 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
3777 return (LRESULT)dwTemp;
3781 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3783 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3786 dwTemp = infoPtr->dwExStyle;
3787 infoPtr->dwExStyle = (DWORD)lParam;
3789 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
3790 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
3791 FIXME("Extended style not implemented %s %s\n",
3792 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
3793 "TBSTYLE_EX_MIXEDBUTTONS" : "",
3794 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
3795 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
3798 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
3799 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
3800 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
3802 return (LRESULT)dwTemp;
3807 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3809 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3810 HIMAGELIST himlTemp;
3813 FIXME("no support for multiple image lists\n");
3817 himlTemp = infoPtr->himlHot;
3818 infoPtr->himlHot = (HIMAGELIST)lParam;
3820 /* FIXME: redraw ? */
3822 return (LRESULT)himlTemp;
3827 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
3829 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3830 INT nOldHotItem = infoPtr->nHotItem;
3831 TBUTTON_INFO *btnPtr;
3833 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
3836 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
3839 infoPtr->nHotItem = (INT)wParam;
3840 if ((INT)wParam >=0)
3842 btnPtr = &infoPtr->buttons[(INT)wParam];
3843 btnPtr->bHot = TRUE;
3844 InvalidateRect (hwnd, &btnPtr->rect,
3845 TOOLBAR_HasText(infoPtr, btnPtr));
3849 btnPtr = &infoPtr->buttons[nOldHotItem];
3850 btnPtr->bHot = FALSE;
3851 InvalidateRect (hwnd, &btnPtr->rect,
3852 TOOLBAR_HasText(infoPtr, btnPtr));
3856 if (nOldHotItem < 0)
3859 return (LRESULT)nOldHotItem;
3864 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3866 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3867 HIMAGELIST himlTemp;
3870 FIXME("no support for multiple image lists\n");
3874 himlTemp = infoPtr->himlDef;
3875 infoPtr->himlDef = (HIMAGELIST)lParam;
3877 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
3879 ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
3880 &infoPtr->nBitmapHeight);
3881 TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
3882 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
3883 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
3885 /* FIXME: redraw ? */
3886 InvalidateRect(hwnd, NULL, TRUE);
3888 return (LRESULT)himlTemp;
3893 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
3895 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3897 infoPtr->nIndent = (INT)wParam;
3901 /* process only on indent changing */
3902 if(infoPtr->nIndent != (INT)wParam)
3904 infoPtr->nIndent = (INT)wParam;
3905 TOOLBAR_CalcToolbar (hwnd);
3906 InvalidateRect(hwnd, NULL, FALSE);
3913 /* << TOOLBAR_SetInsertMark >> */
3917 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
3919 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3921 infoPtr->clrInsertMark = (COLORREF)lParam;
3923 /* FIXME : redraw ??*/
3930 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3932 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3934 if (infoPtr == NULL)
3937 infoPtr->nMaxTextRows = (INT)wParam;
3944 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
3946 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3949 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
3950 infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
3951 infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
3952 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
3953 infoPtr->szPadding.cx, infoPtr->szPadding.cy);
3954 return (LRESULT) oldPad;
3959 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
3961 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3966 if (infoPtr == NULL)
3968 hwndOldNotify = infoPtr->hwndNotify;
3969 infoPtr->hwndNotify = (HWND)wParam;
3971 return hwndOldNotify;
3976 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3978 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3979 LPRECT lprc = (LPRECT)lParam;
3983 if (LOWORD(wParam) > 1) {
3984 FIXME("multiple rows not supported!\n");
3987 if(infoPtr->nRows != LOWORD(wParam))
3989 infoPtr->nRows = LOWORD(wParam);
3991 /* recalculate toolbar */
3992 TOOLBAR_CalcToolbar (hwnd);
3994 /* repaint toolbar */
3995 InvalidateRect(hwnd, NULL, FALSE);
3998 /* return bounding rectangle */
4000 lprc->left = infoPtr->rcBound.left;
4001 lprc->right = infoPtr->rcBound.right;
4002 lprc->top = infoPtr->rcBound.top;
4003 lprc->bottom = infoPtr->rcBound.bottom;
4011 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
4013 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4014 TBUTTON_INFO *btnPtr;
4017 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4021 btnPtr = &infoPtr->buttons[nIndex];
4023 /* if hidden state has changed the invalidate entire window and recalc */
4024 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
4025 btnPtr->fsState = LOWORD(lParam);
4026 TOOLBAR_CalcToolbar (hwnd);
4027 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
4031 /* process state changing if current state doesn't match new state */
4032 if(btnPtr->fsState != LOWORD(lParam))
4034 btnPtr->fsState = LOWORD(lParam);
4035 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4044 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4046 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4047 TBUTTON_INFO *btnPtr;
4050 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4054 btnPtr = &infoPtr->buttons[nIndex];
4056 /* process style change if current style doesn't match new style */
4057 if(btnPtr->fsStyle != LOWORD(lParam))
4059 btnPtr->fsStyle = LOWORD(lParam);
4060 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4063 if (infoPtr->hwndToolTip) {
4064 FIXME("change tool tip!\n");
4072 inline static LRESULT
4073 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
4075 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4077 if (infoPtr == NULL)
4079 infoPtr->hwndToolTip = (HWND)wParam;
4085 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
4087 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4090 TRACE("%s hwnd=0x%04x stub!\n",
4091 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
4093 bTemp = infoPtr->bUnicode;
4094 infoPtr->bUnicode = (BOOL)wParam;
4101 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
4103 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4104 INT iOldVersion = infoPtr->iVersion;
4106 infoPtr->iVersion = iVersion;
4112 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
4114 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4115 LPSIZE lpsize = (LPSIZE)lParam;
4121 * Testing shows the following:
4122 * wParam = 0 adjust cx value
4123 * = 1 set cy value to max size.
4124 * lParam pointer to SIZE structure
4127 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4128 wParam, lParam, lpsize->cx, lpsize->cy);
4132 if (lpsize->cx == -1) {
4133 /* **** this is wrong, native measures each button and sets it */
4134 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4136 else if(HIWORD(lpsize->cx)) {
4138 HWND hwndParent = GetParent(hwnd);
4140 InvalidateRect(hwnd, 0, 1);
4141 GetWindowRect(hwnd, &rc);
4142 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
4143 TRACE("mapped to (%d,%d)-(%d,%d)\n",
4144 rc.left, rc.top, rc.right, rc.bottom);
4145 lpsize->cx = max(rc.right-rc.left,
4146 infoPtr->rcBound.right - infoPtr->rcBound.left);
4149 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4153 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4156 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4160 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4161 lpsize->cx, lpsize->cy);
4167 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
4169 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4170 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4173 /* initialize info structure */
4174 infoPtr->nButtonHeight = 22;
4175 infoPtr->nButtonWidth = 24;
4176 infoPtr->nBitmapHeight = 15;
4177 infoPtr->nBitmapWidth = 16;
4179 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
4181 infoPtr->nMaxTextRows = 1;
4182 infoPtr->cxMin = -1;
4183 infoPtr->cxMax = -1;
4184 infoPtr->nNumBitmaps = 0;
4185 infoPtr->nNumStrings = 0;
4187 infoPtr->bCaptured = FALSE;
4188 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4189 infoPtr->nButtonDown = -1;
4190 infoPtr->nOldHit = -1;
4191 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4192 infoPtr->hwndNotify = GetParent (hwnd);
4193 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
4194 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
4195 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
4196 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
4197 infoPtr->iVersion = 0;
4198 infoPtr->bNtfUnicode = FALSE;
4199 infoPtr->hwndSelf = hwnd;
4200 infoPtr->bDoRedraw = TRUE;
4202 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
4203 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
4205 if (dwStyle & TBSTYLE_TOOLTIPS) {
4206 /* Create tooltip control */
4207 infoPtr->hwndToolTip =
4208 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
4209 CW_USEDEFAULT, CW_USEDEFAULT,
4210 CW_USEDEFAULT, CW_USEDEFAULT,
4213 /* Send NM_TOOLTIPSCREATED notification */
4214 if (infoPtr->hwndToolTip) {
4215 NMTOOLTIPSCREATED nmttc;
4217 nmttc.hwndToolTips = infoPtr->hwndToolTip;
4219 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
4220 NM_TOOLTIPSCREATED);
4224 TOOLBAR_CheckStyle (hwnd, dwStyle);
4226 TOOLBAR_CalcToolbar(hwnd);
4233 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
4235 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4237 /* delete tooltip control */
4238 if (infoPtr->hwndToolTip)
4239 DestroyWindow (infoPtr->hwndToolTip);
4241 /* delete button data */
4242 if (infoPtr->buttons)
4243 COMCTL32_Free (infoPtr->buttons);
4245 /* delete strings */
4246 if (infoPtr->strings) {
4248 for (i = 0; i < infoPtr->nNumStrings; i++)
4249 if (infoPtr->strings[i])
4250 COMCTL32_Free (infoPtr->strings[i]);
4252 COMCTL32_Free (infoPtr->strings);
4255 /* destroy internal image list */
4256 if (infoPtr->himlInt)
4257 ImageList_Destroy (infoPtr->himlInt);
4259 /* delete default font */
4261 DeleteObject (infoPtr->hDefaultFont);
4263 /* free toolbar info data */
4264 COMCTL32_Free (infoPtr);
4265 SetWindowLongA (hwnd, 0, 0);
4272 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
4274 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4275 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4276 NMTBCUSTOMDRAW tbcd;
4277 INT ret = FALSE, ntfret;
4279 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4280 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4281 tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
4282 tbcd.nmcd.hdc = (HDC)wParam;
4283 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4284 /* FIXME: in general the return flags *can* be or'ed together */
4287 case CDRF_DODEFAULT:
4289 case CDRF_SKIPDEFAULT:
4292 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4297 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4298 * to my parent for processing.
4300 if (infoPtr->bTransparent) {
4302 HDC hdc = (HDC)wParam;
4307 parent = GetParent(hwnd);
4308 MapWindowPoints(hwnd, parent, &pt, 1);
4309 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
4310 ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
4311 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
4314 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
4316 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4317 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4318 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
4319 tbcd.nmcd.hdc = (HDC)wParam;
4320 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4323 case CDRF_DODEFAULT:
4325 case CDRF_SKIPDEFAULT:
4328 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4337 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
4339 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4341 return infoPtr->hFont;
4346 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
4348 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4349 TBUTTON_INFO *btnPtr;
4353 pt.x = (INT)LOWORD(lParam);
4354 pt.y = (INT)HIWORD(lParam);
4355 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4358 btnPtr = &infoPtr->buttons[nHit];
4359 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4362 infoPtr->bCaptured = TRUE;
4363 infoPtr->nButtonDown = nHit;
4365 btnPtr->fsState |= TBSTATE_PRESSED;
4367 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4370 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
4371 TOOLBAR_Customize (hwnd);
4378 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
4380 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4381 TBUTTON_INFO *btnPtr;
4386 if (infoPtr->hwndToolTip)
4387 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4388 WM_LBUTTONDOWN, wParam, lParam);
4390 pt.x = (INT)LOWORD(lParam);
4391 pt.y = (INT)HIWORD(lParam);
4392 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4396 btnPtr = &infoPtr->buttons[nHit];
4397 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4400 infoPtr->nOldHit = nHit;
4402 CopyRect(&arrowRect, &btnPtr->rect);
4403 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
4405 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4406 if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
4407 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
4408 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
4412 * this time we must force a Redraw, so the btn is
4413 * painted down before CaptureChanged repaints it up
4415 RedrawWindow(hwnd,&btnPtr->rect,0,
4416 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
4418 nmtb.iItem = btnPtr->idCommand;
4419 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
4422 memset(&nmtb.rcButton, 0, sizeof(RECT));
4423 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4425 if (res != TBDDRET_TREATPRESSED)
4426 /* ??? guess (GA) */
4428 /* otherwise drop through and process as pushed */
4430 /* SetCapture (hwnd); */
4431 infoPtr->bCaptured = TRUE;
4432 infoPtr->nButtonDown = nHit;
4434 btnPtr->fsState |= TBSTATE_PRESSED;
4435 btnPtr->bHot = FALSE;
4437 InvalidateRect(hwnd, &btnPtr->rect,
4438 TOOLBAR_HasText(infoPtr, btnPtr));
4442 /* native issues the TBN_BEGINDRAG here */
4443 nmtb.iItem = btnPtr->idCommand;
4444 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4445 nmtb.tbButton.idCommand = btnPtr->idCommand;
4446 nmtb.tbButton.fsState = btnPtr->fsState;
4447 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4448 nmtb.tbButton.dwData = btnPtr->dwData;
4449 nmtb.tbButton.iString = btnPtr->iString;
4450 nmtb.cchText = 0; /* !!! not correct */
4451 nmtb.pszText = 0; /* !!! not correct */
4452 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4460 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
4462 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4463 TBUTTON_INFO *btnPtr;
4467 BOOL bSendMessage = TRUE;
4472 if (infoPtr->hwndToolTip)
4473 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4474 WM_LBUTTONUP, wParam, lParam);
4476 pt.x = (INT)LOWORD(lParam);
4477 pt.y = (INT)HIWORD(lParam);
4478 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4480 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
4481 /* if the cursor is still inside of the toolbar */
4482 if((infoPtr->nHotItem >= 0) && (nHit != -1))
4483 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
4485 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4486 btnPtr->fsState &= ~TBSTATE_PRESSED;
4488 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
4489 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
4490 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
4492 if (nOldIndex == nHit)
4493 bSendMessage = FALSE;
4494 if ((nOldIndex != nHit) &&
4496 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
4497 btnPtr->fsState |= TBSTATE_CHECKED;
4500 if (btnPtr->fsState & TBSTATE_CHECKED)
4501 btnPtr->fsState &= ~TBSTATE_CHECKED;
4503 btnPtr->fsState |= TBSTATE_CHECKED;
4507 if (nOldIndex != -1)
4509 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
4510 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
4514 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
4515 * that resets bCaptured and btn TBSTATE_PRESSED flags,
4516 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
4518 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
4521 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
4522 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
4523 NM_RELEASEDCAPTURE);
4525 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
4528 nmtb.iItem = btnPtr->idCommand;
4529 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4530 nmtb.tbButton.idCommand = btnPtr->idCommand;
4531 nmtb.tbButton.fsState = btnPtr->fsState;
4532 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4533 nmtb.tbButton.dwData = btnPtr->dwData;
4534 nmtb.tbButton.iString = btnPtr->iString;
4535 nmtb.cchText = 0; /* !!! not correct */
4536 nmtb.pszText = 0; /* !!! not correct */
4537 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4540 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
4541 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
4543 /* !!! Undocumented - toolbar at 4.71 level and above sends
4544 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
4545 * Only NM_RCLICK is documented.
4547 nmmouse.dwItemSpec = btnPtr->idCommand;
4548 nmmouse.dwItemData = btnPtr->dwData;
4549 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
4555 TOOLBAR_CaptureChanged(HWND hwnd)
4557 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4558 TBUTTON_INFO *btnPtr;
4560 infoPtr->bCaptured = FALSE;
4562 if (infoPtr->nButtonDown >= 0)
4564 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4565 btnPtr->fsState &= ~TBSTATE_PRESSED;
4567 infoPtr->nButtonDown = -1;
4568 infoPtr->nOldHit = -1;
4570 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4577 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
4579 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4580 TBUTTON_INFO *hotBtnPtr, *btnPtr;
4583 if (infoPtr->nOldHit < 0)
4586 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
4588 /* Redraw the button if the last button we were over is the hot button and it
4590 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
4592 hotBtnPtr->bHot = FALSE;
4593 rc1 = hotBtnPtr->rect;
4594 InflateRect (&rc1, 1, 1);
4595 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
4599 /* If the last button we were over is depressed then make it not */
4600 /* depressed and redraw it */
4601 if(infoPtr->nOldHit == infoPtr->nButtonDown)
4603 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4605 btnPtr->fsState &= ~TBSTATE_PRESSED;
4607 rc1 = hotBtnPtr->rect;
4608 InflateRect (&rc1, 1, 1);
4609 InvalidateRect (hwnd, &rc1, TRUE);
4612 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
4613 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4619 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
4621 TBUTTON_INFO *btnPtr, *oldBtnPtr;
4622 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4625 TRACKMOUSEEVENT trackinfo;
4627 /* fill in the TRACKMOUSEEVENT struct */
4628 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
4629 trackinfo.dwFlags = TME_QUERY;
4630 trackinfo.hwndTrack = hwnd;
4631 trackinfo.dwHoverTime = HOVER_DEFAULT;
4633 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4634 _TrackMouseEvent(&trackinfo);
4636 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4637 if(!(trackinfo.dwFlags & TME_LEAVE)) {
4638 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
4640 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4641 /* and can properly deactivate the hot toolbar button */
4642 _TrackMouseEvent(&trackinfo);
4645 if (infoPtr->hwndToolTip)
4646 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4647 WM_MOUSEMOVE, wParam, lParam);
4649 pt.x = (INT)LOWORD(lParam);
4650 pt.y = (INT)HIWORD(lParam);
4652 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4654 if (infoPtr->nOldHit != nHit)
4656 /* Remove the effect of an old hot button if the button was enabled and was
4657 drawn with the hot button effect */
4658 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
4659 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
4661 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
4662 oldBtnPtr->bHot = FALSE;
4664 InvalidateRect (hwnd, &oldBtnPtr->rect,
4665 TOOLBAR_HasText(infoPtr, oldBtnPtr));
4668 /* It's not a separator or in nowhere. It's a hot button. */
4671 btnPtr = &infoPtr->buttons[nHit];
4673 infoPtr->nHotItem = nHit;
4675 /* only enabled buttons show hot effect */
4676 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
4678 btnPtr->bHot = TRUE;
4679 InvalidateRect(hwnd, &btnPtr->rect,
4680 TOOLBAR_HasText(infoPtr, btnPtr));
4685 if (infoPtr->bCaptured) {
4686 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4687 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
4688 btnPtr->fsState &= ~TBSTATE_PRESSED;
4689 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
4691 else if (nHit == infoPtr->nButtonDown) {
4692 btnPtr->fsState |= TBSTATE_PRESSED;
4693 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
4696 infoPtr->nOldHit = nHit;
4702 inline static LRESULT
4703 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4705 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
4706 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
4708 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
4712 inline static LRESULT
4713 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
4715 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
4716 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
4718 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
4723 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4725 TOOLBAR_INFO *infoPtr;
4726 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
4729 /* allocate memory for info structure */
4730 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
4731 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
4734 infoPtr->dwStructSize = sizeof(TBBUTTON);
4736 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
4737 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
4738 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
4739 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
4742 /* native control does:
4743 * Get a lot of colors and brushes
4745 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
4746 * CreateFontIndirectA(adr1)
4747 * CreateBitmap(0x27, 0x24, 1, 1, 0)
4748 * hdc = GetDC(toolbar)
4749 * GetSystemMetrics(0x48)
4750 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
4751 * 0, 0, 0, 0, "MARLETT")
4752 * oldfnt = SelectObject(hdc, fnt2)
4753 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
4754 * GetTextMetricsA(hdc, adr3)
4755 * SelectObject(hdc, oldfnt)
4756 * DeleteObject(fnt2)
4758 * InvalidateRect(toolbar, 0, 1)
4759 * SetWindowLongA(toolbar, 0, addr)
4760 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
4763 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
4764 * ie 2 0x4600094c 0x4600094c 0x4600894d
4765 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
4766 * rebar 0x50008844 0x40008844 0x50008845
4767 * pager 0x50000844 0x40000844 0x50008845
4768 * IC35mgr 0x5400084e **nochange**
4769 * on entry to _NCCREATE 0x5400084e
4770 * rowlist 0x5400004e **nochange**
4771 * on entry to _NCCREATE 0x5400004e
4775 /* I think the code below is a bug, but it is the way that the native
4776 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
4777 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
4778 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
4779 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
4780 * Some how, the only cases of this seem to be MFC programs.
4782 * Note also that the addition of _TRANSPARENT occurs *only* here. It
4783 * does not occur in the WM_STYLECHANGING routine.
4784 * (Guy Albertelli 9/2001)
4787 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
4788 styleadd |= TBSTYLE_TRANSPARENT;
4789 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
4790 styleadd |= CCS_TOP; /* default to top */
4791 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
4794 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
4799 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
4801 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4805 if (dwStyle & WS_MINIMIZE)
4806 return 0; /* Nothing to do */
4808 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
4810 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
4813 if (!(dwStyle & CCS_NODIVIDER))
4815 GetWindowRect (hwnd, &rcWindow);
4816 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4817 if( dwStyle & WS_BORDER )
4818 OffsetRect (&rcWindow, 1, 1);
4819 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
4822 ReleaseDC( hwnd, hdc );
4828 inline static LRESULT
4829 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
4831 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4832 LPNMHDR lpnmh = (LPNMHDR)lParam;
4834 if (lpnmh->code == PGN_CALCSIZE) {
4835 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
4837 if (lppgc->dwFlag == PGF_CALCWIDTH) {
4838 lppgc->iWidth = infoPtr->nWidth;
4839 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
4843 lppgc->iHeight = infoPtr->nHeight;
4844 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
4851 TRACE("passing WM_NOTIFY!\n");
4853 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
4854 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
4857 if (lpnmh->code == TTN_GETDISPINFOA) {
4858 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
4860 FIXME("retrieving ASCII string\n");
4863 else if (lpnmh->code == TTN_GETDISPINFOW) {
4864 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
4866 FIXME("retrieving UNICODE string\n");
4877 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
4879 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4883 /* fill ps.rcPaint with a default rect */
4884 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
4886 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
4888 TRACE("psrect=(%d,%d)-(%d,%d)\n",
4889 ps.rcPaint.left, ps.rcPaint.top,
4890 ps.rcPaint.right, ps.rcPaint.bottom);
4892 TOOLBAR_Refresh (hwnd, hdc, &ps);
4893 if (!wParam) EndPaint (hwnd, &ps);
4900 TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
4901 /*****************************************************
4904 * Handles the WM_SETREDRAW message.
4907 * According to testing V4.71 of COMCTL32 returns the
4908 * *previous* status of the redraw flag (either 0 or 1)
4909 * instead of the MSDN documented value of 0 if handled.
4910 * (For laughs see the "consistancy" with same function
4913 *****************************************************/
4915 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4916 BOOL oldredraw = infoPtr->bDoRedraw;
4918 TRACE("set to %s\n",
4919 (wParam) ? "TRUE" : "FALSE");
4920 infoPtr->bDoRedraw = (BOOL) wParam;
4922 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
4924 return (oldredraw) ? 1 : 0;
4929 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
4931 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4932 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4941 /* Resize deadlock check */
4942 if (infoPtr->bAutoSize) {
4943 infoPtr->bAutoSize = FALSE;
4947 /* FIXME: optimize to only update size if the new size doesn't */
4948 /* match the current size */
4950 flags = (INT) wParam;
4952 /* FIXME for flags =
4953 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
4956 TRACE("sizing toolbar!\n");
4958 if (flags == SIZE_RESTORED) {
4959 /* width and height don't apply */
4960 parent = GetParent (hwnd);
4961 GetClientRect(parent, &parent_rect);
4962 x = parent_rect.left;
4963 y = parent_rect.top;
4965 if (dwStyle & CCS_NORESIZE) {
4966 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
4969 * this sets the working width of the toolbar, and
4970 * Calc Toolbar will not adjust it, only the height
4972 infoPtr->nWidth = parent_rect.right - parent_rect.left;
4973 cy = infoPtr->nHeight;
4974 cx = infoPtr->nWidth;
4975 TOOLBAR_CalcToolbar (hwnd);
4976 infoPtr->nWidth = cx;
4977 infoPtr->nHeight = cy;
4980 infoPtr->nWidth = parent_rect.right - parent_rect.left;
4981 TOOLBAR_CalcToolbar (hwnd);
4982 cy = infoPtr->nHeight;
4983 cx = infoPtr->nWidth;
4985 if (dwStyle & CCS_NOMOVEY) {
4986 GetWindowRect(hwnd, &window_rect);
4987 ScreenToClient(parent, (LPPOINT)&window_rect.left);
4988 y = window_rect.top;
4992 if (dwStyle & CCS_NOPARENTALIGN) {
4993 uPosFlags |= SWP_NOMOVE;
4994 cy = infoPtr->nHeight;
4995 cx = infoPtr->nWidth;
4998 if (!(dwStyle & CCS_NODIVIDER))
4999 cy += GetSystemMetrics(SM_CYEDGE);
5001 if (dwStyle & WS_BORDER)
5004 cy += GetSystemMetrics(SM_CYEDGE);
5005 cx += GetSystemMetrics(SM_CYEDGE);
5008 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
5009 cx, cy, uPosFlags | SWP_NOZORDER);
5016 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
5018 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5020 if (nType == GWL_STYLE) {
5021 if (lpStyle->styleNew & TBSTYLE_LIST) {
5022 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
5025 infoPtr->dwDTFlags = DT_CENTER;
5027 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
5028 infoPtr->bBtnTranspnt = (lpStyle->styleNew &
5029 (TBSTYLE_FLAT | TBSTYLE_LIST));
5030 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
5033 TOOLBAR_AutoSize (hwnd);
5035 InvalidateRect(hwnd, NULL, FALSE);
5042 static LRESULT WINAPI
5043 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5045 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
5046 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
5048 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
5049 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
5054 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
5056 case TB_ADDBUTTONSA:
5057 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
5059 case TB_ADDBUTTONSW:
5060 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
5063 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
5066 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
5069 return TOOLBAR_AutoSize (hwnd);
5071 case TB_BUTTONCOUNT:
5072 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
5074 case TB_BUTTONSTRUCTSIZE:
5075 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
5077 case TB_CHANGEBITMAP:
5078 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
5080 case TB_CHECKBUTTON:
5081 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
5083 case TB_COMMANDTOINDEX:
5084 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
5087 return TOOLBAR_Customize (hwnd);
5089 case TB_DELETEBUTTON:
5090 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
5092 case TB_ENABLEBUTTON:
5093 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
5095 case TB_GETANCHORHIGHLIGHT:
5096 return TOOLBAR_GetAnchorHighlight (hwnd);
5099 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
5101 case TB_GETBITMAPFLAGS:
5102 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
5105 return TOOLBAR_GetButton (hwnd, wParam, lParam);
5107 case TB_GETBUTTONINFOA:
5108 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
5110 case TB_GETBUTTONINFOW:
5111 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
5113 case TB_GETBUTTONSIZE:
5114 return TOOLBAR_GetButtonSize (hwnd);
5116 case TB_GETBUTTONTEXTA:
5117 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
5119 case TB_GETBUTTONTEXTW:
5120 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
5122 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
5124 case TB_GETDISABLEDIMAGELIST:
5125 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
5127 case TB_GETEXTENDEDSTYLE:
5128 return TOOLBAR_GetExtendedStyle (hwnd);
5130 case TB_GETHOTIMAGELIST:
5131 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
5134 return TOOLBAR_GetHotItem (hwnd);
5136 case TB_GETIMAGELIST:
5137 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
5139 /* case TB_GETINSERTMARK: */ /* 4.71 */
5140 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5142 case TB_GETITEMRECT:
5143 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
5146 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
5148 /* case TB_GETOBJECT: */ /* 4.71 */
5151 return TOOLBAR_GetPadding (hwnd);
5154 return TOOLBAR_GetRect (hwnd, wParam, lParam);
5157 return TOOLBAR_GetRows (hwnd, wParam, lParam);
5160 return TOOLBAR_GetState (hwnd, wParam, lParam);
5163 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
5165 case TB_GETTEXTROWS:
5166 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
5168 case TB_GETTOOLTIPS:
5169 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
5171 case TB_GETUNICODEFORMAT:
5172 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
5174 case CCM_GETVERSION:
5175 return TOOLBAR_GetVersion (hwnd);
5178 return TOOLBAR_HideButton (hwnd, wParam, lParam);
5181 return TOOLBAR_HitTest (hwnd, wParam, lParam);
5183 case TB_INDETERMINATE:
5184 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
5186 case TB_INSERTBUTTONA:
5187 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
5189 case TB_INSERTBUTTONW:
5190 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
5192 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5194 case TB_ISBUTTONCHECKED:
5195 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
5197 case TB_ISBUTTONENABLED:
5198 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
5200 case TB_ISBUTTONHIDDEN:
5201 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
5203 case TB_ISBUTTONHIGHLIGHTED:
5204 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
5206 case TB_ISBUTTONINDETERMINATE:
5207 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
5209 case TB_ISBUTTONPRESSED:
5210 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
5212 case TB_LOADIMAGES: /* 4.70 */
5213 FIXME("missing standard imagelists\n");
5216 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5217 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5218 /* case TB_MARKBUTTON: */ /* 4.71 */
5219 /* case TB_MOVEBUTTON: */ /* 4.71 */
5221 case TB_PRESSBUTTON:
5222 return TOOLBAR_PressButton (hwnd, wParam, lParam);
5224 /* case TB_REPLACEBITMAP: */
5226 case TB_SAVERESTOREA:
5227 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
5229 case TB_SAVERESTOREW:
5230 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
5232 case TB_SETANCHORHIGHLIGHT:
5233 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
5235 case TB_SETBITMAPSIZE:
5236 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
5238 case TB_SETBUTTONINFOA:
5239 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
5241 case TB_SETBUTTONINFOW:
5242 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
5244 case TB_SETBUTTONSIZE:
5245 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
5247 case TB_SETBUTTONWIDTH:
5248 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
5251 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
5253 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
5255 case TB_SETDISABLEDIMAGELIST:
5256 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
5258 case TB_SETDRAWTEXTFLAGS:
5259 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
5261 case TB_SETEXTENDEDSTYLE:
5262 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
5264 case TB_SETHOTIMAGELIST:
5265 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
5268 return TOOLBAR_SetHotItem (hwnd, wParam);
5270 case TB_SETIMAGELIST:
5271 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
5274 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
5276 /* case TB_SETINSERTMARK: */ /* 4.71 */
5278 case TB_SETINSERTMARKCOLOR:
5279 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
5281 case TB_SETMAXTEXTROWS:
5282 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
5285 return TOOLBAR_SetPadding (hwnd, wParam, lParam);
5288 return TOOLBAR_SetParent (hwnd, wParam, lParam);
5291 return TOOLBAR_SetRows (hwnd, wParam, lParam);
5294 return TOOLBAR_SetState (hwnd, wParam, lParam);
5297 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
5299 case TB_SETTOOLTIPS:
5300 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
5302 case TB_SETUNICODEFORMAT:
5303 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
5306 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
5308 case CCM_SETVERSION:
5309 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
5315 return TOOLBAR_Create (hwnd, wParam, lParam);
5318 return TOOLBAR_Destroy (hwnd, wParam, lParam);
5321 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
5324 return TOOLBAR_GetFont (hwnd, wParam, lParam);
5326 /* case WM_KEYDOWN: */
5327 /* case WM_KILLFOCUS: */
5329 case WM_LBUTTONDBLCLK:
5330 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
5332 case WM_LBUTTONDOWN:
5333 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
5336 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
5339 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
5342 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
5344 case WM_CAPTURECHANGED:
5345 return TOOLBAR_CaptureChanged(hwnd);
5348 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
5351 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
5354 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
5357 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
5360 return TOOLBAR_Notify (hwnd, wParam, lParam);
5362 /* case WM_NOTIFYFORMAT: */
5365 return TOOLBAR_Paint (hwnd, wParam);
5368 return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
5371 return TOOLBAR_Size (hwnd, wParam, lParam);
5373 case WM_STYLECHANGED:
5374 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
5376 /* case WM_SYSCOLORCHANGE: */
5378 /* case WM_WININICHANGE: */
5383 case WM_MEASUREITEM:
5386 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5388 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
5390 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
5394 if (uMsg >= WM_USER)
5395 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
5396 uMsg, wParam, lParam);
5397 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5404 TOOLBAR_Register (void)
5408 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
5409 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
5410 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
5411 wndClass.cbClsExtra = 0;
5412 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
5413 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
5414 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
5415 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
5417 RegisterClassA (&wndClass);
5422 TOOLBAR_Unregister (void)
5424 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);