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 * This code was audited for completeness against the documented features
25 * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
27 * Unless otherwise noted, we believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features or bugs please note them below.
33 * - TBSTYLE_REGISTERDROP
34 * - TBSTYLE_EX_DOUBLEBUFFER
38 * - TB_INSERTMARKHITTEST
47 * - Button wrapping (under construction).
49 * - iListGap custom draw support.
52 * - Run tests using Waite Group Windows95 API Bible Volume 2.
53 * The second cdrom contains executables addstr.exe, btncount.exe,
54 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
55 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
56 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
57 * setparnt.exe, setrows.exe, toolwnd.exe.
58 * - Microsoft's controlspy examples.
59 * - Charles Petzold's 'Programming Windows': gadgets.exe
61 * Differences between MSDN and actual native control operation:
62 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
63 * to the right of the bitmap. Otherwise, this style is
64 * identical to TBSTYLE_FLAT."
65 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
66 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
67 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
68 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
80 #include "wine/unicode.h"
84 #include "wine/debug.h"
86 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
88 static HCURSOR hCursorDrag
= NULL
;
97 BYTE bDropDownPressed
;
102 INT cx
; /* manually set size */
116 } IMLENTRY
, *PIMLENTRY
;
120 DWORD dwStructSize
; /* size of TBBUTTON struct */
121 INT nHeight
; /* height of the toolbar */
122 INT nWidth
; /* width of the toolbar */
124 RECT rcBound
; /* bounding rectangle */
130 INT nRows
; /* number of button rows */
131 INT nMaxTextRows
; /* maximum number of text rows */
132 INT cxMin
; /* minimum button width */
133 INT cxMax
; /* maximum button width */
134 INT nNumButtons
; /* number of buttons */
135 INT nNumBitmaps
; /* number of bitmaps */
136 INT nNumStrings
; /* number of strings */
138 INT nButtonDown
; /* toolbar button being pressed or -1 if none */
139 INT nButtonDrag
; /* toolbar button being dragged or -1 if none */
141 INT nHotItem
; /* index of the "hot" item */
142 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
143 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
144 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
145 SIZE szPadding
; /* padding values around button */
146 INT iListGap
; /* default gap between text and image for toolbar with list style */
148 HFONT hFont
; /* text font */
149 HIMAGELIST himlInt
; /* image list created internally */
150 PIMLENTRY
*himlDef
; /* default image list array */
151 INT cimlDef
; /* default image list array count */
152 PIMLENTRY
*himlHot
; /* hot image list array */
153 INT cimlHot
; /* hot image list array count */
154 PIMLENTRY
*himlDis
; /* disabled image list array */
155 INT cimlDis
; /* disabled image list array count */
156 HWND hwndToolTip
; /* handle to tool tip control */
157 HWND hwndNotify
; /* handle to the window that gets notifications */
158 HWND hwndSelf
; /* my own handle */
159 BOOL bBtnTranspnt
; /* button transparency flag */
160 BOOL bAutoSize
; /* auto size deadlock indicator */
161 BOOL bAnchor
; /* anchor highlight enabled */
162 BOOL bDoRedraw
; /* Redraw status */
163 BOOL bDragOutSent
; /* has TBN_DRAGOUT notification been sent for this drag? */
164 BOOL bUnicode
; /* Notifications are ASCII (FALSE) or Unicode (TRUE)? */
165 BOOL bCaptured
; /* mouse captured? */
166 DWORD dwStyle
; /* regular toolbar style */
167 DWORD dwExStyle
; /* extended toolbar style */
168 DWORD dwDTFlags
; /* DrawText flags */
170 COLORREF clrInsertMark
; /* insert mark color */
171 COLORREF clrBtnHighlight
; /* color for Flat Separator */
172 COLORREF clrBtnShadow
; /* color for Flag Separator */
174 LPWSTR pszTooltipText
; /* temporary store for a string > 80 characters
175 * for TTN_GETDISPINFOW notification */
176 TBINSERTMARK tbim
; /* info on insertion mark */
177 TBUTTON_INFO
*buttons
; /* pointer to button array */
178 LPWSTR
*strings
; /* pointer to string array */
179 TBITMAP_INFO
*bitmaps
;
180 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
183 /* used by customization dialog */
186 PTOOLBAR_INFO tbInfo
;
188 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
196 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
205 #define SEPARATOR_WIDTH 8
207 #define BOTTOM_BORDER 2
208 #define DDARROW_WIDTH 11
209 #define ARROW_HEIGHT 3
210 #define INSERTMARK_WIDTH 2
215 /* gap between border of button and text/image */
218 /* how wide to treat the bitmap if it isn't present */
219 #define LIST_IMAGE_ABSENT_WIDTH 2
221 #define TOOLBAR_NOWHERE (-1)
223 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongPtrW(hwnd,0))
224 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
225 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
227 static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO
*infoPtr
, INT iListGap
)
229 return GetSystemMetrics(SM_CXEDGE
) + iListGap
- infoPtr
->szPadding
.cx
/2;
232 /* Used to find undocumented extended styles */
233 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
234 TBSTYLE_EX_UNDOC1 | \
235 TBSTYLE_EX_MIXEDBUTTONS | \
236 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
238 /* all of the CCS_ styles */
239 #define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \
240 CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT)
242 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
243 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
244 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
245 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
246 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
248 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
249 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
250 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
251 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
252 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
253 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
254 static LRESULT
TOOLBAR_LButtonDown(HWND hwnd
, WPARAM wParam
, LPARAM lParam
);
255 static void TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
);
258 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
262 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
264 LPWSTR lpText
= NULL
;
266 /* NOTE: iString == -1 is undocumented */
267 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
268 lpText
= (LPWSTR
)btnPtr
->iString
;
269 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
270 lpText
= infoPtr
->strings
[btnPtr
->iString
];
276 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
278 if (TRACE_ON(toolbar
)){
279 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
280 btn_num
, bP
->idCommand
, GETIBITMAP(infoPtr
, bP
->iBitmap
),
281 bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
282 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
284 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
285 btn_num
, bP
->idCommand
,
286 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
287 bP
->rect
.left
, bP
->rect
.top
,
288 bP
->rect
.right
, bP
->rect
.bottom
);
294 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
296 if (TRACE_ON(toolbar
)) {
299 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
301 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
302 iP
->nNumStrings
, iP
->dwStyle
);
303 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
305 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
306 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
307 for(i
=0; i
<iP
->nNumButtons
; i
++) {
308 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
314 /***********************************************************************
317 * This function validates that the styles set are implemented and
318 * issues FIXME's warning of possible problems. In a perfect world this
319 * function should be null.
322 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
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
->bUnicode
) ? "via Unicode" : "via ANSI");
342 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
,
343 (WPARAM
)nmhdr
->idFrom
, (LPARAM
)nmhdr
);
346 /***********************************************************************
347 * TOOLBAR_GetBitmapIndex
349 * This function returns the bitmap index associated with a button.
350 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
351 * is issued to retrieve the index.
354 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
356 INT ret
= btnPtr
->iBitmap
;
358 if (ret
== I_IMAGECALLBACK
)
360 /* issue TBN_GETDISPINFO */
363 memset(&nmgd
, 0, sizeof(nmgd
));
364 nmgd
.idCommand
= btnPtr
->idCommand
;
365 nmgd
.lParam
= btnPtr
->dwData
;
366 nmgd
.dwMask
= TBNF_IMAGE
;
367 TOOLBAR_SendNotify(&nmgd
.hdr
, infoPtr
,
368 infoPtr
->bUnicode
? TBN_GETDISPINFOW
: TBN_GETDISPINFOA
);
369 if (nmgd
.dwMask
& TBNF_DI_SETITEM
)
370 btnPtr
->iBitmap
= nmgd
.iImage
;
372 TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
373 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
376 if (ret
!= I_IMAGENONE
)
377 ret
= GETIBITMAP(infoPtr
, ret
);
384 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
387 INT id
= GETHIMLID(infoPtr
, index
);
388 INT iBitmap
= GETIBITMAP(infoPtr
, index
);
390 if (((himl
= GETDEFIMAGELIST(infoPtr
, id
)) &&
391 iBitmap
>= 0 && iBitmap
< ImageList_GetImageCount(himl
)) ||
392 (index
== I_IMAGECALLBACK
))
399 /***********************************************************************
400 * TOOLBAR_GetImageListForDrawing
402 * This function validates the bitmap index (including I_IMAGECALLBACK
403 * functionality) and returns the corresponding image list.
406 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
410 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
411 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
412 ERR("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
413 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
417 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
418 if ((*index
== I_IMAGECALLBACK
) ||
419 (*index
== I_IMAGENONE
)) return NULL
;
420 ERR("TBN_GETDISPINFO returned invalid index %d\n",
427 case IMAGE_LIST_DEFAULT
:
428 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
431 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
433 case IMAGE_LIST_DISABLED
:
434 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
438 FIXME("Shouldn't reach here\n");
442 TRACE("no image list\n");
448 /***********************************************************************
449 * TOOLBAR_TestImageExist
451 * This function is similar to TOOLBAR_GetImageListForDrawing, except it does not
452 * return the image list. The I_IMAGECALLBACK functionality is implemented.
455 TOOLBAR_TestImageExist (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
)
459 if (!himl
) return FALSE
;
461 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
462 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
463 ERR("index %d is not valid, max %d\n",
464 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
468 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
469 if ((index
== I_IMAGECALLBACK
) ||
470 (index
== I_IMAGENONE
)) return FALSE
;
471 ERR("TBN_GETDISPINFO returned invalid index %d\n",
480 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
483 COLORREF oldcolor
, newcolor
;
485 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
486 myrect
.right
= myrect
.left
+ 1;
487 myrect
.top
= lpRect
->top
+ 2;
488 myrect
.bottom
= lpRect
->bottom
- 2;
490 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
491 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
492 oldcolor
= SetBkColor (hdc
, newcolor
);
493 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
495 myrect
.left
= myrect
.right
;
496 myrect
.right
= myrect
.left
+ 1;
498 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
499 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
500 SetBkColor (hdc
, newcolor
);
501 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
503 SetBkColor (hdc
, oldcolor
);
507 /***********************************************************************
508 * TOOLBAR_DrawDDFlatSeparator
510 * This function draws the separator that was flagged as BTNS_DROPDOWN.
511 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
512 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
513 * are horizontal as opposed to the vertical separators for not dropdown
516 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
519 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
522 COLORREF oldcolor
, newcolor
;
524 myrect
.left
= lpRect
->left
;
525 myrect
.right
= lpRect
->right
;
526 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
527 myrect
.bottom
= myrect
.top
+ 1;
529 InflateRect (&myrect
, -2, 0);
531 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
532 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
534 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
535 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
536 oldcolor
= SetBkColor (hdc
, newcolor
);
537 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
539 myrect
.top
= myrect
.bottom
;
540 myrect
.bottom
= myrect
.top
+ 1;
542 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
543 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
544 SetBkColor (hdc
, newcolor
);
545 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
547 SetBkColor (hdc
, oldcolor
);
552 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
557 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
558 hOldPen
= SelectObject ( hdc
, hPen
);
561 MoveToEx (hdc
, x
, y
, NULL
);
562 LineTo (hdc
, x
+5, y
++); x
++;
563 MoveToEx (hdc
, x
, y
, NULL
);
564 LineTo (hdc
, x
+3, y
++); x
++;
565 MoveToEx (hdc
, x
, y
, NULL
);
566 LineTo (hdc
, x
+1, y
++);
567 SelectObject( hdc
, hOldPen
);
568 DeleteObject( hPen
);
572 * Draw the text string for this button.
573 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
574 * is non-zero, so we can simply check himlDef to see if we have
578 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
579 NMTBCUSTOMDRAW
*tbcd
)
581 HDC hdc
= tbcd
->nmcd
.hdc
;
584 COLORREF clrOldBk
= 0;
586 UINT state
= tbcd
->nmcd
.uItemState
;
590 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
591 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
593 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
594 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
595 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
597 else if (state
& CDIS_DISABLED
) {
598 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
599 OffsetRect (rcText
, 1, 1);
600 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
601 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
602 OffsetRect (rcText
, -1, -1);
604 else if (state
& CDIS_INDETERMINATE
) {
605 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
607 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
608 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
609 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
610 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
613 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
616 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
617 SetTextColor (hdc
, clrOld
);
618 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
620 SetBkColor (hdc
, clrOldBk
);
621 SetBkMode (hdc
, oldBkMode
);
623 SelectObject (hdc
, hOldFont
);
629 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
631 HDC hdc
= tbcd
->nmcd
.hdc
;
632 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
635 INT cx
= lpRect
->right
- lpRect
->left
;
636 INT cy
= lpRect
->bottom
- lpRect
->top
;
637 INT cxEdge
= GetSystemMetrics(SM_CXEDGE
);
638 INT cyEdge
= GetSystemMetrics(SM_CYEDGE
);
639 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
640 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
641 PatBlt (hdc
, lpRect
->left
+ cxEdge
, lpRect
->top
+ cyEdge
,
642 cx
- (2 * cxEdge
), cy
- (2 * cyEdge
), PATCOPY
);
643 SetBkColor(hdc
, clrBkOld
);
644 SetTextColor(hdc
, clrTextOld
);
645 SelectObject (hdc
, hbr
);
649 static void TOOLBAR_DrawMasked(HIMAGELIST himl
, int index
, HDC hdc
, INT x
, INT y
, UINT draw_flags
)
652 HBITMAP hbmMask
, hbmImage
;
653 HDC hdcMask
, hdcImage
;
655 ImageList_GetIconSize(himl
, &cx
, &cy
);
657 /* Create src image */
658 hdcImage
= CreateCompatibleDC(hdc
);
659 hbmImage
= CreateCompatibleBitmap(hdc
, cx
, cy
);
660 SelectObject(hdcImage
, hbmImage
);
661 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
662 RGB(0xff, 0xff, 0xff), RGB(0,0,0), draw_flags
);
665 hdcMask
= CreateCompatibleDC(0);
666 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
667 SelectObject(hdcMask
, hbmMask
);
669 /* Remove the background and all white pixels */
670 ImageList_DrawEx(himl
, index
, hdcMask
, 0, 0, cx
, cy
,
671 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_MASK
);
672 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
673 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
675 /* draw the new mask 'etched' to hdc */
676 SetBkColor(hdc
, RGB(255, 255, 255));
677 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
678 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
679 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
680 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
681 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
684 DeleteObject(hbmImage
);
686 DeleteObject (hbmMask
);
692 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
696 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
697 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
698 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
699 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
700 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
701 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
702 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
706 /* draws the image on a toolbar button */
708 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
710 HIMAGELIST himl
= NULL
;
711 BOOL draw_masked
= FALSE
;
714 UINT draw_flags
= ILD_TRANSPARENT
;
716 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
718 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
721 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
725 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (infoPtr
->dwStyle
& TBSTYLE_FLAT
))
727 /* if hot, attempt to draw with hot image list, if fails,
728 use default image list */
729 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
731 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
734 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
739 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
740 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
743 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
744 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
745 draw_flags
|= ILD_BLEND50
;
747 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
748 index
, himl
, left
, top
, offset
);
751 TOOLBAR_DrawMasked (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
753 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
756 /* draws a blank frame for a toolbar button */
758 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
)
760 HDC hdc
= tbcd
->nmcd
.hdc
;
761 RECT rc
= tbcd
->nmcd
.rc
;
762 /* if the state is disabled or indeterminate then the button
763 * cannot have an interactive look like pressed or hot */
764 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
765 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
766 BOOL pressed_look
= !non_interactive_state
&&
767 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
768 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
770 /* app don't want us to draw any edges */
771 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
777 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
778 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
779 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
784 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
786 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
787 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
792 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
, BOOL bDropDownPressed
)
794 HDC hdc
= tbcd
->nmcd
.hdc
;
796 BOOL pressed
= bDropDownPressed
||
797 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
));
799 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
802 DrawEdge (hdc
, rcArrow
, BDR_SUNKENOUTER
, BF_RECT
);
803 else if ( (tbcd
->nmcd
.uItemState
& CDIS_HOT
) &&
804 !(tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) &&
805 !(tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
))
806 DrawEdge (hdc
, rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
811 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
813 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
814 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
818 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
820 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
822 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+1, rcArrow
->top
+1 + (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
823 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
, rcArrow
->top
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
826 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+ offset
, rcArrow
->top
+ offset
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
829 /* draws a complete toolbar button */
831 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
833 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
834 DWORD dwStyle
= infoPtr
->dwStyle
;
835 BOOL hasDropDownArrow
= (TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
836 (btnPtr
->fsStyle
& BTNS_DROPDOWN
)) ||
837 (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
838 BOOL drawSepDropDownArrow
= hasDropDownArrow
&&
839 (~btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
840 RECT rc
, rcArrow
, rcBitmap
, rcText
;
841 LPWSTR lpText
= NULL
;
847 CopyRect (&rcArrow
, &rc
);
848 CopyRect(&rcBitmap
, &rc
);
850 /* get a pointer to the text */
851 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
853 if (hasDropDownArrow
)
857 if (dwStyle
& TBSTYLE_FLAT
)
858 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
860 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
862 if (drawSepDropDownArrow
)
865 rcArrow
.left
= right
;
868 /* copy text rect after adjusting for drop-down arrow
869 * so that text is centred in the rectangle not containing
871 CopyRect(&rcText
, &rc
);
873 /* Center the bitmap horizontally and vertically */
874 if (dwStyle
& TBSTYLE_LIST
)
875 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
);
877 rcBitmap
.left
+=(infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
880 rcBitmap
.top
+= GetSystemMetrics(SM_CYEDGE
);
882 rcBitmap
.top
+=(infoPtr
->nButtonHeight
- infoPtr
->nBitmapHeight
) / 2;
884 TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
885 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
886 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
887 TRACE ("iString: %x\n", btnPtr
->iString
);
888 TRACE ("Stringtext: %s\n", debugstr_w(lpText
));
892 rcText
.left
+= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
893 rcText
.right
-= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
894 if (GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,btnPtr
->iBitmap
)) &&
895 TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
))
897 if (dwStyle
& TBSTYLE_LIST
)
898 rcText
.left
+= infoPtr
->nBitmapWidth
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
900 rcText
.top
+= GetSystemMetrics(SM_CYEDGE
) + OFFSET_Y
+ infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
/2;
903 if (dwStyle
& TBSTYLE_LIST
)
904 rcText
.left
+= LIST_IMAGE_ABSENT_WIDTH
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
906 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
907 (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
)))
908 OffsetRect(&rcText
, 1, 1);
911 /* Initialize fields in all cases, because we use these later
912 * NOTE: applications can and do alter these to customize their
914 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
915 tbcd
.clrText
= comctl32_color
.clrBtnText
;
916 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
917 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
918 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
919 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
920 tbcd
.clrHighlightHotTrack
= 0;
921 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
922 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
923 /* MSDN says that this is the text rectangle.
924 * But (why always a but) tracing of v5.7 of native shows
925 * that this is really a *relative* rectangle based on the
926 * the nmcd.rc. Also the left and top are always 0 ignoring
927 * any bitmap that might be present. */
928 tbcd
.rcText
.left
= 0;
930 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
931 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
932 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
935 tbcd
.hbrMonoDither
= COMCTL32_hPattern55AABrush
;
937 /* FIXME: what are these used for? */
941 /* Issue Item Prepaint notify */
942 infoPtr
->dwItemCustDraw
= 0;
943 infoPtr
->dwItemCDFlag
= 0;
944 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
946 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
947 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
948 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
949 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
950 /* reset these fields so the user can't alter the behaviour like native */
954 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
955 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
956 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
958 /* save the only part of the rect that the user can change */
959 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
960 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
964 if (btnPtr
->fsStyle
& BTNS_SEP
) {
965 /* with the FLAT style, iBitmap is the width and has already */
966 /* been taken into consideration in calculating the width */
967 /* so now we need to draw the vertical separator */
968 /* empirical tests show that iBitmap can/will be non-zero */
969 /* when drawing the vertical bar... */
970 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
971 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
)
972 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
974 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
976 else if (btnPtr
->fsStyle
!= BTNS_SEP
) {
977 FIXME("Draw some kind of separator: fsStyle=%x\n",
983 if (!(tbcd
.nmcd
.uItemState
& CDIS_HOT
) &&
984 ((tbcd
.nmcd
.uItemState
& CDIS_CHECKED
) || (tbcd
.nmcd
.uItemState
& CDIS_INDETERMINATE
)))
985 TOOLBAR_DrawPattern (&rc
, &tbcd
);
987 if ((dwStyle
& TBSTYLE_FLAT
) && (tbcd
.nmcd
.uItemState
& CDIS_HOT
))
989 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
993 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
994 ExtTextOutW(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
995 if (hasDropDownArrow
)
996 ExtTextOutW(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
997 SetBkColor(hdc
, oldclr
);
1001 TOOLBAR_DrawFrame(infoPtr
, dwStyle
& TBSTYLE_FLAT
, &tbcd
);
1003 if (drawSepDropDownArrow
)
1004 TOOLBAR_DrawSepDDArrow(infoPtr
, &tbcd
, &rcArrow
, btnPtr
->bDropDownPressed
);
1006 if (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) || (btnPtr
->fsStyle
& BTNS_SHOWTEXT
))
1007 TOOLBAR_DrawString (infoPtr
, &rcText
, lpText
, &tbcd
);
1009 TOOLBAR_DrawImage(infoPtr
, btnPtr
, rcBitmap
.left
, rcBitmap
.top
, &tbcd
);
1011 if (hasDropDownArrow
&& !drawSepDropDownArrow
)
1013 if (tbcd
.nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
1015 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1 + (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
1016 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
1018 else if (tbcd
.nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
1020 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
1021 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+ offset
, rcArrow
.top
+ offset
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1024 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1028 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1030 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
1031 tbcd
.nmcd
.hdc
= hdc
;
1033 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
1034 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
1035 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
1036 tbcd
.rcText
= rcText
;
1037 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1038 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1039 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1046 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
1048 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1049 TBUTTON_INFO
*btnPtr
;
1050 INT i
, oldBKmode
= 0;
1051 RECT rcTemp
, rcClient
;
1052 NMTBCUSTOMDRAW tbcd
;
1055 /* the app has told us not to redraw the toolbar */
1056 if (!infoPtr
->bDoRedraw
)
1059 /* if imagelist belongs to the app, it can be changed
1060 by the app after setting it */
1061 if (GETDEFIMAGELIST(infoPtr
, 0) != infoPtr
->himlInt
)
1063 infoPtr
->nNumBitmaps
= 0;
1064 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
1065 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
1068 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1070 /* Send initial notify */
1071 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1072 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
1073 tbcd
.nmcd
.hdc
= hdc
;
1074 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1075 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1076 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
1078 if (infoPtr
->bBtnTranspnt
)
1079 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
1081 GetClientRect(hwnd
, &rcClient
);
1083 /* redraw necessary buttons */
1084 btnPtr
= infoPtr
->buttons
;
1085 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
1088 if (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
1090 IntersectRect(&rcTemp
, &rcClient
, &btnPtr
->rect
);
1091 bDraw
= EqualRect(&rcTemp
, &btnPtr
->rect
);
1095 bDraw
&= IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
));
1096 bDraw
= (btnPtr
->fsState
& TBSTATE_HIDDEN
) ? FALSE
: bDraw
;
1098 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
1101 /* draw insert mark if required */
1102 if (infoPtr
->tbim
.iButton
!= -1)
1104 RECT rcButton
= infoPtr
->buttons
[infoPtr
->tbim
.iButton
].rect
;
1106 rcInsertMark
.top
= rcButton
.top
;
1107 rcInsertMark
.bottom
= rcButton
.bottom
;
1108 if (infoPtr
->tbim
.dwFlags
& TBIMHT_AFTER
)
1109 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.right
;
1111 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.left
- INSERTMARK_WIDTH
;
1112 COMCTL32_DrawInsertMark(hdc
, &rcInsertMark
, infoPtr
->clrInsertMark
, FALSE
);
1115 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
1116 SetBkMode (hdc
, oldBKmode
);
1118 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1120 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1121 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
1122 tbcd
.nmcd
.hdc
= hdc
;
1123 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1124 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1128 /***********************************************************************
1129 * TOOLBAR_MeasureString
1131 * This function gets the width and height of a string in pixels. This
1132 * is done first by using GetTextExtentPoint to get the basic width
1133 * and height. The DrawText is called with DT_CALCRECT to get the exact
1134 * width. The reason is because the text may have more than one "&" (or
1135 * prefix characters as M$ likes to call them). The prefix character
1136 * indicates where the underline goes, except for the string "&&" which
1137 * is reduced to a single "&". GetTextExtentPoint does not process these
1138 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
1141 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
1142 HDC hdc
, LPSIZE lpSize
)
1149 if (infoPtr
->nMaxTextRows
> 0 &&
1150 !(btnPtr
->fsState
& TBSTATE_HIDDEN
) &&
1151 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1152 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
1154 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1156 if(lpText
!= NULL
) {
1157 /* first get size of all the text */
1158 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1160 /* feed above size into the rectangle for DrawText */
1161 myrect
.left
= myrect
.top
= 0;
1162 myrect
.right
= lpSize
->cx
;
1163 myrect
.bottom
= lpSize
->cy
;
1165 /* Use DrawText to get true size as drawn (less pesky "&") */
1166 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1167 DT_CALCRECT
| ((btnPtr
->fsStyle
& BTNS_NOPREFIX
) ?
1170 /* feed back to caller */
1171 lpSize
->cx
= myrect
.right
;
1172 lpSize
->cy
= myrect
.bottom
;
1176 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1179 /***********************************************************************
1180 * TOOLBAR_CalcStrings
1182 * This function walks through each string and measures it and returns
1183 * the largest height and width to caller.
1186 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1188 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1189 TBUTTON_INFO
*btnPtr
;
1198 if(infoPtr
->nMaxTextRows
== 0)
1202 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1204 btnPtr
= infoPtr
->buttons
;
1205 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1206 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1208 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1209 if (sz
.cx
> lpSize
->cx
)
1211 if (sz
.cy
> lpSize
->cy
)
1216 SelectObject (hdc
, hOldFont
);
1217 ReleaseDC (hwnd
, hdc
);
1219 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1222 /***********************************************************************
1223 * TOOLBAR_WrapToolbar
1225 * This function walks through the buttons and separators in the
1226 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1227 * wrapping should occur based on the width of the toolbar window.
1228 * It does *not* calculate button placement itself. That task
1229 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1230 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1231 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1233 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1234 * vertical toolbar lists.
1238 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1240 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1241 TBUTTON_INFO
*btnPtr
;
1244 BOOL bWrap
, bButtonWrap
;
1246 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1247 /* no layout is necessary. Applications may use this style */
1248 /* to perform their own layout on the toolbar. */
1249 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1250 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1252 btnPtr
= infoPtr
->buttons
;
1253 x
= infoPtr
->nIndent
;
1255 /* this can get the parents width, to know how far we can extend
1256 * this toolbar. We cannot use its height, as there may be multiple
1257 * toolbars in a rebar control
1259 GetClientRect( GetParent(hwnd
), &rc
);
1260 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1261 bButtonWrap
= FALSE
;
1263 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1264 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1267 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1270 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1272 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1275 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1276 /* it is the actual width of the separator. This is used for */
1277 /* custom controls in toolbars. */
1279 /* BTNS_DROPDOWN separators are treated as buttons for */
1280 /* width. - GA 8/01 */
1281 if ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1282 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
))
1283 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1284 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1286 cx
= infoPtr
->nButtonWidth
;
1288 /* Two or more adjacent separators form a separator group. */
1289 /* The first separator in a group should be wrapped to the */
1290 /* next row if the previous wrapping is on a button. */
1292 (btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1293 (i
+ 1 < infoPtr
->nNumButtons
) &&
1294 (btnPtr
[i
+ 1].fsStyle
& BTNS_SEP
) )
1296 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1297 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1298 x
= infoPtr
->nIndent
;
1300 bButtonWrap
= FALSE
;
1304 /* The layout makes sure the bitmap is visible, but not the button. */
1305 /* Test added to also wrap after a button that starts a row but */
1306 /* is bigger than the area. - GA 8/01 */
1307 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1308 > infoPtr
->nWidth
) ||
1309 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1311 BOOL bFound
= FALSE
;
1313 /* If the current button is a separator and not hidden, */
1314 /* go to the next until it reaches a non separator. */
1315 /* Wrap the last separator if it is before a button. */
1316 while( ( ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1317 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
)) ||
1318 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1319 i
< infoPtr
->nNumButtons
)
1325 if( bFound
&& i
< infoPtr
->nNumButtons
)
1328 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1329 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1330 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1331 x
= infoPtr
->nIndent
;
1332 bButtonWrap
= FALSE
;
1335 else if ( i
>= infoPtr
->nNumButtons
)
1338 /* If the current button is not a separator, find the last */
1339 /* separator and wrap it. */
1340 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1342 if ((btnPtr
[j
].fsStyle
& BTNS_SEP
) &&
1343 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1347 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1348 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1349 x
= infoPtr
->nIndent
;
1350 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1351 bButtonWrap
= FALSE
;
1356 /* If no separator available for wrapping, wrap one of */
1357 /* non-hidden previous button. */
1361 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1363 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1368 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1369 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1370 x
= infoPtr
->nIndent
;
1371 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1377 /* If all above failed, wrap the current button. */
1380 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1381 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1382 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1384 x
= infoPtr
->nIndent
;
1385 if (btnPtr
[i
].fsStyle
& BTNS_SEP
)
1386 bButtonWrap
= FALSE
;
1392 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1393 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1400 /***********************************************************************
1401 * TOOLBAR_CalcToolbar
1403 * This function calculates button and separator placement. It first
1404 * calculates the button sizes, gets the toolbar window width and then
1405 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1406 * on. It assigns a new location to each item and sends this location to
1407 * the tooltip window if appropriate. Finally, it updates the rcBound
1408 * rect and calculates the new required toolbar window height.
1412 TOOLBAR_CalcToolbar (HWND hwnd
)
1414 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1415 DWORD dwStyle
= infoPtr
->dwStyle
;
1416 TBUTTON_INFO
*btnPtr
;
1417 INT i
, nRows
, nSepRows
;
1421 BOOL usesBitmaps
= FALSE
;
1422 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1424 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1426 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1428 for (i
= 0; i
< infoPtr
->nNumButtons
&& !usesBitmaps
; i
++)
1430 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,infoPtr
->buttons
[i
].iBitmap
))
1433 if (dwStyle
& TBSTYLE_LIST
)
1435 infoPtr
->nButtonHeight
= max((usesBitmaps
) ? infoPtr
->nBitmapHeight
:
1436 0, sizeString
.cy
) + infoPtr
->szPadding
.cy
;
1437 infoPtr
->nButtonWidth
= ((usesBitmaps
) ? infoPtr
->nBitmapWidth
:
1438 LIST_IMAGE_ABSENT_WIDTH
) + sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1439 if (sizeString
.cx
> 0)
1440 infoPtr
->nButtonWidth
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1441 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1442 infoPtr
->nButtonWidth
, infoPtr
->nButtonHeight
, usesBitmaps
,
1443 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
1446 if (sizeString
.cy
> 0)
1449 infoPtr
->nButtonHeight
= sizeString
.cy
+
1450 infoPtr
->szPadding
.cy
/2 + /* this is the space to separate text from bitmap */
1451 infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1453 infoPtr
->nButtonHeight
= sizeString
.cy
+ infoPtr
->szPadding
.cy
;
1456 infoPtr
->nButtonHeight
= infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1458 if (sizeString
.cx
> infoPtr
->nBitmapWidth
)
1459 infoPtr
->nButtonWidth
= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1461 infoPtr
->nButtonWidth
= infoPtr
->nBitmapWidth
+ infoPtr
->szPadding
.cx
;
1464 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1465 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1466 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1467 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1469 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1471 x
= infoPtr
->nIndent
;
1474 /* from above, minimum is a button, and possible text */
1475 cx
= infoPtr
->nButtonWidth
;
1477 /* cannot use just ButtonHeight, we may have no buttons! */
1478 if (infoPtr
->nNumButtons
> 0)
1479 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1481 cy
= infoPtr
->nHeight
;
1483 nRows
= nSepRows
= 0;
1485 infoPtr
->rcBound
.top
= y
;
1486 infoPtr
->rcBound
.left
= x
;
1487 infoPtr
->rcBound
.bottom
= y
+ cy
;
1488 infoPtr
->rcBound
.right
= x
;
1490 btnPtr
= infoPtr
->buttons
;
1492 TRACE("cy=%d\n", cy
);
1494 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1497 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1499 SetRectEmpty (&btnPtr
->rect
);
1503 cy
= infoPtr
->nHeight
;
1505 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1506 /* it is the actual width of the separator. This is used for */
1507 /* custom controls in toolbars. */
1508 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1509 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
) {
1510 cy
= (btnPtr
->iBitmap
> 0) ?
1511 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1512 cx
= infoPtr
->nButtonWidth
;
1515 cx
= (btnPtr
->iBitmap
> 0) ?
1516 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1522 else if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1523 (btnPtr
->fsStyle
& BTNS_AUTOSIZE
))
1530 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1532 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1534 SelectObject (hdc
, hOldFont
);
1535 ReleaseDC (hwnd
, hdc
);
1537 /* add space on for button frame, etc */
1538 cx
= sz
.cx
+ infoPtr
->szPadding
.cx
;
1540 /* add list padding */
1541 if ((dwStyle
& TBSTYLE_LIST
) && sz
.cx
> 0)
1542 cx
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1544 if (TOOLBAR_TestImageExist (infoPtr
, btnPtr
, GETDEFIMAGELIST(infoPtr
,0)))
1546 if (dwStyle
& TBSTYLE_LIST
)
1547 cx
+= infoPtr
->nBitmapWidth
;
1548 else if (cx
< (infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
))
1549 cx
= infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
;
1551 else if (dwStyle
& TBSTYLE_LIST
)
1552 cx
+= LIST_IMAGE_ABSENT_WIDTH
;
1555 cx
= infoPtr
->nButtonWidth
;
1557 /* if size has been set manually then don't add on extra space
1558 * for the drop down arrow */
1559 if (!btnPtr
->cx
&& hasDropDownArrows
&&
1560 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) || (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)))
1561 cx
+= DDARROW_WIDTH
;
1563 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1566 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1568 if (infoPtr
->rcBound
.left
> x
)
1569 infoPtr
->rcBound
.left
= x
;
1570 if (infoPtr
->rcBound
.right
< x
+ cx
)
1571 infoPtr
->rcBound
.right
= x
+ cx
;
1572 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1573 infoPtr
->rcBound
.bottom
= y
+ cy
;
1575 /* Set the toolTip only for non-hidden, non-separator button */
1576 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& BTNS_SEP
))
1580 ZeroMemory (&ti
, sizeof(ti
));
1581 ti
.cbSize
= sizeof(ti
);
1583 ti
.uId
= btnPtr
->idCommand
;
1584 ti
.rect
= btnPtr
->rect
;
1585 SendMessageW (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTW
,
1589 /* btnPtr->nRow is zero based. The space between the rows is */
1590 /* also considered as a row. */
1591 btnPtr
->nRow
= nRows
+ nSepRows
;
1593 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1594 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1599 if ( !(btnPtr
->fsStyle
& BTNS_SEP
) )
1603 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1604 /* it is the actual width of the separator. This is used for */
1605 /* custom controls in toolbars. */
1606 if ( !(btnPtr
->fsStyle
& BTNS_DROPDOWN
))
1607 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1608 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1612 /* nSepRows is used to calculate the extra height follwoing */
1616 x
= infoPtr
->nIndent
;
1618 /* Increment row number unless this is the last button */
1619 /* and it has Wrap set. */
1620 if (i
!= infoPtr
->nNumButtons
-1)
1627 /* infoPtr->nRows is the number of rows on the toolbar */
1628 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1631 /********************************************************************
1632 * The following while interesting, does not match the values *
1633 * created above for the button rectangles, nor the rcBound rect. *
1634 * We will comment it out and remove it later. *
1636 * The problem showed up as heights in the pager control that was *
1638 ********************************************************************/
1640 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1642 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1643 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1644 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1648 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1650 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1655 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1657 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1658 TBUTTON_INFO
*btnPtr
;
1661 btnPtr
= infoPtr
->buttons
;
1662 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1663 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1666 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1667 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1668 TRACE(" ON SEPARATOR %d!\n", i
);
1673 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1674 TRACE(" ON BUTTON %d!\n", i
);
1680 TRACE(" NOWHERE!\n");
1681 return TOOLBAR_NOWHERE
;
1686 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1688 TBUTTON_INFO
*btnPtr
;
1691 if (CommandIsIndex
) {
1692 TRACE("command is really index command=%d\n", idCommand
);
1693 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1696 btnPtr
= infoPtr
->buttons
;
1697 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1698 if (btnPtr
->idCommand
== idCommand
) {
1699 TRACE("command=%d index=%d\n", idCommand
, i
);
1703 TRACE("no index found for command=%d\n", idCommand
);
1709 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1711 TBUTTON_INFO
*btnPtr
;
1714 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1717 /* check index button */
1718 btnPtr
= &infoPtr
->buttons
[nIndex
];
1719 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1720 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1724 /* check previous buttons */
1725 nRunIndex
= nIndex
- 1;
1726 while (nRunIndex
>= 0) {
1727 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1728 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1729 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1737 /* check next buttons */
1738 nRunIndex
= nIndex
+ 1;
1739 while (nRunIndex
< infoPtr
->nNumButtons
) {
1740 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1741 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1742 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1755 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1756 WPARAM wParam
, LPARAM lParam
)
1762 msg
.wParam
= wParam
;
1763 msg
.lParam
= lParam
;
1764 msg
.time
= GetMessageTime ();
1765 msg
.pt
.x
= LOWORD(GetMessagePos ());
1766 msg
.pt
.y
= HIWORD(GetMessagePos ());
1768 SendMessageW (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1771 /* keeps available button list box sorted by button id */
1772 static void TOOLBAR_Cust_InsertAvailButton(HWND hwnd
, PCUSTOMBUTTON btnInfoNew
)
1776 PCUSTOMBUTTON btnInfo
;
1777 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1779 TRACE("button %s, idCommand %d\n", debugstr_w(btnInfoNew
->text
), btnInfoNew
->btn
.idCommand
);
1781 count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1783 /* position 0 is always separator */
1784 for (i
= 1; i
< count
; i
++)
1786 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, i
, 0);
1787 if (btnInfoNew
->btn
.idCommand
< btnInfo
->btn
.idCommand
)
1789 i
= SendMessageW(hwndAvail
, LB_INSERTSTRING
, i
, 0);
1790 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1794 /* id higher than all others add to end */
1795 i
= SendMessageW(hwndAvail
, LB_ADDSTRING
, 0, 0);
1796 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1799 static void TOOLBAR_Cust_MoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexFrom
, INT nIndexTo
)
1803 TRACE("index from %d, index to %d\n", nIndexFrom
, nIndexTo
);
1805 if (nIndexFrom
== nIndexTo
)
1808 /* MSDN states that iItem is the index of the button, rather than the
1809 * command ID as used by every other NMTOOLBAR notification */
1810 nmtb
.iItem
= nIndexFrom
;
1811 if (TOOLBAR_SendNotify(&nmtb
.hdr
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1813 PCUSTOMBUTTON btnInfo
;
1815 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1816 int count
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1818 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, nIndexFrom
, 0);
1820 SendMessageW(hwndList
, LB_DELETESTRING
, nIndexFrom
, 0);
1821 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1822 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1823 SendMessageW(hwndList
, LB_SETCURSEL
, nIndexTo
, 0);
1826 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1828 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1830 /* last item is always separator, so -2 instead of -1 */
1831 if (nIndexTo
>= (count
- 2))
1832 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1834 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1836 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, nIndexFrom
, 0);
1837 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1839 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1843 static void TOOLBAR_Cust_AddButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexAvail
, INT nIndexTo
)
1847 TRACE("Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail
, nIndexTo
);
1849 /* MSDN states that iItem is the index of the button, rather than the
1850 * command ID as used by every other NMTOOLBAR notification */
1851 nmtb
.iItem
= nIndexAvail
;
1852 if (TOOLBAR_SendNotify(&nmtb
.hdr
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1854 PCUSTOMBUTTON btnInfo
;
1856 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1857 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1858 int count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1860 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, nIndexAvail
, 0);
1862 if (nIndexAvail
!= 0) /* index == 0 indicates separator */
1864 /* remove from 'available buttons' list */
1865 SendMessageW(hwndAvail
, LB_DELETESTRING
, nIndexAvail
, 0);
1866 if (nIndexAvail
== count
-1)
1867 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
-1 , 0);
1869 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
, 0);
1873 PCUSTOMBUTTON btnNew
;
1875 /* duplicate 'separator' button */
1876 btnNew
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1877 memcpy(btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
1881 /* insert into 'toolbar button' list */
1882 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1883 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1885 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1887 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1891 static void TOOLBAR_Cust_RemoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT index
)
1893 PCUSTOMBUTTON btnInfo
;
1894 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1896 TRACE("Remove: index %d\n", index
);
1898 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, index
, 0);
1900 /* send TBN_QUERYDELETE notification */
1901 if (TOOLBAR_IsButtonRemovable(custInfo
->tbInfo
, index
, btnInfo
))
1905 SendMessageW(hwndList
, LB_DELETESTRING
, index
, 0);
1906 SendMessageW(hwndList
, LB_SETCURSEL
, index
, 0);
1908 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1910 /* insert into 'available button' list */
1911 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
1912 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
1916 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1920 /* drag list notification function for toolbar buttons list box */
1921 static LRESULT
TOOLBAR_Cust_ToolbarDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
1923 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1924 switch (pDLI
->uNotification
)
1928 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
1929 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1930 /* no dragging for last item (separator) */
1931 if (nCurrentItem
>= (nCount
- 1)) return FALSE
;
1936 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
1937 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1938 /* no dragging past last item (separator) */
1939 if ((nCurrentItem
>= 0) && (nCurrentItem
< (nCount
- 1)))
1941 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
1942 /* FIXME: native uses "move button" cursor */
1943 return DL_COPYCURSOR
;
1946 /* not over toolbar buttons list */
1947 if (nCurrentItem
< 0)
1949 POINT ptWindow
= pDLI
->ptCursor
;
1950 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1951 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
1952 /* over available buttons list? */
1953 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
1954 /* FIXME: native uses "move button" cursor */
1955 return DL_COPYCURSOR
;
1957 /* clear drag arrow */
1958 DrawInsert(hwnd
, hwndList
, -1);
1959 return DL_STOPCURSOR
;
1963 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
1964 INT nIndexFrom
= SendMessageW(hwndList
, LB_GETCURSEL
, 0, 0);
1965 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1966 if ((nIndexTo
>= 0) && (nIndexTo
< (nCount
- 1)))
1968 /* clear drag arrow */
1969 DrawInsert(hwnd
, hwndList
, -1);
1971 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
1973 /* not over toolbar buttons list */
1976 POINT ptWindow
= pDLI
->ptCursor
;
1977 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1978 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
1979 /* over available buttons list? */
1980 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
1981 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, nIndexFrom
);
1986 /* Clear drag arrow */
1987 DrawInsert(hwnd
, hwndList
, -1);
1994 /* drag list notification function for available buttons list box */
1995 static LRESULT
TOOLBAR_Cust_AvailDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
1997 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1998 switch (pDLI
->uNotification
)
2004 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2005 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2006 /* no dragging past last item (separator) */
2007 if ((nCurrentItem
>= 0) && (nCurrentItem
< nCount
))
2009 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
2010 /* FIXME: native uses "move button" cursor */
2011 return DL_COPYCURSOR
;
2014 /* not over toolbar buttons list */
2015 if (nCurrentItem
< 0)
2017 POINT ptWindow
= pDLI
->ptCursor
;
2018 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2019 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2020 /* over available buttons list? */
2021 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2022 /* FIXME: native uses "move button" cursor */
2023 return DL_COPYCURSOR
;
2025 /* clear drag arrow */
2026 DrawInsert(hwnd
, hwndList
, -1);
2027 return DL_STOPCURSOR
;
2031 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2032 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2033 INT nIndexFrom
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2034 if ((nIndexTo
>= 0) && (nIndexTo
< nCount
))
2036 /* clear drag arrow */
2037 DrawInsert(hwnd
, hwndList
, -1);
2039 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
2043 /* Clear drag arrow */
2044 DrawInsert(hwnd
, hwndList
, -1);
2050 extern UINT uDragListMessage
;
2052 /***********************************************************************
2053 * TOOLBAR_CustomizeDialogProc
2054 * This function implements the toolbar customization dialog.
2056 static INT_PTR CALLBACK
2057 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2059 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongPtrW (hwnd
, DWLP_USER
);
2060 PCUSTOMBUTTON btnInfo
;
2062 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
2067 custInfo
= (PCUSTDLG_INFO
)lParam
;
2068 SetWindowLongPtrW (hwnd
, DWLP_USER
, (LONG_PTR
)custInfo
);
2076 infoPtr
= custInfo
->tbInfo
;
2078 /* send TBN_QUERYINSERT notification */
2079 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
2081 if (!TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYINSERT
))
2084 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
2085 /* FIXME: this hack won't work on 64-bit - we need to declare a structure for this */
2086 nmtb
.iItem
= (int)hwnd
;
2087 /* Send TBN_INITCUSTOMIZE notification */
2088 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_INITCUSTOMIZE
) ==
2091 TRACE("TBNRF_HIDEHELP requested\n");
2092 ShowWindow(GetDlgItem(hwnd
, IDC_HELP_BTN
), SW_HIDE
);
2095 /* add items to 'toolbar buttons' list and check if removable */
2096 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
2098 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2099 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2100 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2101 btnInfo
->bVirtual
= FALSE
;
2102 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2104 /* send TBN_QUERYDELETE notification */
2105 btnInfo
->bRemovable
= TOOLBAR_IsButtonRemovable(infoPtr
, i
, btnInfo
);
2107 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2108 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2111 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2113 /* insert separator button into 'available buttons' list */
2114 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2115 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2116 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2117 btnInfo
->bVirtual
= FALSE
;
2118 btnInfo
->bRemovable
= TRUE
;
2119 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2120 index
= (int)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2121 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2123 /* insert all buttons into dsa */
2126 /* send TBN_GETBUTTONINFO notification */
2129 nmtb
.pszText
= Buffer
;
2132 /* Clear previous button's text */
2133 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
2135 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
2138 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
2139 nmtb
.tbButton
.fsStyle
, i
,
2140 nmtb
.tbButton
.idCommand
,
2141 nmtb
.tbButton
.iString
,
2142 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
2145 /* insert button into the apropriate list */
2146 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
2149 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2150 btnInfo
->bVirtual
= FALSE
;
2151 btnInfo
->bRemovable
= TRUE
;
2155 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
,
2156 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2159 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
2160 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
2162 if (lstrlenW(nmtb
.pszText
))
2163 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
2164 else if (nmtb
.tbButton
.iString
>= 0 &&
2165 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
2167 lstrcpyW(btnInfo
->text
,
2168 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
2173 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
2176 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2178 /* select first item in the 'available' list */
2179 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
2181 /* append 'virtual' separator button to the 'toolbar buttons' list */
2182 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2183 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2184 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2185 btnInfo
->bVirtual
= TRUE
;
2186 btnInfo
->bRemovable
= FALSE
;
2187 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2188 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2189 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2191 /* select last item in the 'toolbar' list */
2192 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2193 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
2195 MakeDragList(GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
));
2196 MakeDragList(GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
));
2198 /* set focus and disable buttons */
2199 PostMessageW (hwnd
, WM_USER
, 0, 0);
2204 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2205 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2206 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
2207 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
2211 EndDialog(hwnd
, FALSE
);
2215 switch (LOWORD(wParam
))
2217 case IDC_TOOLBARBTN_LBOX
:
2218 if (HIWORD(wParam
) == LBN_SELCHANGE
)
2220 PCUSTOMBUTTON btnInfo
;
2225 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2226 index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2228 /* send TBN_QUERYINSERT notification */
2230 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYINSERT
);
2232 /* get list box item */
2233 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2235 if (index
== (count
- 1))
2237 /* last item (virtual separator) */
2238 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2239 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2241 else if (index
== (count
- 2))
2243 /* second last item (last non-virtual item) */
2244 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2245 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2247 else if (index
== 0)
2250 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2251 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2255 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2256 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2259 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
2263 case IDC_MOVEUP_BTN
:
2265 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2266 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
-1);
2270 case IDC_MOVEDN_BTN
: /* move down */
2272 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2273 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
+1);
2277 case IDC_REMOVE_BTN
: /* remove button */
2279 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2281 if (LB_ERR
== index
)
2284 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, index
);
2288 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2291 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2294 case IDOK
: /* Add button */
2299 index
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2300 indexto
= SendDlgItemMessageW(hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2302 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, index
, indexto
);
2307 EndDialog(hwnd
, FALSE
);
2317 /* delete items from 'toolbar buttons' listbox*/
2318 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2319 for (i
= 0; i
< count
; i
++)
2321 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2323 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2325 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2328 /* delete items from 'available buttons' listbox*/
2329 count
= SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2330 for (i
= 0; i
< count
; i
++)
2332 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2334 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2336 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2341 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2343 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2348 COLORREF oldText
= 0;
2352 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2353 if (btnInfo
== NULL
)
2355 FIXME("btnInfo invalid!\n");
2359 /* set colors and select objects */
2360 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2361 if (btnInfo
->bVirtual
)
2362 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2364 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2365 hPen
= CreatePen( PS_SOLID
, 1,
2366 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2367 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2368 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2370 /* fill background rectangle */
2371 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2372 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2374 /* calculate button and text rectangles */
2375 CopyRect (&rcButton
, &lpdis
->rcItem
);
2376 InflateRect (&rcButton
, -1, -1);
2377 CopyRect (&rcText
, &rcButton
);
2378 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2379 rcText
.left
= rcButton
.right
+ 2;
2381 /* draw focus rectangle */
2382 if (lpdis
->itemState
& ODS_FOCUS
)
2383 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2386 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
2387 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2389 /* draw image and text */
2390 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2391 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2392 btnInfo
->btn
.iBitmap
));
2393 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2394 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2396 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2397 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2399 /* delete objects and reset colors */
2400 SelectObject (lpdis
->hDC
, hOldBrush
);
2401 SelectObject (lpdis
->hDC
, hOldPen
);
2402 SetBkColor (lpdis
->hDC
, oldBk
);
2403 SetTextColor (lpdis
->hDC
, oldText
);
2404 DeleteObject( hPen
);
2409 case WM_MEASUREITEM
:
2410 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2412 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2414 lpmis
->itemHeight
= 15 + 8; /* default height */
2421 if (uDragListMessage
&& (uMsg
== uDragListMessage
))
2423 if (wParam
== IDC_TOOLBARBTN_LBOX
)
2425 LRESULT res
= TOOLBAR_Cust_ToolbarDragListNotification(
2426 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2427 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2430 else if (wParam
== IDC_AVAILBTN_LBOX
)
2432 LRESULT res
= TOOLBAR_Cust_AvailDragListNotification(
2433 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2434 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2443 /***********************************************************************
2444 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2448 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2450 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2451 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2452 INT nIndex
= 0, nButtons
, nCount
;
2456 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2460 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2462 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2464 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2466 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2471 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2473 /* Windows resize all the buttons to the size of a newly added standard image */
2474 if (lpAddBmp
->nID
& 1)
2477 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2478 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2480 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2481 MAKELPARAM((WORD
)24, (WORD
)24));
2482 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2483 MAKELPARAM((WORD
)31, (WORD
)30));
2488 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2489 MAKELPARAM((WORD
)16, (WORD
)16));
2490 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2491 MAKELPARAM((WORD
)22, (WORD
)22));
2494 TOOLBAR_CalcToolbar (hwnd
);
2498 nButtons
= (INT
)wParam
;
2502 TRACE ("adding %d bitmaps!\n", nButtons
);
2505 if (!infoPtr
->cimlDef
) {
2506 /* create new default image list */
2507 TRACE ("creating default image list!\n");
2509 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2510 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2511 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2512 infoPtr
->himlInt
= himlDef
;
2515 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2519 WARN("No default image list available\n");
2523 nCount
= ImageList_GetImageCount(himlDef
);
2525 /* Add bitmaps to the default image list */
2526 if (lpAddBmp
->hInst
== NULL
)
2529 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2530 HDC hdcImage
, hdcBitmap
;
2532 /* copy the bitmap before adding it so that the user's bitmap
2533 * doesn't get modified.
2535 GetObjectW ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2537 hdcImage
= CreateCompatibleDC(0);
2538 hdcBitmap
= CreateCompatibleDC(0);
2540 /* create new bitmap */
2541 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2542 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2543 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2545 /* Copy the user's image */
2546 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2547 hdcBitmap
, 0, 0, SRCCOPY
);
2549 SelectObject (hdcImage
, hOldBitmapLoad
);
2550 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2551 DeleteDC (hdcImage
);
2552 DeleteDC (hdcBitmap
);
2554 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2555 DeleteObject (hbmLoad
);
2557 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2559 /* Add system bitmaps */
2560 switch (lpAddBmp
->nID
)
2562 case IDB_STD_SMALL_COLOR
:
2563 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2564 MAKEINTRESOURCEW(IDB_STD_SMALL
));
2565 nIndex
= ImageList_AddMasked (himlDef
,
2566 hbmLoad
, comctl32_color
.clrBtnFace
);
2567 DeleteObject (hbmLoad
);
2570 case IDB_STD_LARGE_COLOR
:
2571 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2572 MAKEINTRESOURCEW(IDB_STD_LARGE
));
2573 nIndex
= ImageList_AddMasked (himlDef
,
2574 hbmLoad
, comctl32_color
.clrBtnFace
);
2575 DeleteObject (hbmLoad
);
2578 case IDB_VIEW_SMALL_COLOR
:
2579 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2580 MAKEINTRESOURCEW(IDB_VIEW_SMALL
));
2581 nIndex
= ImageList_AddMasked (himlDef
,
2582 hbmLoad
, comctl32_color
.clrBtnFace
);
2583 DeleteObject (hbmLoad
);
2586 case IDB_VIEW_LARGE_COLOR
:
2587 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2588 MAKEINTRESOURCEW(IDB_VIEW_LARGE
));
2589 nIndex
= ImageList_AddMasked (himlDef
,
2590 hbmLoad
, comctl32_color
.clrBtnFace
);
2591 DeleteObject (hbmLoad
);
2594 case IDB_HIST_SMALL_COLOR
:
2595 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2596 MAKEINTRESOURCEW(IDB_HIST_SMALL
));
2597 nIndex
= ImageList_AddMasked (himlDef
,
2598 hbmLoad
, comctl32_color
.clrBtnFace
);
2599 DeleteObject (hbmLoad
);
2602 case IDB_HIST_LARGE_COLOR
:
2603 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2604 MAKEINTRESOURCEW(IDB_HIST_LARGE
));
2605 nIndex
= ImageList_AddMasked (himlDef
,
2606 hbmLoad
, comctl32_color
.clrBtnFace
);
2607 DeleteObject (hbmLoad
);
2611 nIndex
= ImageList_GetImageCount (himlDef
);
2612 ERR ("invalid imagelist!\n");
2618 hbmLoad
= LoadBitmapW (lpAddBmp
->hInst
, (LPWSTR
)lpAddBmp
->nID
);
2619 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2620 DeleteObject (hbmLoad
);
2623 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2625 if (infoPtr
->nNumBitmapInfos
== 0)
2627 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2631 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2632 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2633 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
);
2636 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2637 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2638 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2640 infoPtr
->nNumBitmapInfos
++;
2641 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2645 INT imagecount
= ImageList_GetImageCount(himlDef
);
2647 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2649 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",
2650 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2651 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2653 infoPtr
->nNumBitmaps
= imagecount
;
2656 infoPtr
->nNumBitmaps
+= nButtons
;
2659 InvalidateRect(hwnd
, NULL
, TRUE
);
2666 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2668 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2669 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2670 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2672 TRACE("adding %d buttons!\n", wParam
);
2674 nAddButtons
= (UINT
)wParam
;
2675 nOldButtons
= infoPtr
->nNumButtons
;
2676 nNewButtons
= nOldButtons
+ nAddButtons
;
2678 if (infoPtr
->nNumButtons
== 0) {
2680 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2683 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2685 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2686 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2687 nOldButtons
* sizeof(TBUTTON_INFO
));
2691 infoPtr
->nNumButtons
= nNewButtons
;
2693 /* insert new button data */
2694 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2695 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2696 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2697 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2698 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2699 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2700 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2701 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2702 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2704 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2705 btnPtr
->bHot
= FALSE
;
2707 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2710 ZeroMemory (&ti
, sizeof(ti
));
2711 ti
.cbSize
= sizeof(ti
);
2713 ti
.uId
= btnPtr
->idCommand
;
2715 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2717 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2722 TOOLBAR_CalcToolbar (hwnd
);
2724 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2726 InvalidateRect(hwnd
, NULL
, TRUE
);
2733 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2735 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2736 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2737 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2739 TRACE("adding %d buttons!\n", wParam
);
2741 nAddButtons
= (UINT
)wParam
;
2742 nOldButtons
= infoPtr
->nNumButtons
;
2743 nNewButtons
= nOldButtons
+ nAddButtons
;
2745 if (infoPtr
->nNumButtons
== 0) {
2747 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2750 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2752 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2753 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2754 nOldButtons
* sizeof(TBUTTON_INFO
));
2758 infoPtr
->nNumButtons
= nNewButtons
;
2760 /* insert new button data */
2761 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2762 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2763 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2764 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2765 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2766 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2767 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2768 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2769 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2771 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2772 btnPtr
->bHot
= FALSE
;
2774 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2777 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2778 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2780 ti
.uId
= btnPtr
->idCommand
;
2782 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2785 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2790 TOOLBAR_CalcToolbar (hwnd
);
2792 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2794 InvalidateRect(hwnd
, NULL
, TRUE
);
2801 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2803 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2806 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2809 TRACE("adding string from resource!\n");
2811 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
, szString
, sizeof(szString
));
2813 TRACE("len=%d \"%s\"\n", len
, szString
);
2814 nIndex
= infoPtr
->nNumStrings
;
2815 if (infoPtr
->nNumStrings
== 0) {
2817 Alloc (sizeof(LPWSTR
));
2820 LPWSTR
*oldStrings
= infoPtr
->strings
;
2822 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2823 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2824 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2828 /*Alloc zeros out the allocated memory*/
2829 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2830 infoPtr
->nNumStrings
++;
2833 LPSTR p
= (LPSTR
)lParam
;
2838 TRACE("adding string(s) from array!\n");
2840 nIndex
= infoPtr
->nNumStrings
;
2843 TRACE("len=%d \"%s\"\n", len
, p
);
2845 if (infoPtr
->nNumStrings
== 0) {
2847 Alloc (sizeof(LPWSTR
));
2850 LPWSTR
*oldStrings
= infoPtr
->strings
;
2852 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2853 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2854 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2858 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2859 infoPtr
->nNumStrings
++;
2870 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2872 #define MAX_RESOURCE_STRING_LENGTH 512
2873 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2876 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2877 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2879 TRACE("adding string from resource!\n");
2881 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2882 szString
, MAX_RESOURCE_STRING_LENGTH
);
2884 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2885 TRACE("First char: 0x%x\n", *szString
);
2886 if (szString
[0] == L
'|')
2888 PWSTR p
= szString
+ 1;
2890 nIndex
= infoPtr
->nNumStrings
;
2891 while (*p
!= L
'|' && *p
!= L
'\0') {
2894 if (infoPtr
->nNumStrings
== 0) {
2895 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
2899 LPWSTR
*oldStrings
= infoPtr
->strings
;
2900 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2901 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
2902 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2906 np
=strchrW (p
, '|');
2914 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2915 infoPtr
->strings
[infoPtr
->nNumStrings
] =
2916 Alloc (sizeof(WCHAR
)*(len
+1));
2917 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
2918 infoPtr
->nNumStrings
++;
2925 nIndex
= infoPtr
->nNumStrings
;
2926 if (infoPtr
->nNumStrings
== 0) {
2928 Alloc (sizeof(LPWSTR
));
2931 LPWSTR
*oldStrings
= infoPtr
->strings
;
2933 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2934 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2935 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2939 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2940 infoPtr
->nNumStrings
++;
2944 LPWSTR p
= (LPWSTR
)lParam
;
2949 TRACE("adding string(s) from array!\n");
2950 nIndex
= infoPtr
->nNumStrings
;
2954 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2955 if (infoPtr
->nNumStrings
== 0) {
2957 Alloc (sizeof(LPWSTR
));
2960 LPWSTR
*oldStrings
= infoPtr
->strings
;
2962 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2963 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2964 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2968 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2969 infoPtr
->nNumStrings
++;
2980 TOOLBAR_AutoSize (HWND hwnd
)
2982 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2988 UINT uPosFlags
= SWP_NOZORDER
;
2990 TRACE("resize forced, style=%lx!\n", infoPtr
->dwStyle
);
2992 parent
= GetParent (hwnd
);
2993 GetClientRect(parent
, &parent_rect
);
2995 x
= parent_rect
.left
;
2996 y
= parent_rect
.top
;
2998 /* FIXME: we should be able to early out if nothing */
2999 /* has changed with nWidth != parent_rect width */
3001 if (infoPtr
->dwStyle
& CCS_NORESIZE
) {
3002 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
3005 TOOLBAR_CalcToolbar (hwnd
);
3008 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
3009 TOOLBAR_CalcToolbar (hwnd
);
3010 InvalidateRect( hwnd
, NULL
, TRUE
);
3011 cy
= infoPtr
->nHeight
;
3012 cx
= infoPtr
->nWidth
;
3014 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
3015 GetWindowRect(hwnd
, &window_rect
);
3016 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
3017 y
= window_rect
.top
;
3019 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
3020 GetWindowRect(hwnd
, &window_rect
);
3021 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
3025 if (infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)
3026 uPosFlags
|= SWP_NOMOVE
;
3028 if (!(infoPtr
->dwStyle
& CCS_NODIVIDER
))
3029 cy
+= GetSystemMetrics(SM_CYEDGE
);
3031 if (infoPtr
->dwStyle
& WS_BORDER
)
3034 cy
+= GetSystemMetrics(SM_CYEDGE
);
3035 cx
+= GetSystemMetrics(SM_CXEDGE
);
3038 infoPtr
->bAutoSize
= TRUE
;
3039 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
3040 /* The following line makes sure that the infoPtr->bAutoSize is turned off
3041 * after the setwindowpos calls */
3042 infoPtr
->bAutoSize
= FALSE
;
3049 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3051 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3053 return infoPtr
->nNumButtons
;
3058 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3060 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3062 infoPtr
->dwStructSize
= (DWORD
)wParam
;
3069 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3071 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3072 TBUTTON_INFO
*btnPtr
;
3075 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
3077 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3081 btnPtr
= &infoPtr
->buttons
[nIndex
];
3082 btnPtr
->iBitmap
= LOWORD(lParam
);
3084 /* we HAVE to erase the background, the new bitmap could be */
3086 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3093 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3095 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3096 TBUTTON_INFO
*btnPtr
;
3099 BOOL bChecked
= FALSE
;
3101 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3103 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
3108 btnPtr
= &infoPtr
->buttons
[nIndex
];
3110 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
3112 if (LOWORD(lParam
) == FALSE
)
3113 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
3115 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
3117 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
3118 if (nOldIndex
== nIndex
)
3120 if (nOldIndex
!= -1)
3121 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
3123 btnPtr
->fsState
|= TBSTATE_CHECKED
;
3126 if( bChecked
!= LOWORD(lParam
) )
3128 if (nOldIndex
!= -1)
3129 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
3130 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3133 /* FIXME: Send a WM_NOTIFY?? */
3140 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3142 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3144 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3149 TOOLBAR_Customize (HWND hwnd
)
3151 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3152 CUSTDLG_INFO custInfo
;
3158 custInfo
.tbInfo
= infoPtr
;
3159 custInfo
.tbHwnd
= hwnd
;
3161 /* send TBN_BEGINADJUST notification */
3162 TOOLBAR_SendNotify (&nmhdr
, infoPtr
, TBN_BEGINADJUST
);
3164 if (!(hRes
= FindResourceW (COMCTL32_hModule
,
3165 MAKEINTRESOURCEW(IDD_TBCUSTOMIZE
),
3166 (LPWSTR
)RT_DIALOG
)))
3169 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
3172 ret
= DialogBoxIndirectParamW ((HINSTANCE
)GetWindowLongPtrW(hwnd
, GWLP_HINSTANCE
),
3173 (LPDLGTEMPLATEW
)template,
3175 TOOLBAR_CustomizeDialogProc
,
3178 /* send TBN_ENDADJUST notification */
3179 TOOLBAR_SendNotify (&nmhdr
, infoPtr
, TBN_ENDADJUST
);
3186 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3188 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3189 INT nIndex
= (INT
)wParam
;
3191 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nIndex
];
3193 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3196 memset(&nmtb
, 0, sizeof(nmtb
));
3197 nmtb
.iItem
= btnPtr
->idCommand
;
3198 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
3199 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
3200 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
3201 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
3202 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
3203 nmtb
.tbButton
.iString
= btnPtr
->iString
;
3204 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_DELETINGBUTTON
);
3206 if ((infoPtr
->hwndToolTip
) &&
3207 !(btnPtr
->fsStyle
& BTNS_SEP
)) {
3210 ZeroMemory (&ti
, sizeof(ti
));
3211 ti
.cbSize
= sizeof(ti
);
3213 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3215 SendMessageW (infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
3218 if (infoPtr
->nNumButtons
== 1) {
3219 TRACE(" simple delete!\n");
3220 Free (infoPtr
->buttons
);
3221 infoPtr
->buttons
= NULL
;
3222 infoPtr
->nNumButtons
= 0;
3225 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3226 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3228 infoPtr
->nNumButtons
--;
3229 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3231 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3232 nIndex
* sizeof(TBUTTON_INFO
));
3235 if (nIndex
< infoPtr
->nNumButtons
) {
3236 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3237 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3243 TOOLBAR_CalcToolbar (hwnd
);
3245 InvalidateRect (hwnd
, NULL
, TRUE
);
3252 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3254 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3255 TBUTTON_INFO
*btnPtr
;
3259 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3261 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3266 btnPtr
= &infoPtr
->buttons
[nIndex
];
3268 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3270 /* update the toolbar button state */
3271 if(LOWORD(lParam
) == FALSE
) {
3272 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3274 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3277 /* redraw the button only if the state of the button changed */
3278 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3279 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3285 static inline LRESULT
3286 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3288 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3290 return infoPtr
->bAnchor
;
3295 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3297 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3300 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3304 return infoPtr
->buttons
[nIndex
].iBitmap
;
3308 static inline LRESULT
3309 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3311 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3316 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3318 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3319 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3320 INT nIndex
= (INT
)wParam
;
3321 TBUTTON_INFO
*btnPtr
;
3326 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3329 btnPtr
= &infoPtr
->buttons
[nIndex
];
3330 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3331 lpTbb
->idCommand
= btnPtr
->idCommand
;
3332 lpTbb
->fsState
= btnPtr
->fsState
;
3333 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3334 lpTbb
->bReserved
[0] = 0;
3335 lpTbb
->bReserved
[1] = 0;
3336 lpTbb
->dwData
= btnPtr
->dwData
;
3337 lpTbb
->iString
= btnPtr
->iString
;
3344 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3346 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3347 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3348 TBUTTON_INFO
*btnPtr
;
3351 if (lpTbInfo
== NULL
)
3353 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3356 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3357 lpTbInfo
->dwMask
& 0x80000000);
3361 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3363 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3364 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3365 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3366 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3367 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3368 lpTbInfo
->lParam
= btnPtr
->dwData
;
3369 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3370 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3371 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3372 lpTbInfo
->fsState
= btnPtr
->fsState
;
3373 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3374 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3375 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3376 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3377 can't use TOOLBAR_GetText here */
3379 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3380 lpText
= (LPWSTR
)btnPtr
->iString
;
3381 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3383 lpTbInfo
->pszText
[0] = '\0';
3390 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3392 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3393 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3394 TBUTTON_INFO
*btnPtr
;
3397 if (lpTbInfo
== NULL
)
3399 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3402 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3403 lpTbInfo
->dwMask
& 0x80000000);
3407 btnPtr
= &infoPtr
->buttons
[nIndex
];
3412 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3413 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3414 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3415 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3416 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3417 lpTbInfo
->lParam
= btnPtr
->dwData
;
3418 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3419 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3420 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3421 lpTbInfo
->fsState
= btnPtr
->fsState
;
3422 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3423 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3424 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3425 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3426 can't use TOOLBAR_GetText here */
3428 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3429 lpText
= (LPWSTR
)btnPtr
->iString
;
3430 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3432 lpTbInfo
->pszText
[0] = '\0';
3440 TOOLBAR_GetButtonSize (HWND hwnd
)
3442 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3444 if (infoPtr
->nNumButtons
> 0)
3445 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3446 (WORD
)infoPtr
->nButtonHeight
);
3448 return MAKELONG(23,22);
3453 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3455 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3462 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3466 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3468 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3469 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3474 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3476 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3481 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3485 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3489 ret
= strlenW (lpText
);
3492 strcpyW ((LPWSTR
)lParam
, lpText
);
3500 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3502 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3503 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3504 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3508 inline static LRESULT
3509 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3511 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3515 return infoPtr
->dwExStyle
;
3520 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3522 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3523 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3524 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3529 TOOLBAR_GetHotItem (HWND hwnd
)
3531 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3533 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
3536 if (infoPtr
->nHotItem
< 0)
3539 return (LRESULT
)infoPtr
->nHotItem
;
3544 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3546 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3547 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3548 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3553 TOOLBAR_GetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3555 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3556 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
3558 TRACE("hwnd = %p, lptbim = %p\n", hwnd
, lptbim
);
3560 *lptbim
= infoPtr
->tbim
;
3567 TOOLBAR_GetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3569 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3571 TRACE("hwnd = %p\n", hwnd
);
3573 return (LRESULT
)infoPtr
->clrInsertMark
;
3578 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3580 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3581 TBUTTON_INFO
*btnPtr
;
3585 nIndex
= (INT
)wParam
;
3586 btnPtr
= &infoPtr
->buttons
[nIndex
];
3587 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3589 lpRect
= (LPRECT
)lParam
;
3592 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3595 lpRect
->left
= btnPtr
->rect
.left
;
3596 lpRect
->right
= btnPtr
->rect
.right
;
3597 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3598 lpRect
->top
= btnPtr
->rect
.top
;
3605 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3607 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3608 LPSIZE lpSize
= (LPSIZE
)lParam
;
3613 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3614 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3616 TRACE("maximum size %ld x %ld\n",
3617 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3618 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3624 /* << TOOLBAR_GetObject >> */
3628 TOOLBAR_GetPadding (HWND hwnd
)
3630 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3633 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3634 return (LRESULT
) oldPad
;
3639 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3641 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3642 TBUTTON_INFO
*btnPtr
;
3646 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3647 btnPtr
= &infoPtr
->buttons
[nIndex
];
3648 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3650 lpRect
= (LPRECT
)lParam
;
3654 lpRect
->left
= btnPtr
->rect
.left
;
3655 lpRect
->right
= btnPtr
->rect
.right
;
3656 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3657 lpRect
->top
= btnPtr
->rect
.top
;
3664 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3666 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3668 if (infoPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
3669 return infoPtr
->nRows
;
3676 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3678 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3681 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3685 return infoPtr
->buttons
[nIndex
].fsState
;
3690 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3692 return GetWindowLongW(hwnd
, GWL_STYLE
);
3697 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3699 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3701 return infoPtr
->nMaxTextRows
;
3706 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3708 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3710 return (LRESULT
)infoPtr
->hwndToolTip
;
3715 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3717 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3719 TRACE("%s hwnd=%p\n",
3720 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3722 return infoPtr
->bUnicode
;
3726 inline static LRESULT
3727 TOOLBAR_GetVersion (HWND hwnd
)
3729 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3730 return infoPtr
->iVersion
;
3735 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3737 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3738 TBUTTON_INFO
*btnPtr
;
3743 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3747 btnPtr
= &infoPtr
->buttons
[nIndex
];
3748 if (LOWORD(lParam
) == FALSE
)
3749 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3751 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3753 TOOLBAR_CalcToolbar (hwnd
);
3755 InvalidateRect (hwnd
, NULL
, TRUE
);
3761 inline static LRESULT
3762 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3764 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3769 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3771 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3772 TBUTTON_INFO
*btnPtr
;
3776 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3780 btnPtr
= &infoPtr
->buttons
[nIndex
];
3781 oldState
= btnPtr
->fsState
;
3782 if (LOWORD(lParam
) == FALSE
)
3783 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3785 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3787 if(oldState
!= btnPtr
->fsState
)
3788 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3795 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3797 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3798 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3799 INT nIndex
= (INT
)wParam
;
3800 TBUTTON_INFO
*oldButtons
;
3805 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3808 /* EPP: this seems to be an undocumented call (from my IE4)
3809 * I assume in that case that:
3810 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3811 * - index of insertion is at the end of existing buttons
3812 * I only see this happen with nIndex == -1, but it could have a special
3813 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3815 nIndex
= infoPtr
->nNumButtons
;
3817 } else if (nIndex
< 0)
3820 /* If the string passed is not an index, assume address of string
3821 and do our own AddString */
3822 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3826 TRACE("string %s passed instead of index, adding string\n",
3827 debugstr_a((LPSTR
)lpTbb
->iString
));
3828 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3830 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3831 ptr
[len
- 1] = 0; /* ended by two '\0' */
3832 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3836 TRACE("inserting button index=%d\n", nIndex
);
3837 if (nIndex
> infoPtr
->nNumButtons
) {
3838 nIndex
= infoPtr
->nNumButtons
;
3839 TRACE("adjust index=%d\n", nIndex
);
3842 oldButtons
= infoPtr
->buttons
;
3843 infoPtr
->nNumButtons
++;
3844 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3845 /* pre insert copy */
3847 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3848 nIndex
* sizeof(TBUTTON_INFO
));
3851 /* insert new button */
3852 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3853 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3854 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3855 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3856 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3857 /* if passed string and not index, then add string */
3858 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3859 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3862 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3864 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3867 ZeroMemory (&ti
, sizeof(ti
));
3868 ti
.cbSize
= sizeof (ti
);
3870 ti
.uId
= lpTbb
->idCommand
;
3872 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3874 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3878 /* post insert copy */
3879 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3880 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3881 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3886 TOOLBAR_CalcToolbar (hwnd
);
3888 InvalidateRect (hwnd
, NULL
, TRUE
);
3895 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3897 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3898 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3899 INT nIndex
= (INT
)wParam
;
3900 TBUTTON_INFO
*oldButtons
;
3905 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3908 /* EPP: this seems to be an undocumented call (from my IE4)
3909 * I assume in that case that:
3910 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3911 * - index of insertion is at the end of existing buttons
3912 * I only see this happen with nIndex == -1, but it could have a special
3913 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3915 nIndex
= infoPtr
->nNumButtons
;
3917 } else if (nIndex
< 0)
3920 /* If the string passed is not an index, assume address of string
3921 and do our own AddString */
3922 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3926 TRACE("string %s passed instead of index, adding string\n",
3927 debugstr_w((LPWSTR
)lpTbb
->iString
));
3928 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
3929 ptr
= Alloc(len
*sizeof(WCHAR
));
3930 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
3931 ptr
[len
- 1] = 0; /* ended by two '\0' */
3932 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
3936 TRACE("inserting button index=%d\n", nIndex
);
3937 if (nIndex
> infoPtr
->nNumButtons
) {
3938 nIndex
= infoPtr
->nNumButtons
;
3939 TRACE("adjust index=%d\n", nIndex
);
3942 oldButtons
= infoPtr
->buttons
;
3943 infoPtr
->nNumButtons
++;
3944 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3945 /* pre insert copy */
3947 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3948 nIndex
* sizeof(TBUTTON_INFO
));
3951 /* insert new button */
3952 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3953 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3954 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3955 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3956 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3957 /* if passed string and not index, then add string */
3958 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3959 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
3962 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3964 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3967 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
3968 ti
.cbSize
= sizeof (TTTOOLINFOW
);
3970 ti
.uId
= lpTbb
->idCommand
;
3972 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3974 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3978 /* post insert copy */
3979 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3980 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3981 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3986 TOOLBAR_CalcToolbar (hwnd
);
3988 InvalidateRect (hwnd
, NULL
, TRUE
);
3994 /* << TOOLBAR_InsertMarkHitTest >> */
3998 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4000 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4003 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4007 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
4012 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4014 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4017 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4021 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
4026 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4028 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4031 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4035 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
4040 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4042 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4045 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4049 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
4054 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4056 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4059 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4063 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
4068 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4070 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4073 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4077 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
4082 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4085 tbab
.hInst
= (HINSTANCE
)lParam
;
4086 tbab
.nID
= (UINT_PTR
)wParam
;
4088 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
4090 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
4095 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4097 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4098 WCHAR wAccel
= (WCHAR
)wParam
;
4099 UINT
* pIDButton
= (UINT
*)lParam
;
4100 WCHAR wszAccel
[] = {'&',wAccel
,0};
4103 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
4104 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
4106 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4108 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
4109 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
4110 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
4112 int iLen
= strlenW(wszAccel
);
4113 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
4120 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
4125 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
4127 *pIDButton
= btnPtr
->idCommand
;
4139 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4141 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4144 TBUTTON_INFO
*btnPtr
;
4146 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
4148 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4152 btnPtr
= &infoPtr
->buttons
[nIndex
];
4153 oldState
= btnPtr
->fsState
;
4156 btnPtr
->fsState
|= TBSTATE_MARKED
;
4158 btnPtr
->fsState
&= ~TBSTATE_MARKED
;
4160 if(oldState
!= btnPtr
->fsState
)
4161 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4167 /* fixes up an index of a button affected by a move */
4168 inline static void TOOLBAR_MoveFixupIndex(INT
* pIndex
, INT nIndex
, INT nMoveIndex
, BOOL bMoveUp
)
4172 if (*pIndex
> nIndex
&& *pIndex
<= nMoveIndex
)
4174 else if (*pIndex
== nIndex
)
4175 *pIndex
= nMoveIndex
;
4179 if (*pIndex
>= nMoveIndex
&& *pIndex
< nIndex
)
4181 else if (*pIndex
== nIndex
)
4182 *pIndex
= nMoveIndex
;
4188 TOOLBAR_MoveButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4190 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4193 INT nMoveIndex
= (INT
)lParam
;
4194 TBUTTON_INFO button
;
4196 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4198 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, TRUE
);
4199 if ((nIndex
== -1) || (nMoveIndex
< 0))
4202 if (nMoveIndex
> infoPtr
->nNumButtons
- 1)
4203 nMoveIndex
= infoPtr
->nNumButtons
- 1;
4205 button
= infoPtr
->buttons
[nIndex
];
4207 /* move button right */
4208 if (nIndex
< nMoveIndex
)
4210 nCount
= nMoveIndex
- nIndex
;
4211 memmove(&infoPtr
->buttons
[nIndex
], &infoPtr
->buttons
[nIndex
+1], nCount
*sizeof(TBUTTON_INFO
));
4212 infoPtr
->buttons
[nMoveIndex
] = button
;
4214 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, TRUE
);
4215 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, TRUE
);
4216 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, TRUE
);
4217 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, TRUE
);
4219 else if (nIndex
> nMoveIndex
) /* move button left */
4221 nCount
= nIndex
- nMoveIndex
;
4222 memmove(&infoPtr
->buttons
[nMoveIndex
+1], &infoPtr
->buttons
[nMoveIndex
], nCount
*sizeof(TBUTTON_INFO
));
4223 infoPtr
->buttons
[nMoveIndex
] = button
;
4225 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, FALSE
);
4226 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, FALSE
);
4227 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, FALSE
);
4228 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, FALSE
);
4231 TOOLBAR_CalcToolbar(hwnd
);
4232 InvalidateRect(hwnd
, NULL
, TRUE
);
4239 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4241 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4242 TBUTTON_INFO
*btnPtr
;
4246 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4250 btnPtr
= &infoPtr
->buttons
[nIndex
];
4251 oldState
= btnPtr
->fsState
;
4252 if (LOWORD(lParam
) == FALSE
)
4253 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4255 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4257 if(oldState
!= btnPtr
->fsState
)
4258 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4263 /* FIXME: there might still be some confusion her between number of buttons
4264 * and number of bitmaps */
4266 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4268 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4269 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
4271 int i
= 0, nOldButtons
= 0, pos
= 0;
4272 int nOldBitmaps
, nNewBitmaps
= 0;
4273 HIMAGELIST himlDef
= 0;
4275 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
4276 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
4277 lpReplace
->nButtons
);
4279 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4281 FIXME("changing standard bitmaps not implemented\n");
4284 else if (lpReplace
->hInstOld
!= 0)
4286 FIXME("resources not in the current module not implemented\n");
4291 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4294 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4295 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4296 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4297 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4298 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4300 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4301 nOldButtons
= tbi
->nButtons
;
4302 tbi
->nButtons
= lpReplace
->nButtons
;
4303 tbi
->hInst
= lpReplace
->hInstNew
;
4304 tbi
->nID
= lpReplace
->nIDNew
;
4305 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4308 pos
+= tbi
->nButtons
;
4311 if (nOldButtons
== 0)
4313 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4317 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4318 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4320 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4322 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4323 ImageList_Remove(himlDef
, i
);
4328 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4329 HDC hdcImage
, hdcBitmap
;
4331 /* copy the bitmap before adding it so that the user's bitmap
4332 * doesn't get modified.
4334 GetObjectW (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4336 hdcImage
= CreateCompatibleDC(0);
4337 hdcBitmap
= CreateCompatibleDC(0);
4339 /* create new bitmap */
4340 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4341 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4342 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4344 /* Copy the user's image */
4345 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4346 hdcBitmap
, 0, 0, SRCCOPY
);
4348 SelectObject (hdcImage
, hOldBitmapLoad
);
4349 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4350 DeleteDC (hdcImage
);
4351 DeleteDC (hdcBitmap
);
4353 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4354 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4355 DeleteObject (hbmLoad
);
4358 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4360 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4361 pos
, nOldBitmaps
, nNewBitmaps
);
4363 InvalidateRect(hwnd
, NULL
, TRUE
);
4369 /* helper for TOOLBAR_SaveRestoreW */
4371 TOOLBAR_Save(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4373 FIXME("save to %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4374 debugstr_w(lpSave
->pszValueName
));
4380 /* helper for TOOLBAR_Restore */
4382 TOOLBAR_DeleteAllButtons(TOOLBAR_INFO
*infoPtr
)
4387 ZeroMemory(&ti
, sizeof(ti
));
4388 ti
.cbSize
= sizeof(ti
);
4389 ti
.hwnd
= infoPtr
->hwndSelf
;
4391 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4393 if ((infoPtr
->hwndToolTip
) &&
4394 !(infoPtr
->buttons
[i
].fsStyle
& BTNS_SEP
))
4396 ti
.uId
= infoPtr
->buttons
[i
].idCommand
;
4397 SendMessageW(infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
4401 Free(infoPtr
->buttons
);
4402 infoPtr
->buttons
= NULL
;
4403 infoPtr
->nNumButtons
= 0;
4407 /* helper for TOOLBAR_SaveRestoreW */
4409 TOOLBAR_Restore(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4418 /* restore toolbar information */
4419 TRACE("restore from %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4420 debugstr_w(lpSave
->pszValueName
));
4422 memset(&nmtbr
, 0, sizeof(nmtbr
));
4424 res
= RegOpenKeyExW(lpSave
->hkr
, lpSave
->pszSubKey
, 0,
4425 KEY_QUERY_VALUE
, &hkey
);
4427 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4429 if (!res
&& dwType
!= REG_BINARY
)
4430 res
= ERROR_FILE_NOT_FOUND
;
4433 nmtbr
.pData
= Alloc(dwSize
);
4434 nmtbr
.cbData
= (UINT
)dwSize
;
4435 if (!nmtbr
.pData
) res
= ERROR_OUTOFMEMORY
;
4438 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4439 (LPBYTE
)nmtbr
.pData
, &dwSize
);
4442 nmtbr
.pCurrent
= nmtbr
.pData
;
4444 nmtbr
.cbBytesPerRecord
= sizeof(DWORD
);
4445 nmtbr
.cButtons
= nmtbr
.cbData
/ nmtbr
.cbBytesPerRecord
;
4447 if (!TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
))
4451 /* remove all existing buttons as this function is designed to
4452 * restore the toolbar to a previously saved state */
4453 TOOLBAR_DeleteAllButtons(infoPtr
);
4455 for (i
= 0; i
< nmtbr
.cButtons
; i
++)
4458 nmtbr
.tbButton
.iBitmap
= -1;
4459 nmtbr
.tbButton
.fsState
= 0;
4460 nmtbr
.tbButton
.fsStyle
= 0;
4461 nmtbr
.tbButton
.idCommand
= 0;
4462 if (*nmtbr
.pCurrent
== (DWORD
)-1)
4465 nmtbr
.tbButton
.fsStyle
= TBSTYLE_SEP
;
4466 nmtbr
.tbButton
.iBitmap
= SEPARATOR_WIDTH
;
4468 else if (*nmtbr
.pCurrent
== (DWORD
)-2)
4470 nmtbr
.tbButton
.fsState
= TBSTATE_HIDDEN
;
4472 nmtbr
.tbButton
.idCommand
= (int)*nmtbr
.pCurrent
;
4476 TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
);
4478 /* can't contain real string as we don't know whether
4479 * the client put an ANSI or Unicode string in there */
4480 if (HIWORD(nmtbr
.tbButton
.iString
))
4481 nmtbr
.tbButton
.iString
= 0;
4483 TOOLBAR_InsertButtonW(infoPtr
->hwndSelf
, -1,
4484 (LPARAM
)&nmtbr
.tbButton
);
4487 /* do legacy notifications */
4488 if (infoPtr
->iVersion
< 5)
4490 /* FIXME: send TBN_BEGINADJUST */
4491 FIXME("send TBN_GETBUTTONINFO for each button\n");
4492 /* FIXME: send TBN_ENDADJUST */
4495 /* remove all uninitialised buttons
4496 * note: loop backwards to avoid having to fixup i on a
4498 for (i
= infoPtr
->nNumButtons
- 1; i
>= 0; i
--)
4499 if (infoPtr
->buttons
[i
].iBitmap
== -1)
4500 TOOLBAR_DeleteButton(infoPtr
->hwndSelf
, i
, 0);
4502 /* only indicate success if at least one button survived */
4503 if (infoPtr
->nNumButtons
> 0) ret
= TRUE
;
4514 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSW lpSave
)
4516 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4518 if (lpSave
== NULL
) return 0;
4521 return TOOLBAR_Save(infoPtr
, lpSave
);
4523 return TOOLBAR_Restore(infoPtr
, lpSave
);
4528 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSA lpSave
)
4530 LPWSTR pszValueName
= 0, pszSubKey
= 0;
4531 TBSAVEPARAMSW SaveW
;
4535 if (lpSave
== NULL
) return 0;
4537 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, NULL
, 0);
4538 pszSubKey
= Alloc(len
* sizeof(WCHAR
));
4539 if (pszSubKey
) goto exit
;
4540 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, pszSubKey
, len
);
4542 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, NULL
, 0);
4543 pszValueName
= Alloc(len
* sizeof(WCHAR
));
4544 if (!pszValueName
) goto exit
;
4545 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, pszValueName
, len
);
4547 SaveW
.pszValueName
= pszValueName
;
4548 SaveW
.pszSubKey
= pszSubKey
;
4549 SaveW
.hkr
= lpSave
->hkr
;
4550 result
= TOOLBAR_SaveRestoreW(hwnd
, wParam
, &SaveW
);
4553 Free (pszValueName
);
4561 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4563 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4564 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4566 TRACE("hwnd=%p, bAnchor = %s\n", hwnd
, wParam
? "TRUE" : "FALSE");
4568 infoPtr
->bAnchor
= (BOOL
)wParam
;
4570 /* Native does not remove the hot effect from an already hot button */
4572 return (LRESULT
)bOldAnchor
;
4577 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4579 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4580 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4582 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4585 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4587 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4590 if (infoPtr
->nNumButtons
> 0)
4591 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4592 infoPtr
->nNumButtons
,
4593 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4594 LOWORD(lParam
), HIWORD(lParam
));
4596 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4597 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4600 if ((himlDef
== infoPtr
->himlInt
) &&
4601 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4603 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4604 infoPtr
->nBitmapHeight
);
4612 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4614 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4615 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4616 TBUTTON_INFO
*btnPtr
;
4622 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4625 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4626 lptbbi
->dwMask
& 0x80000000);
4630 btnPtr
= &infoPtr
->buttons
[nIndex
];
4631 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4632 btnPtr
->idCommand
= lptbbi
->idCommand
;
4633 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4634 btnPtr
->iBitmap
= lptbbi
->iImage
;
4635 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4636 btnPtr
->dwData
= lptbbi
->lParam
;
4637 if (lptbbi
->dwMask
& TBIF_SIZE
)
4638 btnPtr
->cx
= lptbbi
->cx
;
4639 if (lptbbi
->dwMask
& TBIF_STATE
)
4640 btnPtr
->fsState
= lptbbi
->fsState
;
4641 if (lptbbi
->dwMask
& TBIF_STYLE
)
4642 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4644 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4645 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4646 /* iString is index, zero it to make Str_SetPtr succeed */
4649 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4652 /* save the button rect to see if we need to redraw the whole toolbar */
4653 oldBtnRect
= btnPtr
->rect
;
4654 TOOLBAR_CalcToolbar(hwnd
);
4656 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4657 InvalidateRect(hwnd
, NULL
, TRUE
);
4659 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4666 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4668 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4669 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4670 TBUTTON_INFO
*btnPtr
;
4676 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4679 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4680 lptbbi
->dwMask
& 0x80000000);
4684 btnPtr
= &infoPtr
->buttons
[nIndex
];
4685 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4686 btnPtr
->idCommand
= lptbbi
->idCommand
;
4687 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4688 btnPtr
->iBitmap
= lptbbi
->iImage
;
4689 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4690 btnPtr
->dwData
= lptbbi
->lParam
;
4691 if (lptbbi
->dwMask
& TBIF_SIZE
)
4692 btnPtr
->cx
= lptbbi
->cx
;
4693 if (lptbbi
->dwMask
& TBIF_STATE
)
4694 btnPtr
->fsState
= lptbbi
->fsState
;
4695 if (lptbbi
->dwMask
& TBIF_STYLE
)
4696 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4698 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4699 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4700 /* iString is index, zero it to make Str_SetPtr succeed */
4702 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4705 /* save the button rect to see if we need to redraw the whole toolbar */
4706 oldBtnRect
= btnPtr
->rect
;
4707 TOOLBAR_CalcToolbar(hwnd
);
4709 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4710 InvalidateRect(hwnd
, NULL
, TRUE
);
4712 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4719 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4721 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4722 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4724 if ((cx
< 0) || (cy
< 0))
4726 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4730 TRACE("%p, cx = %d, cy = %d\n", hwnd
, cx
, cy
);
4732 /* The documentation claims you can only change the button size before
4733 * any button has been added. But this is wrong.
4734 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4735 * it to the toolbar, and it checks that the return value is nonzero - mjm
4736 * Further testing shows that we must actually perform the change too.
4739 * The documentation also does not mention that if 0 is supplied for
4740 * either size, the system changes it to the default of 24 wide and
4741 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4743 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4744 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4750 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4752 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4754 /* if setting to current values, ignore */
4755 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4756 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4757 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4758 infoPtr
->cxMin
, infoPtr
->cxMax
);
4762 /* save new values */
4763 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4764 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4766 /* if both values are 0 then we are done */
4768 TRACE("setting both min and max to 0, norecalc\n");
4772 /* otherwise we need to recalc the toolbar and in some cases
4773 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4774 which doesn't actually draw - GA). */
4775 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4776 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4778 TOOLBAR_CalcToolbar (hwnd
);
4780 InvalidateRect (hwnd
, NULL
, TRUE
);
4787 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4789 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4790 INT nIndex
= (INT
)wParam
;
4792 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4795 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4797 if (infoPtr
->hwndToolTip
) {
4799 FIXME("change tool tip!\n");
4808 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4810 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4811 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4812 HIMAGELIST himlTemp
;
4815 if (infoPtr
->iVersion
>= 5)
4818 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4819 &infoPtr
->cimlDis
, himl
, id
);
4821 /* FIXME: redraw ? */
4823 return (LRESULT
)himlTemp
;
4828 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4830 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4833 TRACE("hwnd = %p, dwMask = 0x%08lx, dwDTFlags = 0x%08lx\n", hwnd
, (DWORD
)wParam
, (DWORD
)lParam
);
4835 dwTemp
= infoPtr
->dwDTFlags
;
4836 infoPtr
->dwDTFlags
=
4837 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4839 return (LRESULT
)dwTemp
;
4842 /* This function differs a bit from what MSDN says it does:
4843 * 1. lParam contains extended style flags to OR with current style
4844 * (MSDN isn't clear on the OR bit)
4845 * 2. wParam appears to contain extended style flags to be reset
4846 * (MSDN says that this parameter is reserved)
4849 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4851 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4854 dwTemp
= infoPtr
->dwExStyle
;
4855 infoPtr
->dwExStyle
&= ~wParam
;
4856 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4858 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4860 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4861 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4862 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4864 TOOLBAR_CalcToolbar (hwnd
);
4866 TOOLBAR_AutoSize(hwnd
);
4868 InvalidateRect(hwnd
, NULL
, TRUE
);
4870 return (LRESULT
)dwTemp
;
4875 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4877 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4878 HIMAGELIST himlTemp
;
4879 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4882 if (infoPtr
->iVersion
>= 5)
4885 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
4887 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
4888 &infoPtr
->cimlHot
, himl
, id
);
4890 /* FIXME: redraw ? */
4892 return (LRESULT
)himlTemp
;
4896 /* Makes previous hot button no longer hot, makes the specified
4897 * button hot and sends appropriate notifications. dwReason is one or
4898 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
4899 * NOTE 1: this function does not validate nHit
4900 * NOTE 2: the name of this function is completely made up and
4901 * not based on any documentation from Microsoft. */
4903 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
4905 if (infoPtr
->nHotItem
!= nHit
)
4907 NMTBHOTITEM nmhotitem
;
4908 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
4909 LRESULT no_highlight
;
4911 /* Remove the effect of an old hot button if the button was
4912 drawn with the hot button effect */
4913 if(infoPtr
->nHotItem
>= 0)
4915 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
4916 oldBtnPtr
->bHot
= FALSE
;
4919 infoPtr
->nHotItem
= nHit
;
4921 /* It's not a separator or in nowhere. It's a hot button. */
4923 btnPtr
= &infoPtr
->buttons
[nHit
];
4925 nmhotitem
.dwFlags
= dwReason
;
4927 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
4929 nmhotitem
.dwFlags
|= HICF_ENTERING
;
4931 nmhotitem
.idNew
= btnPtr
->idCommand
;
4933 nmhotitem
.dwFlags
|= HICF_LEAVING
;
4935 no_highlight
= TOOLBAR_SendNotify(&nmhotitem
.hdr
, infoPtr
, TBN_HOTITEMCHANGE
);
4937 /* now invalidate the old and new buttons so they will be painted */
4939 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
4940 if (btnPtr
&& !no_highlight
)
4942 btnPtr
->bHot
= TRUE
;
4943 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
4949 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
4951 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4952 INT nOldHotItem
= infoPtr
->nHotItem
;
4954 TRACE("hwnd = %p, nHit = %d\n", hwnd
, (INT
)wParam
);
4956 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4959 /* NOTE: an application can still remove the hot item even if anchor
4960 * highlighting is enabled */
4962 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
4963 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
4965 if (nOldHotItem
< 0)
4968 return (LRESULT
)nOldHotItem
;
4973 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4975 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4976 HIMAGELIST himlTemp
;
4977 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4980 if (infoPtr
->iVersion
>= 5)
4983 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
4984 &infoPtr
->cimlDef
, himl
, id
);
4986 infoPtr
->nNumBitmaps
= 0;
4987 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
4988 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
4990 if (!ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
4991 &infoPtr
->nBitmapHeight
))
4993 infoPtr
->nBitmapWidth
= 0;
4994 infoPtr
->nBitmapHeight
= 0;
4997 TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n",
4998 hwnd
, infoPtr
->himlDef
, id
, infoPtr
->nNumBitmaps
,
4999 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
5001 InvalidateRect(hwnd
, NULL
, TRUE
);
5003 return (LRESULT
)himlTemp
;
5008 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5010 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5012 infoPtr
->nIndent
= (INT
)wParam
;
5016 /* process only on indent changing */
5017 if(infoPtr
->nIndent
!= (INT
)wParam
)
5019 infoPtr
->nIndent
= (INT
)wParam
;
5020 TOOLBAR_CalcToolbar (hwnd
);
5021 InvalidateRect(hwnd
, NULL
, FALSE
);
5029 TOOLBAR_SetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5031 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5032 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
5034 TRACE("hwnd = %p, lptbim = { %d, 0x%08lx}\n", hwnd
, lptbim
->iButton
, lptbim
->dwFlags
);
5036 if ((lptbim
->dwFlags
& ~TBIMHT_AFTER
) != 0)
5038 FIXME("Unrecognized flag(s): 0x%08lx\n", (lptbim
->dwFlags
& ~TBIMHT_AFTER
));
5042 if ((lptbim
->iButton
== -1) ||
5043 ((lptbim
->iButton
< infoPtr
->nNumButtons
) &&
5044 (lptbim
->iButton
>= 0)))
5046 infoPtr
->tbim
= *lptbim
;
5047 /* FIXME: don't need to update entire toolbar */
5048 InvalidateRect(hwnd
, NULL
, TRUE
);
5051 ERR("Invalid button index %d\n", lptbim
->iButton
);
5058 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5060 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5062 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
5064 /* FIXME: don't need to update entire toolbar */
5065 InvalidateRect(hwnd
, NULL
, TRUE
);
5072 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5074 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5076 infoPtr
->nMaxTextRows
= (INT
)wParam
;
5078 TOOLBAR_CalcToolbar(hwnd
);
5083 /* MSDN gives slightly wrong info on padding.
5084 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
5085 * 2. It is not used to create a blank area between the edge of the button
5086 * and the text or image if TBSTYLE_LIST is set. It is used to control
5087 * the gap between the image and text.
5088 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
5089 * to control the bottom and right borders [with the border being
5090 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
5091 * is shared evenly on both sides of the button.
5094 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5096 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5099 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5100 infoPtr
->szPadding
.cx
= LOWORD((DWORD
)lParam
);
5101 infoPtr
->szPadding
.cy
= HIWORD((DWORD
)lParam
);
5102 TRACE("cx=%ld, cy=%ld\n",
5103 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5104 return (LRESULT
) oldPad
;
5109 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5111 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5116 hwndOldNotify
= infoPtr
->hwndNotify
;
5117 infoPtr
->hwndNotify
= (HWND
)wParam
;
5119 return (LRESULT
)hwndOldNotify
;
5124 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5126 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5127 LPRECT lprc
= (LPRECT
)lParam
;
5131 if (LOWORD(wParam
) > 1) {
5132 FIXME("multiple rows not supported!\n");
5135 if(infoPtr
->nRows
!= LOWORD(wParam
))
5137 infoPtr
->nRows
= LOWORD(wParam
);
5139 /* recalculate toolbar */
5140 TOOLBAR_CalcToolbar (hwnd
);
5142 /* repaint toolbar */
5143 InvalidateRect(hwnd
, NULL
, TRUE
);
5146 /* return bounding rectangle */
5148 lprc
->left
= infoPtr
->rcBound
.left
;
5149 lprc
->right
= infoPtr
->rcBound
.right
;
5150 lprc
->top
= infoPtr
->rcBound
.top
;
5151 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
5159 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5161 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5162 TBUTTON_INFO
*btnPtr
;
5165 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
5169 btnPtr
= &infoPtr
->buttons
[nIndex
];
5171 /* if hidden state has changed the invalidate entire window and recalc */
5172 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
5173 btnPtr
->fsState
= LOWORD(lParam
);
5174 TOOLBAR_CalcToolbar (hwnd
);
5175 InvalidateRect(hwnd
, 0, TRUE
);
5179 /* process state changing if current state doesn't match new state */
5180 if(btnPtr
->fsState
!= LOWORD(lParam
))
5182 btnPtr
->fsState
= LOWORD(lParam
);
5183 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5191 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5193 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
5199 inline static LRESULT
5200 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5202 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5204 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
5206 infoPtr
->hwndToolTip
= (HWND
)wParam
;
5212 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5214 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5217 TRACE("%s hwnd=%p\n",
5218 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
5220 bTemp
= infoPtr
->bUnicode
;
5221 infoPtr
->bUnicode
= (BOOL
)wParam
;
5228 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5230 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5232 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
5233 comctl32_color
.clrBtnHighlight
:
5234 infoPtr
->clrBtnHighlight
;
5235 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
5236 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
5242 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5244 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5246 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
5247 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
5248 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
5250 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
5251 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
5252 InvalidateRect(hwnd
, NULL
, TRUE
);
5258 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
5260 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5261 INT iOldVersion
= infoPtr
->iVersion
;
5263 infoPtr
->iVersion
= iVersion
;
5265 if (infoPtr
->iVersion
>= 5)
5266 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
5273 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5275 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5276 WORD iString
= HIWORD(wParam
);
5277 WORD buffersize
= LOWORD(wParam
);
5278 LPSTR str
= (LPSTR
)lParam
;
5281 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
5283 if (iString
< infoPtr
->nNumStrings
)
5285 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
5287 TRACE("returning %s\n", debugstr_a(str
));
5290 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5297 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5299 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5300 WORD iString
= HIWORD(wParam
);
5301 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
5302 LPWSTR str
= (LPWSTR
)lParam
;
5305 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
5307 if (iString
< infoPtr
->nNumStrings
)
5309 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
5310 ret
= (len
+1)*sizeof(WCHAR
);
5311 memcpy(str
, infoPtr
->strings
[iString
], ret
);
5314 TRACE("returning %s\n", debugstr_w(str
));
5317 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5322 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
5323 * is the maximum size of the toolbar? */
5324 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5326 SIZE
* pSize
= (SIZE
*)lParam
;
5327 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
5332 /* UNDOCUMENTED MESSAGE: This is an extended version of the
5333 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
5334 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
5337 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5339 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5340 INT nOldHotItem
= infoPtr
->nHotItem
;
5342 TRACE("old item=%d, new item=%d, flags=%08lx\n",
5343 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
5345 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
5348 /* NOTE: an application can still remove the hot item even if anchor
5349 * highlighting is enabled */
5351 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
5355 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
5358 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
5359 * which controls the amount of spacing between the image and the text
5360 * of buttons for TBSTYLE_LIST toolbars. */
5361 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5363 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5365 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
5368 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
5370 infoPtr
->iListGap
= (INT
)wParam
;
5372 InvalidateRect(hwnd
, NULL
, TRUE
);
5377 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
5378 * of image lists associated with the various states. */
5379 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5381 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5383 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5385 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
5389 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5391 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5392 LPSIZE lpsize
= (LPSIZE
)lParam
;
5398 * Testing shows the following:
5399 * wParam = 0 adjust cx value
5400 * = 1 set cy value to max size.
5401 * lParam pointer to SIZE structure
5404 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
5405 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
5409 if (lpsize
->cx
== -1) {
5410 /* **** this is wrong, native measures each button and sets it */
5411 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5413 else if(HIWORD(lpsize
->cx
)) {
5415 HWND hwndParent
= GetParent(hwnd
);
5417 GetWindowRect(hwnd
, &rc
);
5418 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
5419 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
5420 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5421 lpsize
->cx
= max(rc
.right
-rc
.left
,
5422 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
5425 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5429 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5430 /* lpsize->cy = infoPtr->nHeight; */
5433 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
5437 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
5438 lpsize
->cx
, lpsize
->cy
);
5442 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5444 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5446 InvalidateRect(hwnd
, NULL
, TRUE
);
5452 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5454 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5455 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
5458 TRACE("hwnd = %p\n", hwnd
);
5460 /* initialize info structure */
5461 infoPtr
->nButtonHeight
= 22;
5462 infoPtr
->nButtonWidth
= 24;
5463 infoPtr
->nBitmapHeight
= 15;
5464 infoPtr
->nBitmapWidth
= 16;
5466 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5467 infoPtr
->nMaxTextRows
= 1;
5468 infoPtr
->cxMin
= -1;
5469 infoPtr
->cxMax
= -1;
5470 infoPtr
->nNumBitmaps
= 0;
5471 infoPtr
->nNumStrings
= 0;
5473 infoPtr
->bCaptured
= FALSE
;
5474 infoPtr
->nButtonDown
= -1;
5475 infoPtr
->nButtonDrag
= -1;
5476 infoPtr
->nOldHit
= -1;
5477 infoPtr
->nHotItem
= -1;
5478 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5479 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5480 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
: DT_CENTER
| DT_END_ELLIPSIS
;
5481 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5482 infoPtr
->bDragOutSent
= FALSE
;
5483 infoPtr
->iVersion
= 0;
5484 infoPtr
->hwndSelf
= hwnd
;
5485 infoPtr
->bDoRedraw
= TRUE
;
5486 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5487 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5488 infoPtr
->szPadding
.cx
= DEFPAD_CX
;
5489 infoPtr
->szPadding
.cy
= DEFPAD_CY
;
5490 infoPtr
->iListGap
= infoPtr
->szPadding
.cx
/ 2;
5491 infoPtr
->dwStyle
= dwStyle
;
5492 infoPtr
->tbim
.iButton
= -1;
5493 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5494 infoPtr
->bUnicode
= infoPtr
->hwndNotify
&&
5495 (NFR_UNICODE
== SendMessageW(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
));
5497 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5498 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectW (&logFont
);
5500 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5501 /* Create tooltip control */
5502 infoPtr
->hwndToolTip
=
5503 CreateWindowExW (0, TOOLTIPS_CLASSW
, NULL
, 0,
5504 CW_USEDEFAULT
, CW_USEDEFAULT
,
5505 CW_USEDEFAULT
, CW_USEDEFAULT
,
5508 /* Send NM_TOOLTIPSCREATED notification */
5509 if (infoPtr
->hwndToolTip
)
5511 NMTOOLTIPSCREATED nmttc
;
5513 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5515 TOOLBAR_SendNotify (&nmttc
.hdr
, infoPtr
, NM_TOOLTIPSCREATED
);
5519 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5521 TOOLBAR_CalcToolbar(hwnd
);
5528 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5530 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5532 /* delete tooltip control */
5533 if (infoPtr
->hwndToolTip
)
5534 DestroyWindow (infoPtr
->hwndToolTip
);
5536 /* delete temporary buffer for tooltip text */
5537 Free (infoPtr
->pszTooltipText
);
5539 /* delete button data */
5540 if (infoPtr
->buttons
)
5541 Free (infoPtr
->buttons
);
5543 /* delete strings */
5544 if (infoPtr
->strings
) {
5546 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5547 if (infoPtr
->strings
[i
])
5548 Free (infoPtr
->strings
[i
]);
5550 Free (infoPtr
->strings
);
5553 /* destroy internal image list */
5554 if (infoPtr
->himlInt
)
5555 ImageList_Destroy (infoPtr
->himlInt
);
5557 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5558 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5559 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5561 /* delete default font */
5563 DeleteObject (infoPtr
->hDefaultFont
);
5565 /* free toolbar info data */
5567 SetWindowLongPtrW (hwnd
, 0, 0);
5574 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5576 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5577 NMTBCUSTOMDRAW tbcd
;
5581 /* the app has told us not to redraw the toolbar */
5582 if (!infoPtr
->bDoRedraw
)
5585 if (infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) {
5586 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5587 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5588 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5589 ntfret
= TOOLBAR_SendNotify (&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
5590 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5592 /* FIXME: in general the return flags *can* be or'ed together */
5593 switch (infoPtr
->dwBaseCustDraw
)
5595 case CDRF_DODEFAULT
:
5597 case CDRF_SKIPDEFAULT
:
5600 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5605 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5606 * to my parent for processing.
5608 if (infoPtr
->dwStyle
& TBSTYLE_TRANSPARENT
) {
5610 HDC hdc
= (HDC
)wParam
;
5615 parent
= GetParent(hwnd
);
5616 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5617 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5618 ret
= SendMessageW (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5619 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5622 ret
= DefWindowProcW (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5624 if ((infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5625 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5626 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5627 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5628 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5629 ntfret
= TOOLBAR_SendNotify (&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
5630 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5631 switch (infoPtr
->dwBaseCustDraw
)
5633 case CDRF_DODEFAULT
:
5635 case CDRF_SKIPDEFAULT
:
5638 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_POSTERASE)\n",
5647 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5649 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5651 return (LRESULT
)infoPtr
->hFont
;
5656 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5661 pt
.x
= (INT
)LOWORD(lParam
);
5662 pt
.y
= (INT
)HIWORD(lParam
);
5663 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5666 TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5667 else if (GetWindowLongW (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5668 TOOLBAR_Customize (hwnd
);
5675 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5677 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5678 TBUTTON_INFO
*btnPtr
;
5683 BOOL bDragKeyPressed
;
5687 if (infoPtr
->dwStyle
& TBSTYLE_ALTDRAG
)
5688 bDragKeyPressed
= (GetKeyState(VK_MENU
) < 0);
5690 bDragKeyPressed
= (wParam
& MK_SHIFT
);
5692 if (infoPtr
->hwndToolTip
)
5693 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5694 WM_LBUTTONDOWN
, wParam
, lParam
);
5696 pt
.x
= (INT
)LOWORD(lParam
);
5697 pt
.y
= (INT
)HIWORD(lParam
);
5698 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5700 btnPtr
= &infoPtr
->buttons
[nHit
];
5702 if ((nHit
>= 0) && bDragKeyPressed
&& (infoPtr
->dwStyle
& CCS_ADJUSTABLE
))
5704 infoPtr
->nButtonDrag
= nHit
;
5707 /* If drag cursor has not been loaded, load it.
5708 * Note: it doesn't need to be freed */
5710 hCursorDrag
= LoadCursorW(COMCTL32_hModule
, (LPCWSTR
)IDC_MOVEBUTTON
);
5711 SetCursor(hCursorDrag
);
5716 infoPtr
->nOldHit
= nHit
;
5718 CopyRect(&arrowRect
, &btnPtr
->rect
);
5719 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5721 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5722 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5723 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5724 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5725 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5726 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5730 /* draw in pressed state */
5731 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5732 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5734 btnPtr
->bDropDownPressed
= TRUE
;
5735 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5736 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5738 memset(&nmtb
, 0, sizeof(nmtb
));
5739 nmtb
.iItem
= btnPtr
->idCommand
;
5740 nmtb
.rcButton
= btnPtr
->rect
;
5741 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5743 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5745 if (res
!= TBDDRET_TREATPRESSED
)
5749 /* redraw button in unpressed state */
5750 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5751 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5753 btnPtr
->bDropDownPressed
= FALSE
;
5754 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5756 /* find and set hot item
5757 * NOTE: native doesn't do this, but that is a bug */
5759 ScreenToClient(hwnd
, &pt
);
5760 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5761 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5762 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5764 /* remove any left mouse button down or double-click messages
5765 * so that we can get a toggle effect on the button */
5766 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
) ||
5767 PeekMessageW(&msg
, hwnd
, WM_LBUTTONDBLCLK
, WM_LBUTTONDBLCLK
, PM_REMOVE
))
5772 /* otherwise drop through and process as pushed */
5774 infoPtr
->bCaptured
= TRUE
;
5775 infoPtr
->nButtonDown
= nHit
;
5776 infoPtr
->bDragOutSent
= FALSE
;
5778 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5780 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5782 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5783 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5790 memset(&nmtb
, 0, sizeof(nmtb
));
5791 nmtb
.iItem
= btnPtr
->idCommand
;
5792 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_BEGINDRAG
);
5795 nmmouse
.dwHitInfo
= nHit
;
5797 /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
5799 nmmouse
.dwItemSpec
= -1;
5802 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5803 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5806 ClientToScreen(hwnd
, &pt
);
5809 if (!TOOLBAR_SendNotify(&nmmouse
.hdr
, infoPtr
, NM_LDOWN
))
5810 return DefWindowProcW(hwnd
, WM_LBUTTONDOWN
, wParam
, lParam
);
5816 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5818 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5819 TBUTTON_INFO
*btnPtr
;
5823 BOOL bSendMessage
= TRUE
;
5828 if (infoPtr
->hwndToolTip
)
5829 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5830 WM_LBUTTONUP
, wParam
, lParam
);
5832 pt
.x
= (INT
)LOWORD(lParam
);
5833 pt
.y
= (INT
)HIWORD(lParam
);
5834 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5836 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5837 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5839 if (infoPtr
->nButtonDrag
>= 0) {
5843 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDrag
];
5846 SetCursor(LoadCursorW(NULL
, (LPCWSTR
)IDC_ARROW
));
5848 GetClientRect(hwnd
, &rcClient
);
5849 if (PtInRect(&rcClient
, pt
))
5856 else if ((nHit
== -1) && PtInRect(&infoPtr
->buttons
[-nHit
].rect
, pt
))
5859 if (nButton
== infoPtr
->nButtonDrag
)
5861 /* if the button is moved sightly left and we have a
5862 * separator there then remove it */
5863 if (pt
.x
< (btnPtr
->rect
.left
+ (btnPtr
->rect
.right
- btnPtr
->rect
.left
)/2))
5865 if ((nButton
> 0) && (infoPtr
->buttons
[nButton
-1].fsStyle
& BTNS_SEP
))
5866 TOOLBAR_DeleteButton(hwnd
, nButton
- 1, 0);
5868 else /* else insert a separator before the dragged button */
5871 memset(&tbb
, 0, sizeof(tbb
));
5872 tbb
.fsStyle
= BTNS_SEP
;
5874 TOOLBAR_InsertButtonW(hwnd
, nButton
, (LPARAM
)&tbb
);
5881 if ((infoPtr
->nNumButtons
> 0) && (pt
.x
< infoPtr
->buttons
[0].rect
.left
))
5882 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, 0);
5884 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, infoPtr
->nNumButtons
);
5887 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, nButton
);
5892 TRACE("button %d dragged out of toolbar\n", infoPtr
->nButtonDrag
);
5893 TOOLBAR_DeleteButton(hwnd
, (WPARAM
)infoPtr
->nButtonDrag
, 0);
5896 /* button under cursor changed so need to re-set hot item */
5897 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5898 infoPtr
->nButtonDrag
= -1;
5900 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
5902 else if (infoPtr
->nButtonDown
>= 0) {
5903 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5904 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5906 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
5907 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
5908 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
5910 if (nOldIndex
== nHit
)
5911 bSendMessage
= FALSE
;
5912 if ((nOldIndex
!= nHit
) &&
5914 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
5915 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5918 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
5919 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
5921 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5925 if (nOldIndex
!= -1)
5926 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
5929 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5930 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5931 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5933 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
5935 infoPtr
->nButtonDown
= -1;
5937 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5938 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
5939 NM_RELEASEDCAPTURE
);
5941 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5944 memset(&nmtb
, 0, sizeof(nmtb
));
5945 nmtb
.iItem
= btnPtr
->idCommand
;
5946 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5949 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5951 SendMessageW (infoPtr
->hwndNotify
, WM_COMMAND
,
5952 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
5956 /* !!! Undocumented - toolbar at 4.71 level and above sends
5957 * NM_CLICK with the NMMOUSE structure. */
5958 nmmouse
.dwHitInfo
= nHit
;
5960 if (nmmouse
.dwHitInfo
< 0)
5961 nmmouse
.dwItemSpec
= -1;
5964 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5965 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5968 ClientToScreen(hwnd
, &pt
);
5971 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_CLICK
))
5972 return DefWindowProcW(hwnd
, WM_LBUTTONUP
, wParam
, lParam
);
5978 TOOLBAR_RButtonUp( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5980 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5985 pt
.x
= LOWORD(lParam
);
5986 pt
.y
= HIWORD(lParam
);
5988 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5989 nmmouse
.dwHitInfo
= nHit
;
5992 nmmouse
.dwItemSpec
= -1;
5994 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5995 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5998 ClientToScreen(hwnd
, &pt
);
6001 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_RCLICK
))
6002 return DefWindowProcW(hwnd
, WM_RBUTTONUP
, wParam
, lParam
);
6008 TOOLBAR_RButtonDblClk( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6010 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6013 if (!TOOLBAR_SendNotify(&nmhdr
, infoPtr
, NM_RDBLCLK
))
6014 return DefWindowProcW(hwnd
, WM_RBUTTONDBLCLK
, wParam
, lParam
);
6020 TOOLBAR_CaptureChanged(HWND hwnd
)
6022 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6023 TBUTTON_INFO
*btnPtr
;
6025 infoPtr
->bCaptured
= FALSE
;
6027 if (infoPtr
->nButtonDown
>= 0)
6029 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6030 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6032 infoPtr
->nOldHit
= -1;
6034 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
6035 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6041 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6043 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6044 TBUTTON_INFO
*hotBtnPtr
;
6046 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
6048 /* don't remove hot effects when in anchor highlighting mode or when a
6049 * drop-down button is pressed */
6050 if (!infoPtr
->bAnchor
&& (infoPtr
->nOldHit
< 0 || !hotBtnPtr
->bDropDownPressed
))
6051 TOOLBAR_SetHotItemEx(infoPtr
, TOOLBAR_NOWHERE
, HICF_MOUSE
);
6053 if (infoPtr
->nOldHit
< 0)
6056 /* If the last button we were over is depressed then make it not */
6057 /* depressed and redraw it */
6058 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
6060 TBUTTON_INFO
*btnPtr
;
6063 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6065 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6067 rc1
= hotBtnPtr
->rect
;
6068 InflateRect (&rc1
, 1, 1);
6069 InvalidateRect (hwnd
, &rc1
, TRUE
);
6072 if (infoPtr
->bCaptured
&& !infoPtr
->bDragOutSent
)
6075 ZeroMemory(&nmt
, sizeof(nmt
));
6076 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6077 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6078 infoPtr
->bDragOutSent
= TRUE
;
6081 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
6087 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6089 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6091 TRACKMOUSEEVENT trackinfo
;
6093 TBUTTON_INFO
*btnPtr
;
6095 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
) {
6096 /* fill in the TRACKMOUSEEVENT struct */
6097 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
6098 trackinfo
.dwFlags
= TME_QUERY
;
6099 trackinfo
.hwndTrack
= hwnd
;
6100 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
6102 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
6103 _TrackMouseEvent(&trackinfo
);
6105 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
6106 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
6107 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
6109 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
6110 /* and can properly deactivate the hot toolbar button */
6111 _TrackMouseEvent(&trackinfo
);
6115 if (infoPtr
->hwndToolTip
)
6116 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
6117 WM_MOUSEMOVE
, wParam
, lParam
);
6119 pt
.x
= (INT
)LOWORD(lParam
);
6120 pt
.y
= (INT
)HIWORD(lParam
);
6122 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
6124 if ((infoPtr
->dwStyle
& TBSTYLE_FLAT
) && (!infoPtr
->bAnchor
|| (nHit
>= 0)))
6125 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
6127 if (infoPtr
->nOldHit
!= nHit
)
6129 if (infoPtr
->bCaptured
)
6131 if (!infoPtr
->bDragOutSent
)
6134 ZeroMemory(&nmt
, sizeof(nmt
));
6135 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6136 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6137 infoPtr
->bDragOutSent
= TRUE
;
6140 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6141 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
6142 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6143 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6145 else if (nHit
== infoPtr
->nButtonDown
) {
6146 btnPtr
->fsState
|= TBSTATE_PRESSED
;
6147 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6149 infoPtr
->nOldHit
= nHit
;
6157 inline static LRESULT
6158 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6160 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
6161 return DefWindowProcW (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
6163 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
6167 inline static LRESULT
6168 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6170 if (!(GetWindowLongW(hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
6171 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
6173 return DefWindowProcW (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
6178 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6180 TOOLBAR_INFO
*infoPtr
;
6181 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
6184 /* allocate memory for info structure */
6185 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
6186 SetWindowLongPtrW (hwnd
, 0, (LONG_PTR
)infoPtr
);
6189 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
6192 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
6193 if (!GetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
)) {
6194 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW (GetParent (hwnd
), GWLP_HINSTANCE
);
6195 SetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
, (LONG_PTR
)hInst
);
6198 /* native control does:
6199 * Get a lot of colors and brushes
6201 * SystemParametersInfoW(0x1f, 0x3c, adr1, 0)
6202 * CreateFontIndirectW(adr1)
6203 * CreateBitmap(0x27, 0x24, 1, 1, 0)
6204 * hdc = GetDC(toolbar)
6205 * GetSystemMetrics(0x48)
6206 * fnt2=CreateFontW(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
6207 * 0, 0, 0, 0, "MARLETT")
6208 * oldfnt = SelectObject(hdc, fnt2)
6209 * GetCharWidthW(hdc, 0x36, 0x36, adr2)
6210 * GetTextMetricsW(hdc, adr3)
6211 * SelectObject(hdc, oldfnt)
6212 * DeleteObject(fnt2)
6214 * InvalidateRect(toolbar, 0, 1)
6215 * SetWindowLongW(toolbar, 0, addr)
6216 * SetWindowLongW(toolbar, -16, xxx) **sometimes**
6219 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
6220 * ie 2 0x4600094c 0x4600094c 0x4600894d
6221 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
6222 * rebar 0x50008844 0x40008844 0x50008845
6223 * pager 0x50000844 0x40000844 0x50008845
6224 * IC35mgr 0x5400084e **nochange**
6225 * on entry to _NCCREATE 0x5400084e
6226 * rowlist 0x5400004e **nochange**
6227 * on entry to _NCCREATE 0x5400004e
6231 /* I think the code below is a bug, but it is the way that the native
6232 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
6233 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
6234 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
6235 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
6236 * Somehow, the only cases of this seem to be MFC programs.
6238 * Note also that the addition of _TRANSPARENT occurs *only* here. It
6239 * does not occur in the WM_STYLECHANGING routine.
6240 * (Guy Albertelli 9/2001)
6243 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
6244 styleadd
|= TBSTYLE_TRANSPARENT
;
6245 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
6246 styleadd
|= CCS_TOP
; /* default to top */
6247 SetWindowLongW (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
6250 return DefWindowProcW (hwnd
, WM_NCCREATE
, wParam
, lParam
);
6255 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6257 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
6261 if (dwStyle
& WS_MINIMIZE
)
6262 return 0; /* Nothing to do */
6264 DefWindowProcW (hwnd
, WM_NCPAINT
, wParam
, lParam
);
6266 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
6269 if (!(dwStyle
& CCS_NODIVIDER
))
6271 GetWindowRect (hwnd
, &rcWindow
);
6272 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
6273 if( dwStyle
& WS_BORDER
)
6274 OffsetRect (&rcWindow
, 1, 1);
6275 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
6278 ReleaseDC( hwnd
, hdc
);
6284 /* handles requests from the tooltip control on what text to display */
6285 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
6287 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
6289 TRACE("button index = %d\n", index
);
6291 Free (infoPtr
->pszTooltipText
);
6292 infoPtr
->pszTooltipText
= NULL
;
6297 if (infoPtr
->bUnicode
)
6299 WCHAR wszBuffer
[INFOTIPSIZE
+1];
6300 NMTBGETINFOTIPW tbgit
;
6301 unsigned int len
; /* in chars */
6303 wszBuffer
[0] = '\0';
6304 wszBuffer
[INFOTIPSIZE
] = '\0';
6306 tbgit
.pszText
= wszBuffer
;
6307 tbgit
.cchTextMax
= INFOTIPSIZE
;
6308 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6309 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6311 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
6313 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
6315 len
= strlenW(tbgit
.pszText
);
6316 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6318 /* need to allocate temporary buffer in infoPtr as there
6319 * isn't enough space in buffer passed to us by the
6320 * tooltip control */
6321 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6322 if (infoPtr
->pszTooltipText
)
6324 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6325 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6331 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6337 CHAR szBuffer
[INFOTIPSIZE
+1];
6338 NMTBGETINFOTIPA tbgit
;
6339 unsigned int len
; /* in chars */
6342 szBuffer
[INFOTIPSIZE
] = '\0';
6344 tbgit
.pszText
= szBuffer
;
6345 tbgit
.cchTextMax
= INFOTIPSIZE
;
6346 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6347 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6349 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
6351 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
6353 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
6354 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6356 /* need to allocate temporary buffer in infoPtr as there
6357 * isn't enough space in buffer passed to us by the
6358 * tooltip control */
6359 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6360 if (infoPtr
->pszTooltipText
)
6362 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
6363 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6369 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
6374 /* if button has text, but it is not shown then automatically
6375 * use that text as tooltip */
6376 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
6377 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
6379 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
6380 unsigned int len
= pszText
? strlenW(pszText
) : 0;
6382 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
6384 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6386 /* need to allocate temporary buffer in infoPtr as there
6387 * isn't enough space in buffer passed to us by the
6388 * tooltip control */
6389 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6390 if (infoPtr
->pszTooltipText
)
6392 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
6393 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6399 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
6404 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
6406 /* last resort: send notification on to app */
6407 /* FIXME: find out what is really used here */
6408 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
6412 inline static LRESULT
6413 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6415 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6416 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
6418 switch (lpnmh
->code
)
6422 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
6424 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
6425 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
6426 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
6430 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
6431 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
6439 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
6441 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
6442 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
6443 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
6444 lppgs
->iScroll
, lppgs
->iDir
);
6448 case TTN_GETDISPINFOW
:
6449 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
6451 case TTN_GETDISPINFOA
:
6452 FIXME("TTN_GETDISPINFOA - should not be received; please report\n");
6462 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
6466 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
6468 if (lParam
== NF_QUERY
)
6471 if (lParam
== NF_REQUERY
) {
6472 format
= SendMessageW(infoPtr
->hwndNotify
,
6473 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
6474 if ((format
!= NFR_ANSI
) && (format
!= NFR_UNICODE
)) {
6475 ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n",
6486 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
6488 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6492 /* fill ps.rcPaint with a default rect */
6493 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
6495 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
6497 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
6498 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
6499 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
6501 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
6502 if (!wParam
) EndPaint (hwnd
, &ps
);
6509 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6510 /*****************************************************
6513 * Handles the WM_SETREDRAW message.
6516 * According to testing V4.71 of COMCTL32 returns the
6517 * *previous* status of the redraw flag (either 0 or 1)
6518 * instead of the MSDN documented value of 0 if handled.
6519 * (For laughs see the "consistency" with same function
6522 *****************************************************/
6524 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6525 BOOL oldredraw
= infoPtr
->bDoRedraw
;
6527 TRACE("set to %s\n",
6528 (wParam
) ? "TRUE" : "FALSE");
6529 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
6531 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
6533 return (oldredraw
) ? 1 : 0;
6538 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6540 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6541 DWORD dwStyle
= infoPtr
->dwStyle
;
6550 /* Resize deadlock check */
6551 if (infoPtr
->bAutoSize
) {
6552 infoPtr
->bAutoSize
= FALSE
;
6556 /* FIXME: optimize to only update size if the new size doesn't */
6557 /* match the current size */
6559 flags
= (INT
) wParam
;
6561 /* FIXME for flags =
6562 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
6565 TRACE("sizing toolbar!\n");
6567 if (flags
== SIZE_RESTORED
) {
6568 /* width and height don't apply */
6569 parent
= GetParent (hwnd
);
6570 GetClientRect(parent
, &parent_rect
);
6571 x
= parent_rect
.left
;
6572 y
= parent_rect
.top
;
6574 if (dwStyle
& CCS_NORESIZE
) {
6575 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
6578 * this sets the working width of the toolbar, and
6579 * Calc Toolbar will not adjust it, only the height
6581 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6582 cy
= infoPtr
->nHeight
;
6583 cx
= infoPtr
->nWidth
;
6584 TOOLBAR_CalcToolbar (hwnd
);
6585 infoPtr
->nWidth
= cx
;
6586 infoPtr
->nHeight
= cy
;
6589 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6590 TOOLBAR_CalcToolbar (hwnd
);
6591 cy
= infoPtr
->nHeight
;
6592 cx
= infoPtr
->nWidth
;
6594 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
6595 GetWindowRect(hwnd
, &window_rect
);
6596 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
6597 y
= window_rect
.top
;
6599 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6600 GetWindowRect(hwnd
, &window_rect
);
6601 y
= parent_rect
.bottom
-
6602 ( window_rect
.bottom
- window_rect
.top
);
6606 if (dwStyle
& CCS_NOPARENTALIGN
) {
6607 uPosFlags
|= SWP_NOMOVE
;
6608 cy
= infoPtr
->nHeight
;
6609 cx
= infoPtr
->nWidth
;
6612 if (!(dwStyle
& CCS_NODIVIDER
))
6613 cy
+= GetSystemMetrics(SM_CYEDGE
);
6615 if (dwStyle
& WS_BORDER
)
6618 cy
+= GetSystemMetrics(SM_CYEDGE
);
6619 cx
+= GetSystemMetrics(SM_CXEDGE
);
6622 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6624 RECT delta_width
, delta_height
, client
, dummy
;
6625 DWORD min_x
, max_x
, min_y
, max_y
;
6626 TBUTTON_INFO
*btnPtr
;
6629 GetClientRect(hwnd
, &client
);
6630 if(client
.right
> infoPtr
->client_rect
.right
)
6632 min_x
= infoPtr
->client_rect
.right
;
6633 max_x
= client
.right
;
6637 max_x
= infoPtr
->client_rect
.right
;
6638 min_x
= client
.right
;
6640 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6642 min_y
= infoPtr
->client_rect
.bottom
;
6643 max_y
= client
.bottom
;
6647 max_y
= infoPtr
->client_rect
.bottom
;
6648 min_y
= client
.bottom
;
6651 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6652 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6654 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6655 btnPtr
= infoPtr
->buttons
;
6656 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6657 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6658 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6659 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6662 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) != (SWP_NOSIZE
| SWP_NOMOVE
))
6663 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6665 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6671 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6673 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6675 if (nType
== GWL_STYLE
)
6677 if (lpStyle
->styleNew
& TBSTYLE_LIST
)
6678 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
;
6680 infoPtr
->dwDTFlags
= DT_CENTER
| DT_END_ELLIPSIS
;
6682 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6683 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6684 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6686 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6688 infoPtr
->dwStyle
= lpStyle
->styleNew
;
6690 /* only resize if one of the CCS_* styles was changed */
6691 if ((infoPtr
->dwStyle
^ lpStyle
->styleNew
) & COMMON_STYLES
)
6693 TOOLBAR_AutoSize (hwnd
);
6695 InvalidateRect(hwnd
, NULL
, TRUE
);
6704 TOOLBAR_SysColorChange (HWND hwnd
)
6706 COMCTL32_RefreshSysColors();
6713 static LRESULT WINAPI
6714 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6716 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6718 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6719 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6721 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
6722 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
6727 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6729 case TB_ADDBUTTONSA
:
6730 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6732 case TB_ADDBUTTONSW
:
6733 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6736 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6739 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6742 return TOOLBAR_AutoSize (hwnd
);
6744 case TB_BUTTONCOUNT
:
6745 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6747 case TB_BUTTONSTRUCTSIZE
:
6748 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6750 case TB_CHANGEBITMAP
:
6751 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6753 case TB_CHECKBUTTON
:
6754 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6756 case TB_COMMANDTOINDEX
:
6757 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6760 return TOOLBAR_Customize (hwnd
);
6762 case TB_DELETEBUTTON
:
6763 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6765 case TB_ENABLEBUTTON
:
6766 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6768 case TB_GETANCHORHIGHLIGHT
:
6769 return TOOLBAR_GetAnchorHighlight (hwnd
);
6772 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6774 case TB_GETBITMAPFLAGS
:
6775 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6778 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6780 case TB_GETBUTTONINFOA
:
6781 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6783 case TB_GETBUTTONINFOW
:
6784 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6786 case TB_GETBUTTONSIZE
:
6787 return TOOLBAR_GetButtonSize (hwnd
);
6789 case TB_GETBUTTONTEXTA
:
6790 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6792 case TB_GETBUTTONTEXTW
:
6793 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6795 case TB_GETDISABLEDIMAGELIST
:
6796 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6798 case TB_GETEXTENDEDSTYLE
:
6799 return TOOLBAR_GetExtendedStyle (hwnd
);
6801 case TB_GETHOTIMAGELIST
:
6802 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6805 return TOOLBAR_GetHotItem (hwnd
);
6807 case TB_GETIMAGELIST
:
6808 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6810 case TB_GETINSERTMARK
:
6811 return TOOLBAR_GetInsertMark (hwnd
, wParam
, lParam
);
6813 case TB_GETINSERTMARKCOLOR
:
6814 return TOOLBAR_GetInsertMarkColor (hwnd
, wParam
, lParam
);
6816 case TB_GETITEMRECT
:
6817 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6820 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6822 /* case TB_GETOBJECT: */ /* 4.71 */
6825 return TOOLBAR_GetPadding (hwnd
);
6828 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6831 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6834 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6837 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6840 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6843 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6845 case TB_GETTEXTROWS
:
6846 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6848 case TB_GETTOOLTIPS
:
6849 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6851 case TB_GETUNICODEFORMAT
:
6852 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6855 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6858 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6860 case TB_INDETERMINATE
:
6861 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6863 case TB_INSERTBUTTONA
:
6864 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6866 case TB_INSERTBUTTONW
:
6867 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6869 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6871 case TB_ISBUTTONCHECKED
:
6872 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6874 case TB_ISBUTTONENABLED
:
6875 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6877 case TB_ISBUTTONHIDDEN
:
6878 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
6880 case TB_ISBUTTONHIGHLIGHTED
:
6881 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
6883 case TB_ISBUTTONINDETERMINATE
:
6884 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
6886 case TB_ISBUTTONPRESSED
:
6887 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
6890 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
6892 case TB_MAPACCELERATORA
:
6893 case TB_MAPACCELERATORW
:
6894 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
6897 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
6900 return TOOLBAR_MoveButton (hwnd
, wParam
, lParam
);
6902 case TB_PRESSBUTTON
:
6903 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
6905 case TB_REPLACEBITMAP
:
6906 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
6908 case TB_SAVERESTOREA
:
6909 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, (LPTBSAVEPARAMSA
)lParam
);
6911 case TB_SAVERESTOREW
:
6912 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, (LPTBSAVEPARAMSW
)lParam
);
6914 case TB_SETANCHORHIGHLIGHT
:
6915 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
6917 case TB_SETBITMAPSIZE
:
6918 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
6920 case TB_SETBUTTONINFOA
:
6921 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
6923 case TB_SETBUTTONINFOW
:
6924 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
6926 case TB_SETBUTTONSIZE
:
6927 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
6929 case TB_SETBUTTONWIDTH
:
6930 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
6933 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
6935 case TB_SETDISABLEDIMAGELIST
:
6936 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
6938 case TB_SETDRAWTEXTFLAGS
:
6939 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
6941 case TB_SETEXTENDEDSTYLE
:
6942 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
6944 case TB_SETHOTIMAGELIST
:
6945 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
6948 return TOOLBAR_SetHotItem (hwnd
, wParam
);
6950 case TB_SETIMAGELIST
:
6951 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
6954 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
6956 case TB_SETINSERTMARK
:
6957 return TOOLBAR_SetInsertMark (hwnd
, wParam
, lParam
);
6959 case TB_SETINSERTMARKCOLOR
:
6960 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
6962 case TB_SETMAXTEXTROWS
:
6963 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
6966 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
6969 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
6972 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
6975 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
6978 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
6980 case TB_SETTOOLTIPS
:
6981 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
6983 case TB_SETUNICODEFORMAT
:
6984 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
6987 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
6990 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
6993 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
6996 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
6999 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
7002 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
7004 /* Common Control Messages */
7006 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
7007 case CCM_GETCOLORSCHEME
:
7008 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7010 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
7011 case CCM_SETCOLORSCHEME
:
7012 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7014 case CCM_GETVERSION
:
7015 return TOOLBAR_GetVersion (hwnd
);
7017 case CCM_SETVERSION
:
7018 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
7024 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
7027 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
7030 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
7033 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
7035 /* case WM_KEYDOWN: */
7036 /* case WM_KILLFOCUS: */
7038 case WM_LBUTTONDBLCLK
:
7039 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
7041 case WM_LBUTTONDOWN
:
7042 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
7045 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
7048 return TOOLBAR_RButtonUp (hwnd
, wParam
, lParam
);
7050 case WM_RBUTTONDBLCLK
:
7051 return TOOLBAR_RButtonDblClk (hwnd
, wParam
, lParam
);
7054 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
7057 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
7059 case WM_CAPTURECHANGED
:
7060 return TOOLBAR_CaptureChanged(hwnd
);
7063 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
7066 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
7069 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
7072 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
7075 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
7077 case WM_NOTIFYFORMAT
:
7078 return TOOLBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
7081 return TOOLBAR_Paint (hwnd
, wParam
);
7084 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
7087 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
7089 case WM_STYLECHANGED
:
7090 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
7092 case WM_SYSCOLORCHANGE
:
7093 return TOOLBAR_SysColorChange (hwnd
);
7095 /* case WM_WININICHANGE: */
7100 case WM_MEASUREITEM
:
7102 return SendMessageW (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
7104 /* We see this in Outlook Express 5.x and just does DefWindowProc */
7105 case PGM_FORWARDMOUSE
:
7106 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7109 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
7110 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
7111 uMsg
, wParam
, lParam
);
7112 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7118 TOOLBAR_Register (void)
7122 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
7123 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
7124 wndClass
.lpfnWndProc
= ToolbarWindowProc
;
7125 wndClass
.cbClsExtra
= 0;
7126 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
7127 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
7128 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
7129 wndClass
.lpszClassName
= TOOLBARCLASSNAMEW
;
7131 RegisterClassW (&wndClass
);
7136 TOOLBAR_Unregister (void)
7138 UnregisterClassW (TOOLBARCLASSNAMEW
, NULL
);
7141 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
7146 /* Check if the entry already exists */
7147 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
7149 /* If this is a new entry we must create it and insert into the array */
7154 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
7157 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
7158 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
7173 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
7177 for (i
= 0; i
< *cies
; i
++)
7187 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
7195 for (i
= 0; i
< cies
; i
++)
7197 if (pies
[i
]->id
== id
)
7209 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
7211 HIMAGELIST himlDef
= 0;
7212 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
7215 himlDef
= pie
->himl
;
7221 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
7223 if (infoPtr
->bUnicode
)
7224 return TOOLBAR_SendNotify(&nmtb
->hdr
, infoPtr
, TBN_GETBUTTONINFOW
);
7231 nmtba
.iItem
= nmtb
->iItem
;
7232 nmtba
.pszText
= Buffer
;
7233 nmtba
.cchText
= 256;
7234 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
7236 if (TOOLBAR_SendNotify(&nmtba
.hdr
, infoPtr
, TBN_GETBUTTONINFOA
))
7238 int ccht
= strlen(nmtba
.pszText
);
7240 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
7241 nmtb
->pszText
, nmtb
->cchText
);
7243 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
7252 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
7253 int iItem
, PCUSTOMBUTTON btnInfo
)
7257 /* MSDN states that iItem is the index of the button, rather than the
7258 * command ID as used by every other NMTOOLBAR notification */
7260 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
7262 return TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYDELETE
);