4 * Copyright 1998,1999 Eric Kohl
5 * Copyright 2000 Eric Kohl for CodeWeavers
6 * Copyright 2004 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Differences between MSDN and actual native control operation:
25 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
26 * to the right of the bitmap. Otherwise, this style is
27 * identical to TBSTYLE_FLAT."
28 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
29 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
30 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
31 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
33 * This code was audited for completeness against the documented features
34 * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
36 * Unless otherwise noted, we believe this code to be complete, as per
37 * the specification mentioned above.
38 * If you discover missing features or bugs please note them below.
43 * - TBSTYLE_REGISTERDROP
44 * - TBSTYLE_EX_DOUBLEBUFFER
47 * - TB_GETINSERTMARKCOLOR
50 * - TB_INSERTMARKHITTEST
60 * - TBN_DELETINGBUTTON
66 * - Button wrapping (under construction).
68 * - iListGap custom draw support.
69 * - Customization dialog:
70 * - Minor buglet in 'available buttons' list:
71 * Buttons are not listed in MS-like order. MS seems to use a single
72 * internal list to store the button information of both listboxes.
73 * - Drag list support.
76 * - Run tests using Waite Group Windows95 API Bible Volume 2.
77 * The second cdrom contains executables addstr.exe, btncount.exe,
78 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
79 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
80 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
81 * setparnt.exe, setrows.exe, toolwnd.exe.
82 * - Microsofts controlspy examples.
83 * - Charles Petzold's 'Programming Windows': gadgets.exe
93 #include "wine/unicode.h"
97 #include "wine/debug.h"
99 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
112 INT cx
; /* manually set size */
126 } IMLENTRY
, *PIMLENTRY
;
130 DWORD dwStructSize
; /* size of TBBUTTON struct */
131 INT nHeight
; /* height of the toolbar */
132 INT nWidth
; /* width of the toolbar */
139 INT nRows
; /* number of button rows */
140 INT nMaxTextRows
; /* maximum number of text rows */
141 INT cxMin
; /* minimum button width */
142 INT cxMax
; /* maximum button width */
143 INT nNumButtons
; /* number of buttons */
144 INT nNumBitmaps
; /* number of bitmaps */
145 INT nNumStrings
; /* number of strings */
147 BOOL bUnicode
; /* ASCII (FALSE) or Unicode (TRUE)? */
148 BOOL bCaptured
; /* mouse captured? */
151 INT nHotItem
; /* index of the "hot" item */
152 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
153 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
154 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
155 SIZE szPadding
; /* padding values around button */
156 INT iListGap
; /* default gap between text and image for toolbar with list style */
158 HFONT hFont
; /* text font */
159 HIMAGELIST himlInt
; /* image list created internally */
160 PIMLENTRY
*himlDef
; /* default image list array */
161 INT cimlDef
; /* default image list array count */
162 PIMLENTRY
*himlHot
; /* hot image list array */
163 INT cimlHot
; /* hot image list array count */
164 PIMLENTRY
*himlDis
; /* disabled image list array */
165 INT cimlDis
; /* disabled image list array count */
166 HWND hwndToolTip
; /* handle to tool tip control */
167 HWND hwndNotify
; /* handle to the window that gets notifications */
168 HWND hwndSelf
; /* my own handle */
169 BOOL bTransparent
; /* background transparency flag */
170 BOOL bBtnTranspnt
; /* button transparency flag */
171 BOOL bAutoSize
; /* auto size deadlock indicator */
172 BOOL bAnchor
; /* anchor highlight enabled */
173 BOOL bNtfUnicode
; /* TRUE if NOTIFYs use {W} */
174 BOOL bDoRedraw
; /* Redraw status */
175 DWORD dwExStyle
; /* extended toolbar style */
176 DWORD dwDTFlags
; /* DrawText flags */
178 COLORREF clrInsertMark
; /* insert mark color */
179 COLORREF clrBtnHighlight
; /* color for Flat Separator */
180 COLORREF clrBtnShadow
; /* color for Flag Separator */
181 RECT rcBound
; /* bounding rectangle */
183 LPWSTR pszTooltipText
; /* temporary store for a string > 80 characters
184 * for TTN_GETDISPINFOW notification */
185 TBUTTON_INFO
*buttons
; /* pointer to button array */
186 LPWSTR
*strings
; /* pointer to string array */
187 TBITMAP_INFO
*bitmaps
;
188 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
191 /* used by customization dialog */
194 PTOOLBAR_INFO tbInfo
;
196 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
204 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
213 #define SEPARATOR_WIDTH 8
215 #define BOTTOM_BORDER 2
216 #define DDARROW_WIDTH 11
217 #define ARROW_HEIGHT 3
219 /* gap between border of button and text/image */
222 /* how wide to treat the bitmap if it isn't present */
223 #define LIST_IMAGE_ABSENT_WIDTH 2
225 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
226 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
227 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
229 static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO
*infoPtr
, INT iListGap
)
231 return GetSystemMetrics(SM_CXEDGE
) + iListGap
- infoPtr
->szPadding
.cx
/2;
234 /* Used to find undocumented extended styles */
235 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
236 TBSTYLE_EX_UNDOC1 | \
237 TBSTYLE_EX_MIXEDBUTTONS | \
238 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
240 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
241 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
242 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
243 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
244 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
246 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
247 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
248 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
249 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
250 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
251 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
254 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
258 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
260 LPWSTR lpText
= NULL
;
262 /* FIXME: iString == -1 is undocumented */
263 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
264 lpText
= (LPWSTR
)btnPtr
->iString
;
265 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
266 lpText
= infoPtr
->strings
[btnPtr
->iString
];
272 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
274 if (TRACE_ON(toolbar
)){
275 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
276 btn_num
, bP
->idCommand
, GETIBITMAP(infoPtr
, bP
->iBitmap
),
277 bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
278 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
280 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
281 btn_num
, bP
->idCommand
,
282 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
283 bP
->rect
.left
, bP
->rect
.top
,
284 bP
->rect
.right
, bP
->rect
.bottom
);
290 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
292 if (TRACE_ON(toolbar
)) {
296 dwStyle
= GetWindowLongA (iP
->hwndSelf
, GWL_STYLE
);
297 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
299 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
300 iP
->nNumStrings
, dwStyle
);
301 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
303 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
304 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
305 for(i
=0; i
<iP
->nNumButtons
; i
++) {
306 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
312 /***********************************************************************
315 * This function validates that the styles set are implemented and
316 * issues FIXME's warning of possible problems. In a perfect world this
317 * function should be null.
320 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
322 if (dwStyle
& TBSTYLE_ALTDRAG
)
323 FIXME("[%p] TBSTYLE_ALTDRAG not implemented\n", hwnd
);
324 if (dwStyle
& TBSTYLE_REGISTERDROP
)
325 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd
);
330 TOOLBAR_SendNotify (NMHDR
*nmhdr
, TOOLBAR_INFO
*infoPtr
, UINT code
)
332 if(!IsWindow(infoPtr
->hwndSelf
))
333 return 0; /* we have just been destroyed */
335 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
336 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
339 TRACE("to window %p, code=%08x, %s\n", infoPtr
->hwndNotify
, code
,
340 (infoPtr
->bNtfUnicode
) ? "via Unicode" : "via ANSI");
342 if (infoPtr
->bNtfUnicode
)
343 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
344 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
346 return SendMessageA (infoPtr
->hwndNotify
, WM_NOTIFY
,
347 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
350 /***********************************************************************
351 * TOOLBAR_GetBitmapIndex
353 * This function returns the bitmap index associated with a button.
354 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
355 * is issued to retrieve the index.
358 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
360 INT ret
= btnPtr
->iBitmap
;
362 if (ret
== I_IMAGECALLBACK
) {
363 /* issue TBN_GETDISPINFO */
366 nmgd
.idCommand
= btnPtr
->idCommand
;
367 nmgd
.lParam
= btnPtr
->dwData
;
368 nmgd
.dwMask
= TBNF_IMAGE
;
369 TOOLBAR_SendNotify ((NMHDR
*) &nmgd
, infoPtr
,
370 (infoPtr
->bNtfUnicode
) ? TBN_GETDISPINFOW
:
372 if (nmgd
.dwMask
& TBNF_DI_SETITEM
) {
373 btnPtr
->iBitmap
= nmgd
.iImage
;
376 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
377 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
380 if (ret
!= I_IMAGENONE
)
381 ret
= GETIBITMAP(infoPtr
, ret
);
388 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
391 INT id
= GETHIMLID(infoPtr
, index
);
392 INT iBitmap
= GETIBITMAP(infoPtr
, index
);
394 if (((himl
= GETDEFIMAGELIST(infoPtr
, id
)) &&
395 iBitmap
>= 0 && iBitmap
< ImageList_GetImageCount(himl
)) ||
396 (index
== I_IMAGECALLBACK
))
403 /***********************************************************************
404 * TOOLBAR_GetImageListForDrawing
406 * This function validates the bitmap index (including I_IMAGECALLBACK
407 * functionality) and returns the corresponding image list.
410 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
414 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
415 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
416 ERR("index %d,%d is not valid, max %d\n",
417 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
421 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
422 if ((*index
== I_IMAGECALLBACK
) ||
423 (*index
== I_IMAGENONE
)) return NULL
;
424 ERR("TBN_GETDISPINFO returned invalid index %d\n",
431 case IMAGE_LIST_DEFAULT
:
432 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
435 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
437 case IMAGE_LIST_DISABLED
:
438 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
442 FIXME("Shouldn't reach here\n");
446 TRACE("no image list\n");
452 /***********************************************************************
453 * TOOLBAR_TestImageExist
455 * This function is similar to TOOLBAR_GetImageListForDrawing, except it does not
456 * return the image list. The I_IMAGECALLBACK functionality is implemented.
459 TOOLBAR_TestImageExist (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
)
463 if (!himl
) return FALSE
;
465 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
466 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
467 ERR("index %d is not valid, max %d\n",
468 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
472 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
473 if ((index
== I_IMAGECALLBACK
) ||
474 (index
== I_IMAGENONE
)) return FALSE
;
475 ERR("TBN_GETDISPINFO returned invalid index %d\n",
484 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
487 COLORREF oldcolor
, newcolor
;
489 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
490 myrect
.right
= myrect
.left
+ 1;
491 myrect
.top
= lpRect
->top
+ 2;
492 myrect
.bottom
= lpRect
->bottom
- 2;
494 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
495 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
496 oldcolor
= SetBkColor (hdc
, newcolor
);
497 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
499 myrect
.left
= myrect
.right
;
500 myrect
.right
= myrect
.left
+ 1;
502 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
503 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
504 SetBkColor (hdc
, newcolor
);
505 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
507 SetBkColor (hdc
, oldcolor
);
511 /***********************************************************************
512 * TOOLBAR_DrawDDFlatSeparator
514 * This function draws the separator that was flagged as BTNS_DROPDOWN.
515 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
516 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
517 * are horizontal as opposed to the vertical separators for not dropdown
520 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
523 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
526 COLORREF oldcolor
, newcolor
;
528 myrect
.left
= lpRect
->left
;
529 myrect
.right
= lpRect
->right
;
530 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
531 myrect
.bottom
= myrect
.top
+ 1;
533 InflateRect (&myrect
, -2, 0);
535 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
536 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
538 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
539 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
540 oldcolor
= SetBkColor (hdc
, newcolor
);
541 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
543 myrect
.top
= myrect
.bottom
;
544 myrect
.bottom
= myrect
.top
+ 1;
546 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
547 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
548 SetBkColor (hdc
, newcolor
);
549 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
551 SetBkColor (hdc
, oldcolor
);
556 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
561 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
562 hOldPen
= SelectObject ( hdc
, hPen
);
565 MoveToEx (hdc
, x
, y
, NULL
);
566 LineTo (hdc
, x
+5, y
++); x
++;
567 MoveToEx (hdc
, x
, y
, NULL
);
568 LineTo (hdc
, x
+3, y
++); x
++;
569 MoveToEx (hdc
, x
, y
, NULL
);
570 LineTo (hdc
, x
+1, y
++);
571 SelectObject( hdc
, hOldPen
);
572 DeleteObject( hPen
);
576 * Draw the text string for this button.
577 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
578 * is non-zero, so we can simply check himlDef to see if we have
582 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
583 NMTBCUSTOMDRAW
*tbcd
)
585 HDC hdc
= tbcd
->nmcd
.hdc
;
588 COLORREF clrOldBk
= 0;
590 UINT state
= tbcd
->nmcd
.uItemState
;
594 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
595 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
597 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
598 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
599 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
601 else if (state
& CDIS_DISABLED
) {
602 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
603 OffsetRect (rcText
, 1, 1);
604 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
605 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
606 OffsetRect (rcText
, -1, -1);
608 else if (state
& CDIS_INDETERMINATE
) {
609 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
611 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
612 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
613 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
614 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
617 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
620 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
621 SetTextColor (hdc
, clrOld
);
622 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
624 SetBkColor (hdc
, clrOldBk
);
625 SetBkMode (hdc
, oldBkMode
);
627 SelectObject (hdc
, hOldFont
);
633 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
635 HDC hdc
= tbcd
->nmcd
.hdc
;
636 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
639 INT cx
= lpRect
->right
- lpRect
->left
;
640 INT cy
= lpRect
->bottom
- lpRect
->top
;
641 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
642 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
643 PatBlt (hdc
, lpRect
->left
, lpRect
->top
, cx
, cy
, PATCOPY
);
644 SetBkColor(hdc
, clrBkOld
);
645 SetTextColor(hdc
, clrTextOld
);
646 SelectObject (hdc
, hbr
);
650 static void TOOLBAR_DrawMasked(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
651 HDC hdc
, INT x
, INT y
)
655 TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
660 HBITMAP hbmMask
, hbmImage
;
661 HDC hdcMask
, hdcImage
;
663 ImageList_GetIconSize(himl
, &cx
, &cy
);
665 /* Create src image */
666 hdcImage
= CreateCompatibleDC(hdc
);
667 hbmImage
= CreateBitmap(cx
, cy
, GetDeviceCaps(hdc
,PLANES
),
668 GetDeviceCaps(hdc
,BITSPIXEL
), NULL
);
669 SelectObject(hdcImage
, hbmImage
);
670 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
671 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_NORMAL
);
674 hdcMask
= CreateCompatibleDC(0);
675 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
676 SelectObject(hdcMask
, hbmMask
);
678 /* Remove the background and all white pixels */
679 SetBkColor(hdcImage
, ImageList_GetBkColor(himl
));
680 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, SRCCOPY
);
681 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
682 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
684 /* draw the new mask 'etched' to hdc */
685 SetBkColor(hdc
, RGB(255, 255, 255));
686 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
687 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
688 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
689 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
690 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
693 DeleteObject(hbmImage
);
695 DeleteObject (hbmMask
);
702 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
706 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
707 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
708 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
709 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
710 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
711 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
712 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
716 /* draws the image on a toolbar button */
718 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
720 HIMAGELIST himl
= NULL
;
721 BOOL draw_masked
= FALSE
;
724 UINT draw_flags
= ILD_NORMAL
;
726 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
728 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
732 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (GetWindowLongW(infoPtr
->hwndSelf
, GWL_STYLE
) & TBSTYLE_FLAT
))
734 /* if hot, attempt to draw with hot image list, if fails,
735 use default image list */
736 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
738 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
741 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
743 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
744 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
747 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
748 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
749 draw_flags
|= ILD_BLEND50
;
751 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
752 index
, himl
, left
, top
, offset
);
755 TOOLBAR_DrawMasked (infoPtr
, btnPtr
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
);
757 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
760 /* draws a blank frame for a toolbar button */
762 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
)
764 HDC hdc
= tbcd
->nmcd
.hdc
;
765 RECT rc
= tbcd
->nmcd
.rc
;
766 /* if the state is disabled or indeterminate then the button
767 * cannot have an interactive look like pressed or hot */
768 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
769 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
770 BOOL pressed_look
= !non_interactive_state
&&
771 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
772 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
774 /* app don't want us to draw any edges */
775 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
781 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
782 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
783 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
788 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
790 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
791 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
796 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
)
798 HDC hdc
= tbcd
->nmcd
.hdc
;
803 if ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) || (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
))
804 DrawEdge (hdc
, rcArrow
, BDR_SUNKENOUTER
, BF_RECT
| BF_ADJUST
);
805 else if ( (tbcd
->nmcd
.uItemState
& CDIS_HOT
) &&
806 !(tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) &&
807 !(tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
))
808 DrawEdge (hdc
, rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
812 if ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) || (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
))
813 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
815 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
816 BF_SOFT
| BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
819 if (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
820 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
822 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
824 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+1, rcArrow
->top
+1 + (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
825 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
, rcArrow
->top
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
828 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+ offset
, rcArrow
->top
+ offset
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
831 /* draws a complete toolbar button */
833 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
835 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
836 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
837 BOOL hasDropDownArrow
= (TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
838 (btnPtr
->fsStyle
& BTNS_DROPDOWN
)) ||
839 (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
840 BOOL drawSepDropDownArrow
= hasDropDownArrow
&&
841 (~btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
842 RECT rc
, rcArrow
, rcBitmap
, rcText
;
843 LPWSTR lpText
= NULL
;
849 CopyRect (&rcArrow
, &rc
);
850 CopyRect(&rcBitmap
, &rc
);
852 /* get a pointer to the text */
853 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
855 if (hasDropDownArrow
)
859 if (dwStyle
& TBSTYLE_FLAT
)
860 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
862 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
864 if (drawSepDropDownArrow
)
867 rcArrow
.left
= right
;
870 /* copy text rect after adjusting for drop-down arrow
871 * so that text is centred in the rectangle not containing
873 CopyRect(&rcText
, &rc
);
875 /* Center the bitmap horizontally and vertically */
876 if (dwStyle
& TBSTYLE_LIST
)
877 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
879 rcBitmap
.left
+=(infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
882 rcBitmap
.top
+= GetSystemMetrics(SM_CYEDGE
) + OFFSET_Y
;
884 rcBitmap
.top
+=(infoPtr
->nButtonHeight
- infoPtr
->nBitmapHeight
) / 2;
886 TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
887 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
888 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
889 TRACE ("iString: %x\n", btnPtr
->iString
);
890 TRACE ("Stringtext: %s\n", debugstr_w(lpText
));
894 rcText
.left
+= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
895 rcText
.right
-= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
896 if (GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,btnPtr
->iBitmap
)) &&
897 TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
))
899 if (dwStyle
& TBSTYLE_LIST
)
900 rcText
.left
+= infoPtr
->nBitmapWidth
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
902 rcText
.top
+= GetSystemMetrics(SM_CYEDGE
) + OFFSET_Y
+ infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
/2;
905 if (dwStyle
& TBSTYLE_LIST
)
906 rcText
.left
+= LIST_IMAGE_ABSENT_WIDTH
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
908 if (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
))
909 OffsetRect (&rcText
, 1, 1);
912 /* Initialize fields in all cases, because we use these later
913 * NOTE: applications can and do alter these to customize their
915 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
916 tbcd
.clrText
= comctl32_color
.clrBtnText
;
917 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
918 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
919 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
920 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
921 tbcd
.clrHighlightHotTrack
= 0;
922 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
923 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
924 /* MSDN says that this is the text rectangle.
925 * But (why always a but) tracing of v5.7 of native shows
926 * that this is really a *relative* rectangle based on the
927 * the nmcd.rc. Also the left and top are always 0 ignoring
928 * any bitmap that might be present. */
929 tbcd
.rcText
.left
= 0;
931 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
932 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
933 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
936 tbcd
.hbrMonoDither
= COMCTL32_hPattern55AABrush
;
938 /* FIXME: what are these used for? */
942 /* Issue Item Prepaint notify */
943 infoPtr
->dwItemCustDraw
= 0;
944 infoPtr
->dwItemCDFlag
= 0;
945 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
947 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
948 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
949 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
950 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
951 /* reset these fields so the user can't alter the behaviour like native */
955 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
956 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
957 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
959 /* save the only part of the rect that the user can change */
960 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
961 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
965 if (btnPtr
->fsStyle
& BTNS_SEP
) {
966 /* with the FLAT style, iBitmap is the width and has already */
967 /* been taken into consideration in calculating the width */
968 /* so now we need to draw the vertical separator */
969 /* empirical tests show that iBitmap can/will be non-zero */
970 /* when drawing the vertical bar... */
971 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
972 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
)
973 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
975 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
977 else if (btnPtr
->fsStyle
!= BTNS_SEP
) {
978 FIXME("Draw some kind of separator: fsStyle=%x\n",
984 if (!(tbcd
.nmcd
.uItemState
& CDIS_HOT
) &&
985 ((tbcd
.nmcd
.uItemState
& CDIS_CHECKED
) || (tbcd
.nmcd
.uItemState
& CDIS_INDETERMINATE
)))
986 TOOLBAR_DrawPattern (&rc
, &tbcd
);
988 if ((dwStyle
& TBSTYLE_FLAT
) && (tbcd
.nmcd
.uItemState
& CDIS_HOT
))
990 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
994 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
995 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
996 if (hasDropDownArrow
)
997 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
998 SetBkColor(hdc
, oldclr
);
1002 TOOLBAR_DrawFrame(infoPtr
, dwStyle
& TBSTYLE_FLAT
, &tbcd
);
1004 if (drawSepDropDownArrow
)
1005 TOOLBAR_DrawSepDDArrow(infoPtr
, dwStyle
& TBSTYLE_FLAT
, &tbcd
, &rcArrow
);
1007 if (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) || (btnPtr
->fsStyle
& BTNS_SHOWTEXT
))
1008 TOOLBAR_DrawString (infoPtr
, &rcText
, lpText
, &tbcd
);
1010 TOOLBAR_DrawImage(infoPtr
, btnPtr
, rcBitmap
.left
, rcBitmap
.top
, &tbcd
);
1012 if (hasDropDownArrow
&& !drawSepDropDownArrow
)
1014 if (tbcd
.nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
1016 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1 + (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
1017 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
1019 else if (tbcd
.nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
1021 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
1022 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+ offset
, rcArrow
.top
+ offset
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1025 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1029 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1031 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
1032 tbcd
.nmcd
.hdc
= hdc
;
1034 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
1035 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
1036 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
1037 tbcd
.rcText
= rcText
;
1038 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1039 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1040 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1047 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
1049 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1050 TBUTTON_INFO
*btnPtr
;
1051 INT i
, oldBKmode
= 0;
1052 RECT rcTemp
, rcClient
;
1053 NMTBCUSTOMDRAW tbcd
;
1056 /* the app has told us not to redraw the toolbar */
1057 if (!infoPtr
->bDoRedraw
)
1060 /* if imagelist belongs to the app, it can be changed
1061 by the app after setting it */
1062 if (GETDEFIMAGELIST(infoPtr
, 0) != infoPtr
->himlInt
)
1064 infoPtr
->nNumBitmaps
= 0;
1065 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
1066 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
1069 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1071 /* Send initial notify */
1072 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1073 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
1074 tbcd
.nmcd
.hdc
= hdc
;
1075 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1076 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1077 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
1079 if (infoPtr
->bBtnTranspnt
)
1080 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
1082 GetClientRect(hwnd
, &rcClient
);
1084 /* redraw necessary buttons */
1085 btnPtr
= infoPtr
->buttons
;
1086 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
1089 if (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
1091 IntersectRect(&rcTemp
, &rcClient
, &btnPtr
->rect
);
1092 bDraw
= EqualRect(&rcTemp
, &btnPtr
->rect
);
1096 bDraw
&= IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
));
1097 bDraw
= (btnPtr
->fsState
& TBSTATE_HIDDEN
) ? FALSE
: bDraw
;
1099 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
1102 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
1103 SetBkMode (hdc
, oldBKmode
);
1105 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1107 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1108 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
1109 tbcd
.nmcd
.hdc
= hdc
;
1110 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1111 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1115 /***********************************************************************
1116 * TOOLBAR_MeasureString
1118 * This function gets the width and height of a string in pixels. This
1119 * is done first by using GetTextExtentPoint to get the basic width
1120 * and height. The DrawText is called with DT_CALCRECT to get the exact
1121 * width. The reason is because the text may have more than one "&" (or
1122 * prefix characters as M$ likes to call them). The prefix character
1123 * indicates where the underline goes, except for the string "&&" which
1124 * is reduced to a single "&". GetTextExtentPoint does not process these
1125 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
1128 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
1129 HDC hdc
, LPSIZE lpSize
)
1136 if (infoPtr
->nMaxTextRows
> 0 &&
1137 !(btnPtr
->fsState
& TBSTATE_HIDDEN
) &&
1138 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1139 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
1141 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1143 if(lpText
!= NULL
) {
1144 /* first get size of all the text */
1145 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1147 /* feed above size into the rectangle for DrawText */
1148 myrect
.left
= myrect
.top
= 0;
1149 myrect
.right
= lpSize
->cx
;
1150 myrect
.bottom
= lpSize
->cy
;
1152 /* Use DrawText to get true size as drawn (less pesky "&") */
1153 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1154 DT_CALCRECT
| ((btnPtr
->fsStyle
& BTNS_NOPREFIX
) ?
1157 /* feed back to caller */
1158 lpSize
->cx
= myrect
.right
;
1159 lpSize
->cy
= myrect
.bottom
;
1163 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1166 /***********************************************************************
1167 * TOOLBAR_CalcStrings
1169 * This function walks through each string and measures it and returns
1170 * the largest height and width to caller.
1173 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1175 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1176 TBUTTON_INFO
*btnPtr
;
1185 if(infoPtr
->nMaxTextRows
== 0)
1189 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1191 btnPtr
= infoPtr
->buttons
;
1192 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1193 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1195 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1196 if (sz
.cx
> lpSize
->cx
)
1198 if (sz
.cy
> lpSize
->cy
)
1203 SelectObject (hdc
, hOldFont
);
1204 ReleaseDC (hwnd
, hdc
);
1206 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1209 /***********************************************************************
1210 * TOOLBAR_WrapToolbar
1212 * This function walks through the buttons and separators in the
1213 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1214 * wrapping should occur based on the width of the toolbar window.
1215 * It does *not* calculate button placement itself. That task
1216 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1217 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1218 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1220 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1221 * vertical toolbar lists.
1225 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1227 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1228 TBUTTON_INFO
*btnPtr
;
1231 BOOL bWrap
, bButtonWrap
;
1233 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1234 /* no layout is necessary. Applications may use this style */
1235 /* to perform their own layout on the toolbar. */
1236 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1237 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1239 btnPtr
= infoPtr
->buttons
;
1240 x
= infoPtr
->nIndent
;
1242 /* this can get the parents width, to know how far we can extend
1243 * this toolbar. We cannot use its height, as there may be multiple
1244 * toolbars in a rebar control
1246 GetClientRect( GetParent(hwnd
), &rc
);
1247 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1248 bButtonWrap
= FALSE
;
1250 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1251 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1254 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1257 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1259 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1262 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1263 /* it is the actual width of the separator. This is used for */
1264 /* custom controls in toolbars. */
1266 /* BTNS_DROPDOWN separators are treated as buttons for */
1267 /* width. - GA 8/01 */
1268 if ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1269 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
))
1270 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1271 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1273 cx
= infoPtr
->nButtonWidth
;
1275 /* Two or more adjacent separators form a separator group. */
1276 /* The first separator in a group should be wrapped to the */
1277 /* next row if the previous wrapping is on a button. */
1279 (btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1280 (i
+ 1 < infoPtr
->nNumButtons
) &&
1281 (btnPtr
[i
+ 1].fsStyle
& BTNS_SEP
) )
1283 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1284 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1285 x
= infoPtr
->nIndent
;
1287 bButtonWrap
= FALSE
;
1291 /* The layout makes sure the bitmap is visible, but not the button. */
1292 /* Test added to also wrap after a button that starts a row but */
1293 /* is bigger than the area. - GA 8/01 */
1294 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1295 > infoPtr
->nWidth
) ||
1296 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1298 BOOL bFound
= FALSE
;
1300 /* If the current button is a separator and not hidden, */
1301 /* go to the next until it reaches a non separator. */
1302 /* Wrap the last separator if it is before a button. */
1303 while( ( ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1304 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
)) ||
1305 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1306 i
< infoPtr
->nNumButtons
)
1312 if( bFound
&& i
< infoPtr
->nNumButtons
)
1315 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1316 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1317 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1318 x
= infoPtr
->nIndent
;
1319 bButtonWrap
= FALSE
;
1322 else if ( i
>= infoPtr
->nNumButtons
)
1325 /* If the current button is not a separator, find the last */
1326 /* separator and wrap it. */
1327 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1329 if ((btnPtr
[j
].fsStyle
& BTNS_SEP
) &&
1330 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1334 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1335 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1336 x
= infoPtr
->nIndent
;
1337 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1338 bButtonWrap
= FALSE
;
1343 /* If no separator available for wrapping, wrap one of */
1344 /* non-hidden previous button. */
1348 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1350 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1355 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1356 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1357 x
= infoPtr
->nIndent
;
1358 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1364 /* If all above failed, wrap the current button. */
1367 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1368 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1369 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1371 x
= infoPtr
->nIndent
;
1372 if (btnPtr
[i
].fsStyle
& BTNS_SEP
)
1373 bButtonWrap
= FALSE
;
1379 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1380 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1387 /***********************************************************************
1388 * TOOLBAR_CalcToolbar
1390 * This function calculates button and separator placement. It first
1391 * calculates the button sizes, gets the toolbar window width and then
1392 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1393 * on. It assigns a new location to each item and sends this location to
1394 * the tooltip window if appropriate. Finally, it updates the rcBound
1395 * rect and calculates the new required toolbar window height.
1399 TOOLBAR_CalcToolbar (HWND hwnd
)
1401 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1402 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
1403 TBUTTON_INFO
*btnPtr
;
1404 INT i
, nRows
, nSepRows
;
1408 BOOL usesBitmaps
= FALSE
;
1409 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1411 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1413 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1415 for (i
= 0; i
< infoPtr
->nNumButtons
&& !usesBitmaps
; i
++)
1417 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,infoPtr
->buttons
[i
].iBitmap
))
1420 if (dwStyle
& TBSTYLE_LIST
)
1422 infoPtr
->nButtonHeight
= max((usesBitmaps
) ? infoPtr
->nBitmapHeight
:
1423 0, sizeString
.cy
) + infoPtr
->szPadding
.cy
;
1424 infoPtr
->nButtonWidth
= ((usesBitmaps
) ? infoPtr
->nBitmapWidth
:
1425 LIST_IMAGE_ABSENT_WIDTH
) + sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1426 if (sizeString
.cx
> 0)
1427 infoPtr
->nButtonWidth
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1428 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1429 infoPtr
->nButtonWidth
, infoPtr
->nButtonHeight
, usesBitmaps
,
1430 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
1433 if (sizeString
.cy
> 0)
1436 infoPtr
->nButtonHeight
= sizeString
.cy
+
1437 infoPtr
->szPadding
.cy
/2 + /* this is the space to separate text from bitmap */
1438 infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1440 infoPtr
->nButtonHeight
= sizeString
.cy
+ infoPtr
->szPadding
.cy
;
1443 infoPtr
->nButtonHeight
= infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1445 if (sizeString
.cx
> infoPtr
->nBitmapWidth
)
1446 infoPtr
->nButtonWidth
= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1448 infoPtr
->nButtonWidth
= infoPtr
->nBitmapWidth
+ infoPtr
->szPadding
.cx
;
1451 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1452 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1453 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1454 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1456 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1458 x
= infoPtr
->nIndent
;
1461 /* from above, minimum is a button, and possible text */
1462 cx
= infoPtr
->nButtonWidth
;
1464 /* cannot use just ButtonHeight, we may have no buttons! */
1465 if (infoPtr
->nNumButtons
> 0)
1466 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1468 cy
= infoPtr
->nHeight
;
1470 nRows
= nSepRows
= 0;
1472 infoPtr
->rcBound
.top
= y
;
1473 infoPtr
->rcBound
.left
= x
;
1474 infoPtr
->rcBound
.bottom
= y
+ cy
;
1475 infoPtr
->rcBound
.right
= x
;
1477 btnPtr
= infoPtr
->buttons
;
1479 TRACE("cy=%d\n", cy
);
1481 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1484 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1486 SetRectEmpty (&btnPtr
->rect
);
1490 cy
= infoPtr
->nHeight
;
1492 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1493 /* it is the actual width of the separator. This is used for */
1494 /* custom controls in toolbars. */
1495 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1496 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
) {
1497 cy
= (btnPtr
->iBitmap
> 0) ?
1498 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1499 cx
= infoPtr
->nButtonWidth
;
1502 cx
= (btnPtr
->iBitmap
> 0) ?
1503 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1509 else if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1510 (btnPtr
->fsStyle
& BTNS_AUTOSIZE
))
1517 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1519 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1521 SelectObject (hdc
, hOldFont
);
1522 ReleaseDC (hwnd
, hdc
);
1524 /* add space on for button frame, etc */
1525 cx
= sz
.cx
+ infoPtr
->szPadding
.cx
;
1527 /* add list padding */
1528 if ((dwStyle
& TBSTYLE_LIST
) && sz
.cx
> 0)
1529 cx
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1531 if (TOOLBAR_TestImageExist (infoPtr
, btnPtr
, GETDEFIMAGELIST(infoPtr
,0)))
1533 if (dwStyle
& TBSTYLE_LIST
)
1534 cx
+= infoPtr
->nBitmapWidth
;
1535 else if (cx
< (infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
))
1536 cx
= infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
;
1538 else if (dwStyle
& TBSTYLE_LIST
)
1539 cx
+= LIST_IMAGE_ABSENT_WIDTH
;
1542 cx
= infoPtr
->nButtonWidth
;
1544 /* if size has been set manually then don't add on extra space
1545 * for the drop down arrow */
1546 if (!btnPtr
->cx
&& hasDropDownArrows
&&
1547 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) || (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)))
1548 cx
+= DDARROW_WIDTH
;
1550 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1553 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1555 if (infoPtr
->rcBound
.left
> x
)
1556 infoPtr
->rcBound
.left
= x
;
1557 if (infoPtr
->rcBound
.right
< x
+ cx
)
1558 infoPtr
->rcBound
.right
= x
+ cx
;
1559 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1560 infoPtr
->rcBound
.bottom
= y
+ cy
;
1562 /* Set the toolTip only for non-hidden, non-separator button */
1563 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& BTNS_SEP
))
1567 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
1568 ti
.cbSize
= sizeof(TTTOOLINFOA
);
1570 ti
.uId
= btnPtr
->idCommand
;
1571 ti
.rect
= btnPtr
->rect
;
1572 SendMessageA (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTA
,
1576 /* btnPtr->nRow is zero based. The space between the rows is */
1577 /* also considered as a row. */
1578 btnPtr
->nRow
= nRows
+ nSepRows
;
1580 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1581 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1586 if ( !(btnPtr
->fsStyle
& BTNS_SEP
) )
1590 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1591 /* it is the actual width of the separator. This is used for */
1592 /* custom controls in toolbars. */
1593 if ( !(btnPtr
->fsStyle
& BTNS_DROPDOWN
))
1594 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1595 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1599 /* nSepRows is used to calculate the extra height follwoing */
1603 x
= infoPtr
->nIndent
;
1605 /* Increment row number unless this is the last button */
1606 /* and it has Wrap set. */
1607 if (i
!= infoPtr
->nNumButtons
-1)
1614 /* infoPtr->nRows is the number of rows on the toolbar */
1615 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1618 /********************************************************************
1619 * The following while interesting, does not match the values *
1620 * created above for the button rectangles, nor the rcBound rect. *
1621 * We will comment it out and remove it later. *
1623 * The problem showed up as heights in the pager control that was *
1625 ********************************************************************/
1627 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1629 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1630 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1631 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1635 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1637 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1642 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1644 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1645 TBUTTON_INFO
*btnPtr
;
1648 btnPtr
= infoPtr
->buttons
;
1649 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1650 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1653 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1654 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1655 TRACE(" ON SEPARATOR %d!\n", i
);
1660 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1661 TRACE(" ON BUTTON %d!\n", i
);
1667 TRACE(" NOWHERE!\n");
1673 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1675 TBUTTON_INFO
*btnPtr
;
1678 if (CommandIsIndex
) {
1679 TRACE("command is really index command=%d\n", idCommand
);
1680 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1683 btnPtr
= infoPtr
->buttons
;
1684 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1685 if (btnPtr
->idCommand
== idCommand
) {
1686 TRACE("command=%d index=%d\n", idCommand
, i
);
1690 TRACE("no index found for command=%d\n", idCommand
);
1696 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1698 TBUTTON_INFO
*btnPtr
;
1701 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1704 /* check index button */
1705 btnPtr
= &infoPtr
->buttons
[nIndex
];
1706 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1707 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1711 /* check previous buttons */
1712 nRunIndex
= nIndex
- 1;
1713 while (nRunIndex
>= 0) {
1714 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1715 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1716 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1724 /* check next buttons */
1725 nRunIndex
= nIndex
+ 1;
1726 while (nRunIndex
< infoPtr
->nNumButtons
) {
1727 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1728 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1729 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1742 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1743 WPARAM wParam
, LPARAM lParam
)
1749 msg
.wParam
= wParam
;
1750 msg
.lParam
= lParam
;
1751 msg
.time
= GetMessageTime ();
1752 msg
.pt
.x
= LOWORD(GetMessagePos ());
1753 msg
.pt
.y
= HIWORD(GetMessagePos ());
1755 SendMessageA (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1759 /***********************************************************************
1760 * TOOLBAR_CustomizeDialogProc
1761 * This function implements the toolbar customization dialog.
1763 static INT_PTR CALLBACK
1764 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1766 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongA (hwnd
, DWL_USER
);
1767 PCUSTOMBUTTON btnInfo
;
1769 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
1774 custInfo
= (PCUSTDLG_INFO
)lParam
;
1775 SetWindowLongA (hwnd
, DWL_USER
, (DWORD
)custInfo
);
1783 infoPtr
= custInfo
->tbInfo
;
1785 /* send TBN_QUERYINSERT notification */
1786 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
1788 if (!TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYINSERT
))
1791 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
1792 nmtb
.iItem
= (int)hwnd
;
1793 /* Send TBN_INITCUSTOMIZE notification */
1794 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_INITCUSTOMIZE
) ==
1797 TRACE("TBNRF_HIDEHELP requested\n");
1798 ShowWindow(GetDlgItem(hwnd
, IDC_HELP_BTN
), SW_HIDE
);
1801 /* add items to 'toolbar buttons' list and check if removable */
1802 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
1804 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1805 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1806 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1807 btnInfo
->bVirtual
= FALSE
;
1808 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1810 /* send TBN_QUERYDELETE notification */
1811 btnInfo
->bRemovable
= TOOLBAR_IsButtonRemovable(infoPtr
, i
, btnInfo
);
1813 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1814 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1817 /* insert separator button into 'available buttons' list */
1818 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1819 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1820 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1821 btnInfo
->bVirtual
= FALSE
;
1822 btnInfo
->bRemovable
= TRUE
;
1823 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1824 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1825 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1827 /* insert all buttons into dsa */
1830 /* send TBN_GETBUTTONINFO notification */
1833 nmtb
.pszText
= Buffer
;
1836 /* Clear previous button's text */
1837 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
1839 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
1842 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
1843 nmtb
.tbButton
.fsStyle
, i
,
1844 nmtb
.tbButton
.idCommand
,
1845 nmtb
.tbButton
.iString
,
1846 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
1849 /* insert button into the apropriate list */
1850 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
1853 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1854 btnInfo
->bVirtual
= FALSE
;
1855 btnInfo
->bRemovable
= TRUE
;
1857 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1858 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
,
1859 LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1863 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
,
1864 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1867 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
1868 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
1870 if (lstrlenW(nmtb
.pszText
))
1871 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
1872 else if (nmtb
.tbButton
.iString
>= 0 &&
1873 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
1875 lstrcpyW(btnInfo
->text
,
1876 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
1881 /* select first item in the 'available' list */
1882 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
1884 /* append 'virtual' separator button to the 'toolbar buttons' list */
1885 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1886 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1887 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1888 btnInfo
->bVirtual
= TRUE
;
1889 btnInfo
->bRemovable
= FALSE
;
1890 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1891 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1892 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1894 /* select last item in the 'toolbar' list */
1895 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
1896 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
1898 /* set focus and disable buttons */
1899 PostMessageA (hwnd
, WM_USER
, 0, 0);
1904 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1905 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1906 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
1907 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
1911 EndDialog(hwnd
, FALSE
);
1915 switch (LOWORD(wParam
))
1917 case IDC_TOOLBARBTN_LBOX
:
1918 if (HIWORD(wParam
) == LBN_SELCHANGE
)
1920 PCUSTOMBUTTON btnInfo
;
1925 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1926 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1928 /* send TBN_QUERYINSERT notification */
1930 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1933 /* get list box item */
1934 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1936 if (index
== (count
- 1))
1938 /* last item (virtual separator) */
1939 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1940 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1942 else if (index
== (count
- 2))
1944 /* second last item (last non-virtual item) */
1945 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1946 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1948 else if (index
== 0)
1951 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1952 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1956 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1957 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1960 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
1964 case IDC_MOVEUP_BTN
:
1966 PCUSTOMBUTTON btnInfo
;
1970 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1971 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1972 TRACE("Move up: index %d\n", index
);
1974 /* send TBN_QUERYINSERT notification */
1977 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1980 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1982 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1983 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
-1, 0);
1984 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
-1, (LPARAM
)btnInfo
);
1985 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
1988 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1989 else if (index
>= (count
- 3))
1990 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1992 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1993 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
-1, (LPARAM
)&(btnInfo
->btn
));
1998 case IDC_MOVEDN_BTN
: /* move down */
2000 PCUSTOMBUTTON btnInfo
;
2004 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2005 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2006 TRACE("Move up: index %d\n", index
);
2008 /* send TBN_QUERYINSERT notification */
2010 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2013 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2015 /* move button down */
2016 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2017 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
+1, 0);
2018 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
+1, (LPARAM
)btnInfo
);
2019 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
+1 , 0);
2022 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2023 else if (index
>= (count
- 3))
2024 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2026 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2027 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
+1, (LPARAM
)&(btnInfo
->btn
));
2032 case IDC_REMOVE_BTN
: /* remove button */
2034 PCUSTOMBUTTON btnInfo
;
2037 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2039 if (LB_ERR
== index
)
2042 TRACE("Remove: index %d\n", index
);
2044 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
,
2045 LB_GETITEMDATA
, index
, 0);
2047 /* send TBN_QUERYDELETE notification */
2048 if (TOOLBAR_IsButtonRemovable(infoPtr
, index
, btnInfo
))
2050 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2051 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2052 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2054 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2056 /* insert into 'available button' list */
2057 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
2059 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2060 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2068 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2071 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2074 case IDOK
: /* Add button */
2079 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2080 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2081 TRACE("Add: index %d\n", index
);
2083 /* send TBN_QUERYINSERT notification */
2085 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2088 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2092 /* remove from 'available buttons' list */
2093 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2094 if (index
== count
-1)
2095 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
2097 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2101 PCUSTOMBUTTON btnNew
;
2103 /* duplicate 'separator' button */
2104 btnNew
= (PCUSTOMBUTTON
)Alloc (sizeof(CUSTOMBUTTON
));
2105 memcpy (btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
2109 /* insert into 'toolbar button' list */
2110 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2111 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
, 0);
2112 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2114 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
, (LPARAM
)&(btnInfo
->btn
));
2120 EndDialog(hwnd
, FALSE
);
2130 /* delete items from 'toolbar buttons' listbox*/
2131 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2132 for (i
= 0; i
< count
; i
++)
2134 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2136 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2138 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2141 /* delete items from 'available buttons' listbox*/
2142 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2143 for (i
= 0; i
< count
; i
++)
2145 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2147 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2149 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2154 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2156 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2157 DWORD dwStyle
= GetWindowLongA (infoPtr
->hwndSelf
, GWL_STYLE
);
2162 COLORREF oldText
= 0;
2166 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2167 if (btnInfo
== NULL
)
2169 FIXME("btnInfo invalid!\n");
2173 /* set colors and select objects */
2174 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2175 if (btnInfo
->bVirtual
)
2176 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2178 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2179 hPen
= CreatePen( PS_SOLID
, 1,
2180 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2181 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2182 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2184 /* fill background rectangle */
2185 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2186 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2188 /* calculate button and text rectangles */
2189 CopyRect (&rcButton
, &lpdis
->rcItem
);
2190 InflateRect (&rcButton
, -1, -1);
2191 CopyRect (&rcText
, &rcButton
);
2192 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2193 rcText
.left
= rcButton
.right
+ 2;
2195 /* draw focus rectangle */
2196 if (lpdis
->itemState
& ODS_FOCUS
)
2197 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2200 if (!(dwStyle
& TBSTYLE_FLAT
))
2201 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2203 /* draw image and text */
2204 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2205 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2206 btnInfo
->btn
.iBitmap
));
2207 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2208 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2210 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2211 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2213 /* delete objects and reset colors */
2214 SelectObject (lpdis
->hDC
, hOldBrush
);
2215 SelectObject (lpdis
->hDC
, hOldPen
);
2216 SetBkColor (lpdis
->hDC
, oldBk
);
2217 SetTextColor (lpdis
->hDC
, oldText
);
2218 DeleteObject( hPen
);
2223 case WM_MEASUREITEM
:
2224 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2226 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2228 if (custInfo
&& custInfo
->tbInfo
)
2229 lpmis
->itemHeight
= custInfo
->tbInfo
->nBitmapHeight
+ 8;
2231 lpmis
->itemHeight
= 15 + 8; /* default height */
2243 /***********************************************************************
2244 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2248 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2250 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2251 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2252 INT nIndex
= 0, nButtons
, nCount
;
2256 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2260 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2262 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2264 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2266 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2271 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2273 /* Windows resize all the buttons to the size of a newly added standard image */
2274 if (lpAddBmp
->nID
& 1)
2277 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2278 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2280 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2281 MAKELPARAM((WORD
)24, (WORD
)24));
2282 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2283 MAKELPARAM((WORD
)31, (WORD
)30));
2288 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2289 MAKELPARAM((WORD
)16, (WORD
)16));
2290 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2291 MAKELPARAM((WORD
)22, (WORD
)22));
2294 TOOLBAR_CalcToolbar (hwnd
);
2298 nButtons
= (INT
)wParam
;
2302 TRACE ("adding %d bitmaps!\n", nButtons
);
2305 if (!infoPtr
->cimlDef
) {
2306 /* create new default image list */
2307 TRACE ("creating default image list!\n");
2309 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2310 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2311 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2312 infoPtr
->himlInt
= himlDef
;
2315 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2319 WARN("No default image list available\n");
2323 nCount
= ImageList_GetImageCount(himlDef
);
2325 /* Add bitmaps to the default image list */
2326 if (lpAddBmp
->hInst
== NULL
)
2329 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2330 HDC hdcImage
, hdcBitmap
;
2332 /* copy the bitmap before adding it so that the user's bitmap
2333 * doesn't get modified.
2335 GetObjectA ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2337 hdcImage
= CreateCompatibleDC(0);
2338 hdcBitmap
= CreateCompatibleDC(0);
2340 /* create new bitmap */
2341 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2342 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2343 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2345 /* Copy the user's image */
2346 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2347 hdcBitmap
, 0, 0, SRCCOPY
);
2349 SelectObject (hdcImage
, hOldBitmapLoad
);
2350 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2351 DeleteDC (hdcImage
);
2352 DeleteDC (hdcBitmap
);
2354 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2355 DeleteObject (hbmLoad
);
2357 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2359 /* Add system bitmaps */
2360 switch (lpAddBmp
->nID
)
2362 case IDB_STD_SMALL_COLOR
:
2363 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2364 MAKEINTRESOURCEA(IDB_STD_SMALL
));
2365 nIndex
= ImageList_AddMasked (himlDef
,
2366 hbmLoad
, comctl32_color
.clrBtnFace
);
2367 DeleteObject (hbmLoad
);
2370 case IDB_STD_LARGE_COLOR
:
2371 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2372 MAKEINTRESOURCEA(IDB_STD_LARGE
));
2373 nIndex
= ImageList_AddMasked (himlDef
,
2374 hbmLoad
, comctl32_color
.clrBtnFace
);
2375 DeleteObject (hbmLoad
);
2378 case IDB_VIEW_SMALL_COLOR
:
2379 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2380 MAKEINTRESOURCEA(IDB_VIEW_SMALL
));
2381 nIndex
= ImageList_AddMasked (himlDef
,
2382 hbmLoad
, comctl32_color
.clrBtnFace
);
2383 DeleteObject (hbmLoad
);
2386 case IDB_VIEW_LARGE_COLOR
:
2387 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2388 MAKEINTRESOURCEA(IDB_VIEW_LARGE
));
2389 nIndex
= ImageList_AddMasked (himlDef
,
2390 hbmLoad
, comctl32_color
.clrBtnFace
);
2391 DeleteObject (hbmLoad
);
2394 case IDB_HIST_SMALL_COLOR
:
2395 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2396 MAKEINTRESOURCEA(IDB_HIST_SMALL
));
2397 nIndex
= ImageList_AddMasked (himlDef
,
2398 hbmLoad
, comctl32_color
.clrBtnFace
);
2399 DeleteObject (hbmLoad
);
2402 case IDB_HIST_LARGE_COLOR
:
2403 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2404 MAKEINTRESOURCEA(IDB_HIST_LARGE
));
2405 nIndex
= ImageList_AddMasked (himlDef
,
2406 hbmLoad
, comctl32_color
.clrBtnFace
);
2407 DeleteObject (hbmLoad
);
2411 nIndex
= ImageList_GetImageCount (himlDef
);
2412 ERR ("invalid imagelist!\n");
2418 hbmLoad
= LoadBitmapA (lpAddBmp
->hInst
, (LPSTR
)lpAddBmp
->nID
);
2419 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2420 DeleteObject (hbmLoad
);
2423 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2425 if (infoPtr
->nNumBitmapInfos
== 0)
2427 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2431 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2432 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2433 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
);
2436 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2437 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2438 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2440 infoPtr
->nNumBitmapInfos
++;
2441 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2445 INT imagecount
= ImageList_GetImageCount(himlDef
);
2447 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2449 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",
2450 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2451 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2453 infoPtr
->nNumBitmaps
= imagecount
;
2456 infoPtr
->nNumBitmaps
+= nButtons
;
2459 InvalidateRect(hwnd
, NULL
, TRUE
);
2466 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2468 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2469 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2470 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2472 TRACE("adding %d buttons!\n", wParam
);
2474 nAddButtons
= (UINT
)wParam
;
2475 nOldButtons
= infoPtr
->nNumButtons
;
2476 nNewButtons
= nOldButtons
+ nAddButtons
;
2478 if (infoPtr
->nNumButtons
== 0) {
2480 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2483 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2485 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2486 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2487 nOldButtons
* sizeof(TBUTTON_INFO
));
2491 infoPtr
->nNumButtons
= nNewButtons
;
2493 /* insert new button data */
2494 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2495 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2496 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2497 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2498 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2499 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2500 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2501 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2502 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2504 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2505 btnPtr
->bHot
= FALSE
;
2507 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2510 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
2511 ti
.cbSize
= sizeof (TTTOOLINFOA
);
2513 ti
.uId
= btnPtr
->idCommand
;
2515 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
2517 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
2522 TOOLBAR_CalcToolbar (hwnd
);
2524 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2526 InvalidateRect(hwnd
, NULL
, TRUE
);
2533 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2535 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2536 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2537 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2539 TRACE("adding %d buttons!\n", wParam
);
2541 nAddButtons
= (UINT
)wParam
;
2542 nOldButtons
= infoPtr
->nNumButtons
;
2543 nNewButtons
= nOldButtons
+ nAddButtons
;
2545 if (infoPtr
->nNumButtons
== 0) {
2547 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2550 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2552 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2553 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2554 nOldButtons
* sizeof(TBUTTON_INFO
));
2558 infoPtr
->nNumButtons
= nNewButtons
;
2560 /* insert new button data */
2561 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2562 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2563 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2564 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2565 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2566 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2567 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2568 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2569 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2571 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2572 btnPtr
->bHot
= FALSE
;
2574 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2577 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2578 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2580 ti
.uId
= btnPtr
->idCommand
;
2582 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2585 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2590 TOOLBAR_CalcToolbar (hwnd
);
2592 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2594 InvalidateRect(hwnd
, NULL
, TRUE
);
2601 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2603 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2606 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2609 TRACE("adding string from resource!\n");
2611 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
,
2614 TRACE("len=%d \"%s\"\n", len
, szString
);
2615 nIndex
= infoPtr
->nNumStrings
;
2616 if (infoPtr
->nNumStrings
== 0) {
2618 Alloc (sizeof(LPWSTR
));
2621 LPWSTR
*oldStrings
= infoPtr
->strings
;
2623 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2624 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2625 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2629 /*Alloc zeros out the allocated memory*/
2630 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2631 infoPtr
->nNumStrings
++;
2634 LPSTR p
= (LPSTR
)lParam
;
2639 TRACE("adding string(s) from array!\n");
2641 nIndex
= infoPtr
->nNumStrings
;
2644 TRACE("len=%d \"%s\"\n", len
, p
);
2646 if (infoPtr
->nNumStrings
== 0) {
2648 Alloc (sizeof(LPWSTR
));
2651 LPWSTR
*oldStrings
= infoPtr
->strings
;
2653 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2654 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2655 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2659 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2660 infoPtr
->nNumStrings
++;
2671 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2673 #define MAX_RESOURCE_STRING_LENGTH 512
2674 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2677 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2678 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2680 TRACE("adding string from resource!\n");
2682 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2683 szString
, MAX_RESOURCE_STRING_LENGTH
);
2685 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2686 TRACE("First char: 0x%x\n", *szString
);
2687 if (szString
[0] == L
'|')
2689 PWSTR p
= szString
+ 1;
2691 nIndex
= infoPtr
->nNumStrings
;
2692 while (*p
!= L
'|' && *p
!= L
'\0') {
2695 if (infoPtr
->nNumStrings
== 0) {
2696 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
2700 LPWSTR
*oldStrings
= infoPtr
->strings
;
2701 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2702 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
2703 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2707 np
=strchrW (p
, '|');
2715 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2716 infoPtr
->strings
[infoPtr
->nNumStrings
] =
2717 Alloc (sizeof(WCHAR
)*(len
+1));
2718 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
2719 infoPtr
->nNumStrings
++;
2726 nIndex
= infoPtr
->nNumStrings
;
2727 if (infoPtr
->nNumStrings
== 0) {
2729 Alloc (sizeof(LPWSTR
));
2732 LPWSTR
*oldStrings
= infoPtr
->strings
;
2734 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2735 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2736 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2740 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2741 infoPtr
->nNumStrings
++;
2745 LPWSTR p
= (LPWSTR
)lParam
;
2750 TRACE("adding string(s) from array!\n");
2751 nIndex
= infoPtr
->nNumStrings
;
2755 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2756 if (infoPtr
->nNumStrings
== 0) {
2758 Alloc (sizeof(LPWSTR
));
2761 LPWSTR
*oldStrings
= infoPtr
->strings
;
2763 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2764 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2765 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2769 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2770 infoPtr
->nNumStrings
++;
2781 TOOLBAR_AutoSize (HWND hwnd
)
2783 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2784 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
2790 UINT uPosFlags
= SWP_NOZORDER
;
2792 TRACE("resize forced, style=%lx!\n", dwStyle
);
2794 parent
= GetParent (hwnd
);
2795 GetClientRect(parent
, &parent_rect
);
2797 x
= parent_rect
.left
;
2798 y
= parent_rect
.top
;
2800 /* FIXME: we should be able to early out if nothing */
2801 /* has changed with nWidth != parent_rect width */
2803 if (dwStyle
& CCS_NORESIZE
) {
2804 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
2807 TOOLBAR_CalcToolbar (hwnd
);
2810 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
2811 TOOLBAR_CalcToolbar (hwnd
);
2812 InvalidateRect( hwnd
, NULL
, TRUE
);
2813 cy
= infoPtr
->nHeight
;
2814 cx
= infoPtr
->nWidth
;
2816 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
2817 GetWindowRect(hwnd
, &window_rect
);
2818 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
2819 y
= window_rect
.top
;
2821 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
2822 GetWindowRect(hwnd
, &window_rect
);
2823 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
2827 if (dwStyle
& CCS_NOPARENTALIGN
)
2828 uPosFlags
|= SWP_NOMOVE
;
2830 if (!(dwStyle
& CCS_NODIVIDER
))
2831 cy
+= GetSystemMetrics(SM_CYEDGE
);
2833 if (dwStyle
& WS_BORDER
)
2836 cy
+= GetSystemMetrics(SM_CYEDGE
);
2837 cx
+= GetSystemMetrics(SM_CYEDGE
);
2840 infoPtr
->bAutoSize
= TRUE
;
2841 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
2842 /* The following line makes sure that the infoPtr->bAutoSize is turned off
2843 * after the setwindowpos calls */
2844 infoPtr
->bAutoSize
= FALSE
;
2851 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2853 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2855 return infoPtr
->nNumButtons
;
2860 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2862 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2864 if (infoPtr
== NULL
) {
2865 ERR("(%p, 0x%x, 0x%lx)\n", hwnd
, wParam
, lParam
);
2866 ERR("infoPtr == NULL!\n");
2870 infoPtr
->dwStructSize
= (DWORD
)wParam
;
2877 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2879 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2880 TBUTTON_INFO
*btnPtr
;
2883 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
2885 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2889 btnPtr
= &infoPtr
->buttons
[nIndex
];
2890 btnPtr
->iBitmap
= LOWORD(lParam
);
2892 /* we HAVE to erase the background, the new bitmap could be */
2894 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2901 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2903 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2904 TBUTTON_INFO
*btnPtr
;
2907 BOOL bChecked
= FALSE
;
2909 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2911 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
2916 btnPtr
= &infoPtr
->buttons
[nIndex
];
2918 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
2920 if (LOWORD(lParam
) == FALSE
)
2921 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
2923 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
2925 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
2926 if (nOldIndex
== nIndex
)
2928 if (nOldIndex
!= -1)
2929 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
2931 btnPtr
->fsState
|= TBSTATE_CHECKED
;
2934 if( bChecked
!= LOWORD(lParam
) )
2936 if (nOldIndex
!= -1)
2937 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
2938 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2941 /* FIXME: Send a WM_NOTIFY?? */
2948 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2950 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2952 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2957 TOOLBAR_Customize (HWND hwnd
)
2959 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2960 CUSTDLG_INFO custInfo
;
2966 custInfo
.tbInfo
= infoPtr
;
2967 custInfo
.tbHwnd
= hwnd
;
2969 /* send TBN_BEGINADJUST notification */
2970 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
2973 if (!(hRes
= FindResourceA (COMCTL32_hModule
,
2974 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE
),
2978 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
2981 ret
= DialogBoxIndirectParamA ((HINSTANCE
)GetWindowLongA(hwnd
, GWL_HINSTANCE
),
2982 (LPDLGTEMPLATEA
)template,
2984 TOOLBAR_CustomizeDialogProc
,
2987 /* send TBN_ENDADJUST notification */
2988 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
2996 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2998 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2999 INT nIndex
= (INT
)wParam
;
3001 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3004 if ((infoPtr
->hwndToolTip
) &&
3005 !(infoPtr
->buttons
[nIndex
].fsStyle
& BTNS_SEP
)) {
3008 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3009 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3011 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3013 SendMessageA (infoPtr
->hwndToolTip
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
3016 if (infoPtr
->nNumButtons
== 1) {
3017 TRACE(" simple delete!\n");
3018 Free (infoPtr
->buttons
);
3019 infoPtr
->buttons
= NULL
;
3020 infoPtr
->nNumButtons
= 0;
3023 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3024 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3026 infoPtr
->nNumButtons
--;
3027 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3029 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3030 nIndex
* sizeof(TBUTTON_INFO
));
3033 if (nIndex
< infoPtr
->nNumButtons
) {
3034 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3035 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3041 TOOLBAR_CalcToolbar (hwnd
);
3043 InvalidateRect (hwnd
, NULL
, TRUE
);
3050 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3052 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3053 TBUTTON_INFO
*btnPtr
;
3057 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3059 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3064 btnPtr
= &infoPtr
->buttons
[nIndex
];
3066 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3068 /* update the toolbar button state */
3069 if(LOWORD(lParam
) == FALSE
) {
3070 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3072 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3075 /* redraw the button only if the state of the button changed */
3076 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3077 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3083 static inline LRESULT
3084 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3086 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3088 return infoPtr
->bAnchor
;
3093 TOOLBAR_GetBitmap (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
].iBitmap
;
3106 static inline LRESULT
3107 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3109 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3114 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3116 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3117 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3118 INT nIndex
= (INT
)wParam
;
3119 TBUTTON_INFO
*btnPtr
;
3121 if (infoPtr
== NULL
)
3127 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3130 btnPtr
= &infoPtr
->buttons
[nIndex
];
3131 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3132 lpTbb
->idCommand
= btnPtr
->idCommand
;
3133 lpTbb
->fsState
= btnPtr
->fsState
;
3134 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3135 lpTbb
->bReserved
[0] = 0;
3136 lpTbb
->bReserved
[1] = 0;
3137 lpTbb
->dwData
= btnPtr
->dwData
;
3138 lpTbb
->iString
= btnPtr
->iString
;
3145 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3147 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3148 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3149 TBUTTON_INFO
*btnPtr
;
3152 if (infoPtr
== NULL
)
3154 if (lpTbInfo
== NULL
)
3156 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3159 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3160 lpTbInfo
->dwMask
& 0x80000000);
3164 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3166 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3167 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3168 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3169 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3170 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3171 lpTbInfo
->lParam
= btnPtr
->dwData
;
3172 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3173 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3174 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3175 lpTbInfo
->fsState
= btnPtr
->fsState
;
3176 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3177 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3178 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3179 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3180 can't use TOOLBAR_GetText here */
3182 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3183 lpText
= (LPWSTR
)btnPtr
->iString
;
3184 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3186 lpTbInfo
->pszText
[0] = '\0';
3193 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3195 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3196 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3197 TBUTTON_INFO
*btnPtr
;
3200 if (infoPtr
== NULL
)
3202 if (lpTbInfo
== NULL
)
3204 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3207 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3208 lpTbInfo
->dwMask
& 0x80000000);
3212 btnPtr
= &infoPtr
->buttons
[nIndex
];
3217 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3218 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3219 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3220 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3221 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3222 lpTbInfo
->lParam
= btnPtr
->dwData
;
3223 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3224 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3225 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3226 lpTbInfo
->fsState
= btnPtr
->fsState
;
3227 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3228 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3229 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3230 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3231 can't use TOOLBAR_GetText here */
3233 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3234 lpText
= (LPWSTR
)btnPtr
->iString
;
3235 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3237 lpTbInfo
->pszText
[0] = '\0';
3245 TOOLBAR_GetButtonSize (HWND hwnd
)
3247 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3249 if (infoPtr
->nNumButtons
> 0)
3250 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3251 (WORD
)infoPtr
->nButtonHeight
);
3253 return MAKELONG(8,7);
3258 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3260 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3267 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3271 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3273 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3274 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3279 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3281 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3288 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3292 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3294 strcpyW ((LPWSTR
)lParam
, lpText
);
3296 return strlenW (lpText
);
3301 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3303 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3304 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3305 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3309 inline static LRESULT
3310 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3312 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3316 return infoPtr
->dwExStyle
;
3321 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3323 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3324 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3325 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3330 TOOLBAR_GetHotItem (HWND hwnd
)
3332 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3334 if (!(GetWindowLongA (hwnd
, GWL_STYLE
) & TBSTYLE_FLAT
))
3337 if (infoPtr
->nHotItem
< 0)
3340 return (LRESULT
)infoPtr
->nHotItem
;
3345 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3347 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3348 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3349 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3353 /* << TOOLBAR_GetInsertMark >> */
3354 /* << TOOLBAR_GetInsertMarkColor >> */
3358 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3360 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3361 TBUTTON_INFO
*btnPtr
;
3365 if (infoPtr
== NULL
)
3367 nIndex
= (INT
)wParam
;
3368 btnPtr
= &infoPtr
->buttons
[nIndex
];
3369 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3371 lpRect
= (LPRECT
)lParam
;
3374 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3377 lpRect
->left
= btnPtr
->rect
.left
;
3378 lpRect
->right
= btnPtr
->rect
.right
;
3379 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3380 lpRect
->top
= btnPtr
->rect
.top
;
3387 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3389 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3390 LPSIZE lpSize
= (LPSIZE
)lParam
;
3395 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3396 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3398 TRACE("maximum size %ld x %ld\n",
3399 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3400 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3406 /* << TOOLBAR_GetObject >> */
3410 TOOLBAR_GetPadding (HWND hwnd
)
3412 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3415 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3416 return (LRESULT
) oldPad
;
3421 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3423 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3424 TBUTTON_INFO
*btnPtr
;
3428 if (infoPtr
== NULL
)
3430 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3431 btnPtr
= &infoPtr
->buttons
[nIndex
];
3432 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3434 lpRect
= (LPRECT
)lParam
;
3438 lpRect
->left
= btnPtr
->rect
.left
;
3439 lpRect
->right
= btnPtr
->rect
.right
;
3440 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3441 lpRect
->top
= btnPtr
->rect
.top
;
3448 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3450 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3452 if (GetWindowLongA (hwnd
, GWL_STYLE
) & TBSTYLE_WRAPABLE
)
3453 return infoPtr
->nRows
;
3460 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3462 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3465 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3469 return infoPtr
->buttons
[nIndex
].fsState
;
3474 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3476 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3479 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3483 return infoPtr
->buttons
[nIndex
].fsStyle
;
3488 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3490 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3492 if (infoPtr
== NULL
)
3495 return infoPtr
->nMaxTextRows
;
3500 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3502 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3504 if (infoPtr
== NULL
)
3506 return (LRESULT
)infoPtr
->hwndToolTip
;
3511 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3513 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3515 TRACE("%s hwnd=%p stub!\n",
3516 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3518 return infoPtr
->bUnicode
;
3522 inline static LRESULT
3523 TOOLBAR_GetVersion (HWND hwnd
)
3525 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3526 return infoPtr
->iVersion
;
3531 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3533 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3534 TBUTTON_INFO
*btnPtr
;
3539 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3543 btnPtr
= &infoPtr
->buttons
[nIndex
];
3544 if (LOWORD(lParam
) == FALSE
)
3545 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3547 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3549 TOOLBAR_CalcToolbar (hwnd
);
3551 InvalidateRect (hwnd
, NULL
, TRUE
);
3557 inline static LRESULT
3558 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3560 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3565 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3567 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3568 TBUTTON_INFO
*btnPtr
;
3572 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3576 btnPtr
= &infoPtr
->buttons
[nIndex
];
3577 oldState
= btnPtr
->fsState
;
3578 if (LOWORD(lParam
) == FALSE
)
3579 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3581 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3583 if(oldState
!= btnPtr
->fsState
)
3584 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3591 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3593 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3594 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3595 INT nIndex
= (INT
)wParam
;
3596 TBUTTON_INFO
*oldButtons
;
3601 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3604 /* EPP: this seems to be an undocumented call (from my IE4)
3605 * I assume in that case that:
3606 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3607 * - index of insertion is at the end of existing buttons
3608 * I only see this happen with nIndex == -1, but it could have a special
3609 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3611 nIndex
= infoPtr
->nNumButtons
;
3613 } else if (nIndex
< 0)
3616 /* If the string passed is not an index, assume address of string
3617 and do our own AddString */
3618 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3622 TRACE("string %s passed instead of index, adding string\n",
3623 debugstr_a((LPSTR
)lpTbb
->iString
));
3624 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3626 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3627 ptr
[len
- 1] = 0; /* ended by two '\0' */
3628 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3632 TRACE("inserting button index=%d\n", nIndex
);
3633 if (nIndex
> infoPtr
->nNumButtons
) {
3634 nIndex
= infoPtr
->nNumButtons
;
3635 TRACE("adjust index=%d\n", nIndex
);
3638 oldButtons
= infoPtr
->buttons
;
3639 infoPtr
->nNumButtons
++;
3640 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3641 /* pre insert copy */
3643 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3644 nIndex
* sizeof(TBUTTON_INFO
));
3647 /* insert new button */
3648 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3649 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3650 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3651 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3652 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3653 /* if passed string and not index, then add string */
3654 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3655 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3658 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3660 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3663 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3664 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3666 ti
.uId
= lpTbb
->idCommand
;
3668 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
3670 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
3674 /* post insert copy */
3675 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3676 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3677 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3682 TOOLBAR_CalcToolbar (hwnd
);
3684 InvalidateRect (hwnd
, NULL
, TRUE
);
3691 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3693 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3694 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3695 INT nIndex
= (INT
)wParam
;
3696 TBUTTON_INFO
*oldButtons
;
3701 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3704 /* EPP: this seems to be an undocumented call (from my IE4)
3705 * I assume in that case that:
3706 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3707 * - index of insertion is at the end of existing buttons
3708 * I only see this happen with nIndex == -1, but it could have a special
3709 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3711 nIndex
= infoPtr
->nNumButtons
;
3713 } else if (nIndex
< 0)
3716 /* If the string passed is not an index, assume address of string
3717 and do our own AddString */
3718 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3722 TRACE("string %s passed instead of index, adding string\n",
3723 debugstr_w((LPWSTR
)lpTbb
->iString
));
3724 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
3725 ptr
= Alloc(len
*sizeof(WCHAR
));
3726 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
3727 ptr
[len
- 1] = 0; /* ended by two '\0' */
3728 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
3732 TRACE("inserting button index=%d\n", nIndex
);
3733 if (nIndex
> infoPtr
->nNumButtons
) {
3734 nIndex
= infoPtr
->nNumButtons
;
3735 TRACE("adjust index=%d\n", nIndex
);
3738 oldButtons
= infoPtr
->buttons
;
3739 infoPtr
->nNumButtons
++;
3740 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3741 /* pre insert copy */
3743 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3744 nIndex
* sizeof(TBUTTON_INFO
));
3747 /* insert new button */
3748 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3749 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3750 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3751 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3752 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3753 /* if passed string and not index, then add string */
3754 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3755 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
3758 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3760 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3763 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
3764 ti
.cbSize
= sizeof (TTTOOLINFOW
);
3766 ti
.uId
= lpTbb
->idCommand
;
3768 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3770 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3774 /* post insert copy */
3775 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3776 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3777 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3782 TOOLBAR_CalcToolbar (hwnd
);
3784 InvalidateRect (hwnd
, NULL
, TRUE
);
3790 /* << TOOLBAR_InsertMarkHitTest >> */
3794 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3796 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3799 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3803 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
3808 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3810 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3813 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3817 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
3822 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3824 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3827 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3831 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
3836 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3838 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3841 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3845 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
3850 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3852 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3855 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3859 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
3864 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3866 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3869 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3873 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
3878 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3881 tbab
.hInst
= (HINSTANCE
)lParam
;
3882 tbab
.nID
= (UINT_PTR
)wParam
;
3884 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
3886 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
3891 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3893 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3894 WCHAR wAccel
= (WCHAR
)wParam
;
3895 UINT
* pIDButton
= (UINT
*)lParam
;
3896 WCHAR wszAccel
[] = {'&',wAccel
,0};
3899 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
3900 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
3902 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
3904 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
3905 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
3906 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
3908 int iLen
= strlenW(wszAccel
);
3909 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
3916 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
3921 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
3923 *pIDButton
= btnPtr
->idCommand
;
3935 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3937 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3940 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
3942 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3947 infoPtr
->buttons
[nIndex
].fsState
|= TBSTATE_MARKED
;
3949 infoPtr
->buttons
[nIndex
].fsState
&= ~TBSTATE_MARKED
;
3954 /* << TOOLBAR_MoveButton >> */
3958 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3960 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3961 TBUTTON_INFO
*btnPtr
;
3965 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3969 btnPtr
= &infoPtr
->buttons
[nIndex
];
3970 oldState
= btnPtr
->fsState
;
3971 if (LOWORD(lParam
) == FALSE
)
3972 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
3974 btnPtr
->fsState
|= TBSTATE_PRESSED
;
3976 if(oldState
!= btnPtr
->fsState
)
3977 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3982 /* FIXME: there might still be some confusion her between number of buttons
3983 * and number of bitmaps */
3985 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3987 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3988 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
3990 int i
= 0, nOldButtons
= 0, pos
= 0;
3991 int nOldBitmaps
, nNewBitmaps
;
3992 HIMAGELIST himlDef
= 0;
3994 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
3995 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
3996 lpReplace
->nButtons
);
3998 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4000 FIXME("changing standard bitmaps not implemented\n");
4003 else if (lpReplace
->hInstOld
!= 0)
4005 FIXME("resources not in the current module not implemented\n");
4010 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4013 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4014 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4015 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4016 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4017 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4019 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4020 nOldButtons
= tbi
->nButtons
;
4021 tbi
->nButtons
= lpReplace
->nButtons
;
4022 tbi
->hInst
= lpReplace
->hInstNew
;
4023 tbi
->nID
= lpReplace
->nIDNew
;
4024 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4027 pos
+= tbi
->nButtons
;
4030 if (nOldButtons
== 0)
4032 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4036 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4037 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4039 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4041 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4042 ImageList_Remove(himlDef
, i
);
4046 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4047 HDC hdcImage
, hdcBitmap
;
4049 /* copy the bitmap before adding it so that the user's bitmap
4050 * doesn't get modified.
4052 GetObjectA (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4054 hdcImage
= CreateCompatibleDC(0);
4055 hdcBitmap
= CreateCompatibleDC(0);
4057 /* create new bitmap */
4058 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4059 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4060 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4062 /* Copy the user's image */
4063 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4064 hdcBitmap
, 0, 0, SRCCOPY
);
4066 SelectObject (hdcImage
, hOldBitmapLoad
);
4067 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4068 DeleteDC (hdcImage
);
4069 DeleteDC (hdcBitmap
);
4071 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4072 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4073 DeleteObject (hbmLoad
);
4076 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4078 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4079 pos
, nOldBitmaps
, nNewBitmaps
);
4081 InvalidateRect(hwnd
, NULL
, TRUE
);
4087 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4090 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4091 LPTBSAVEPARAMSA lpSave
= (LPTBSAVEPARAMSA
)lParam
;
4093 if (lpSave
== NULL
) return 0;
4096 /* save toolbar information */
4097 FIXME("save to \"%s\" \"%s\"\n",
4098 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4103 /* restore toolbar information */
4105 FIXME("restore from \"%s\" \"%s\"\n",
4106 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4117 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4120 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4121 LPTBSAVEPARAMSW lpSave
= (LPTBSAVEPARAMSW
)lParam
;
4127 /* save toolbar information */
4128 FIXME("save to \"%s\" \"%s\"\n",
4129 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4134 /* restore toolbar information */
4136 FIXME("restore from \"%s\" \"%s\"\n",
4137 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4148 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4150 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4151 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4153 infoPtr
->bAnchor
= (BOOL
)wParam
;
4155 return (LRESULT
)bOldAnchor
;
4160 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4162 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4163 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4165 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4168 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4170 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4173 if (infoPtr
->nNumButtons
> 0)
4174 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4175 infoPtr
->nNumButtons
,
4176 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4177 LOWORD(lParam
), HIWORD(lParam
));
4179 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4180 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4183 if ((himlDef
== infoPtr
->himlInt
) &&
4184 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4186 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4187 infoPtr
->nBitmapHeight
);
4195 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4197 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4198 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4199 TBUTTON_INFO
*btnPtr
;
4205 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4208 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4209 lptbbi
->dwMask
& 0x80000000);
4213 btnPtr
= &infoPtr
->buttons
[nIndex
];
4214 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4215 btnPtr
->idCommand
= lptbbi
->idCommand
;
4216 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4217 btnPtr
->iBitmap
= lptbbi
->iImage
;
4218 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4219 btnPtr
->dwData
= lptbbi
->lParam
;
4220 if (lptbbi
->dwMask
& TBIF_SIZE
)
4221 btnPtr
->cx
= lptbbi
->cx
;
4222 if (lptbbi
->dwMask
& TBIF_STATE
)
4223 btnPtr
->fsState
= lptbbi
->fsState
;
4224 if (lptbbi
->dwMask
& TBIF_STYLE
)
4225 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4227 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4228 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4229 /* iString is index, zero it to make Str_SetPtr succeed */
4232 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4235 /* save the button rect to see if we need to redraw the whole toolbar */
4236 oldBtnRect
= btnPtr
->rect
;
4237 TOOLBAR_CalcToolbar(hwnd
);
4239 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4240 InvalidateRect(hwnd
, NULL
, TRUE
);
4242 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4249 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4251 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4252 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4253 TBUTTON_INFO
*btnPtr
;
4259 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4262 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4263 lptbbi
->dwMask
& 0x80000000);
4267 btnPtr
= &infoPtr
->buttons
[nIndex
];
4268 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4269 btnPtr
->idCommand
= lptbbi
->idCommand
;
4270 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4271 btnPtr
->iBitmap
= lptbbi
->iImage
;
4272 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4273 btnPtr
->dwData
= lptbbi
->lParam
;
4274 if (lptbbi
->dwMask
& TBIF_SIZE
)
4275 btnPtr
->cx
= lptbbi
->cx
;
4276 if (lptbbi
->dwMask
& TBIF_STATE
)
4277 btnPtr
->fsState
= lptbbi
->fsState
;
4278 if (lptbbi
->dwMask
& TBIF_STYLE
)
4279 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4281 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4282 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4283 /* iString is index, zero it to make Str_SetPtr succeed */
4285 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4288 /* save the button rect to see if we need to redraw the whole toolbar */
4289 oldBtnRect
= btnPtr
->rect
;
4290 TOOLBAR_CalcToolbar(hwnd
);
4292 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4293 InvalidateRect(hwnd
, NULL
, TRUE
);
4295 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4302 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4304 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4305 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4307 if ((cx
< 0) || (cy
< 0))
4309 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4313 /* The documentation claims you can only change the button size before
4314 * any button has been added. But this is wrong.
4315 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4316 * it to the toolbar, and it checks that the return value is nonzero - mjm
4317 * Further testing shows that we must actually perform the change too.
4320 * The documentation also does not mention that if 0 is supplied for
4321 * either size, the system changes it to the default of 24 wide and
4322 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4324 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4325 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4331 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4333 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4335 if (infoPtr
== NULL
) {
4336 TRACE("Toolbar not initialized yet?????\n");
4340 /* if setting to current values, ignore */
4341 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4342 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4343 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4344 infoPtr
->cxMin
, infoPtr
->cxMax
);
4348 /* save new values */
4349 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4350 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4352 /* if both values are 0 then we are done */
4354 TRACE("setting both min and max to 0, norecalc\n");
4358 /* otherwise we need to recalc the toolbar and in some cases
4359 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4360 which doesn't actually draw - GA). */
4361 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4362 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4364 TOOLBAR_CalcToolbar (hwnd
);
4366 InvalidateRect (hwnd
, NULL
, TRUE
);
4373 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4375 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4376 INT nIndex
= (INT
)wParam
;
4378 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4381 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4383 if (infoPtr
->hwndToolTip
) {
4385 FIXME("change tool tip!\n");
4394 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4396 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4397 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4398 HIMAGELIST himlTemp
;
4401 if (infoPtr
->iVersion
>= 5)
4404 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4405 &infoPtr
->cimlDis
, himl
, id
);
4407 /* FIXME: redraw ? */
4409 return (LRESULT
)himlTemp
;
4414 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4416 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4419 dwTemp
= infoPtr
->dwDTFlags
;
4420 infoPtr
->dwDTFlags
=
4421 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4423 return (LRESULT
)dwTemp
;
4426 /* This function differs a bit from what MSDN says it does:
4427 * 1. lParam contains extended style flags to OR with current style
4428 * (MSDN isn't clear on the OR bit)
4429 * 2. wParam appears to contain extended style flags to be reset
4430 * (MSDN says that this parameter is reserved)
4433 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4435 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4438 dwTemp
= infoPtr
->dwExStyle
;
4439 infoPtr
->dwExStyle
&= ~wParam
;
4440 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4442 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4444 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4445 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4446 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4448 TOOLBAR_CalcToolbar (hwnd
);
4450 TOOLBAR_AutoSize(hwnd
);
4452 InvalidateRect(hwnd
, NULL
, TRUE
);
4454 return (LRESULT
)dwTemp
;
4459 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4461 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4462 HIMAGELIST himlTemp
;
4463 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4466 if (infoPtr
->iVersion
>= 5)
4469 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
4471 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
4472 &infoPtr
->cimlHot
, himl
, id
);
4474 /* FIXME: redraw ? */
4476 return (LRESULT
)himlTemp
;
4480 /* Makes previous hot button no longer hot, makes the specified
4481 * button hot and sends appropriate notifications. dwReason is one or
4482 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
4483 * NOTE 1: this function does not validate nHit
4484 * NOTE 2: the name of this function is completely made up and
4485 * not based on any documentation from Microsoft. */
4487 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
4489 if (infoPtr
->nHotItem
!= nHit
)
4491 NMTBHOTITEM nmhotitem
;
4492 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
4493 LRESULT no_highlight
;
4495 /* Remove the effect of an old hot button if the button was
4496 drawn with the hot button effect */
4497 if(infoPtr
->nHotItem
>= 0)
4499 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
4500 oldBtnPtr
->bHot
= FALSE
;
4503 infoPtr
->nHotItem
= nHit
;
4505 /* It's not a separator or in nowhere. It's a hot button. */
4507 btnPtr
= &infoPtr
->buttons
[nHit
];
4509 nmhotitem
.dwFlags
= dwReason
;
4511 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
4513 nmhotitem
.dwFlags
|= HICF_ENTERING
;
4515 nmhotitem
.idNew
= btnPtr
->idCommand
;
4517 nmhotitem
.dwFlags
|= HICF_LEAVING
;
4519 no_highlight
= TOOLBAR_SendNotify((NMHDR
*)&nmhotitem
, infoPtr
, TBN_HOTITEMCHANGE
);
4521 /* now invalidate the old and new buttons so they will be painted */
4523 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
4524 if (btnPtr
&& !no_highlight
)
4526 btnPtr
->bHot
= TRUE
;
4527 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
4533 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
4535 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4536 INT nOldHotItem
= infoPtr
->nHotItem
;
4538 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4541 if (GetWindowLongW(hwnd
, GWL_STYLE
) & TBSTYLE_FLAT
)
4542 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
4544 if (nOldHotItem
< 0)
4547 return (LRESULT
)nOldHotItem
;
4552 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4554 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4555 HIMAGELIST himlTemp
;
4556 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4559 if (infoPtr
->iVersion
>= 5)
4562 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
4563 &infoPtr
->cimlDef
, himl
, id
);
4565 infoPtr
->nNumBitmaps
= 0;
4566 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
4567 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
4569 ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
4570 &infoPtr
->nBitmapHeight
);
4571 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4572 hwnd
, (INT
)infoPtr
->himlDef
, infoPtr
->nNumBitmaps
,
4573 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
4575 InvalidateRect(hwnd
, NULL
, TRUE
);
4577 return (LRESULT
)himlTemp
;
4582 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4584 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4586 infoPtr
->nIndent
= (INT
)wParam
;
4590 /* process only on indent changing */
4591 if(infoPtr
->nIndent
!= (INT
)wParam
)
4593 infoPtr
->nIndent
= (INT
)wParam
;
4594 TOOLBAR_CalcToolbar (hwnd
);
4595 InvalidateRect(hwnd
, NULL
, FALSE
);
4602 /* << TOOLBAR_SetInsertMark >> */
4606 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4608 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4610 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
4612 /* FIXME : redraw ??*/
4619 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4621 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4623 if (infoPtr
== NULL
)
4626 infoPtr
->nMaxTextRows
= (INT
)wParam
;
4628 TOOLBAR_CalcToolbar(hwnd
);
4633 /* MSDN gives slightly wrong info on padding.
4634 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
4635 * 2. It is not used to create a blank area between the edge of the button
4636 * and the text or image if TBSTYLE_LIST is set. It is used to control
4637 * the gap between the image and text.
4638 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
4639 * to control the bottom and right borders [with the border being
4640 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
4641 * is shared evenly on both sides of the button.
4644 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4646 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4649 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4650 infoPtr
->szPadding
.cx
= LOWORD((DWORD
)lParam
);
4651 infoPtr
->szPadding
.cy
= HIWORD((DWORD
)lParam
);
4652 TRACE("cx=%ld, cy=%ld\n",
4653 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4654 return (LRESULT
) oldPad
;
4659 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4661 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4666 if (infoPtr
== NULL
)
4668 hwndOldNotify
= infoPtr
->hwndNotify
;
4669 infoPtr
->hwndNotify
= (HWND
)wParam
;
4671 return (LRESULT
)hwndOldNotify
;
4676 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4678 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4679 LPRECT lprc
= (LPRECT
)lParam
;
4683 if (LOWORD(wParam
) > 1) {
4684 FIXME("multiple rows not supported!\n");
4687 if(infoPtr
->nRows
!= LOWORD(wParam
))
4689 infoPtr
->nRows
= LOWORD(wParam
);
4691 /* recalculate toolbar */
4692 TOOLBAR_CalcToolbar (hwnd
);
4694 /* repaint toolbar */
4695 InvalidateRect(hwnd
, NULL
, TRUE
);
4698 /* return bounding rectangle */
4700 lprc
->left
= infoPtr
->rcBound
.left
;
4701 lprc
->right
= infoPtr
->rcBound
.right
;
4702 lprc
->top
= infoPtr
->rcBound
.top
;
4703 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
4711 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4713 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4714 TBUTTON_INFO
*btnPtr
;
4717 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4721 btnPtr
= &infoPtr
->buttons
[nIndex
];
4723 /* if hidden state has changed the invalidate entire window and recalc */
4724 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
4725 btnPtr
->fsState
= LOWORD(lParam
);
4726 TOOLBAR_CalcToolbar (hwnd
);
4727 InvalidateRect(hwnd
, 0, TRUE
);
4731 /* process state changing if current state doesn't match new state */
4732 if(btnPtr
->fsState
!= LOWORD(lParam
))
4734 btnPtr
->fsState
= LOWORD(lParam
);
4735 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4743 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4745 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
4751 inline static LRESULT
4752 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4754 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4756 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
4758 if (infoPtr
== NULL
)
4760 infoPtr
->hwndToolTip
= (HWND
)wParam
;
4766 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4768 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4771 TRACE("%s hwnd=%p stub!\n",
4772 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
4774 bTemp
= infoPtr
->bUnicode
;
4775 infoPtr
->bUnicode
= (BOOL
)wParam
;
4782 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4784 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4786 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
4787 comctl32_color
.clrBtnHighlight
:
4788 infoPtr
->clrBtnHighlight
;
4789 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
4790 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
4796 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4798 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4800 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4801 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
4802 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
4804 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
4805 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
4806 InvalidateRect(hwnd
, NULL
, TRUE
);
4812 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
4814 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4815 INT iOldVersion
= infoPtr
->iVersion
;
4817 infoPtr
->iVersion
= iVersion
;
4819 if (infoPtr
->iVersion
>= 5)
4820 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
4827 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4829 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4830 WORD iString
= HIWORD(wParam
);
4831 WORD buffersize
= LOWORD(wParam
);
4832 LPSTR str
= (LPSTR
)lParam
;
4835 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
4837 if (iString
< infoPtr
->nNumStrings
)
4839 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
4841 TRACE("returning %s\n", debugstr_a(str
));
4844 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
4851 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4853 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4854 WORD iString
= HIWORD(wParam
);
4855 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
4856 LPWSTR str
= (LPWSTR
)lParam
;
4859 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
4861 if (iString
< infoPtr
->nNumStrings
)
4863 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
4864 ret
= (len
+1)*sizeof(WCHAR
);
4865 memcpy(str
, infoPtr
->strings
[iString
], ret
);
4868 TRACE("returning %s\n", debugstr_w(str
));
4871 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
4876 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
4877 * is the maximum size of the toolbar? */
4878 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4880 SIZE
* pSize
= (SIZE
*)lParam
;
4881 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
4886 /* UNDOCUMENTED MESSAGE: This is an extended version of the
4887 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
4888 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
4891 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4893 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4894 INT nOldHotItem
= infoPtr
->nHotItem
;
4896 TRACE("old item=%d, new item=%d, flags=%08lx\n",
4897 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
4899 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4902 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
4906 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
4909 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
4910 * which controls the amount of spacing between the image and the text
4911 * of buttons for TBSTYLE_LIST toolbars. */
4912 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4914 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4916 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
4919 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
4921 infoPtr
->iListGap
= (INT
)wParam
;
4923 TOOLBAR_CalcToolbar(hwnd
);
4924 InvalidateRect(hwnd
, NULL
, TRUE
);
4929 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
4930 * of image lists associated with the various states. */
4931 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4933 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4935 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
4937 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
4941 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4943 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4944 LPSIZE lpsize
= (LPSIZE
)lParam
;
4950 * Testing shows the following:
4951 * wParam = 0 adjust cx value
4952 * = 1 set cy value to max size.
4953 * lParam pointer to SIZE structure
4956 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4957 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
4961 if (lpsize
->cx
== -1) {
4962 /* **** this is wrong, native measures each button and sets it */
4963 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
4965 else if(HIWORD(lpsize
->cx
)) {
4967 HWND hwndParent
= GetParent(hwnd
);
4969 GetWindowRect(hwnd
, &rc
);
4970 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
4971 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
4972 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4973 lpsize
->cx
= max(rc
.right
-rc
.left
,
4974 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
4977 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
4981 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
4982 /* lpsize->cy = infoPtr->nHeight; */
4985 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4989 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4990 lpsize
->cx
, lpsize
->cy
);
4994 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4996 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
4998 InvalidateRect(hwnd
, NULL
, TRUE
);
5004 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5006 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5007 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
5010 TRACE("hwnd = %p\n", hwnd
);
5012 /* initialize info structure */
5013 infoPtr
->nButtonHeight
= 22;
5014 infoPtr
->nButtonWidth
= 24;
5015 infoPtr
->nBitmapHeight
= 15;
5016 infoPtr
->nBitmapWidth
= 16;
5018 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5019 infoPtr
->nMaxTextRows
= 1;
5020 infoPtr
->cxMin
= -1;
5021 infoPtr
->cxMax
= -1;
5022 infoPtr
->nNumBitmaps
= 0;
5023 infoPtr
->nNumStrings
= 0;
5025 infoPtr
->bCaptured
= FALSE
;
5026 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
5027 infoPtr
->nButtonDown
= -1;
5028 infoPtr
->nOldHit
= -1;
5029 infoPtr
->nHotItem
= -1;
5030 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5031 infoPtr
->bTransparent
= (dwStyle
& TBSTYLE_TRANSPARENT
);
5032 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5033 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
: DT_CENTER
;
5034 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5035 infoPtr
->iVersion
= 0;
5036 infoPtr
->hwndSelf
= hwnd
;
5037 infoPtr
->bDoRedraw
= TRUE
;
5038 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5039 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5040 /* not sure where the +1 comes from, but this comes to the same value
5041 * as native so this is probably correct */
5042 infoPtr
->szPadding
.cx
= 2*(GetSystemMetrics(SM_CXEDGE
)+OFFSET_X
) + 1;
5043 infoPtr
->szPadding
.cy
= 2*(GetSystemMetrics(SM_CYEDGE
)+OFFSET_Y
);
5044 infoPtr
->iListGap
= infoPtr
->szPadding
.cx
/ 2;
5045 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5046 TOOLBAR_NotifyFormat(infoPtr
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
);
5048 SystemParametersInfoA (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5049 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectA (&logFont
);
5051 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5052 /* Create tooltip control */
5053 infoPtr
->hwndToolTip
=
5054 CreateWindowExA (0, TOOLTIPS_CLASSA
, NULL
, 0,
5055 CW_USEDEFAULT
, CW_USEDEFAULT
,
5056 CW_USEDEFAULT
, CW_USEDEFAULT
,
5059 /* Send NM_TOOLTIPSCREATED notification */
5060 if (infoPtr
->hwndToolTip
) {
5061 NMTOOLTIPSCREATED nmttc
;
5063 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5065 TOOLBAR_SendNotify ((NMHDR
*) &nmttc
, infoPtr
,
5066 NM_TOOLTIPSCREATED
);
5070 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5072 TOOLBAR_CalcToolbar(hwnd
);
5079 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5081 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5083 /* delete tooltip control */
5084 if (infoPtr
->hwndToolTip
)
5085 DestroyWindow (infoPtr
->hwndToolTip
);
5087 /* delete temporary buffer for tooltip text */
5088 if (infoPtr
->pszTooltipText
)
5089 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5091 /* delete button data */
5092 if (infoPtr
->buttons
)
5093 Free (infoPtr
->buttons
);
5095 /* delete strings */
5096 if (infoPtr
->strings
) {
5098 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5099 if (infoPtr
->strings
[i
])
5100 Free (infoPtr
->strings
[i
]);
5102 Free (infoPtr
->strings
);
5105 /* destroy internal image list */
5106 if (infoPtr
->himlInt
)
5107 ImageList_Destroy (infoPtr
->himlInt
);
5109 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5110 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5111 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5113 /* delete default font */
5115 DeleteObject (infoPtr
->hDefaultFont
);
5117 /* free toolbar info data */
5119 SetWindowLongA (hwnd
, 0, 0);
5126 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5128 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5129 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
5130 NMTBCUSTOMDRAW tbcd
;
5134 if (dwStyle
& TBSTYLE_CUSTOMERASE
) {
5135 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5136 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5137 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5138 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5139 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5141 /* FIXME: in general the return flags *can* be or'ed together */
5142 switch (infoPtr
->dwBaseCustDraw
)
5144 case CDRF_DODEFAULT
:
5146 case CDRF_SKIPDEFAULT
:
5149 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5154 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5155 * to my parent for processing.
5157 if (infoPtr
->bTransparent
) {
5159 HDC hdc
= (HDC
)wParam
;
5164 parent
= GetParent(hwnd
);
5165 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5166 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5167 ret
= SendMessageA (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5168 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5171 ret
= DefWindowProcA (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5173 if ((dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5174 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5175 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5176 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5177 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5178 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5179 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5180 switch (infoPtr
->dwBaseCustDraw
)
5182 case CDRF_DODEFAULT
:
5184 case CDRF_SKIPDEFAULT
:
5187 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5196 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5198 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5200 return (LRESULT
)infoPtr
->hFont
;
5205 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5207 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5208 TBUTTON_INFO
*btnPtr
;
5212 pt
.x
= (INT
)LOWORD(lParam
);
5213 pt
.y
= (INT
)HIWORD(lParam
);
5214 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5217 btnPtr
= &infoPtr
->buttons
[nHit
];
5218 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
))
5221 infoPtr
->bCaptured
= TRUE
;
5222 infoPtr
->nButtonDown
= nHit
;
5224 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5226 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5228 else if (GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5229 TOOLBAR_Customize (hwnd
);
5236 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5238 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5239 TBUTTON_INFO
*btnPtr
;
5244 if (infoPtr
->hwndToolTip
)
5245 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5246 WM_LBUTTONDOWN
, wParam
, lParam
);
5248 pt
.x
= (INT
)LOWORD(lParam
);
5249 pt
.y
= (INT
)HIWORD(lParam
);
5250 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5252 btnPtr
= &infoPtr
->buttons
[nHit
];
5256 infoPtr
->nOldHit
= nHit
;
5258 CopyRect(&arrowRect
, &btnPtr
->rect
);
5259 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5261 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5262 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5263 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5264 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5265 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5266 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5270 /* draw in pressed state */
5271 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5272 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5273 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5275 nmtb
.iItem
= btnPtr
->idCommand
;
5276 memset(&nmtb
.tbButton
, 0, sizeof(TBBUTTON
));
5279 CopyRect(&nmtb
.rcButton
, &btnPtr
->rect
);
5280 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5282 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5284 if (res
!= TBDDRET_TREATPRESSED
)
5288 /* redraw button in unpressed state */
5289 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5290 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5292 /* find and set hot item
5293 * NOTE: native doesn't do this, but that is a bug */
5295 ScreenToClient(hwnd
, &pt
);
5296 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5297 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5299 /* remove any left mouse button down messages so that we can
5300 * get a toggle effect on the button */
5301 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
))
5306 /* otherwise drop through and process as pushed */
5308 infoPtr
->bCaptured
= TRUE
;
5309 infoPtr
->nButtonDown
= nHit
;
5311 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5313 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5315 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5316 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5320 /* native issues the TBN_BEGINDRAG here */
5321 nmtb
.iItem
= btnPtr
->idCommand
;
5322 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
5323 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
5324 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
5325 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
5326 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
5327 nmtb
.tbButton
.iString
= btnPtr
->iString
;
5328 nmtb
.cchText
= 0; /* !!! not correct */
5329 nmtb
.pszText
= 0; /* !!! not correct */
5330 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5338 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5340 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5341 TBUTTON_INFO
*btnPtr
;
5345 BOOL bSendMessage
= TRUE
;
5350 if (infoPtr
->hwndToolTip
)
5351 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5352 WM_LBUTTONUP
, wParam
, lParam
);
5354 pt
.x
= (INT
)LOWORD(lParam
);
5355 pt
.y
= (INT
)HIWORD(lParam
);
5356 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5358 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5360 if (0 <= infoPtr
->nButtonDown
) {
5361 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5362 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5364 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
5365 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
5366 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
5368 if (nOldIndex
== nHit
)
5369 bSendMessage
= FALSE
;
5370 if ((nOldIndex
!= nHit
) &&
5372 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
5373 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5376 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
5377 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
5379 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5383 if (nOldIndex
!= -1)
5384 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
5387 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5388 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5389 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5391 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
5393 infoPtr
->nButtonDown
= -1;
5395 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5396 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
5397 NM_RELEASEDCAPTURE
);
5399 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5402 nmtb
.iItem
= btnPtr
->idCommand
;
5403 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
5404 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
5405 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
5406 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
5407 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
5408 nmtb
.tbButton
.iString
= btnPtr
->iString
;
5409 nmtb
.cchText
= 0; /* !!! not correct */
5410 nmtb
.pszText
= 0; /* !!! not correct */
5411 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5414 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5416 SendMessageA (infoPtr
->hwndNotify
, WM_COMMAND
,
5417 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
5419 /* !!! Undocumented - toolbar at 4.71 level and above sends
5420 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
5421 * Only NM_RCLICK is documented.
5423 nmmouse
.dwItemSpec
= btnPtr
->idCommand
;
5424 nmmouse
.dwItemData
= btnPtr
->dwData
;
5425 TOOLBAR_SendNotify ((NMHDR
*) &nmmouse
, infoPtr
, NM_CLICK
);
5432 TOOLBAR_CaptureChanged(HWND hwnd
)
5434 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5435 TBUTTON_INFO
*btnPtr
;
5437 infoPtr
->bCaptured
= FALSE
;
5439 if (infoPtr
->nButtonDown
>= 0)
5441 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5442 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5444 infoPtr
->nOldHit
= -1;
5446 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5447 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5453 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5455 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5456 TBUTTON_INFO
*hotBtnPtr
, *btnPtr
;
5459 TOOLBAR_SetHotItemEx(infoPtr
, -1, HICF_MOUSE
);
5461 if (infoPtr
->nOldHit
< 0)
5464 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
5466 /* If the last button we were over is depressed then make it not */
5467 /* depressed and redraw it */
5468 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
5470 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5472 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5474 rc1
= hotBtnPtr
->rect
;
5475 InflateRect (&rc1
, 1, 1);
5476 InvalidateRect (hwnd
, &rc1
, TRUE
);
5479 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
5485 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5487 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5489 TRACKMOUSEEVENT trackinfo
;
5491 TBUTTON_INFO
*btnPtr
;
5493 /* fill in the TRACKMOUSEEVENT struct */
5494 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
5495 trackinfo
.dwFlags
= TME_QUERY
;
5496 trackinfo
.hwndTrack
= hwnd
;
5497 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
5499 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
5500 _TrackMouseEvent(&trackinfo
);
5502 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
5503 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
5504 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
5506 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
5507 /* and can properly deactivate the hot toolbar button */
5508 _TrackMouseEvent(&trackinfo
);
5511 if (infoPtr
->hwndToolTip
)
5512 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5513 WM_MOUSEMOVE
, wParam
, lParam
);
5515 pt
.x
= (INT
)LOWORD(lParam
);
5516 pt
.y
= (INT
)HIWORD(lParam
);
5518 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5520 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
5522 if (infoPtr
->nOldHit
!= nHit
)
5524 if (infoPtr
->bCaptured
)
5526 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5527 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
5528 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5529 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5531 else if (nHit
== infoPtr
->nButtonDown
) {
5532 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5533 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5535 infoPtr
->nOldHit
= nHit
;
5543 inline static LRESULT
5544 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5546 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
5547 return DefWindowProcA (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
5549 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
5553 inline static LRESULT
5554 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5556 if (!(GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
5557 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
5559 return DefWindowProcA (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
5564 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5566 TOOLBAR_INFO
*infoPtr
;
5567 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
5570 /* allocate memory for info structure */
5571 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
5572 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
5575 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
5578 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5579 if (!GetWindowLongA (hwnd
, GWL_HINSTANCE
)) {
5580 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongA (GetParent (hwnd
), GWL_HINSTANCE
);
5581 SetWindowLongA (hwnd
, GWL_HINSTANCE
, (DWORD
)hInst
);
5584 /* native control does:
5585 * Get a lot of colors and brushes
5587 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5588 * CreateFontIndirectA(adr1)
5589 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5590 * hdc = GetDC(toolbar)
5591 * GetSystemMetrics(0x48)
5592 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5593 * 0, 0, 0, 0, "MARLETT")
5594 * oldfnt = SelectObject(hdc, fnt2)
5595 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5596 * GetTextMetricsA(hdc, adr3)
5597 * SelectObject(hdc, oldfnt)
5598 * DeleteObject(fnt2)
5600 * InvalidateRect(toolbar, 0, 1)
5601 * SetWindowLongA(toolbar, 0, addr)
5602 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5605 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5606 * ie 2 0x4600094c 0x4600094c 0x4600894d
5607 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5608 * rebar 0x50008844 0x40008844 0x50008845
5609 * pager 0x50000844 0x40000844 0x50008845
5610 * IC35mgr 0x5400084e **nochange**
5611 * on entry to _NCCREATE 0x5400084e
5612 * rowlist 0x5400004e **nochange**
5613 * on entry to _NCCREATE 0x5400004e
5617 /* I think the code below is a bug, but it is the way that the native
5618 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5619 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5620 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5621 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5622 * Some how, the only cases of this seem to be MFC programs.
5624 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5625 * does not occur in the WM_STYLECHANGING routine.
5626 * (Guy Albertelli 9/2001)
5629 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
5630 styleadd
|= TBSTYLE_TRANSPARENT
;
5631 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
5632 styleadd
|= CCS_TOP
; /* default to top */
5633 SetWindowLongA (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
5636 return DefWindowProcA (hwnd
, WM_NCCREATE
, wParam
, lParam
);
5641 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5643 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
5647 if (dwStyle
& WS_MINIMIZE
)
5648 return 0; /* Nothing to do */
5650 DefWindowProcA (hwnd
, WM_NCPAINT
, wParam
, lParam
);
5652 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
5655 if (!(dwStyle
& CCS_NODIVIDER
))
5657 GetWindowRect (hwnd
, &rcWindow
);
5658 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
5659 if( dwStyle
& WS_BORDER
)
5660 OffsetRect (&rcWindow
, 1, 1);
5661 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
5664 ReleaseDC( hwnd
, hdc
);
5670 /* handles requests from the tooltip control on what text to display */
5671 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
5673 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
5675 TRACE("button index = %d\n", index
);
5677 if (infoPtr
->pszTooltipText
)
5679 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5680 infoPtr
->pszTooltipText
= NULL
;
5686 if (infoPtr
->bNtfUnicode
)
5688 WCHAR wszBuffer
[INFOTIPSIZE
+1];
5689 NMTBGETINFOTIPW tbgit
;
5690 int len
; /* in chars */
5692 wszBuffer
[0] = '\0';
5693 wszBuffer
[INFOTIPSIZE
] = '\0';
5695 tbgit
.pszText
= wszBuffer
;
5696 tbgit
.cchTextMax
= INFOTIPSIZE
;
5697 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
5698 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
5700 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
5702 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
5704 len
= strlenW(tbgit
.pszText
);
5705 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5707 /* need to allocate temporary buffer in infoPtr as there
5708 * isn't enough space in buffer passed to us by the
5709 * tooltip control */
5710 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5711 if (infoPtr
->pszTooltipText
)
5713 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
5714 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5720 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
5726 CHAR szBuffer
[INFOTIPSIZE
+1];
5727 NMTBGETINFOTIPA tbgit
;
5728 int len
; /* in chars */
5731 szBuffer
[INFOTIPSIZE
] = '\0';
5733 tbgit
.pszText
= szBuffer
;
5734 tbgit
.cchTextMax
= INFOTIPSIZE
;
5735 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
5736 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
5738 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
5740 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
5742 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
5743 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5745 /* need to allocate temporary buffer in infoPtr as there
5746 * isn't enough space in buffer passed to us by the
5747 * tooltip control */
5748 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5749 if (infoPtr
->pszTooltipText
)
5751 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
5752 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5758 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
5763 /* if button has text, but it is not shown then automatically
5764 * use that text as tooltip */
5765 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
5766 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
5768 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
5769 int len
= pszText
? strlenW(pszText
) : 0;
5771 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
5773 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5775 /* need to allocate temporary buffer in infoPtr as there
5776 * isn't enough space in buffer passed to us by the
5777 * tooltip control */
5778 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5779 if (infoPtr
->pszTooltipText
)
5781 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
5782 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5788 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
5793 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
5795 /* last resort: send notification on to app */
5796 /* FIXME: find out what is really used here */
5797 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
5801 inline static LRESULT
5802 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5804 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5805 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
5807 switch (lpnmh
->code
)
5811 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
5813 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
5814 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5815 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5819 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5820 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5828 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
5830 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
5831 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
5832 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
5833 lppgs
->iScroll
, lppgs
->iDir
);
5837 case TTN_GETDISPINFOW
:
5838 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
5840 case TTN_GETDISPINFOA
:
5841 FIXME("TTN_GETDISPINFOA - stub\n");
5851 TOOLBAR_NotifyFormatFake(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5853 /* remove this routine when Toolbar is improved to pass infoPtr
5854 * around instead of hwnd.
5856 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5857 return TOOLBAR_NotifyFormat(infoPtr
, wParam
, lParam
);
5862 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
5866 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
5868 if ((lParam
== NF_QUERY
) && ((HWND
)wParam
== infoPtr
->hwndToolTip
))
5871 if (lParam
== NF_REQUERY
) {
5872 i
= SendMessageA(infoPtr
->hwndNotify
,
5873 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
5874 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
5875 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5879 infoPtr
->bNtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
5882 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
5887 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
5889 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5893 /* fill ps.rcPaint with a default rect */
5894 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
5896 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
5898 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
5899 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
5900 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
5902 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
5903 if (!wParam
) EndPaint (hwnd
, &ps
);
5910 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5911 /*****************************************************
5914 * Handles the WM_SETREDRAW message.
5917 * According to testing V4.71 of COMCTL32 returns the
5918 * *previous* status of the redraw flag (either 0 or 1)
5919 * instead of the MSDN documented value of 0 if handled.
5920 * (For laughs see the "consistency" with same function
5923 *****************************************************/
5925 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5926 BOOL oldredraw
= infoPtr
->bDoRedraw
;
5928 TRACE("set to %s\n",
5929 (wParam
) ? "TRUE" : "FALSE");
5930 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
5932 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
5934 return (oldredraw
) ? 1 : 0;
5939 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5941 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5942 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
5951 /* Resize deadlock check */
5952 if (infoPtr
->bAutoSize
) {
5953 infoPtr
->bAutoSize
= FALSE
;
5957 /* FIXME: optimize to only update size if the new size doesn't */
5958 /* match the current size */
5960 flags
= (INT
) wParam
;
5962 /* FIXME for flags =
5963 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5966 TRACE("sizing toolbar!\n");
5968 if (flags
== SIZE_RESTORED
) {
5969 /* width and height don't apply */
5970 parent
= GetParent (hwnd
);
5971 GetClientRect(parent
, &parent_rect
);
5972 x
= parent_rect
.left
;
5973 y
= parent_rect
.top
;
5975 if (dwStyle
& CCS_NORESIZE
) {
5976 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
5979 * this sets the working width of the toolbar, and
5980 * Calc Toolbar will not adjust it, only the height
5982 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
5983 cy
= infoPtr
->nHeight
;
5984 cx
= infoPtr
->nWidth
;
5985 TOOLBAR_CalcToolbar (hwnd
);
5986 infoPtr
->nWidth
= cx
;
5987 infoPtr
->nHeight
= cy
;
5990 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
5991 TOOLBAR_CalcToolbar (hwnd
);
5992 cy
= infoPtr
->nHeight
;
5993 cx
= infoPtr
->nWidth
;
5995 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
5996 GetWindowRect(hwnd
, &window_rect
);
5997 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
5998 y
= window_rect
.top
;
6000 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6001 GetWindowRect(hwnd
, &window_rect
);
6002 y
= parent_rect
.bottom
-
6003 ( window_rect
.bottom
- window_rect
.top
);
6007 if (dwStyle
& CCS_NOPARENTALIGN
) {
6008 uPosFlags
|= SWP_NOMOVE
;
6009 cy
= infoPtr
->nHeight
;
6010 cx
= infoPtr
->nWidth
;
6013 if (!(dwStyle
& CCS_NODIVIDER
))
6014 cy
+= GetSystemMetrics(SM_CYEDGE
);
6016 if (dwStyle
& WS_BORDER
)
6019 cy
+= GetSystemMetrics(SM_CYEDGE
);
6020 cx
+= GetSystemMetrics(SM_CYEDGE
);
6023 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6025 RECT delta_width
, delta_height
, client
, dummy
;
6026 DWORD min_x
, max_x
, min_y
, max_y
;
6027 TBUTTON_INFO
*btnPtr
;
6030 GetClientRect(hwnd
, &client
);
6031 if(client
.right
> infoPtr
->client_rect
.right
)
6033 min_x
= infoPtr
->client_rect
.right
;
6034 max_x
= client
.right
;
6038 max_x
= infoPtr
->client_rect
.right
;
6039 min_x
= client
.right
;
6041 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6043 min_y
= infoPtr
->client_rect
.bottom
;
6044 max_y
= client
.bottom
;
6048 max_y
= infoPtr
->client_rect
.bottom
;
6049 min_y
= client
.bottom
;
6052 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6053 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6055 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6056 btnPtr
= infoPtr
->buttons
;
6057 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6058 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6059 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6060 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6063 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) == (SWP_NOSIZE
| SWP_NOMOVE
))
6064 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6066 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6072 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6074 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6076 if (nType
== GWL_STYLE
) {
6077 if (lpStyle
->styleNew
& TBSTYLE_LIST
) {
6078 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
;
6081 infoPtr
->dwDTFlags
= DT_CENTER
;
6083 infoPtr
->bTransparent
= (lpStyle
->styleNew
& TBSTYLE_TRANSPARENT
);
6084 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6085 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6086 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6088 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6091 TOOLBAR_CalcToolbar(hwnd
);
6093 TOOLBAR_AutoSize (hwnd
);
6095 InvalidateRect(hwnd
, NULL
, TRUE
);
6102 TOOLBAR_SysColorChange (HWND hwnd
)
6104 COMCTL32_RefreshSysColors();
6111 static LRESULT WINAPI
6112 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6114 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6116 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6117 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6119 if (!TOOLBAR_GetInfoPtr(hwnd
) && (uMsg
!= WM_NCCREATE
))
6120 return DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
6125 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6127 case TB_ADDBUTTONSA
:
6128 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6130 case TB_ADDBUTTONSW
:
6131 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6134 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6137 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6140 return TOOLBAR_AutoSize (hwnd
);
6142 case TB_BUTTONCOUNT
:
6143 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6145 case TB_BUTTONSTRUCTSIZE
:
6146 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6148 case TB_CHANGEBITMAP
:
6149 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6151 case TB_CHECKBUTTON
:
6152 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6154 case TB_COMMANDTOINDEX
:
6155 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6158 return TOOLBAR_Customize (hwnd
);
6160 case TB_DELETEBUTTON
:
6161 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6163 case TB_ENABLEBUTTON
:
6164 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6166 case TB_GETANCHORHIGHLIGHT
:
6167 return TOOLBAR_GetAnchorHighlight (hwnd
);
6170 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6172 case TB_GETBITMAPFLAGS
:
6173 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6176 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6178 case TB_GETBUTTONINFOA
:
6179 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6181 case TB_GETBUTTONINFOW
:
6182 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6184 case TB_GETBUTTONSIZE
:
6185 return TOOLBAR_GetButtonSize (hwnd
);
6187 case TB_GETBUTTONTEXTA
:
6188 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6190 case TB_GETBUTTONTEXTW
:
6191 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6193 case TB_GETDISABLEDIMAGELIST
:
6194 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6196 case TB_GETEXTENDEDSTYLE
:
6197 return TOOLBAR_GetExtendedStyle (hwnd
);
6199 case TB_GETHOTIMAGELIST
:
6200 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6203 return TOOLBAR_GetHotItem (hwnd
);
6205 case TB_GETIMAGELIST
:
6206 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6208 /* case TB_GETINSERTMARK: */ /* 4.71 */
6209 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
6211 case TB_GETITEMRECT
:
6212 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6215 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6217 /* case TB_GETOBJECT: */ /* 4.71 */
6220 return TOOLBAR_GetPadding (hwnd
);
6223 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6226 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6229 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6232 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6235 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6238 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6240 case TB_GETTEXTROWS
:
6241 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6243 case TB_GETTOOLTIPS
:
6244 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6246 case TB_GETUNICODEFORMAT
:
6247 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6250 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6253 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6255 case TB_INDETERMINATE
:
6256 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6258 case TB_INSERTBUTTONA
:
6259 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6261 case TB_INSERTBUTTONW
:
6262 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6264 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6266 case TB_ISBUTTONCHECKED
:
6267 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6269 case TB_ISBUTTONENABLED
:
6270 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6272 case TB_ISBUTTONHIDDEN
:
6273 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
6275 case TB_ISBUTTONHIGHLIGHTED
:
6276 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
6278 case TB_ISBUTTONINDETERMINATE
:
6279 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
6281 case TB_ISBUTTONPRESSED
:
6282 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
6285 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
6287 case TB_MAPACCELERATORA
:
6288 case TB_MAPACCELERATORW
:
6289 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
6292 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
6294 /* case TB_MOVEBUTTON: */ /* 4.71 */
6296 case TB_PRESSBUTTON
:
6297 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
6299 case TB_REPLACEBITMAP
:
6300 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
6302 case TB_SAVERESTOREA
:
6303 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, lParam
);
6305 case TB_SAVERESTOREW
:
6306 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, lParam
);
6308 case TB_SETANCHORHIGHLIGHT
:
6309 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
6311 case TB_SETBITMAPSIZE
:
6312 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
6314 case TB_SETBUTTONINFOA
:
6315 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
6317 case TB_SETBUTTONINFOW
:
6318 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
6320 case TB_SETBUTTONSIZE
:
6321 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
6323 case TB_SETBUTTONWIDTH
:
6324 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
6327 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
6329 case TB_SETDISABLEDIMAGELIST
:
6330 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
6332 case TB_SETDRAWTEXTFLAGS
:
6333 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
6335 case TB_SETEXTENDEDSTYLE
:
6336 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
6338 case TB_SETHOTIMAGELIST
:
6339 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
6342 return TOOLBAR_SetHotItem (hwnd
, wParam
);
6344 case TB_SETIMAGELIST
:
6345 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
6348 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
6350 /* case TB_SETINSERTMARK: */ /* 4.71 */
6352 case TB_SETINSERTMARKCOLOR
:
6353 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
6355 case TB_SETMAXTEXTROWS
:
6356 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
6359 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
6362 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
6365 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
6368 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
6371 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
6373 case TB_SETTOOLTIPS
:
6374 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
6376 case TB_SETUNICODEFORMAT
:
6377 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
6380 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
6383 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
6386 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
6389 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
6392 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
6395 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
6397 /* Common Control Messages */
6399 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
6400 case CCM_GETCOLORSCHEME
:
6401 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
6403 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
6404 case CCM_SETCOLORSCHEME
:
6405 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
6407 case CCM_GETVERSION
:
6408 return TOOLBAR_GetVersion (hwnd
);
6410 case CCM_SETVERSION
:
6411 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
6417 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
6420 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
6423 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
6426 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
6428 /* case WM_KEYDOWN: */
6429 /* case WM_KILLFOCUS: */
6431 case WM_LBUTTONDBLCLK
:
6432 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
6434 case WM_LBUTTONDOWN
:
6435 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
6438 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
6441 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
6444 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
6446 case WM_CAPTURECHANGED
:
6447 return TOOLBAR_CaptureChanged(hwnd
);
6450 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
6453 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
6456 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
6459 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
6462 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
6464 case WM_NOTIFYFORMAT
:
6465 return TOOLBAR_NotifyFormatFake (hwnd
, wParam
, lParam
);
6468 return TOOLBAR_Paint (hwnd
, wParam
);
6471 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
6474 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
6476 case WM_STYLECHANGED
:
6477 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
6479 case WM_SYSCOLORCHANGE
:
6480 return TOOLBAR_SysColorChange (hwnd
);
6482 /* case WM_WININICHANGE: */
6487 case WM_MEASUREITEM
:
6489 return SendMessageA (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
6491 /* We see this in Outlook Express 5.x and just does DefWindowProc */
6492 case PGM_FORWARDMOUSE
:
6493 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
6496 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
6497 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
6498 uMsg
, wParam
, lParam
);
6499 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
6506 TOOLBAR_Register (void)
6510 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
6511 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
6512 wndClass
.lpfnWndProc
= (WNDPROC
)ToolbarWindowProc
;
6513 wndClass
.cbClsExtra
= 0;
6514 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
6515 wndClass
.hCursor
= LoadCursorA (0, (LPSTR
)IDC_ARROW
);
6516 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
6517 wndClass
.lpszClassName
= TOOLBARCLASSNAMEA
;
6519 RegisterClassA (&wndClass
);
6524 TOOLBAR_Unregister (void)
6526 UnregisterClassA (TOOLBARCLASSNAMEA
, NULL
);
6529 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
6534 /* Check if the entry already exists */
6535 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
6537 /* If this is a new entry we must create it and insert into the array */
6542 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
6545 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
6546 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
6561 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
6565 for (i
= 0; i
< *cies
; i
++)
6575 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
6583 for (i
= 0; i
< cies
; i
++)
6585 if (pies
[i
]->id
== id
)
6597 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
6599 HIMAGELIST himlDef
= 0;
6600 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
6603 himlDef
= pie
->himl
;
6609 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
6611 if (infoPtr
->bUnicode
)
6612 return TOOLBAR_SendNotify ((NMHDR
*) nmtb
, infoPtr
, TBN_GETBUTTONINFOW
);
6619 nmtba
.iItem
= nmtb
->iItem
;
6620 nmtba
.pszText
= Buffer
;
6621 nmtba
.cchText
= 256;
6622 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
6624 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtba
, infoPtr
, TBN_GETBUTTONINFOA
))
6626 int ccht
= strlen(nmtba
.pszText
);
6628 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
6629 nmtb
->pszText
, nmtb
->cchText
);
6631 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
6640 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
6641 int iItem
, PCUSTOMBUTTON btnInfo
)
6646 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
6648 return TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYDELETE
);