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 COLORREF clrBtnHighlight; /* color for Flat Separator */
133 COLORREF clrBtnShadow; /* color for Flag Separator */
134 RECT rcBound; /* bounding rectangle */
137 TBUTTON_INFO *buttons; /* pointer to button array */
138 LPWSTR *strings; /* pointer to string array */
139 } TOOLBAR_INFO, *PTOOLBAR_INFO;
142 /* used by customization dialog */
145 PTOOLBAR_INFO tbInfo;
147 } CUSTDLG_INFO, *PCUSTDLG_INFO;
155 } CUSTOMBUTTON, *PCUSTOMBUTTON;
158 #define SEPARATOR_WIDTH 8
160 #define BOTTOM_BORDER 2
161 #define DDARROW_WIDTH 11
163 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
164 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
165 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
167 /* Used to find undocumented extended styles */
168 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
169 TBSTYLE_EX_UNDOC1 | \
170 TBSTYLE_EX_MIXEDBUTTONS | \
171 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
174 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
178 TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
180 LPWSTR lpText = NULL;
182 /* FIXME: iString == -1 is undocumented */
183 if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
184 lpText = (LPWSTR)btnPtr->iString;
185 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
186 lpText = infoPtr->strings[btnPtr->iString];
192 TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
194 if (TRACE_ON(toolbar)){
195 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
196 btn_num, bP->idCommand,
197 bP->iBitmap, bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
198 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr,bP)));
200 TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
201 btn_num, bP->idCommand,
202 (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
203 bP->rect.left, bP->rect.top,
204 bP->rect.right, bP->rect.bottom);
210 TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
212 if (TRACE_ON(toolbar)) {
216 dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
217 TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
219 iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
220 iP->nNumStrings, dwStyle);
221 TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
223 iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
224 (iP->bDoRedraw) ? "TRUE" : "FALSE");
225 for(i=0; i<iP->nNumButtons; i++) {
226 TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
232 /***********************************************************************
235 * This function validates that the styles set are implemented and
236 * issues FIXME's warning of possible problems. In a perfect world this
237 * function should be null.
240 TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
242 if (dwStyle & TBSTYLE_ALTDRAG)
243 FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd);
244 if (dwStyle & TBSTYLE_REGISTERDROP)
245 FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
250 TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
252 if(!IsWindow(infoPtr->hwndSelf))
253 return 0; /* we have just been destroyed */
255 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
256 nmhdr->hwndFrom = infoPtr->hwndSelf;
259 TRACE("to window %04x, code=%08x, %s\n", infoPtr->hwndNotify, code,
260 (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
262 if (infoPtr->bNtfUnicode)
263 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
264 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
266 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
267 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
270 /***********************************************************************
271 * TOOLBAR_GetBitmapIndex
273 * This function returns the bitmap index associated with a button.
274 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
275 * is issued to retrieve the index.
278 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
280 INT ret = btnPtr->iBitmap;
282 if (ret == I_IMAGECALLBACK) {
283 /* issue TBN_GETDISPINFO */
286 nmgd.idCommand = btnPtr->idCommand;
287 nmgd.lParam = btnPtr->dwData;
288 nmgd.dwMask = TBNF_IMAGE;
289 TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
290 (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
292 if (nmgd.dwMask & TBNF_DI_SETITEM) {
293 btnPtr->iBitmap = nmgd.iImage;
296 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
297 ret, nmgd.dwMask, infoPtr->nNumBitmaps);
304 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
306 if (((index>=0) && (index <= infoPtr->nNumBitmaps)) ||
307 (index == I_IMAGECALLBACK))
314 /***********************************************************************
315 * TOOLBAR_DrawImageList
317 * This function validates the bitmap index (including I_IMAGECALLBACK
318 * functionality). It then draws the image via the ImageList_Draw
319 * function. It returns TRUE if the image was drawn, FALSE otherwise.
322 TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
323 HDC hdc, UINT left, UINT top, UINT draw_flags)
327 if (!himl) return FALSE;
329 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
330 ERR("index %d is not valid, max %d\n",
331 btnPtr->iBitmap, infoPtr->nNumBitmaps);
335 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
336 if (index == -1) return FALSE;
337 ERR("TBN_GETDISPINFO returned invalid index %d\n",
341 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
342 index, himl, left, top, draw_flags);
344 ImageList_Draw (himl, index, hdc, left, top, draw_flags);
349 /***********************************************************************
350 * TOOLBAR_TestImageExist
352 * This function is similar to TOOLBAR_DrawImageList, except it does not
353 * draw the image. The I_IMAGECALLBACK functionality is implemented.
356 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
360 if (!himl) return FALSE;
362 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
363 ERR("index %d is not valid, max %d\n",
364 btnPtr->iBitmap, infoPtr->nNumBitmaps);
368 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
369 if (index == -1) return FALSE;
370 ERR("TBN_GETDISPINFO returned invalid index %d\n",
379 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr)
382 COLORREF oldcolor, newcolor;
384 myrect.left = (lpRect->left + lpRect->right) / 2 - 1;
385 myrect.right = myrect.left + 1;
386 myrect.top = lpRect->top + 2;
387 myrect.bottom = lpRect->bottom - 2;
389 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
390 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
391 oldcolor = SetBkColor (hdc, newcolor);
392 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
394 myrect.left = myrect.right;
395 myrect.right = myrect.left + 1;
397 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
398 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
399 SetBkColor (hdc, newcolor);
400 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
402 SetBkColor (hdc, oldcolor);
406 /***********************************************************************
407 * TOOLBAR_DrawDDFlatSeparator
409 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
410 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
411 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
412 * are horizontal as opposed to the vertical separators for not dropdown
415 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
418 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLBAR_INFO *infoPtr)
421 COLORREF oldcolor, newcolor;
423 myrect.left = lpRect->left;
424 myrect.right = lpRect->right;
425 myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
426 myrect.bottom = myrect.top + 1;
428 InflateRect (&myrect, -2, 0);
430 TRACE("rect=(%d,%d)-(%d,%d)\n",
431 myrect.left, myrect.top, myrect.right, myrect.bottom);
433 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
434 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
435 oldcolor = SetBkColor (hdc, newcolor);
436 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
438 myrect.top = myrect.bottom;
439 myrect.bottom = myrect.top + 1;
441 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
442 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
443 SetBkColor (hdc, newcolor);
444 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
446 SetBkColor (hdc, oldcolor);
451 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
454 SelectObject ( hdc, GetSysColorPen (colorRef));
457 MoveToEx (hdc, x, y, NULL);
458 LineTo (hdc, x+5, y++); x++;
459 MoveToEx (hdc, x, y, NULL);
460 LineTo (hdc, x+3, y++); x++;
461 MoveToEx (hdc, x, y, NULL);
462 LineTo (hdc, x+1, y++);
466 * Draw the text string for this button.
467 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
468 * is non-zero, so we can simply check himlDef to see if we have
472 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
473 HDC hdc, INT nState, DWORD dwStyle)
475 RECT rcText = btnPtr->rect;
478 LPWSTR lpText = NULL;
479 HIMAGELIST himl = infoPtr->himlDef;
481 TRACE ("iString: %x\n", btnPtr->iString);
483 /* get a pointer to the text */
484 lpText = TOOLBAR_GetText(infoPtr, btnPtr);
486 TRACE ("Stringtext: %s\n", debugstr_w(lpText));
491 InflateRect (&rcText, -3, -3);
493 if (himl && TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
494 /* The following test looked like this before
495 * I changed it. IE4 "Links" toolbar would not
496 * draw correctly with the original code. - GA 8/01
497 * ((dwStyle & TBSTYLE_LIST) &&
498 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
499 * (btnPtr->iBitmap != I_IMAGENONE))
501 if (dwStyle & TBSTYLE_LIST) {
502 /* LIST style w/ ICON offset is by matching native. */
503 /* Matches IE4 "Links" bar. - GA 8/01 */
504 rcText.left += (infoPtr->nBitmapWidth + 2);
507 rcText.top += infoPtr->nBitmapHeight + 1;
511 if (dwStyle & TBSTYLE_LIST) {
512 /* LIST style w/o ICON offset is by matching native. */
513 /* Matches IE4 "menu" bar. - GA 8/01 */
518 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
519 OffsetRect (&rcText, 1, 1);
521 TRACE("string rect=(%d,%d)-(%d,%d)\n",
522 rcText.left, rcText.top, rcText.right, rcText.bottom);
524 hOldFont = SelectObject (hdc, infoPtr->hFont);
525 if (!(nState & TBSTATE_ENABLED)) {
526 clrOld = SetTextColor (hdc, comctl32_color.clr3dHilight);
527 OffsetRect (&rcText, 1, 1);
528 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
529 SetTextColor (hdc, comctl32_color.clr3dShadow);
530 OffsetRect (&rcText, -1, -1);
532 else if (nState & TBSTATE_INDETERMINATE) {
533 clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
536 /*************************************************************
537 * we cannot do this till we implement NM_CUSTOMDRAW for *
538 * each item. Whether the "hot" item is drawn raised, or *
539 * drawn with a blue background and white text is determined *
540 * by the flags returned on the notification. Till then *
541 * this is commented out. *
542 *************************************************************/
543 else if (btnPtr->bHot)
544 clrOld = SetTextColor (hdc, comctl32_color.clrHighlightText);
548 clrOld = SetTextColor (hdc, comctl32_color.clrBtnText);
551 DrawTextW (hdc, lpText, -1, &rcText, infoPtr->dwDTFlags);
552 SetTextColor (hdc, clrOld);
553 SelectObject (hdc, hOldFont);
559 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
561 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
562 INT cx = lpRect->right - lpRect->left;
563 INT cy = lpRect->bottom - lpRect->top;
564 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
565 SelectObject (hdc, hbr);
570 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
571 HDC hdc, INT x, INT y)
573 /* FIXME: this function is a hack since it uses image list
574 internals directly */
576 HIMAGELIST himl = infoPtr->himlDef;
584 /* create new dc's */
585 hdcImageList = CreateCompatibleDC (0);
586 hdcMask = CreateCompatibleDC (0);
588 /* create new bitmap */
589 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
590 SelectObject (hdcMask, hbmMask);
592 /* copy the mask bitmap */
593 SelectObject (hdcImageList, himl->hbmMask);
594 SetBkColor (hdcImageList, RGB(255, 255, 255));
595 SetTextColor (hdcImageList, RGB(0, 0, 0));
596 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
597 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
599 /* draw the new mask */
600 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
601 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
602 hdcMask, 0, 0, 0xB8074A);
604 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
605 BitBlt (hdc, x, y, himl->cx, himl->cy,
606 hdcMask, 0, 0, 0xB8074A);
608 DeleteObject (hbmMask);
610 DeleteDC (hdcImageList);
615 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
617 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
618 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
619 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
620 (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
621 RECT rc, rcArrow, rcBitmap;
623 if (btnPtr->fsState & TBSTATE_HIDDEN)
627 CopyRect (&rcArrow, &rc);
628 CopyRect(&rcBitmap, &rc);
630 if (!infoPtr->bBtnTranspnt)
631 FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
633 if (hasDropDownArrow)
635 if (dwStyle & TBSTYLE_FLAT)
636 rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
638 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
639 rcArrow.left = rc.right;
642 /* Center the bitmap horizontally and vertically */
643 if (dwStyle & TBSTYLE_LIST)
646 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
648 if(TOOLBAR_HasText(infoPtr, btnPtr))
649 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
651 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
653 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
654 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
655 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
658 if (btnPtr->fsStyle & TBSTYLE_SEP) {
659 /* with the FLAT style, iBitmap is the width and has already */
660 /* been taken into consideration in calculating the width */
661 /* so now we need to draw the vertical separator */
662 /* empirical tests show that iBitmap can/will be non-zero */
663 /* when drawing the vertical bar... */
664 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
665 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
666 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
668 TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
670 else if (btnPtr->fsStyle != TBSTYLE_SEP) {
671 FIXME("Draw some kind of separator: fsStyle=%x\n",
678 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
679 if (!(dwStyle & TBSTYLE_FLAT))
681 DrawEdge (hdc, &rc, EDGE_RAISED,
682 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
683 if (hasDropDownArrow)
684 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
685 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
688 if (hasDropDownArrow)
690 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
691 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
694 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
695 hdc, rcBitmap.left, rcBitmap.top,
697 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
699 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
703 /* pressed TBSTYLE_BUTTON */
704 if (btnPtr->fsState & TBSTATE_PRESSED) {
705 if (dwStyle & TBSTYLE_FLAT)
707 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
708 if (hasDropDownArrow)
709 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
713 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
714 if (hasDropDownArrow)
715 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
718 if (hasDropDownArrow)
719 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
721 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
722 hdc, rcBitmap.left+1, rcBitmap.top+1,
725 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
729 /* checked TBSTYLE_CHECK */
730 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
731 (btnPtr->fsState & TBSTATE_CHECKED)) {
732 if (dwStyle & TBSTYLE_FLAT)
733 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
734 BF_RECT | BF_ADJUST);
736 DrawEdge (hdc, &rc, EDGE_SUNKEN,
737 BF_RECT | BF_MIDDLE | BF_ADJUST);
739 TOOLBAR_DrawPattern (hdc, &rc);
741 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
742 hdc, rcBitmap.left+1, rcBitmap.top+1,
745 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
750 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
751 DrawEdge (hdc, &rc, EDGE_RAISED,
752 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
754 TOOLBAR_DrawPattern (hdc, &rc);
755 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
756 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
761 if (dwStyle & TBSTYLE_FLAT)
766 /*************************************************************
767 * we cannot do this till we implement NM_CUSTOMDRAW for *
768 * each item. Whether the "hot" item is drawn raised, or *
769 * drawn with a blue background and white text is determined *
770 * by the flags returned on the notification. Till then *
771 * this is commented out. *
772 *************************************************************/
777 oldclr = SetBkColor(hdc, comctl32_color.clrHighlight);
778 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
779 if (hasDropDownArrow)
780 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
781 SetBkColor(hdc, oldclr);
786 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
787 if (hasDropDownArrow)
788 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
792 else /* The following code needs to be removed after
793 * "hot item" support has been implemented for the
794 * case where it is being de-selected.
797 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
798 if (hasDropDownArrow)
799 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
803 if (hasDropDownArrow)
804 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
807 /* if hot, attempt to draw with himlHot, if fails, use himlDef */
808 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
811 rcBitmap.top, ILD_NORMAL))
812 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
813 hdc, rcBitmap.left, rcBitmap.top,
817 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
818 hdc, rcBitmap.left, rcBitmap.top,
823 DrawEdge (hdc, &rc, EDGE_RAISED,
824 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
826 if (hasDropDownArrow)
828 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
829 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
830 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
833 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
834 hdc, rcBitmap.left, rcBitmap.top,
838 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
843 TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
845 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
846 TBUTTON_INFO *btnPtr;
847 INT i, oldBKmode = 0;
850 /* if imagelist belongs to the app, it can be changed
851 by the app after setting it */
852 if (infoPtr->himlDef != infoPtr->himlInt)
853 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
855 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
857 if (infoPtr->bBtnTranspnt)
858 oldBKmode = SetBkMode (hdc, TRANSPARENT);
860 /* redraw necessary buttons */
861 btnPtr = infoPtr->buttons;
862 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
864 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
865 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
868 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
869 SetBkMode (hdc, oldBKmode);
872 /***********************************************************************
873 * TOOLBAR_MeasureString
875 * This function gets the width and height of a string in pixels. This
876 * is done first by using GetTextExtentPoint to get the basic width
877 * and height. The DrawText is called with DT_CALCRECT to get the exact
878 * width. The reason is because the text may have more than one "&" (or
879 * prefix characters as M$ likes to call them). The prefix character
880 * indicates where the underline goes, except for the string "&&" which
881 * is reduced to a single "&". GetTextExtentPoint does not process these
882 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
885 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
886 HDC hdc, LPSIZE lpSize)
893 if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
895 LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
898 /* first get size of all the text */
899 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
901 /* feed above size into the rectangle for DrawText */
902 myrect.left = myrect.top = 0;
903 myrect.right = lpSize->cx;
904 myrect.bottom = lpSize->cy;
906 /* Use DrawText to get true size as drawn (less pesky "&") */
907 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
908 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
911 /* feed back to caller */
912 lpSize->cx = myrect.right;
913 lpSize->cy = myrect.bottom;
917 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
920 /***********************************************************************
921 * TOOLBAR_CalcStrings
923 * This function walks through each string and measures it and returns
924 * the largest height and width to caller.
927 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
929 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
930 TBUTTON_INFO *btnPtr;
940 hOldFont = SelectObject (hdc, infoPtr->hFont);
942 btnPtr = infoPtr->buttons;
943 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
944 if(TOOLBAR_HasText(infoPtr, btnPtr))
946 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
947 if (sz.cx > lpSize->cx)
949 if (sz.cy > lpSize->cy)
954 SelectObject (hdc, hOldFont);
955 ReleaseDC (hwnd, hdc);
957 TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
960 /***********************************************************************
961 * TOOLBAR_WrapToolbar
963 * This function walks through the buttons and seperators in the
964 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
965 * wrapping should occur based on the width of the toolbar window.
966 * It does *not* calculate button placement itself. That task
967 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
968 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
969 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
971 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
972 * vertical toolbar lists.
976 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
978 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
979 TBUTTON_INFO *btnPtr;
982 BOOL bWrap, bButtonWrap;
984 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
985 /* no layout is necessary. Applications may use this style */
986 /* to perform their own layout on the toolbar. */
987 if( !(dwStyle & TBSTYLE_WRAPABLE) &&
988 !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) ) return;
990 btnPtr = infoPtr->buttons;
991 x = infoPtr->nIndent;
993 /* this can get the parents width, to know how far we can extend
994 * this toolbar. We cannot use its height, as there may be multiple
995 * toolbars in a rebar control
997 GetClientRect( GetParent(hwnd), &rc );
998 infoPtr->nWidth = rc.right - rc.left;
1001 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1002 infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
1005 for (i = 0; i < infoPtr->nNumButtons; i++ )
1008 btnPtr[i].fsState &= ~TBSTATE_WRAP;
1010 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
1013 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1014 /* it is the actual width of the separator. This is used for */
1015 /* custom controls in toolbars. */
1017 /* TBSTYLE_DROPDOWN separators are treated as buttons for */
1018 /* width. - GA 8/01 */
1019 if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1020 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
1021 cx = (btnPtr[i].iBitmap > 0) ?
1022 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
1024 cx = infoPtr->nButtonWidth;
1026 /* Two or more adjacent separators form a separator group. */
1027 /* The first separator in a group should be wrapped to the */
1028 /* next row if the previous wrapping is on a button. */
1030 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1031 (i + 1 < infoPtr->nNumButtons ) &&
1032 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
1034 TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
1035 btnPtr[i].fsState |= TBSTATE_WRAP;
1036 x = infoPtr->nIndent;
1038 bButtonWrap = FALSE;
1042 /* The layout makes sure the bitmap is visible, but not the button. */
1043 /* Test added to also wrap after a button that starts a row but */
1044 /* is bigger than the area. - GA 8/01 */
1045 if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
1046 > infoPtr->nWidth ) ||
1047 ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
1049 BOOL bFound = FALSE;
1051 /* If the current button is a separator and not hidden, */
1052 /* go to the next until it reaches a non separator. */
1053 /* Wrap the last separator if it is before a button. */
1054 while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1055 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
1056 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
1057 i < infoPtr->nNumButtons )
1063 if( bFound && i < infoPtr->nNumButtons )
1066 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1067 i, btnPtr[i].fsStyle, x, cx);
1068 btnPtr[i].fsState |= TBSTATE_WRAP;
1069 x = infoPtr->nIndent;
1070 bButtonWrap = FALSE;
1073 else if ( i >= infoPtr->nNumButtons)
1076 /* If the current button is not a separator, find the last */
1077 /* separator and wrap it. */
1078 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1080 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
1081 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
1085 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1086 i, btnPtr[i].fsStyle, x, cx);
1087 x = infoPtr->nIndent;
1088 btnPtr[j].fsState |= TBSTATE_WRAP;
1089 bButtonWrap = FALSE;
1094 /* If no separator available for wrapping, wrap one of */
1095 /* non-hidden previous button. */
1099 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1101 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
1106 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1107 i, btnPtr[i].fsStyle, x, cx);
1108 x = infoPtr->nIndent;
1109 btnPtr[j].fsState |= TBSTATE_WRAP;
1115 /* If all above failed, wrap the current button. */
1118 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1119 i, btnPtr[i].fsStyle, x, cx);
1120 btnPtr[i].fsState |= TBSTATE_WRAP;
1122 x = infoPtr->nIndent;
1123 if (btnPtr[i].fsStyle & TBSTYLE_SEP )
1124 bButtonWrap = FALSE;
1130 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1131 i, btnPtr[i].fsStyle, x, cx);
1138 /***********************************************************************
1139 * TOOLBAR_CalcToolbar
1141 * This function calculates button and separator placement. It first
1142 * calculates the button sizes, gets the toolbar window width and then
1143 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1144 * on. It assigns a new location to each item and sends this location to
1145 * the tooltip window if appropriate. Finally, it updates the rcBound
1146 * rect and calculates the new required toolbar window height.
1150 TOOLBAR_CalcToolbar (HWND hwnd)
1152 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
1153 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1154 TBUTTON_INFO *btnPtr;
1155 INT i, nRows, nSepRows;
1159 BOOL usesBitmaps = FALSE;
1160 BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
1162 TOOLBAR_CalcStrings (hwnd, &sizeString);
1164 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
1166 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
1169 if (dwStyle & TBSTYLE_LIST)
1171 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
1172 0, sizeString.cy) + infoPtr->szPadding.cy;
1173 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
1174 0) + sizeString.cx + 6;
1175 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1176 infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
1177 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
1178 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
1181 if (sizeString.cy > 0)
1184 infoPtr->nButtonHeight = sizeString.cy +
1185 2 + /* this is the space to separate text from bitmap */
1186 infoPtr->nBitmapHeight + 6;
1188 infoPtr->nButtonHeight = sizeString.cy + 6;
1190 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
1191 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
1193 if (sizeString.cx > infoPtr->nBitmapWidth)
1194 infoPtr->nButtonWidth = sizeString.cx + 6;
1195 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
1196 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
1199 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
1200 infoPtr->nButtonWidth = infoPtr->cxMin;
1201 if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
1202 infoPtr->nButtonWidth = infoPtr->cxMax;
1204 TOOLBAR_WrapToolbar( hwnd, dwStyle );
1206 x = infoPtr->nIndent;
1210 * We will set the height below, and we set the width on entry
1211 * so we do not reset them here..
1214 GetClientRect( hwnd, &rc );
1215 /* get initial values for toolbar */
1216 infoPtr->nWidth = rc.right - rc.left;
1217 infoPtr->nHeight = rc.bottom - rc.top;
1220 /* from above, minimum is a button, and possible text */
1221 cx = infoPtr->nButtonWidth;
1223 /* cannot use just ButtonHeight, we may have no buttons! */
1224 if (infoPtr->nNumButtons > 0)
1225 infoPtr->nHeight = infoPtr->nButtonHeight;
1227 cy = infoPtr->nHeight;
1229 nRows = nSepRows = 0;
1231 infoPtr->rcBound.top = y;
1232 infoPtr->rcBound.left = x;
1233 infoPtr->rcBound.bottom = y + cy;
1234 infoPtr->rcBound.right = x;
1236 btnPtr = infoPtr->buttons;
1238 /* do not base height/width on parent, if the parent is a */
1239 /* rebar control it could have multiple rows of toolbars */
1240 /* GetClientRect( GetParent(hwnd), &rc ); */
1241 /* cx = rc.right - rc.left; */
1242 /* cy = rc.bottom - rc.top; */
1244 TRACE("cy=%d\n", cy);
1246 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
1249 if (btnPtr->fsState & TBSTATE_HIDDEN)
1251 SetRectEmpty (&btnPtr->rect);
1255 cy = infoPtr->nHeight;
1257 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1258 /* it is the actual width of the separator. This is used for */
1259 /* custom controls in toolbars. */
1260 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1261 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
1262 cy = (btnPtr->iBitmap > 0) ?
1263 btnPtr->iBitmap : SEPARATOR_WIDTH;
1264 cx = infoPtr->nButtonWidth;
1267 cx = (btnPtr->iBitmap > 0) ?
1268 btnPtr->iBitmap : SEPARATOR_WIDTH;
1272 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
1279 hOldFont = SelectObject (hdc, infoPtr->hFont);
1281 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1283 SelectObject (hdc, hOldFont);
1284 ReleaseDC (hwnd, hdc);
1286 /* Fudge amount measured against IE4 "menu" and "Links" */
1287 /* toolbars with native control (v4.71). - GA 8/01 */
1288 cx = sz.cx + 6 + 5 + 5;
1289 if ((dwStyle & TBSTYLE_LIST) &&
1290 (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
1291 cx += infoPtr->nBitmapWidth;
1294 cx = infoPtr->nButtonWidth;
1296 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1297 cx += DDARROW_WIDTH;
1299 if (btnPtr->fsState & TBSTATE_WRAP )
1302 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
1304 if (infoPtr->rcBound.left > x)
1305 infoPtr->rcBound.left = x;
1306 if (infoPtr->rcBound.right < x + cx)
1307 infoPtr->rcBound.right = x + cx;
1308 if (infoPtr->rcBound.bottom < y + cy)
1309 infoPtr->rcBound.bottom = y + cy;
1311 /* Set the toolTip only for non-hidden, non-separator button */
1312 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
1316 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1317 ti.cbSize = sizeof(TTTOOLINFOA);
1319 ti.uId = btnPtr->idCommand;
1320 ti.rect = btnPtr->rect;
1321 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
1325 /* btnPtr->nRow is zero based. The space between the rows is */
1326 /* also considered as a row. */
1327 btnPtr->nRow = nRows + nSepRows;
1329 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1330 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow,
1335 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
1339 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1340 /* it is the actual width of the separator. This is used for */
1341 /* custom controls in toolbars. */
1342 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1343 y += cy + ( (btnPtr->iBitmap > 0 ) ?
1344 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
1348 /* nSepRows is used to calculate the extra height follwoing */
1352 x = infoPtr->nIndent;
1354 /* Increment row number unless this is the last button */
1355 /* and it has Wrap set. */
1356 if (i != infoPtr->nNumButtons-1)
1363 /* infoPtr->nRows is the number of rows on the toolbar */
1364 infoPtr->nRows = nRows + nSepRows + 1;
1367 /********************************************************************
1368 * The following while interesting, does not match the values *
1369 * created above for the button rectangles, nor the rcBound rect. *
1370 * We will comment it out and remove it later. *
1372 * The problem showed up as heights in the pager control that was *
1374 ********************************************************************/
1376 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1378 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
1379 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
1380 nSepRows * (infoPtr->nBitmapHeight + 1) +
1384 infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1386 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
1391 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
1393 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1394 TBUTTON_INFO *btnPtr;
1397 btnPtr = infoPtr->buttons;
1398 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1399 if (btnPtr->fsState & TBSTATE_HIDDEN)
1402 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1403 if (PtInRect (&btnPtr->rect, *lpPt)) {
1404 TRACE(" ON SEPARATOR %d!\n", i);
1409 if (PtInRect (&btnPtr->rect, *lpPt)) {
1410 TRACE(" ON BUTTON %d!\n", i);
1416 TRACE(" NOWHERE!\n");
1422 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
1424 TBUTTON_INFO *btnPtr;
1427 if (CommandIsIndex) {
1428 TRACE("command is really index command=%d\n", idCommand);
1429 if (idCommand >= infoPtr->nNumButtons) return -1;
1432 btnPtr = infoPtr->buttons;
1433 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1434 if (btnPtr->idCommand == idCommand) {
1435 TRACE("command=%d index=%d\n", idCommand, i);
1439 TRACE("no index found for command=%d\n", idCommand);
1445 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
1447 TBUTTON_INFO *btnPtr;
1450 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
1453 /* check index button */
1454 btnPtr = &infoPtr->buttons[nIndex];
1455 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1456 if (btnPtr->fsState & TBSTATE_CHECKED)
1460 /* check previous buttons */
1461 nRunIndex = nIndex - 1;
1462 while (nRunIndex >= 0) {
1463 btnPtr = &infoPtr->buttons[nRunIndex];
1464 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1465 if (btnPtr->fsState & TBSTATE_CHECKED)
1473 /* check next buttons */
1474 nRunIndex = nIndex + 1;
1475 while (nRunIndex < infoPtr->nNumButtons) {
1476 btnPtr = &infoPtr->buttons[nRunIndex];
1477 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1478 if (btnPtr->fsState & TBSTATE_CHECKED)
1491 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
1492 WPARAM wParam, LPARAM lParam)
1498 msg.wParam = wParam;
1499 msg.lParam = lParam;
1500 msg.time = GetMessageTime ();
1501 msg.pt.x = LOWORD(GetMessagePos ());
1502 msg.pt.y = HIWORD(GetMessagePos ());
1504 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
1508 /***********************************************************************
1509 * TOOLBAR_CustomizeDialogProc
1510 * This function implements the toolbar customization dialog.
1513 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1515 PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
1516 PCUSTOMBUTTON btnInfo;
1518 TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
1523 custInfo = (PCUSTDLG_INFO)lParam;
1524 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
1532 infoPtr = custInfo->tbInfo;
1534 /* send TBN_QUERYINSERT notification */
1535 nmtb.iItem = custInfo->tbInfo->nNumButtons;
1537 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
1540 /* add items to 'toolbar buttons' list and check if removable */
1541 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
1543 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1544 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1545 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1546 btnInfo->bVirtual = FALSE;
1547 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1549 /* send TBN_QUERYDELETE notification */
1551 btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
1555 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
1556 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1559 /* insert separator button into 'available buttons' list */
1560 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1561 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1562 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1563 btnInfo->bVirtual = FALSE;
1564 btnInfo->bRemovable = TRUE;
1565 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1566 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1567 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1569 /* insert all buttons into dsa */
1572 /* send TBN_GETBUTTONINFO notification */
1574 nmtb.pszText = Buffer;
1577 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA))
1580 TRACE("style: %x\n", nmtb.tbButton.fsStyle);
1582 /* insert button into the apropriate list */
1583 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
1586 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1587 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1588 btnInfo->bVirtual = FALSE;
1589 btnInfo->bRemovable = TRUE;
1590 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1591 strcpy (btnInfo->text, nmtb.pszText);
1593 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1594 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1598 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1599 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1600 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1601 strcpy (btnInfo->text, nmtb.pszText);
1603 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1607 /* select first item in the 'available' list */
1608 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
1610 /* append 'virtual' separator button to the 'toolbar buttons' list */
1611 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1612 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1613 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1614 btnInfo->bVirtual = TRUE;
1615 btnInfo->bRemovable = FALSE;
1616 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1617 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1618 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1620 /* select last item in the 'toolbar' list */
1621 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
1622 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
1624 /* set focus and disable buttons */
1625 PostMessageA (hwnd, WM_USER, 0, 0);
1630 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1631 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1632 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
1633 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
1637 EndDialog(hwnd, FALSE);
1641 switch (LOWORD(wParam))
1643 case IDC_TOOLBARBTN_LBOX:
1644 if (HIWORD(wParam) == LBN_SELCHANGE)
1646 PCUSTOMBUTTON btnInfo;
1651 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1652 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1654 /* send TBN_QUERYINSERT notification */
1656 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1659 /* get list box item */
1660 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1662 if (index == (count - 1))
1664 /* last item (virtual separator) */
1665 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1666 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1668 else if (index == (count - 2))
1670 /* second last item (last non-virtual item) */
1671 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1672 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1674 else if (index == 0)
1677 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1678 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1682 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1683 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1686 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
1690 case IDC_MOVEUP_BTN:
1692 PCUSTOMBUTTON btnInfo;
1696 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1697 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1698 TRACE("Move up: index %d\n", index);
1700 /* send TBN_QUERYINSERT notification */
1703 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1706 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1708 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1709 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
1710 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
1711 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1714 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1715 else if (index >= (count - 3))
1716 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1718 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1719 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
1724 case IDC_MOVEDN_BTN: /* move down */
1726 PCUSTOMBUTTON btnInfo;
1730 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1731 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1732 TRACE("Move up: index %d\n", index);
1734 /* send TBN_QUERYINSERT notification */
1736 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1739 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1741 /* move button down */
1742 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1743 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
1744 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
1745 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
1748 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1749 else if (index >= (count - 3))
1750 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1752 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1753 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
1758 case IDC_REMOVE_BTN: /* remove button */
1760 PCUSTOMBUTTON btnInfo;
1763 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1764 TRACE("Remove: index %d\n", index);
1766 /* send TBN_QUERYDELETE notification */
1768 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1771 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1772 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1773 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
1775 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1777 /* insert into 'available button' list */
1778 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
1780 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1781 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1784 COMCTL32_Free (btnInfo);
1789 case IDOK: /* Add button */
1794 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1795 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
1796 TRACE("Add: index %d\n", index);
1798 /* send TBN_QUERYINSERT notification */
1800 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1803 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
1807 /* remove from 'available buttons' list */
1808 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
1809 if (index == count-1)
1810 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1812 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
1816 PCUSTOMBUTTON btnNew;
1818 /* duplicate 'separator' button */
1819 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
1820 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
1824 /* insert into 'toolbar button' list */
1825 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1826 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
1827 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1829 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
1835 EndDialog(hwnd, FALSE);
1845 /* delete items from 'toolbar buttons' listbox*/
1846 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1847 for (i = 0; i < count; i++)
1849 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
1850 COMCTL32_Free(btnInfo);
1851 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
1853 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
1856 /* delete items from 'available buttons' listbox*/
1857 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1858 for (i = 0; i < count; i++)
1860 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
1861 COMCTL32_Free(btnInfo);
1862 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
1864 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
1869 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
1871 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
1876 COLORREF oldText = 0;
1880 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
1881 if (btnInfo == NULL)
1883 FIXME("btnInfo invalid!\n");
1887 /* set colors and select objects */
1888 oldBk = SetBkColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlight:comctl32_color.clrWindow);
1889 if (btnInfo->bVirtual)
1890 oldText = SetTextColor (lpdis->hDC, comctl32_color.clrGrayText);
1892 oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText);
1893 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1894 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1896 /* fill background rectangle */
1897 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
1898 lpdis->rcItem.right, lpdis->rcItem.bottom);
1900 /* calculate button and text rectangles */
1901 CopyRect (&rcButton, &lpdis->rcItem);
1902 InflateRect (&rcButton, -1, -1);
1903 CopyRect (&rcText, &rcButton);
1904 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
1905 rcText.left = rcButton.right + 2;
1907 /* draw focus rectangle */
1908 if (lpdis->itemState & ODS_FOCUS)
1909 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
1912 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
1914 /* draw image and text */
1915 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
1916 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
1917 rcButton.left+3, rcButton.top+3, ILD_NORMAL);
1918 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText,
1919 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
1921 /* delete objects and reset colors */
1922 SelectObject (lpdis->hDC, hOldBrush);
1923 SelectObject (lpdis->hDC, hOldPen);
1924 SetBkColor (lpdis->hDC, oldBk);
1925 SetTextColor (lpdis->hDC, oldText);
1931 case WM_MEASUREITEM:
1932 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
1934 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
1936 if (custInfo && custInfo->tbInfo)
1937 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
1939 lpmis->itemHeight = 15 + 8; /* default height */
1951 /***********************************************************************
1952 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
1956 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1958 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1959 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
1960 INT nIndex = 0, nButtons, nCount;
1963 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
1967 if (lpAddBmp->hInst == HINST_COMMCTRL)
1969 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
1971 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
1973 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
1978 TRACE ("adding %d internal bitmaps!\n", nButtons);
1980 /* Windows resize all the buttons to the size of a newly added standard image */
1981 if (lpAddBmp->nID & 1)
1984 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
1985 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
1987 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
1988 MAKELPARAM((WORD)24, (WORD)24));
1989 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
1990 MAKELPARAM((WORD)31, (WORD)30));
1995 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
1996 MAKELPARAM((WORD)16, (WORD)16));
1997 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
1998 MAKELPARAM((WORD)22, (WORD)22));
2001 TOOLBAR_CalcToolbar (hwnd);
2005 nButtons = (INT)wParam;
2009 TRACE ("adding %d bitmaps!\n", nButtons);
2012 if (!(infoPtr->himlDef)) {
2013 /* create new default image list */
2014 TRACE ("creating default image list!\n");
2017 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
2018 ILC_COLOR | ILC_MASK, nButtons, 2);
2019 infoPtr->himlInt = infoPtr->himlDef;
2022 nCount = ImageList_GetImageCount(infoPtr->himlDef);
2024 /* Add bitmaps to the default image list */
2025 if (lpAddBmp->hInst == (HINSTANCE)0)
2028 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
2031 else if (lpAddBmp->hInst == HINST_COMMCTRL)
2033 /* Add system bitmaps */
2034 switch (lpAddBmp->nID)
2036 case IDB_STD_SMALL_COLOR:
2037 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2038 MAKEINTRESOURCEA(IDB_STD_SMALL));
2039 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2040 hbmLoad, CLR_DEFAULT);
2041 DeleteObject (hbmLoad);
2044 case IDB_STD_LARGE_COLOR:
2045 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2046 MAKEINTRESOURCEA(IDB_STD_LARGE));
2047 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2048 hbmLoad, CLR_DEFAULT);
2049 DeleteObject (hbmLoad);
2052 case IDB_VIEW_SMALL_COLOR:
2053 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2054 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
2055 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2056 hbmLoad, CLR_DEFAULT);
2057 DeleteObject (hbmLoad);
2060 case IDB_VIEW_LARGE_COLOR:
2061 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2062 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
2063 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2064 hbmLoad, CLR_DEFAULT);
2065 DeleteObject (hbmLoad);
2068 case IDB_HIST_SMALL_COLOR:
2069 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2070 MAKEINTRESOURCEA(IDB_HIST_SMALL));
2071 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2072 hbmLoad, CLR_DEFAULT);
2073 DeleteObject (hbmLoad);
2076 case IDB_HIST_LARGE_COLOR:
2077 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2078 MAKEINTRESOURCEA(IDB_HIST_LARGE));
2079 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2080 hbmLoad, CLR_DEFAULT);
2081 DeleteObject (hbmLoad);
2085 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
2086 ERR ("invalid imagelist!\n");
2092 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
2093 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
2094 DeleteObject (hbmLoad);
2099 INT imagecount = ImageList_GetImageCount(infoPtr->himlDef);
2101 if (infoPtr->nNumBitmaps + nButtons != imagecount)
2103 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",
2104 infoPtr->nNumBitmaps, nCount, imagecount - nCount,
2105 infoPtr->nNumBitmaps+nButtons,imagecount);
2107 infoPtr->nNumBitmaps = imagecount;
2110 infoPtr->nNumBitmaps += nButtons;
2113 InvalidateRect(hwnd, NULL, FALSE);
2120 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2122 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2123 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2124 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2126 TRACE("adding %d buttons!\n", wParam);
2128 nAddButtons = (UINT)wParam;
2129 nOldButtons = infoPtr->nNumButtons;
2130 nNewButtons = nOldButtons + nAddButtons;
2132 if (infoPtr->nNumButtons == 0) {
2134 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2137 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2139 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2140 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2141 nOldButtons * sizeof(TBUTTON_INFO));
2142 COMCTL32_Free (oldButtons);
2145 infoPtr->nNumButtons = nNewButtons;
2147 /* insert new button data */
2148 for (nCount = 0; nCount < nAddButtons; nCount++) {
2149 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2150 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2151 btnPtr->idCommand = lpTbb[nCount].idCommand;
2152 btnPtr->fsState = lpTbb[nCount].fsState;
2153 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2154 btnPtr->dwData = lpTbb[nCount].dwData;
2155 btnPtr->iString = lpTbb[nCount].iString;
2156 btnPtr->bHot = FALSE;
2158 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2161 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2162 ti.cbSize = sizeof (TTTOOLINFOA);
2164 ti.uId = btnPtr->idCommand;
2166 ti.lpszText = LPSTR_TEXTCALLBACKA;
2168 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2173 TOOLBAR_CalcToolbar (hwnd);
2175 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2177 InvalidateRect(hwnd, NULL, FALSE);
2184 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2186 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2187 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2188 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2190 TRACE("adding %d buttons!\n", wParam);
2192 nAddButtons = (UINT)wParam;
2193 nOldButtons = infoPtr->nNumButtons;
2194 nNewButtons = nOldButtons + nAddButtons;
2196 if (infoPtr->nNumButtons == 0) {
2198 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2201 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2203 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2204 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2205 nOldButtons * sizeof(TBUTTON_INFO));
2206 COMCTL32_Free (oldButtons);
2209 infoPtr->nNumButtons = nNewButtons;
2211 /* insert new button data */
2212 for (nCount = 0; nCount < nAddButtons; nCount++) {
2213 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2214 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2215 btnPtr->idCommand = lpTbb[nCount].idCommand;
2216 btnPtr->fsState = lpTbb[nCount].fsState;
2217 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2218 btnPtr->dwData = lpTbb[nCount].dwData;
2219 btnPtr->iString = lpTbb[nCount].iString;
2220 btnPtr->bHot = FALSE;
2222 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2225 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2226 ti.cbSize = sizeof (TTTOOLINFOW);
2228 ti.uId = btnPtr->idCommand;
2230 ti.lpszText = LPSTR_TEXTCALLBACKW;
2232 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2237 TOOLBAR_CalcToolbar (hwnd);
2239 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2241 InvalidateRect(hwnd, NULL, FALSE);
2248 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2250 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2253 if ((wParam) && (HIWORD(lParam) == 0)) {
2256 TRACE("adding string from resource!\n");
2258 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
2261 TRACE("len=%d \"%s\"\n", len, szString);
2262 nIndex = infoPtr->nNumStrings;
2263 if (infoPtr->nNumStrings == 0) {
2265 COMCTL32_Alloc (sizeof(LPWSTR));
2268 LPWSTR *oldStrings = infoPtr->strings;
2270 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2271 memcpy (&infoPtr->strings[0], &oldStrings[0],
2272 sizeof(LPWSTR) * infoPtr->nNumStrings);
2273 COMCTL32_Free (oldStrings);
2276 /*COMCTL32_Alloc zeros out the allocated memory*/
2277 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
2278 infoPtr->nNumStrings++;
2281 LPSTR p = (LPSTR)lParam;
2286 TRACE("adding string(s) from array!\n");
2288 nIndex = infoPtr->nNumStrings;
2291 TRACE("len=%d \"%s\"\n", len, p);
2293 if (infoPtr->nNumStrings == 0) {
2295 COMCTL32_Alloc (sizeof(LPWSTR));
2298 LPWSTR *oldStrings = infoPtr->strings;
2300 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2301 memcpy (&infoPtr->strings[0], &oldStrings[0],
2302 sizeof(LPWSTR) * infoPtr->nNumStrings);
2303 COMCTL32_Free (oldStrings);
2306 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
2307 infoPtr->nNumStrings++;
2318 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2320 #define MAX_RESOURCE_STRING_LENGTH 512
2321 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2324 if ((wParam) && (HIWORD(lParam) == 0)) {
2325 WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
2327 TRACE("adding string from resource!\n");
2329 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
2330 szString, MAX_RESOURCE_STRING_LENGTH);
2332 TRACE("len=%d %s\n", len, debugstr_w(szString));
2333 TRACE("First char: 0x%x\n", *szString);
2334 if (szString[0] == L'|')
2336 PWSTR p = szString + 1;
2338 nIndex = infoPtr->nNumStrings;
2339 while (*p != L'|') {
2341 if (infoPtr->nNumStrings == 0) {
2343 COMCTL32_Alloc (sizeof(LPWSTR));
2346 LPWSTR *oldStrings = infoPtr->strings;
2348 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2349 memcpy (&infoPtr->strings[0], &oldStrings[0],
2350 sizeof(LPWSTR) * infoPtr->nNumStrings);
2351 COMCTL32_Free (oldStrings);
2354 len = COMCTL32_StrChrW (p, L'|') - p;
2355 TRACE("len=%d %s\n", len, debugstr_w(p));
2356 infoPtr->strings[infoPtr->nNumStrings] =
2357 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
2358 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
2359 infoPtr->nNumStrings++;
2366 nIndex = infoPtr->nNumStrings;
2367 if (infoPtr->nNumStrings == 0) {
2369 COMCTL32_Alloc (sizeof(LPWSTR));
2372 LPWSTR *oldStrings = infoPtr->strings;
2374 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2375 memcpy (&infoPtr->strings[0], &oldStrings[0],
2376 sizeof(LPWSTR) * infoPtr->nNumStrings);
2377 COMCTL32_Free (oldStrings);
2380 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
2381 infoPtr->nNumStrings++;
2385 LPWSTR p = (LPWSTR)lParam;
2390 TRACE("adding string(s) from array!\n");
2391 nIndex = infoPtr->nNumStrings;
2395 TRACE("len=%d %s\n", len, debugstr_w(p));
2396 if (infoPtr->nNumStrings == 0) {
2398 COMCTL32_Alloc (sizeof(LPWSTR));
2401 LPWSTR *oldStrings = infoPtr->strings;
2403 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2404 memcpy (&infoPtr->strings[0], &oldStrings[0],
2405 sizeof(LPWSTR) * infoPtr->nNumStrings);
2406 COMCTL32_Free (oldStrings);
2409 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
2410 infoPtr->nNumStrings++;
2421 TOOLBAR_AutoSize (HWND hwnd)
2423 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2424 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2430 UINT uPosFlags = SWP_NOZORDER;
2432 TRACE("resize forced, style=%lx!\n", dwStyle);
2434 parent = GetParent (hwnd);
2435 GetClientRect(parent, &parent_rect);
2437 x = parent_rect.left;
2438 y = parent_rect.top;
2440 /* FIXME: we should be able to early out if nothing */
2441 /* has changed with nWidth != parent_rect width */
2443 if (dwStyle & CCS_NORESIZE) {
2444 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2447 TOOLBAR_CalcToolbar (hwnd);
2450 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2451 TOOLBAR_CalcToolbar (hwnd);
2452 InvalidateRect( hwnd, NULL, TRUE );
2453 cy = infoPtr->nHeight;
2454 cx = infoPtr->nWidth;
2456 if (dwStyle & CCS_NOMOVEY) {
2457 GetWindowRect(hwnd, &window_rect);
2458 ScreenToClient(parent, (LPPOINT)&window_rect.left);
2459 y = window_rect.top;
2463 if (dwStyle & CCS_NOPARENTALIGN)
2464 uPosFlags |= SWP_NOMOVE;
2466 if (!(dwStyle & CCS_NODIVIDER))
2467 cy += GetSystemMetrics(SM_CYEDGE);
2469 if (dwStyle & WS_BORDER)
2472 cy += GetSystemMetrics(SM_CYEDGE);
2473 cx += GetSystemMetrics(SM_CYEDGE);
2476 infoPtr->bAutoSize = TRUE;
2477 SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
2479 /* The following line makes sure that the infoPtr->bAutoSize is turned off after
2480 * the setwindowpos calls */
2481 infoPtr->bAutoSize = FALSE;
2488 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
2490 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2492 return infoPtr->nNumButtons;
2497 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2499 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2501 if (infoPtr == NULL) {
2502 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
2503 ERR("infoPtr == NULL!\n");
2507 infoPtr->dwStructSize = (DWORD)wParam;
2514 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2516 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2517 TBUTTON_INFO *btnPtr;
2520 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2524 btnPtr = &infoPtr->buttons[nIndex];
2525 btnPtr->iBitmap = LOWORD(lParam);
2527 /* we HAVE to erase the background, the new bitmap could be */
2529 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2536 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2538 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2539 TBUTTON_INFO *btnPtr;
2542 BOOL bChecked = FALSE;
2544 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2548 btnPtr = &infoPtr->buttons[nIndex];
2550 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
2553 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
2555 if (LOWORD(lParam) == FALSE)
2556 btnPtr->fsState &= ~TBSTATE_CHECKED;
2558 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2560 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
2561 if (nOldIndex == nIndex)
2563 if (nOldIndex != -1)
2564 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2566 btnPtr->fsState |= TBSTATE_CHECKED;
2569 if( bChecked != LOWORD(lParam) )
2571 if (nOldIndex != -1)
2573 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
2574 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
2576 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2579 /* FIXME: Send a WM_NOTIFY?? */
2586 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
2588 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2590 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2595 TOOLBAR_Customize (HWND hwnd)
2597 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2598 CUSTDLG_INFO custInfo;
2604 custInfo.tbInfo = infoPtr;
2605 custInfo.tbHwnd = hwnd;
2607 /* send TBN_BEGINADJUST notification */
2608 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2611 if (!(hRes = FindResourceA (COMCTL32_hModule,
2612 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
2616 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
2619 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
2620 (LPDLGTEMPLATEA)template,
2622 (DLGPROC)TOOLBAR_CustomizeDialogProc,
2625 /* send TBN_ENDADJUST notification */
2626 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2634 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2636 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2637 INT nIndex = (INT)wParam;
2639 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2642 if ((infoPtr->hwndToolTip) &&
2643 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
2646 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2647 ti.cbSize = sizeof (TTTOOLINFOA);
2649 ti.uId = infoPtr->buttons[nIndex].idCommand;
2651 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
2654 if (infoPtr->nNumButtons == 1) {
2655 TRACE(" simple delete!\n");
2656 COMCTL32_Free (infoPtr->buttons);
2657 infoPtr->buttons = NULL;
2658 infoPtr->nNumButtons = 0;
2661 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2662 TRACE("complex delete! [nIndex=%d]\n", nIndex);
2664 infoPtr->nNumButtons--;
2665 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2667 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2668 nIndex * sizeof(TBUTTON_INFO));
2671 if (nIndex < infoPtr->nNumButtons) {
2672 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
2673 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
2676 COMCTL32_Free (oldButtons);
2679 TOOLBAR_CalcToolbar (hwnd);
2681 InvalidateRect (hwnd, NULL, TRUE);
2688 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2690 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2691 TBUTTON_INFO *btnPtr;
2695 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2699 btnPtr = &infoPtr->buttons[nIndex];
2701 bState = btnPtr->fsState & TBSTATE_ENABLED;
2703 /* update the toolbar button state */
2704 if(LOWORD(lParam) == FALSE) {
2705 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
2707 btnPtr->fsState |= TBSTATE_ENABLED;
2710 /* redraw the button only if the state of the button changed */
2711 if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
2713 InvalidateRect(hwnd, &btnPtr->rect,
2714 TOOLBAR_HasText(infoPtr, btnPtr));
2721 static inline LRESULT
2722 TOOLBAR_GetAnchorHighlight (HWND hwnd)
2724 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2726 return infoPtr->bAnchor;
2731 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2733 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2736 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2740 return infoPtr->buttons[nIndex].iBitmap;
2744 static inline LRESULT
2745 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2747 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
2752 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2754 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2755 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2756 INT nIndex = (INT)wParam;
2757 TBUTTON_INFO *btnPtr;
2759 if (infoPtr == NULL)
2765 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2768 btnPtr = &infoPtr->buttons[nIndex];
2769 lpTbb->iBitmap = btnPtr->iBitmap;
2770 lpTbb->idCommand = btnPtr->idCommand;
2771 lpTbb->fsState = btnPtr->fsState;
2772 lpTbb->fsStyle = btnPtr->fsStyle;
2773 lpTbb->dwData = btnPtr->dwData;
2774 lpTbb->iString = btnPtr->iString;
2781 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2783 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2784 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
2785 TBUTTON_INFO *btnPtr;
2788 if (infoPtr == NULL)
2790 if (lpTbInfo == NULL)
2792 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
2795 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
2796 lpTbInfo->dwMask & 0x80000000);
2800 if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
2802 if (lpTbInfo->dwMask & TBIF_COMMAND)
2803 lpTbInfo->idCommand = btnPtr->idCommand;
2804 if (lpTbInfo->dwMask & TBIF_IMAGE)
2805 lpTbInfo->iImage = btnPtr->iBitmap;
2806 if (lpTbInfo->dwMask & TBIF_LPARAM)
2807 lpTbInfo->lParam = btnPtr->dwData;
2808 if (lpTbInfo->dwMask & TBIF_SIZE)
2809 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
2810 if (lpTbInfo->dwMask & TBIF_STATE)
2811 lpTbInfo->fsState = btnPtr->fsState;
2812 if (lpTbInfo->dwMask & TBIF_STYLE)
2813 lpTbInfo->fsStyle = btnPtr->fsStyle;
2814 if (lpTbInfo->dwMask & TBIF_TEXT) {
2815 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
2816 Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
2823 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2825 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2826 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
2827 TBUTTON_INFO *btnPtr;
2830 if (infoPtr == NULL)
2832 if (lpTbInfo == NULL)
2834 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
2837 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
2838 lpTbInfo->dwMask & 0x80000000);
2842 btnPtr = &infoPtr->buttons[nIndex];
2844 if (lpTbInfo->dwMask & TBIF_COMMAND)
2845 lpTbInfo->idCommand = btnPtr->idCommand;
2846 if (lpTbInfo->dwMask & TBIF_IMAGE)
2847 lpTbInfo->iImage = btnPtr->iBitmap;
2848 if (lpTbInfo->dwMask & TBIF_LPARAM)
2849 lpTbInfo->lParam = btnPtr->dwData;
2850 if (lpTbInfo->dwMask & TBIF_SIZE)
2851 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
2852 if (lpTbInfo->dwMask & TBIF_STATE)
2853 lpTbInfo->fsState = btnPtr->fsState;
2854 if (lpTbInfo->dwMask & TBIF_STYLE)
2855 lpTbInfo->fsStyle = btnPtr->fsStyle;
2856 if (lpTbInfo->dwMask & TBIF_TEXT) {
2857 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
2858 Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
2866 TOOLBAR_GetButtonSize (HWND hwnd)
2868 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2870 if (infoPtr->nNumButtons > 0)
2871 return MAKELONG((WORD)infoPtr->nButtonWidth,
2872 (WORD)infoPtr->nButtonHeight);
2874 return MAKELONG(8,7);
2879 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2881 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2888 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2892 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
2894 return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
2895 (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
2900 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2902 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2909 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2913 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
2915 strcpyW ((LPWSTR)lParam, lpText);
2917 return strlenW (lpText);
2922 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2924 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2926 return (LRESULT)infoPtr->himlDis;
2930 inline static LRESULT
2931 TOOLBAR_GetExtendedStyle (HWND hwnd)
2933 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2935 return infoPtr->dwExStyle;
2940 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2942 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2944 return (LRESULT)infoPtr->himlHot;
2949 TOOLBAR_GetHotItem (HWND hwnd)
2951 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2953 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2956 if (infoPtr->nHotItem < 0)
2959 return (LRESULT)infoPtr->nHotItem;
2964 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2966 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2968 return (LRESULT)infoPtr->himlDef;
2972 /* << TOOLBAR_GetInsertMark >> */
2973 /* << TOOLBAR_GetInsertMarkColor >> */
2977 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
2979 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2980 TBUTTON_INFO *btnPtr;
2984 if (infoPtr == NULL)
2986 nIndex = (INT)wParam;
2987 btnPtr = &infoPtr->buttons[nIndex];
2988 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2990 lpRect = (LPRECT)lParam;
2993 if (btnPtr->fsState & TBSTATE_HIDDEN)
2996 lpRect->left = btnPtr->rect.left;
2997 lpRect->right = btnPtr->rect.right;
2998 lpRect->bottom = btnPtr->rect.bottom;
2999 lpRect->top = btnPtr->rect.top;
3006 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3008 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3009 LPSIZE lpSize = (LPSIZE)lParam;
3014 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
3015 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
3017 TRACE("maximum size %d x %d\n",
3018 infoPtr->rcBound.right - infoPtr->rcBound.left,
3019 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
3025 /* << TOOLBAR_GetObject >> */
3029 TOOLBAR_GetPadding (HWND hwnd)
3031 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3034 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
3035 return (LRESULT) oldPad;
3040 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3042 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3043 TBUTTON_INFO *btnPtr;
3047 if (infoPtr == NULL)
3049 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3050 btnPtr = &infoPtr->buttons[nIndex];
3051 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3053 lpRect = (LPRECT)lParam;
3057 lpRect->left = btnPtr->rect.left;
3058 lpRect->right = btnPtr->rect.right;
3059 lpRect->bottom = btnPtr->rect.bottom;
3060 lpRect->top = btnPtr->rect.top;
3067 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3069 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3071 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
3072 return infoPtr->nRows;
3079 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
3081 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3084 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3088 return infoPtr->buttons[nIndex].fsState;
3093 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3095 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3098 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3102 return infoPtr->buttons[nIndex].fsStyle;
3107 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3109 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3111 if (infoPtr == NULL)
3114 return infoPtr->nMaxTextRows;
3119 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
3121 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3123 if (infoPtr == NULL)
3125 return infoPtr->hwndToolTip;
3130 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
3132 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3134 TRACE("%s hwnd=0x%x stub!\n",
3135 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
3137 return infoPtr->bUnicode;
3141 inline static LRESULT
3142 TOOLBAR_GetVersion (HWND hwnd)
3144 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3145 return infoPtr->iVersion;
3150 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3152 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3153 TBUTTON_INFO *btnPtr;
3158 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3162 btnPtr = &infoPtr->buttons[nIndex];
3163 if (LOWORD(lParam) == FALSE)
3164 btnPtr->fsState &= ~TBSTATE_HIDDEN;
3166 btnPtr->fsState |= TBSTATE_HIDDEN;
3168 TOOLBAR_CalcToolbar (hwnd);
3170 InvalidateRect (hwnd, NULL, TRUE);
3176 inline static LRESULT
3177 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
3179 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
3184 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3186 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3187 TBUTTON_INFO *btnPtr;
3190 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3194 btnPtr = &infoPtr->buttons[nIndex];
3195 if (LOWORD(lParam) == FALSE)
3196 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
3198 btnPtr->fsState |= TBSTATE_INDETERMINATE;
3200 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3207 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3209 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3210 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3211 INT nIndex = (INT)wParam;
3212 TBUTTON_INFO *oldButtons;
3217 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3220 /* EPP: this seems to be an undocumented call (from my IE4)
3221 * I assume in that case that:
3222 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3223 * - index of insertion is at the end of existing buttons
3224 * I only see this happen with nIndex == -1, but it could have a special
3225 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3227 nIndex = infoPtr->nNumButtons;
3229 } else if (nIndex < 0)
3232 /* If the string passed is not an index, assume address of string
3233 and do our own AddString */
3234 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3238 TRACE("string %s passed instead of index, adding string\n",
3239 debugstr_a((LPSTR)lpTbb->iString));
3240 len = strlen((LPSTR)lpTbb->iString) + 2;
3241 ptr = COMCTL32_Alloc(len);
3242 strcpy(ptr, (LPSTR)lpTbb->iString);
3243 ptr[len - 1] = 0; /* ended by two '\0' */
3244 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
3248 TRACE("inserting button index=%d\n", nIndex);
3249 if (nIndex > infoPtr->nNumButtons) {
3250 nIndex = infoPtr->nNumButtons;
3251 TRACE("adjust index=%d\n", nIndex);
3254 oldButtons = infoPtr->buttons;
3255 infoPtr->nNumButtons++;
3256 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3257 /* pre insert copy */
3259 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3260 nIndex * sizeof(TBUTTON_INFO));
3263 /* insert new button */
3264 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3265 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3266 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3267 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3268 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3269 /* if passed string and not index, then add string */
3270 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3271 Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
3274 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3276 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3279 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
3280 ti.cbSize = sizeof (TTTOOLINFOA);
3282 ti.uId = lpTbb->idCommand;
3284 ti.lpszText = LPSTR_TEXTCALLBACKA;
3286 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
3290 /* post insert copy */
3291 if (nIndex < infoPtr->nNumButtons - 1) {
3292 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3293 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3296 COMCTL32_Free (oldButtons);
3298 TOOLBAR_CalcToolbar (hwnd);
3300 InvalidateRect (hwnd, NULL, TRUE);
3307 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3309 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3310 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3311 INT nIndex = (INT)wParam;
3312 TBUTTON_INFO *oldButtons;
3317 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3320 /* EPP: this seems to be an undocumented call (from my IE4)
3321 * I assume in that case that:
3322 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3323 * - index of insertion is at the end of existing buttons
3324 * I only see this happen with nIndex == -1, but it could have a special
3325 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3327 nIndex = infoPtr->nNumButtons;
3329 } else if (nIndex < 0)
3332 /* If the string passed is not an index, assume address of string
3333 and do our own AddString */
3334 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3338 TRACE("string %s passed instead of index, adding string\n",
3339 debugstr_w((LPWSTR)lpTbb->iString));
3340 len = strlenW((LPWSTR)lpTbb->iString) + 2;
3341 ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
3342 strcpyW(ptr, (LPWSTR)lpTbb->iString);
3343 ptr[len - 1] = 0; /* ended by two '\0' */
3344 lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
3348 TRACE("inserting button index=%d\n", nIndex);
3349 if (nIndex > infoPtr->nNumButtons) {
3350 nIndex = infoPtr->nNumButtons;
3351 TRACE("adjust index=%d\n", nIndex);
3354 oldButtons = infoPtr->buttons;
3355 infoPtr->nNumButtons++;
3356 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3357 /* pre insert copy */
3359 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3360 nIndex * sizeof(TBUTTON_INFO));
3363 /* insert new button */
3364 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3365 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3366 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3367 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3368 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3369 /* if passed string and not index, then add string */
3370 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3371 Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
3374 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3376 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3379 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
3380 ti.cbSize = sizeof (TTTOOLINFOW);
3382 ti.uId = lpTbb->idCommand;
3384 ti.lpszText = LPSTR_TEXTCALLBACKW;
3386 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
3390 /* post insert copy */
3391 if (nIndex < infoPtr->nNumButtons - 1) {
3392 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3393 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3396 COMCTL32_Free (oldButtons);
3398 TOOLBAR_CalcToolbar (hwnd);
3400 InvalidateRect (hwnd, NULL, TRUE);
3406 /* << TOOLBAR_InsertMarkHitTest >> */
3410 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
3412 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3415 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3419 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
3424 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
3426 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3429 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3433 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
3438 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
3440 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3443 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3447 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
3452 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
3454 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3457 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3461 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
3466 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3468 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3471 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3475 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
3480 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
3482 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3485 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3489 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
3493 /* << TOOLBAR_LoadImages >> */
3494 /* << TOOLBAR_MapAccelerator >> */
3495 /* << TOOLBAR_MarkButton >> */
3496 /* << TOOLBAR_MoveButton >> */
3500 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3502 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3503 TBUTTON_INFO *btnPtr;
3506 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3510 btnPtr = &infoPtr->buttons[nIndex];
3511 if (LOWORD(lParam) == FALSE)
3512 btnPtr->fsState &= ~TBSTATE_PRESSED;
3514 btnPtr->fsState |= TBSTATE_PRESSED;
3516 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3522 /* << TOOLBAR_ReplaceBitmap >> */
3526 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3529 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3530 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
3532 if (lpSave == NULL) return 0;
3535 /* save toolbar information */
3536 FIXME("save to \"%s\" \"%s\"\n",
3537 lpSave->pszSubKey, lpSave->pszValueName);
3542 /* restore toolbar information */
3544 FIXME("restore from \"%s\" \"%s\"\n",
3545 lpSave->pszSubKey, lpSave->pszValueName);
3556 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3559 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3560 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
3566 /* save toolbar information */
3567 FIXME("save to \"%s\" \"%s\"\n",
3568 lpSave->pszSubKey, lpSave->pszValueName);
3573 /* restore toolbar information */
3575 FIXME("restore from \"%s\" \"%s\"\n",
3576 lpSave->pszSubKey, lpSave->pszValueName);
3587 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
3589 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3590 BOOL bOldAnchor = infoPtr->bAnchor;
3592 infoPtr->bAnchor = (BOOL)wParam;
3594 return (LRESULT)bOldAnchor;
3599 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3601 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3603 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
3606 if (infoPtr->nNumButtons > 0)
3607 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
3608 infoPtr->nNumButtons,
3609 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
3610 LOWORD(lParam), HIWORD(lParam));
3612 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
3613 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
3615 /* uses image list internals directly */
3616 if (infoPtr->himlDef) {
3617 infoPtr->himlDef->cx = infoPtr->nBitmapWidth;
3618 infoPtr->himlDef->cy = infoPtr->nBitmapHeight;
3626 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3628 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3629 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
3630 TBUTTON_INFO *btnPtr;
3635 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
3638 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3639 lptbbi->dwMask & 0x80000000);
3643 btnPtr = &infoPtr->buttons[nIndex];
3644 if (lptbbi->dwMask & TBIF_COMMAND)
3645 btnPtr->idCommand = lptbbi->idCommand;
3646 if (lptbbi->dwMask & TBIF_IMAGE)
3647 btnPtr->iBitmap = lptbbi->iImage;
3648 if (lptbbi->dwMask & TBIF_LPARAM)
3649 btnPtr->dwData = lptbbi->lParam;
3650 /* if (lptbbi->dwMask & TBIF_SIZE) */
3651 /* btnPtr->cx = lptbbi->cx; */
3652 if (lptbbi->dwMask & TBIF_STATE)
3653 btnPtr->fsState = lptbbi->fsState;
3654 if (lptbbi->dwMask & TBIF_STYLE)
3655 btnPtr->fsStyle = lptbbi->fsStyle;
3657 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3658 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3659 /* iString is index, zero it to make Str_SetPtr succeed */
3662 Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
3669 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3671 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3672 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
3673 TBUTTON_INFO *btnPtr;
3678 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
3681 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3682 lptbbi->dwMask & 0x80000000);
3686 btnPtr = &infoPtr->buttons[nIndex];
3687 if (lptbbi->dwMask & TBIF_COMMAND)
3688 btnPtr->idCommand = lptbbi->idCommand;
3689 if (lptbbi->dwMask & TBIF_IMAGE)
3690 btnPtr->iBitmap = lptbbi->iImage;
3691 if (lptbbi->dwMask & TBIF_LPARAM)
3692 btnPtr->dwData = lptbbi->lParam;
3693 /* if (lptbbi->dwMask & TBIF_SIZE) */
3694 /* btnPtr->cx = lptbbi->cx; */
3695 if (lptbbi->dwMask & TBIF_STATE)
3696 btnPtr->fsState = lptbbi->fsState;
3697 if (lptbbi->dwMask & TBIF_STYLE)
3698 btnPtr->fsStyle = lptbbi->fsStyle;
3700 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3701 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3702 /* iString is index, zero it to make Str_SetPtr succeed */
3704 Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
3711 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3713 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3714 INT cx = LOWORD(lParam), cy = HIWORD(lParam);
3716 if ((cx < 0) || (cy < 0))
3718 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
3722 /* The documentation claims you can only change the button size before
3723 * any button has been added. But this is wrong.
3724 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
3725 * it to the toolbar, and it checks that the return value is nonzero - mjm
3726 * Further testing shows that we must actually perform the change too.
3729 * The documentation also does not mention that if 0 is supplied for
3730 * either size, the system changes it to the default of 24 wide and
3731 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
3733 infoPtr->nButtonWidth = (cx) ? cx : 24;
3734 infoPtr->nButtonHeight = (cy) ? cy : 22;
3740 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
3742 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3744 if (infoPtr == NULL) {
3745 TRACE("Toolbar not initialized yet?????\n");
3749 /* if setting to current values, ignore */
3750 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
3751 (infoPtr->cxMax == (INT)HIWORD(lParam))) {
3752 TRACE("matches current width, min=%d, max=%d, no recalc\n",
3753 infoPtr->cxMin, infoPtr->cxMax);
3757 /* save new values */
3758 infoPtr->cxMin = (INT)LOWORD(lParam);
3759 infoPtr->cxMax = (INT)HIWORD(lParam);
3761 /* if both values are 0 then we are done */
3763 TRACE("setting both min and max to 0, norecalc\n");
3767 /* otherwise we need to recalc the toolbar and in some cases
3768 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
3769 which doesn't actually draw - GA). */
3770 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
3771 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
3773 TOOLBAR_CalcToolbar (hwnd);
3775 InvalidateRect (hwnd, NULL, TRUE);
3782 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
3784 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3785 INT nIndex = (INT)wParam;
3787 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3790 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
3792 if (infoPtr->hwndToolTip) {
3794 FIXME("change tool tip!\n");
3803 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3805 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3806 HIMAGELIST himlTemp;
3810 FIXME("no support for multiple image lists\n");
3814 himlTemp = infoPtr->himlDis;
3815 infoPtr->himlDis = (HIMAGELIST)lParam;
3817 /* FIXME: redraw ? */
3819 return (LRESULT)himlTemp;
3824 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
3826 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3829 dwTemp = infoPtr->dwDTFlags;
3830 infoPtr->dwDTFlags =
3831 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
3833 return (LRESULT)dwTemp;
3837 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3839 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3842 dwTemp = infoPtr->dwExStyle;
3843 infoPtr->dwExStyle = (DWORD)lParam;
3845 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
3846 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
3847 FIXME("Extended style not implemented %s %s\n",
3848 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
3849 "TBSTYLE_EX_MIXEDBUTTONS" : "",
3850 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
3851 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
3854 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
3855 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
3856 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
3858 return (LRESULT)dwTemp;
3863 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3865 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3866 HIMAGELIST himlTemp;
3869 FIXME("no support for multiple image lists\n");
3873 himlTemp = infoPtr->himlHot;
3874 infoPtr->himlHot = (HIMAGELIST)lParam;
3876 /* FIXME: redraw ? */
3878 return (LRESULT)himlTemp;
3883 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
3885 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3886 INT nOldHotItem = infoPtr->nHotItem;
3887 TBUTTON_INFO *btnPtr;
3889 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
3892 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
3895 infoPtr->nHotItem = (INT)wParam;
3896 if ((INT)wParam >=0)
3898 btnPtr = &infoPtr->buttons[(INT)wParam];
3899 btnPtr->bHot = TRUE;
3900 InvalidateRect (hwnd, &btnPtr->rect,
3901 TOOLBAR_HasText(infoPtr, btnPtr));
3905 btnPtr = &infoPtr->buttons[nOldHotItem];
3906 btnPtr->bHot = FALSE;
3907 InvalidateRect (hwnd, &btnPtr->rect,
3908 TOOLBAR_HasText(infoPtr, btnPtr));
3912 if (nOldHotItem < 0)
3915 return (LRESULT)nOldHotItem;
3920 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3922 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3923 HIMAGELIST himlTemp;
3926 FIXME("no support for multiple image lists\n");
3930 himlTemp = infoPtr->himlDef;
3931 infoPtr->himlDef = (HIMAGELIST)lParam;
3933 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
3935 ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
3936 &infoPtr->nBitmapHeight);
3937 TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
3938 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
3939 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
3941 /* FIXME: redraw ? */
3942 InvalidateRect(hwnd, NULL, TRUE);
3944 return (LRESULT)himlTemp;
3949 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
3951 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3953 infoPtr->nIndent = (INT)wParam;
3957 /* process only on indent changing */
3958 if(infoPtr->nIndent != (INT)wParam)
3960 infoPtr->nIndent = (INT)wParam;
3961 TOOLBAR_CalcToolbar (hwnd);
3962 InvalidateRect(hwnd, NULL, FALSE);
3969 /* << TOOLBAR_SetInsertMark >> */
3973 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
3975 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3977 infoPtr->clrInsertMark = (COLORREF)lParam;
3979 /* FIXME : redraw ??*/
3986 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3988 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3990 if (infoPtr == NULL)
3993 infoPtr->nMaxTextRows = (INT)wParam;
4000 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
4002 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4005 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4006 infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
4007 infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
4008 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
4009 infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4010 return (LRESULT) oldPad;
4015 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4017 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4022 if (infoPtr == NULL)
4024 hwndOldNotify = infoPtr->hwndNotify;
4025 infoPtr->hwndNotify = (HWND)wParam;
4027 return hwndOldNotify;
4032 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4034 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4035 LPRECT lprc = (LPRECT)lParam;
4039 if (LOWORD(wParam) > 1) {
4040 FIXME("multiple rows not supported!\n");
4043 if(infoPtr->nRows != LOWORD(wParam))
4045 infoPtr->nRows = LOWORD(wParam);
4047 /* recalculate toolbar */
4048 TOOLBAR_CalcToolbar (hwnd);
4050 /* repaint toolbar */
4051 InvalidateRect(hwnd, NULL, FALSE);
4054 /* return bounding rectangle */
4056 lprc->left = infoPtr->rcBound.left;
4057 lprc->right = infoPtr->rcBound.right;
4058 lprc->top = infoPtr->rcBound.top;
4059 lprc->bottom = infoPtr->rcBound.bottom;
4067 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
4069 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4070 TBUTTON_INFO *btnPtr;
4073 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4077 btnPtr = &infoPtr->buttons[nIndex];
4079 /* if hidden state has changed the invalidate entire window and recalc */
4080 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
4081 btnPtr->fsState = LOWORD(lParam);
4082 TOOLBAR_CalcToolbar (hwnd);
4083 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
4087 /* process state changing if current state doesn't match new state */
4088 if(btnPtr->fsState != LOWORD(lParam))
4090 btnPtr->fsState = LOWORD(lParam);
4091 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4100 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4102 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4103 TBUTTON_INFO *btnPtr;
4106 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4110 btnPtr = &infoPtr->buttons[nIndex];
4112 /* process style change if current style doesn't match new style */
4113 if(btnPtr->fsStyle != LOWORD(lParam))
4115 btnPtr->fsStyle = LOWORD(lParam);
4116 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4119 if (infoPtr->hwndToolTip) {
4120 FIXME("change tool tip!\n");
4128 inline static LRESULT
4129 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
4131 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4133 if (infoPtr == NULL)
4135 infoPtr->hwndToolTip = (HWND)wParam;
4141 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
4143 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4146 TRACE("%s hwnd=0x%04x stub!\n",
4147 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
4149 bTemp = infoPtr->bUnicode;
4150 infoPtr->bUnicode = (BOOL)wParam;
4157 TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4159 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4161 lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
4162 comctl32_color.clrBtnHighlight :
4163 infoPtr->clrBtnHighlight;
4164 lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
4165 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
4171 TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4173 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4175 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4176 lParam->clrBtnHighlight, lParam->clrBtnShadow,
4177 infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow);
4179 infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
4180 infoPtr->clrBtnShadow = lParam->clrBtnShadow;
4181 InvalidateRect(hwnd, 0, 0);
4187 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
4189 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4190 INT iOldVersion = infoPtr->iVersion;
4192 infoPtr->iVersion = iVersion;
4198 /*********************************************************************/
4200 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */
4201 /* without the restriction of TBSTYLE_FLAT. This implementation is */
4202 /* based on relay traces of the native control and IE 5.5 */
4204 /*********************************************************************/
4206 TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam)
4208 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4209 INT nOldHotItem = infoPtr->nHotItem;
4210 TBUTTON_INFO *btnPtr;
4212 NMTBHOTITEM nmhotitem;
4214 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4217 infoPtr->nHotItem = (INT)wParam;
4218 if (nOldHotItem != infoPtr->nHotItem) {
4219 nmhotitem.dwFlags = (DWORD)lParam;
4220 if ( !(nmhotitem.dwFlags & HICF_ENTERING) )
4221 nmhotitem.idOld = (nOldHotItem >= 0) ?
4222 infoPtr->buttons[nOldHotItem].idCommand : 0;
4223 if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
4224 nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
4225 infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
4226 no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
4228 if ((INT)wParam >=0) {
4229 btnPtr = &infoPtr->buttons[(INT)wParam];
4230 btnPtr->bHot = (no_hi) ? FALSE : TRUE;
4231 InvalidateRect (hwnd, &btnPtr->rect,
4232 TOOLBAR_HasText(infoPtr, btnPtr));
4234 if (nOldHotItem>=0) {
4235 btnPtr = &infoPtr->buttons[nOldHotItem];
4236 btnPtr->bHot = FALSE;
4237 InvalidateRect (hwnd, &btnPtr->rect,
4238 TOOLBAR_HasText(infoPtr, btnPtr));
4241 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
4242 nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi);
4244 if (nOldHotItem < 0)
4247 return (LRESULT)nOldHotItem;
4252 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
4254 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4255 LPSIZE lpsize = (LPSIZE)lParam;
4261 * Testing shows the following:
4262 * wParam = 0 adjust cx value
4263 * = 1 set cy value to max size.
4264 * lParam pointer to SIZE structure
4267 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4268 wParam, lParam, lpsize->cx, lpsize->cy);
4272 if (lpsize->cx == -1) {
4273 /* **** this is wrong, native measures each button and sets it */
4274 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4276 else if(HIWORD(lpsize->cx)) {
4278 HWND hwndParent = GetParent(hwnd);
4280 InvalidateRect(hwnd, 0, 1);
4281 GetWindowRect(hwnd, &rc);
4282 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
4283 TRACE("mapped to (%d,%d)-(%d,%d)\n",
4284 rc.left, rc.top, rc.right, rc.bottom);
4285 lpsize->cx = max(rc.right-rc.left,
4286 infoPtr->rcBound.right - infoPtr->rcBound.left);
4289 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4293 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4294 /* lpsize->cy = infoPtr->nHeight; */
4297 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4301 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4302 lpsize->cx, lpsize->cy);
4308 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
4310 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4311 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4314 /* initialize info structure */
4315 infoPtr->nButtonHeight = 22;
4316 infoPtr->nButtonWidth = 24;
4317 infoPtr->nBitmapHeight = 15;
4318 infoPtr->nBitmapWidth = 16;
4320 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
4322 infoPtr->nMaxTextRows = 1;
4323 infoPtr->cxMin = -1;
4324 infoPtr->cxMax = -1;
4325 infoPtr->nNumBitmaps = 0;
4326 infoPtr->nNumStrings = 0;
4328 infoPtr->bCaptured = FALSE;
4329 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4330 infoPtr->nButtonDown = -1;
4331 infoPtr->nOldHit = -1;
4332 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4333 infoPtr->hwndNotify = GetParent (hwnd);
4334 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
4335 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
4336 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
4337 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
4338 infoPtr->iVersion = 0;
4339 infoPtr->hwndSelf = hwnd;
4340 infoPtr->bDoRedraw = TRUE;
4341 infoPtr->clrBtnHighlight = CLR_DEFAULT;
4342 infoPtr->clrBtnShadow = CLR_DEFAULT;
4343 infoPtr->szPadding.cx = 7;
4344 infoPtr->szPadding.cy = 6;
4345 TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
4347 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
4348 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
4350 if (dwStyle & TBSTYLE_TOOLTIPS) {
4351 /* Create tooltip control */
4352 infoPtr->hwndToolTip =
4353 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
4354 CW_USEDEFAULT, CW_USEDEFAULT,
4355 CW_USEDEFAULT, CW_USEDEFAULT,
4358 /* Send NM_TOOLTIPSCREATED notification */
4359 if (infoPtr->hwndToolTip) {
4360 NMTOOLTIPSCREATED nmttc;
4362 nmttc.hwndToolTips = infoPtr->hwndToolTip;
4364 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
4365 NM_TOOLTIPSCREATED);
4369 TOOLBAR_CheckStyle (hwnd, dwStyle);
4371 TOOLBAR_CalcToolbar(hwnd);
4378 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
4380 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4382 /* delete tooltip control */
4383 if (infoPtr->hwndToolTip)
4384 DestroyWindow (infoPtr->hwndToolTip);
4386 /* delete button data */
4387 if (infoPtr->buttons)
4388 COMCTL32_Free (infoPtr->buttons);
4390 /* delete strings */
4391 if (infoPtr->strings) {
4393 for (i = 0; i < infoPtr->nNumStrings; i++)
4394 if (infoPtr->strings[i])
4395 COMCTL32_Free (infoPtr->strings[i]);
4397 COMCTL32_Free (infoPtr->strings);
4400 /* destroy internal image list */
4401 if (infoPtr->himlInt)
4402 ImageList_Destroy (infoPtr->himlInt);
4404 /* delete default font */
4406 DeleteObject (infoPtr->hDefaultFont);
4408 /* free toolbar info data */
4409 COMCTL32_Free (infoPtr);
4410 SetWindowLongA (hwnd, 0, 0);
4417 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
4419 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4420 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4421 NMTBCUSTOMDRAW tbcd;
4422 INT ret = FALSE, ntfret;
4424 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4425 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4426 tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
4427 tbcd.nmcd.hdc = (HDC)wParam;
4428 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4429 /* FIXME: in general the return flags *can* be or'ed together */
4432 case CDRF_DODEFAULT:
4434 case CDRF_SKIPDEFAULT:
4437 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4442 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4443 * to my parent for processing.
4445 if (infoPtr->bTransparent) {
4447 HDC hdc = (HDC)wParam;
4452 parent = GetParent(hwnd);
4453 MapWindowPoints(hwnd, parent, &pt, 1);
4454 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
4455 ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
4456 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
4459 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
4461 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4462 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4463 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
4464 tbcd.nmcd.hdc = (HDC)wParam;
4465 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4468 case CDRF_DODEFAULT:
4470 case CDRF_SKIPDEFAULT:
4473 FIXME("[%04x] response %d not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4482 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
4484 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4486 return infoPtr->hFont;
4491 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
4493 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4494 TBUTTON_INFO *btnPtr;
4498 pt.x = (INT)LOWORD(lParam);
4499 pt.y = (INT)HIWORD(lParam);
4500 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4503 btnPtr = &infoPtr->buttons[nHit];
4504 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4507 infoPtr->bCaptured = TRUE;
4508 infoPtr->nButtonDown = nHit;
4510 btnPtr->fsState |= TBSTATE_PRESSED;
4512 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4515 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
4516 TOOLBAR_Customize (hwnd);
4523 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
4525 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4526 TBUTTON_INFO *btnPtr;
4531 if (infoPtr->hwndToolTip)
4532 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4533 WM_LBUTTONDOWN, wParam, lParam);
4535 pt.x = (INT)LOWORD(lParam);
4536 pt.y = (INT)HIWORD(lParam);
4537 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4541 btnPtr = &infoPtr->buttons[nHit];
4542 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4545 infoPtr->nOldHit = nHit;
4547 CopyRect(&arrowRect, &btnPtr->rect);
4548 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
4550 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4551 if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
4552 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
4553 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
4557 * this time we must force a Redraw, so the btn is
4558 * painted down before CaptureChanged repaints it up
4560 RedrawWindow(hwnd,&btnPtr->rect,0,
4561 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
4563 nmtb.iItem = btnPtr->idCommand;
4564 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
4567 memset(&nmtb.rcButton, 0, sizeof(RECT));
4568 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4570 if (res != TBDDRET_TREATPRESSED)
4571 /* ??? guess (GA) */
4573 /* otherwise drop through and process as pushed */
4575 /* SetCapture (hwnd); */
4576 infoPtr->bCaptured = TRUE;
4577 infoPtr->nButtonDown = nHit;
4579 btnPtr->fsState |= TBSTATE_PRESSED;
4580 btnPtr->bHot = FALSE;
4582 InvalidateRect(hwnd, &btnPtr->rect,
4583 TOOLBAR_HasText(infoPtr, btnPtr));
4587 /* native issues the TBN_BEGINDRAG here */
4588 nmtb.iItem = btnPtr->idCommand;
4589 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4590 nmtb.tbButton.idCommand = btnPtr->idCommand;
4591 nmtb.tbButton.fsState = btnPtr->fsState;
4592 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4593 nmtb.tbButton.dwData = btnPtr->dwData;
4594 nmtb.tbButton.iString = btnPtr->iString;
4595 nmtb.cchText = 0; /* !!! not correct */
4596 nmtb.pszText = 0; /* !!! not correct */
4597 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4605 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
4607 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4608 TBUTTON_INFO *btnPtr;
4612 BOOL bSendMessage = TRUE;
4617 if (infoPtr->hwndToolTip)
4618 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4619 WM_LBUTTONUP, wParam, lParam);
4621 pt.x = (INT)LOWORD(lParam);
4622 pt.y = (INT)HIWORD(lParam);
4623 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4625 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
4626 /* if the cursor is still inside of the toolbar */
4627 if((infoPtr->nHotItem >= 0) && (nHit != -1))
4628 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
4630 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4631 btnPtr->fsState &= ~TBSTATE_PRESSED;
4633 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
4634 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
4635 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
4637 if (nOldIndex == nHit)
4638 bSendMessage = FALSE;
4639 if ((nOldIndex != nHit) &&
4641 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
4642 btnPtr->fsState |= TBSTATE_CHECKED;
4645 if (btnPtr->fsState & TBSTATE_CHECKED)
4646 btnPtr->fsState &= ~TBSTATE_CHECKED;
4648 btnPtr->fsState |= TBSTATE_CHECKED;
4652 if (nOldIndex != -1)
4654 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
4655 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
4659 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
4660 * that resets bCaptured and btn TBSTATE_PRESSED flags,
4661 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
4663 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
4666 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
4667 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
4668 NM_RELEASEDCAPTURE);
4670 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
4673 nmtb.iItem = btnPtr->idCommand;
4674 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4675 nmtb.tbButton.idCommand = btnPtr->idCommand;
4676 nmtb.tbButton.fsState = btnPtr->fsState;
4677 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4678 nmtb.tbButton.dwData = btnPtr->dwData;
4679 nmtb.tbButton.iString = btnPtr->iString;
4680 nmtb.cchText = 0; /* !!! not correct */
4681 nmtb.pszText = 0; /* !!! not correct */
4682 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4685 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
4686 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
4688 /* !!! Undocumented - toolbar at 4.71 level and above sends
4689 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
4690 * Only NM_RCLICK is documented.
4692 nmmouse.dwItemSpec = btnPtr->idCommand;
4693 nmmouse.dwItemData = btnPtr->dwData;
4694 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
4700 TOOLBAR_CaptureChanged(HWND hwnd)
4702 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4703 TBUTTON_INFO *btnPtr;
4705 infoPtr->bCaptured = FALSE;
4707 if (infoPtr->nButtonDown >= 0)
4709 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4710 btnPtr->fsState &= ~TBSTATE_PRESSED;
4712 infoPtr->nButtonDown = -1;
4713 infoPtr->nOldHit = -1;
4715 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4722 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
4724 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4725 TBUTTON_INFO *hotBtnPtr, *btnPtr;
4728 if (infoPtr->nOldHit < 0)
4731 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
4733 /* Redraw the button if the last button we were over is the hot button and it
4735 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
4737 hotBtnPtr->bHot = FALSE;
4738 rc1 = hotBtnPtr->rect;
4739 InflateRect (&rc1, 1, 1);
4740 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
4744 /* If the last button we were over is depressed then make it not */
4745 /* depressed and redraw it */
4746 if(infoPtr->nOldHit == infoPtr->nButtonDown)
4748 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4750 btnPtr->fsState &= ~TBSTATE_PRESSED;
4752 rc1 = hotBtnPtr->rect;
4753 InflateRect (&rc1, 1, 1);
4754 InvalidateRect (hwnd, &rc1, TRUE);
4757 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
4758 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4764 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
4766 TBUTTON_INFO *btnPtr, *oldBtnPtr;
4767 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4770 TRACKMOUSEEVENT trackinfo;
4772 /* fill in the TRACKMOUSEEVENT struct */
4773 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
4774 trackinfo.dwFlags = TME_QUERY;
4775 trackinfo.hwndTrack = hwnd;
4776 trackinfo.dwHoverTime = HOVER_DEFAULT;
4778 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4779 _TrackMouseEvent(&trackinfo);
4781 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4782 if(!(trackinfo.dwFlags & TME_LEAVE)) {
4783 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
4785 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4786 /* and can properly deactivate the hot toolbar button */
4787 _TrackMouseEvent(&trackinfo);
4790 if (infoPtr->hwndToolTip)
4791 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4792 WM_MOUSEMOVE, wParam, lParam);
4794 pt.x = (INT)LOWORD(lParam);
4795 pt.y = (INT)HIWORD(lParam);
4797 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4799 if (infoPtr->nOldHit != nHit)
4801 /* Remove the effect of an old hot button if the button was enabled and was
4802 drawn with the hot button effect */
4803 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
4804 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
4806 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
4807 oldBtnPtr->bHot = FALSE;
4809 InvalidateRect (hwnd, &oldBtnPtr->rect,
4810 TOOLBAR_HasText(infoPtr, oldBtnPtr));
4813 /* It's not a separator or in nowhere. It's a hot button. */
4816 btnPtr = &infoPtr->buttons[nHit];
4818 infoPtr->nHotItem = nHit;
4820 /* only enabled buttons show hot effect */
4821 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
4823 btnPtr->bHot = TRUE;
4824 InvalidateRect(hwnd, &btnPtr->rect,
4825 TOOLBAR_HasText(infoPtr, btnPtr));
4830 if (infoPtr->bCaptured) {
4831 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4832 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
4833 btnPtr->fsState &= ~TBSTATE_PRESSED;
4834 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
4836 else if (nHit == infoPtr->nButtonDown) {
4837 btnPtr->fsState |= TBSTATE_PRESSED;
4838 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
4841 infoPtr->nOldHit = nHit;
4847 inline static LRESULT
4848 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4850 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
4851 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
4853 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
4857 inline static LRESULT
4858 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
4860 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
4861 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
4863 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
4868 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4870 TOOLBAR_INFO *infoPtr;
4871 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
4874 /* allocate memory for info structure */
4875 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
4876 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
4879 infoPtr->dwStructSize = sizeof(TBBUTTON);
4881 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
4882 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
4883 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
4884 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
4887 /* native control does:
4888 * Get a lot of colors and brushes
4890 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
4891 * CreateFontIndirectA(adr1)
4892 * CreateBitmap(0x27, 0x24, 1, 1, 0)
4893 * hdc = GetDC(toolbar)
4894 * GetSystemMetrics(0x48)
4895 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
4896 * 0, 0, 0, 0, "MARLETT")
4897 * oldfnt = SelectObject(hdc, fnt2)
4898 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
4899 * GetTextMetricsA(hdc, adr3)
4900 * SelectObject(hdc, oldfnt)
4901 * DeleteObject(fnt2)
4903 * InvalidateRect(toolbar, 0, 1)
4904 * SetWindowLongA(toolbar, 0, addr)
4905 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
4908 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
4909 * ie 2 0x4600094c 0x4600094c 0x4600894d
4910 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
4911 * rebar 0x50008844 0x40008844 0x50008845
4912 * pager 0x50000844 0x40000844 0x50008845
4913 * IC35mgr 0x5400084e **nochange**
4914 * on entry to _NCCREATE 0x5400084e
4915 * rowlist 0x5400004e **nochange**
4916 * on entry to _NCCREATE 0x5400004e
4920 /* I think the code below is a bug, but it is the way that the native
4921 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
4922 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
4923 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
4924 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
4925 * Some how, the only cases of this seem to be MFC programs.
4927 * Note also that the addition of _TRANSPARENT occurs *only* here. It
4928 * does not occur in the WM_STYLECHANGING routine.
4929 * (Guy Albertelli 9/2001)
4932 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
4933 styleadd |= TBSTYLE_TRANSPARENT;
4934 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
4935 styleadd |= CCS_TOP; /* default to top */
4936 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
4939 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
4944 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
4946 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4950 if (dwStyle & WS_MINIMIZE)
4951 return 0; /* Nothing to do */
4953 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
4955 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
4958 if (!(dwStyle & CCS_NODIVIDER))
4960 GetWindowRect (hwnd, &rcWindow);
4961 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
4962 if( dwStyle & WS_BORDER )
4963 OffsetRect (&rcWindow, 1, 1);
4964 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
4967 ReleaseDC( hwnd, hdc );
4973 inline static LRESULT
4974 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
4976 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4977 LPNMHDR lpnmh = (LPNMHDR)lParam;
4979 if (lpnmh->code == PGN_CALCSIZE) {
4980 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
4982 if (lppgc->dwFlag == PGF_CALCWIDTH) {
4983 lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
4984 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
4988 lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4989 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
4996 TRACE("passing WM_NOTIFY!\n");
4998 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
4999 if (infoPtr->bNtfUnicode)
5000 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
5003 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
5007 if (lpnmh->code == TTN_GETDISPINFOA) {
5008 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
5010 FIXME("retrieving ASCII string\n");
5013 else if (lpnmh->code == TTN_GETDISPINFOW) {
5014 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
5016 FIXME("retrieving UNICODE string\n");
5027 TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
5029 /* remove this routine when Toolbar is improved to pass infoPtr
5030 * around instead of hwnd.
5032 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5033 return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
5038 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
5042 if (lParam == NF_REQUERY) {
5043 i = SendMessageA(GetParent(infoPtr->hwndSelf),
5044 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
5045 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
5046 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5050 infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
5053 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
5058 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
5060 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5064 /* fill ps.rcPaint with a default rect */
5065 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
5067 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
5069 TRACE("psrect=(%d,%d)-(%d,%d)\n",
5070 ps.rcPaint.left, ps.rcPaint.top,
5071 ps.rcPaint.right, ps.rcPaint.bottom);
5073 TOOLBAR_Refresh (hwnd, hdc, &ps);
5074 if (!wParam) EndPaint (hwnd, &ps);
5081 TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
5082 /*****************************************************
5085 * Handles the WM_SETREDRAW message.
5088 * According to testing V4.71 of COMCTL32 returns the
5089 * *previous* status of the redraw flag (either 0 or 1)
5090 * instead of the MSDN documented value of 0 if handled.
5091 * (For laughs see the "consistancy" with same function
5094 *****************************************************/
5096 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5097 BOOL oldredraw = infoPtr->bDoRedraw;
5099 TRACE("set to %s\n",
5100 (wParam) ? "TRUE" : "FALSE");
5101 infoPtr->bDoRedraw = (BOOL) wParam;
5103 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
5105 return (oldredraw) ? 1 : 0;
5110 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
5112 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5113 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5122 /* Resize deadlock check */
5123 if (infoPtr->bAutoSize) {
5124 infoPtr->bAutoSize = FALSE;
5128 /* FIXME: optimize to only update size if the new size doesn't */
5129 /* match the current size */
5131 flags = (INT) wParam;
5133 /* FIXME for flags =
5134 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5137 TRACE("sizing toolbar!\n");
5139 if (flags == SIZE_RESTORED) {
5140 /* width and height don't apply */
5141 parent = GetParent (hwnd);
5142 GetClientRect(parent, &parent_rect);
5143 x = parent_rect.left;
5144 y = parent_rect.top;
5146 if (dwStyle & CCS_NORESIZE) {
5147 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
5150 * this sets the working width of the toolbar, and
5151 * Calc Toolbar will not adjust it, only the height
5153 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5154 cy = infoPtr->nHeight;
5155 cx = infoPtr->nWidth;
5156 TOOLBAR_CalcToolbar (hwnd);
5157 infoPtr->nWidth = cx;
5158 infoPtr->nHeight = cy;
5161 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5162 TOOLBAR_CalcToolbar (hwnd);
5163 cy = infoPtr->nHeight;
5164 cx = infoPtr->nWidth;
5166 if (dwStyle & CCS_NOMOVEY) {
5167 GetWindowRect(hwnd, &window_rect);
5168 ScreenToClient(parent, (LPPOINT)&window_rect.left);
5169 y = window_rect.top;
5173 if (dwStyle & CCS_NOPARENTALIGN) {
5174 uPosFlags |= SWP_NOMOVE;
5175 cy = infoPtr->nHeight;
5176 cx = infoPtr->nWidth;
5179 if (!(dwStyle & CCS_NODIVIDER))
5180 cy += GetSystemMetrics(SM_CYEDGE);
5182 if (dwStyle & WS_BORDER)
5185 cy += GetSystemMetrics(SM_CYEDGE);
5186 cx += GetSystemMetrics(SM_CYEDGE);
5189 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
5190 cx, cy, uPosFlags | SWP_NOZORDER);
5197 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
5199 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5201 if (nType == GWL_STYLE) {
5202 if (lpStyle->styleNew & TBSTYLE_LIST) {
5203 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
5206 infoPtr->dwDTFlags = DT_CENTER;
5208 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
5209 infoPtr->bBtnTranspnt = (lpStyle->styleNew &
5210 (TBSTYLE_FLAT | TBSTYLE_LIST));
5211 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
5214 TOOLBAR_AutoSize (hwnd);
5216 InvalidateRect(hwnd, NULL, FALSE);
5223 TOOLBAR_SysColorChange (HWND hwnd)
5225 COMCTL32_RefreshSysColors();
5232 static LRESULT WINAPI
5233 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5235 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
5236 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
5238 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
5239 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
5244 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
5246 case TB_ADDBUTTONSA:
5247 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
5249 case TB_ADDBUTTONSW:
5250 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
5253 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
5256 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
5259 return TOOLBAR_AutoSize (hwnd);
5261 case TB_BUTTONCOUNT:
5262 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
5264 case TB_BUTTONSTRUCTSIZE:
5265 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
5267 case TB_CHANGEBITMAP:
5268 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
5270 case TB_CHECKBUTTON:
5271 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
5273 case TB_COMMANDTOINDEX:
5274 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
5277 return TOOLBAR_Customize (hwnd);
5279 case TB_DELETEBUTTON:
5280 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
5282 case TB_ENABLEBUTTON:
5283 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
5285 case TB_GETANCHORHIGHLIGHT:
5286 return TOOLBAR_GetAnchorHighlight (hwnd);
5289 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
5291 case TB_GETBITMAPFLAGS:
5292 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
5295 return TOOLBAR_GetButton (hwnd, wParam, lParam);
5297 case TB_GETBUTTONINFOA:
5298 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
5300 case TB_GETBUTTONINFOW:
5301 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
5303 case TB_GETBUTTONSIZE:
5304 return TOOLBAR_GetButtonSize (hwnd);
5306 case TB_GETBUTTONTEXTA:
5307 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
5309 case TB_GETBUTTONTEXTW:
5310 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
5312 case TB_GETDISABLEDIMAGELIST:
5313 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
5315 case TB_GETEXTENDEDSTYLE:
5316 return TOOLBAR_GetExtendedStyle (hwnd);
5318 case TB_GETHOTIMAGELIST:
5319 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
5322 return TOOLBAR_GetHotItem (hwnd);
5324 case TB_GETIMAGELIST:
5325 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
5327 /* case TB_GETINSERTMARK: */ /* 4.71 */
5328 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5330 case TB_GETITEMRECT:
5331 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
5334 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
5336 /* case TB_GETOBJECT: */ /* 4.71 */
5339 return TOOLBAR_GetPadding (hwnd);
5342 return TOOLBAR_GetRect (hwnd, wParam, lParam);
5345 return TOOLBAR_GetRows (hwnd, wParam, lParam);
5348 return TOOLBAR_GetState (hwnd, wParam, lParam);
5351 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
5353 case TB_GETTEXTROWS:
5354 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
5356 case TB_GETTOOLTIPS:
5357 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
5359 case TB_GETUNICODEFORMAT:
5360 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
5363 return TOOLBAR_HideButton (hwnd, wParam, lParam);
5366 return TOOLBAR_HitTest (hwnd, wParam, lParam);
5368 case TB_INDETERMINATE:
5369 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
5371 case TB_INSERTBUTTONA:
5372 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
5374 case TB_INSERTBUTTONW:
5375 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
5377 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5379 case TB_ISBUTTONCHECKED:
5380 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
5382 case TB_ISBUTTONENABLED:
5383 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
5385 case TB_ISBUTTONHIDDEN:
5386 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
5388 case TB_ISBUTTONHIGHLIGHTED:
5389 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
5391 case TB_ISBUTTONINDETERMINATE:
5392 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
5394 case TB_ISBUTTONPRESSED:
5395 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
5397 case TB_LOADIMAGES: /* 4.70 */
5398 FIXME("missing standard imagelists\n");
5401 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5402 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5403 /* case TB_MARKBUTTON: */ /* 4.71 */
5404 /* case TB_MOVEBUTTON: */ /* 4.71 */
5406 case TB_PRESSBUTTON:
5407 return TOOLBAR_PressButton (hwnd, wParam, lParam);
5409 /* case TB_REPLACEBITMAP: */
5411 case TB_SAVERESTOREA:
5412 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
5414 case TB_SAVERESTOREW:
5415 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
5417 case TB_SETANCHORHIGHLIGHT:
5418 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
5420 case TB_SETBITMAPSIZE:
5421 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
5423 case TB_SETBUTTONINFOA:
5424 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
5426 case TB_SETBUTTONINFOW:
5427 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
5429 case TB_SETBUTTONSIZE:
5430 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
5432 case TB_SETBUTTONWIDTH:
5433 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
5436 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
5438 case TB_SETDISABLEDIMAGELIST:
5439 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
5441 case TB_SETDRAWTEXTFLAGS:
5442 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
5444 case TB_SETEXTENDEDSTYLE:
5445 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
5447 case TB_SETHOTIMAGELIST:
5448 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
5451 return TOOLBAR_SetHotItem (hwnd, wParam);
5453 case TB_SETIMAGELIST:
5454 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
5457 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
5459 /* case TB_SETINSERTMARK: */ /* 4.71 */
5461 case TB_SETINSERTMARKCOLOR:
5462 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
5464 case TB_SETMAXTEXTROWS:
5465 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
5468 return TOOLBAR_SetPadding (hwnd, wParam, lParam);
5471 return TOOLBAR_SetParent (hwnd, wParam, lParam);
5474 return TOOLBAR_SetRows (hwnd, wParam, lParam);
5477 return TOOLBAR_SetState (hwnd, wParam, lParam);
5480 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
5482 case TB_SETTOOLTIPS:
5483 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
5485 case TB_SETUNICODEFORMAT:
5486 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
5489 return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
5492 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
5495 /* Common Control Messages */
5497 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
5498 case CCM_GETCOLORSCHEME:
5499 return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5501 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
5502 case CCM_SETCOLORSCHEME:
5503 return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5505 case CCM_GETVERSION:
5506 return TOOLBAR_GetVersion (hwnd);
5508 case CCM_SETVERSION:
5509 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
5515 return TOOLBAR_Create (hwnd, wParam, lParam);
5518 return TOOLBAR_Destroy (hwnd, wParam, lParam);
5521 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
5524 return TOOLBAR_GetFont (hwnd, wParam, lParam);
5526 /* case WM_KEYDOWN: */
5527 /* case WM_KILLFOCUS: */
5529 case WM_LBUTTONDBLCLK:
5530 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
5532 case WM_LBUTTONDOWN:
5533 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
5536 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
5539 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
5542 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
5544 case WM_CAPTURECHANGED:
5545 return TOOLBAR_CaptureChanged(hwnd);
5548 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
5551 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
5554 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
5557 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
5560 return TOOLBAR_Notify (hwnd, wParam, lParam);
5562 case WM_NOTIFYFORMAT:
5563 TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
5566 return TOOLBAR_Paint (hwnd, wParam);
5569 return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
5572 return TOOLBAR_Size (hwnd, wParam, lParam);
5574 case WM_STYLECHANGED:
5575 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
5577 case WM_SYSCOLORCHANGE:
5578 return TOOLBAR_SysColorChange (hwnd);
5580 /* case WM_WININICHANGE: */
5585 case WM_MEASUREITEM:
5588 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5590 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
5592 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
5595 /* We see this in Outlook Express 5.x and just does DefWindowProc */
5596 case PGM_FORWARDMOUSE:
5597 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5600 if (uMsg >= WM_USER)
5601 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
5602 uMsg, wParam, lParam);
5603 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5610 TOOLBAR_Register (void)
5614 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
5615 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
5616 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
5617 wndClass.cbClsExtra = 0;
5618 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
5619 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
5620 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
5621 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
5623 RegisterClassA (&wndClass);
5628 TOOLBAR_Unregister (void)
5630 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);