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
216 /* vertical padding used in list mode when image is present */
219 /* how wide to treat the bitmap if it isn't present */
220 #define NONLIST_NOTEXT_OFFSET 2
222 #define TOOLBAR_NOWHERE (-1)
224 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongPtrW(hwnd,0))
225 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
226 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
228 /* Used to find undocumented extended styles */
229 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
230 TBSTYLE_EX_UNDOC1 | \
231 TBSTYLE_EX_MIXEDBUTTONS | \
232 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
234 /* all of the CCS_ styles */
235 #define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \
236 CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT)
238 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
239 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
240 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
241 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
242 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
244 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
245 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
246 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
247 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
248 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
249 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
250 static LRESULT
TOOLBAR_LButtonDown(HWND hwnd
, WPARAM wParam
, LPARAM lParam
);
251 static void TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
);
252 static LRESULT
TOOLBAR_AutoSize(HWND hwnd
);
255 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
259 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
261 LPWSTR lpText
= NULL
;
263 /* NOTE: iString == -1 is undocumented */
264 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
265 lpText
= (LPWSTR
)btnPtr
->iString
;
266 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
267 lpText
= infoPtr
->strings
[btnPtr
->iString
];
273 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
275 if (TRACE_ON(toolbar
)){
276 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
277 btn_num
, bP
->idCommand
, GETIBITMAP(infoPtr
, bP
->iBitmap
),
278 bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
279 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
281 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
282 btn_num
, bP
->idCommand
,
283 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
284 bP
->rect
.left
, bP
->rect
.top
,
285 bP
->rect
.right
, bP
->rect
.bottom
);
291 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
293 if (TRACE_ON(toolbar
)) {
296 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
298 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
299 iP
->nNumStrings
, iP
->dwStyle
);
300 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
302 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
303 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
304 for(i
=0; i
<iP
->nNumButtons
; i
++) {
305 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
311 /***********************************************************************
314 * This function validates that the styles set are implemented and
315 * issues FIXME's warning of possible problems. In a perfect world this
316 * function should be null.
319 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
321 if (dwStyle
& TBSTYLE_REGISTERDROP
)
322 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd
);
327 TOOLBAR_SendNotify (NMHDR
*nmhdr
, TOOLBAR_INFO
*infoPtr
, UINT code
)
329 if(!IsWindow(infoPtr
->hwndSelf
))
330 return 0; /* we have just been destroyed */
332 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
333 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
336 TRACE("to window %p, code=%08x, %s\n", infoPtr
->hwndNotify
, code
,
337 (infoPtr
->bUnicode
) ? "via Unicode" : "via ANSI");
339 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
,
340 (WPARAM
)nmhdr
->idFrom
, (LPARAM
)nmhdr
);
343 /***********************************************************************
344 * TOOLBAR_GetBitmapIndex
346 * This function returns the bitmap index associated with a button.
347 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
348 * is issued to retrieve the index.
351 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
353 INT ret
= btnPtr
->iBitmap
;
355 if (ret
== I_IMAGECALLBACK
)
357 /* issue TBN_GETDISPINFO */
360 memset(&nmgd
, 0, sizeof(nmgd
));
361 nmgd
.idCommand
= btnPtr
->idCommand
;
362 nmgd
.lParam
= btnPtr
->dwData
;
363 nmgd
.dwMask
= TBNF_IMAGE
;
364 TOOLBAR_SendNotify(&nmgd
.hdr
, infoPtr
,
365 infoPtr
->bUnicode
? TBN_GETDISPINFOW
: TBN_GETDISPINFOA
);
366 if (nmgd
.dwMask
& TBNF_DI_SETITEM
)
367 btnPtr
->iBitmap
= nmgd
.iImage
;
369 TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
370 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
373 if (ret
!= I_IMAGENONE
)
374 ret
= GETIBITMAP(infoPtr
, ret
);
381 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
384 INT id
= GETHIMLID(infoPtr
, index
);
385 INT iBitmap
= GETIBITMAP(infoPtr
, index
);
387 if (((himl
= GETDEFIMAGELIST(infoPtr
, id
)) &&
388 iBitmap
>= 0 && iBitmap
< ImageList_GetImageCount(himl
)) ||
389 (index
== I_IMAGECALLBACK
))
397 TOOLBAR_IsValidImageList(TOOLBAR_INFO
*infoPtr
, INT index
)
399 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, index
));
400 return (himl
!= NULL
) && (ImageList_GetImageCount(himl
) > 0);
404 /***********************************************************************
405 * TOOLBAR_GetImageListForDrawing
407 * This function validates the bitmap index (including I_IMAGECALLBACK
408 * functionality) and returns the corresponding image list.
411 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
415 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
416 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
417 ERR("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
418 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
422 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
423 if ((*index
== I_IMAGECALLBACK
) ||
424 (*index
== I_IMAGENONE
)) return NULL
;
425 ERR("TBN_GETDISPINFO returned invalid index %d\n",
432 case IMAGE_LIST_DEFAULT
:
433 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
436 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
438 case IMAGE_LIST_DISABLED
:
439 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
443 FIXME("Shouldn't reach here\n");
447 TRACE("no image list\n");
454 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
457 COLORREF oldcolor
, newcolor
;
459 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
460 myrect
.right
= myrect
.left
+ 1;
461 myrect
.top
= lpRect
->top
+ 2;
462 myrect
.bottom
= lpRect
->bottom
- 2;
464 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
465 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
466 oldcolor
= SetBkColor (hdc
, newcolor
);
467 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
469 myrect
.left
= myrect
.right
;
470 myrect
.right
= myrect
.left
+ 1;
472 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
473 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
474 SetBkColor (hdc
, newcolor
);
475 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
477 SetBkColor (hdc
, oldcolor
);
481 /***********************************************************************
482 * TOOLBAR_DrawDDFlatSeparator
484 * This function draws the separator that was flagged as BTNS_DROPDOWN.
485 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
486 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
487 * are horizontal as opposed to the vertical separators for not dropdown
490 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
493 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
496 COLORREF oldcolor
, newcolor
;
498 myrect
.left
= lpRect
->left
;
499 myrect
.right
= lpRect
->right
;
500 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
501 myrect
.bottom
= myrect
.top
+ 1;
503 InflateRect (&myrect
, -2, 0);
505 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
506 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
508 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
509 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
510 oldcolor
= SetBkColor (hdc
, newcolor
);
511 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
513 myrect
.top
= myrect
.bottom
;
514 myrect
.bottom
= myrect
.top
+ 1;
516 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
517 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
518 SetBkColor (hdc
, newcolor
);
519 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
521 SetBkColor (hdc
, oldcolor
);
526 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
531 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
532 hOldPen
= SelectObject ( hdc
, hPen
);
535 MoveToEx (hdc
, x
, y
, NULL
);
536 LineTo (hdc
, x
+5, y
++); x
++;
537 MoveToEx (hdc
, x
, y
, NULL
);
538 LineTo (hdc
, x
+3, y
++); x
++;
539 MoveToEx (hdc
, x
, y
, NULL
);
540 LineTo (hdc
, x
+1, y
++);
541 SelectObject( hdc
, hOldPen
);
542 DeleteObject( hPen
);
546 * Draw the text string for this button.
547 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
548 * is non-zero, so we can simply check himlDef to see if we have
552 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
553 NMTBCUSTOMDRAW
*tbcd
)
555 HDC hdc
= tbcd
->nmcd
.hdc
;
558 COLORREF clrOldBk
= 0;
560 UINT state
= tbcd
->nmcd
.uItemState
;
564 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
565 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
567 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
568 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
569 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
571 else if (state
& CDIS_DISABLED
) {
572 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
573 OffsetRect (rcText
, 1, 1);
574 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
575 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
576 OffsetRect (rcText
, -1, -1);
578 else if (state
& CDIS_INDETERMINATE
) {
579 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
581 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
582 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
583 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
584 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
587 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
590 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
591 SetTextColor (hdc
, clrOld
);
592 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
594 SetBkColor (hdc
, clrOldBk
);
595 SetBkMode (hdc
, oldBkMode
);
597 SelectObject (hdc
, hOldFont
);
603 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
605 HDC hdc
= tbcd
->nmcd
.hdc
;
606 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
609 INT cx
= lpRect
->right
- lpRect
->left
;
610 INT cy
= lpRect
->bottom
- lpRect
->top
;
611 INT cxEdge
= GetSystemMetrics(SM_CXEDGE
);
612 INT cyEdge
= GetSystemMetrics(SM_CYEDGE
);
613 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
614 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
615 PatBlt (hdc
, lpRect
->left
+ cxEdge
, lpRect
->top
+ cyEdge
,
616 cx
- (2 * cxEdge
), cy
- (2 * cyEdge
), PATCOPY
);
617 SetBkColor(hdc
, clrBkOld
);
618 SetTextColor(hdc
, clrTextOld
);
619 SelectObject (hdc
, hbr
);
623 static void TOOLBAR_DrawMasked(HIMAGELIST himl
, int index
, HDC hdc
, INT x
, INT y
, UINT draw_flags
)
626 HBITMAP hbmMask
, hbmImage
;
627 HDC hdcMask
, hdcImage
;
629 ImageList_GetIconSize(himl
, &cx
, &cy
);
631 /* Create src image */
632 hdcImage
= CreateCompatibleDC(hdc
);
633 hbmImage
= CreateCompatibleBitmap(hdc
, cx
, cy
);
634 SelectObject(hdcImage
, hbmImage
);
635 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
636 RGB(0xff, 0xff, 0xff), RGB(0,0,0), draw_flags
);
639 hdcMask
= CreateCompatibleDC(0);
640 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
641 SelectObject(hdcMask
, hbmMask
);
643 /* Remove the background and all white pixels */
644 ImageList_DrawEx(himl
, index
, hdcMask
, 0, 0, cx
, cy
,
645 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_MASK
);
646 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
647 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
649 /* draw the new mask 'etched' to hdc */
650 SetBkColor(hdc
, RGB(255, 255, 255));
651 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
652 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
653 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
654 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
655 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
658 DeleteObject(hbmImage
);
660 DeleteObject (hbmMask
);
666 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
670 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
671 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
672 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
673 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
674 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
675 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
676 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
680 /* draws the image on a toolbar button */
682 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
684 HIMAGELIST himl
= NULL
;
685 BOOL draw_masked
= FALSE
;
688 UINT draw_flags
= ILD_TRANSPARENT
;
690 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
692 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
695 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
699 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (infoPtr
->dwStyle
& TBSTYLE_FLAT
))
701 /* if hot, attempt to draw with hot image list, if fails,
702 use default image list */
703 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
705 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
708 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
713 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
714 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
717 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
718 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
719 draw_flags
|= ILD_BLEND50
;
721 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
722 index
, himl
, left
, top
, offset
);
725 TOOLBAR_DrawMasked (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
727 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
730 /* draws a blank frame for a toolbar button */
732 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
)
734 HDC hdc
= tbcd
->nmcd
.hdc
;
735 RECT rc
= tbcd
->nmcd
.rc
;
736 /* if the state is disabled or indeterminate then the button
737 * cannot have an interactive look like pressed or hot */
738 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
739 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
740 BOOL pressed_look
= !non_interactive_state
&&
741 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
742 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
744 /* app don't want us to draw any edges */
745 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
748 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
751 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
752 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
753 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
758 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
760 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
761 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
766 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
, BOOL bDropDownPressed
)
768 HDC hdc
= tbcd
->nmcd
.hdc
;
770 BOOL pressed
= bDropDownPressed
||
771 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
));
773 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
776 DrawEdge (hdc
, rcArrow
, BDR_SUNKENOUTER
, BF_RECT
);
777 else if ( (tbcd
->nmcd
.uItemState
& CDIS_HOT
) &&
778 !(tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) &&
779 !(tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
))
780 DrawEdge (hdc
, rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
785 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
787 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
788 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
792 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
794 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
796 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+1, rcArrow
->top
+1 + (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
797 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
, rcArrow
->top
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
800 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+ offset
, rcArrow
->top
+ offset
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
803 /* draws a complete toolbar button */
805 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
807 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
808 DWORD dwStyle
= infoPtr
->dwStyle
;
809 BOOL hasDropDownArrow
= (TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
810 (btnPtr
->fsStyle
& BTNS_DROPDOWN
)) ||
811 (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
812 BOOL drawSepDropDownArrow
= hasDropDownArrow
&&
813 (~btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
814 RECT rc
, rcArrow
, rcBitmap
, rcText
;
815 LPWSTR lpText
= NULL
;
821 CopyRect (&rcArrow
, &rc
);
823 /* get a pointer to the text */
824 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
826 if (hasDropDownArrow
)
830 if (dwStyle
& TBSTYLE_FLAT
)
831 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
833 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
835 if (drawSepDropDownArrow
)
838 rcArrow
.left
= right
;
841 /* copy text & bitmap rects after adjusting for drop-down arrow
842 * so that text & bitmap is centred in the rectangle not containing
844 CopyRect(&rcText
, &rc
);
845 CopyRect(&rcBitmap
, &rc
);
847 /* Center the bitmap horizontally and vertically */
848 if (dwStyle
& TBSTYLE_LIST
)
851 infoPtr
->nMaxTextRows
> 0 &&
852 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
853 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
854 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
) + infoPtr
->szPadding
.cx
/ 2;
856 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
) + infoPtr
->iListGap
/ 2;
859 rcBitmap
.left
+= (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
861 rcBitmap
.top
+= infoPtr
->szPadding
.cy
/ 2;
863 TRACE("iBitmap=%d, start=(%ld,%ld) w=%d, h=%d\n",
864 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
865 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
866 TRACE("Text=%s\n", debugstr_w(lpText
));
867 TRACE("iListGap=%d, padding = { %ld, %ld }\n", infoPtr
->iListGap
, infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
869 /* calculate text position */
872 rcText
.left
+= GetSystemMetrics(SM_CXEDGE
);
873 rcText
.right
-= GetSystemMetrics(SM_CXEDGE
);
874 if (dwStyle
& TBSTYLE_LIST
)
876 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
))
877 rcText
.left
+= infoPtr
->nBitmapWidth
+ infoPtr
->iListGap
+ 2;
881 if (ImageList_GetImageCount(GETDEFIMAGELIST(infoPtr
, 0)) > 0)
882 rcText
.top
+= infoPtr
->szPadding
.cy
/2 + infoPtr
->nBitmapHeight
+ 1;
884 rcText
.top
+= infoPtr
->szPadding
.cy
/2 + 2;
888 /* Initialize fields in all cases, because we use these later
889 * NOTE: applications can and do alter these to customize their
891 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
892 tbcd
.clrText
= comctl32_color
.clrBtnText
;
893 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
894 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
895 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
896 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
897 tbcd
.clrHighlightHotTrack
= 0;
898 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
899 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
900 /* MSDN says that this is the text rectangle.
901 * But (why always a but) tracing of v5.7 of native shows
902 * that this is really a *relative* rectangle based on the
903 * the nmcd.rc. Also the left and top are always 0 ignoring
904 * any bitmap that might be present. */
905 tbcd
.rcText
.left
= 0;
907 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
908 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
909 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
912 tbcd
.hbrMonoDither
= COMCTL32_hPattern55AABrush
;
914 /* FIXME: what are these used for? */
918 /* Issue Item Prepaint notify */
919 infoPtr
->dwItemCustDraw
= 0;
920 infoPtr
->dwItemCDFlag
= 0;
921 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
923 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
924 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
925 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
926 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
927 /* reset these fields so the user can't alter the behaviour like native */
931 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
932 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
933 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
935 /* save the only part of the rect that the user can change */
936 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
937 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
941 if (btnPtr
->fsStyle
& BTNS_SEP
) {
942 /* with the FLAT style, iBitmap is the width and has already */
943 /* been taken into consideration in calculating the width */
944 /* so now we need to draw the vertical separator */
945 /* empirical tests show that iBitmap can/will be non-zero */
946 /* when drawing the vertical bar... */
947 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
948 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
)
949 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
951 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
953 else if (btnPtr
->fsStyle
!= BTNS_SEP
) {
954 FIXME("Draw some kind of separator: fsStyle=%x\n",
960 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
961 (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
)))
962 OffsetRect(&rcText
, 1, 1);
964 if (!(tbcd
.nmcd
.uItemState
& CDIS_HOT
) &&
965 ((tbcd
.nmcd
.uItemState
& CDIS_CHECKED
) || (tbcd
.nmcd
.uItemState
& CDIS_INDETERMINATE
)))
966 TOOLBAR_DrawPattern (&rc
, &tbcd
);
968 if ((dwStyle
& TBSTYLE_FLAT
) && (tbcd
.nmcd
.uItemState
& CDIS_HOT
))
970 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
974 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
975 ExtTextOutW(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
976 if (hasDropDownArrow
)
977 ExtTextOutW(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
978 SetBkColor(hdc
, oldclr
);
982 TOOLBAR_DrawFrame(infoPtr
, &tbcd
);
984 if (drawSepDropDownArrow
)
985 TOOLBAR_DrawSepDDArrow(infoPtr
, &tbcd
, &rcArrow
, btnPtr
->bDropDownPressed
);
987 if (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) || (btnPtr
->fsStyle
& BTNS_SHOWTEXT
))
988 TOOLBAR_DrawString (infoPtr
, &rcText
, lpText
, &tbcd
);
990 TOOLBAR_DrawImage(infoPtr
, btnPtr
, rcBitmap
.left
, rcBitmap
.top
, &tbcd
);
992 if (hasDropDownArrow
&& !drawSepDropDownArrow
)
994 if (tbcd
.nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
996 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1 + (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
997 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
999 else if (tbcd
.nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
1001 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
1002 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+ offset
, rcArrow
.top
+ offset
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1005 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1009 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1011 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
1012 tbcd
.nmcd
.hdc
= hdc
;
1014 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
1015 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
1016 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
1017 tbcd
.rcText
= rcText
;
1018 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1019 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1020 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1027 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
1029 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1030 TBUTTON_INFO
*btnPtr
;
1031 INT i
, oldBKmode
= 0;
1032 RECT rcTemp
, rcClient
;
1033 NMTBCUSTOMDRAW tbcd
;
1036 /* the app has told us not to redraw the toolbar */
1037 if (!infoPtr
->bDoRedraw
)
1040 /* if imagelist belongs to the app, it can be changed
1041 by the app after setting it */
1042 if (GETDEFIMAGELIST(infoPtr
, 0) != infoPtr
->himlInt
)
1044 infoPtr
->nNumBitmaps
= 0;
1045 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
1046 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
1049 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1051 /* Send initial notify */
1052 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1053 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
1054 tbcd
.nmcd
.hdc
= hdc
;
1055 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1056 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1057 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
1059 if (infoPtr
->bBtnTranspnt
)
1060 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
1062 GetClientRect(hwnd
, &rcClient
);
1064 /* redraw necessary buttons */
1065 btnPtr
= infoPtr
->buttons
;
1066 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
1069 if (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
1071 IntersectRect(&rcTemp
, &rcClient
, &btnPtr
->rect
);
1072 bDraw
= EqualRect(&rcTemp
, &btnPtr
->rect
);
1076 bDraw
&= IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
));
1077 bDraw
= (btnPtr
->fsState
& TBSTATE_HIDDEN
) ? FALSE
: bDraw
;
1079 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
1082 /* draw insert mark if required */
1083 if (infoPtr
->tbim
.iButton
!= -1)
1085 RECT rcButton
= infoPtr
->buttons
[infoPtr
->tbim
.iButton
].rect
;
1087 rcInsertMark
.top
= rcButton
.top
;
1088 rcInsertMark
.bottom
= rcButton
.bottom
;
1089 if (infoPtr
->tbim
.dwFlags
& TBIMHT_AFTER
)
1090 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.right
;
1092 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.left
- INSERTMARK_WIDTH
;
1093 COMCTL32_DrawInsertMark(hdc
, &rcInsertMark
, infoPtr
->clrInsertMark
, FALSE
);
1096 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
1097 SetBkMode (hdc
, oldBKmode
);
1099 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1101 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1102 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
1103 tbcd
.nmcd
.hdc
= hdc
;
1104 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1105 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1109 /***********************************************************************
1110 * TOOLBAR_MeasureString
1112 * This function gets the width and height of a string in pixels. This
1113 * is done first by using GetTextExtentPoint to get the basic width
1114 * and height. The DrawText is called with DT_CALCRECT to get the exact
1115 * width. The reason is because the text may have more than one "&" (or
1116 * prefix characters as M$ likes to call them). The prefix character
1117 * indicates where the underline goes, except for the string "&&" which
1118 * is reduced to a single "&". GetTextExtentPoint does not process these
1119 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
1122 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
1123 HDC hdc
, LPSIZE lpSize
)
1130 if (infoPtr
->nMaxTextRows
> 0 &&
1131 !(btnPtr
->fsState
& TBSTATE_HIDDEN
) &&
1132 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1133 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
1135 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1137 if(lpText
!= NULL
) {
1138 /* first get size of all the text */
1139 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1141 /* feed above size into the rectangle for DrawText */
1142 myrect
.left
= myrect
.top
= 0;
1143 myrect
.right
= lpSize
->cx
;
1144 myrect
.bottom
= lpSize
->cy
;
1146 /* Use DrawText to get true size as drawn (less pesky "&") */
1147 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1148 DT_CALCRECT
| ((btnPtr
->fsStyle
& BTNS_NOPREFIX
) ?
1151 /* feed back to caller */
1152 lpSize
->cx
= myrect
.right
;
1153 lpSize
->cy
= myrect
.bottom
;
1157 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1160 /***********************************************************************
1161 * TOOLBAR_CalcStrings
1163 * This function walks through each string and measures it and returns
1164 * the largest height and width to caller.
1167 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1169 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1170 TBUTTON_INFO
*btnPtr
;
1179 if (infoPtr
->nMaxTextRows
== 0)
1183 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1185 if (infoPtr
->nNumButtons
== 0)
1189 GetTextMetricsW(hdc
, &tm
);
1190 lpSize
->cy
= tm
.tmHeight
;
1193 btnPtr
= infoPtr
->buttons
;
1194 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1195 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1197 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1198 if (sz
.cx
> lpSize
->cx
)
1200 if (sz
.cy
> lpSize
->cy
)
1205 SelectObject (hdc
, hOldFont
);
1206 ReleaseDC (hwnd
, hdc
);
1208 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1211 /***********************************************************************
1212 * TOOLBAR_WrapToolbar
1214 * This function walks through the buttons and separators in the
1215 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1216 * wrapping should occur based on the width of the toolbar window.
1217 * It does *not* calculate button placement itself. That task
1218 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1219 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1220 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1222 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1223 * vertical toolbar lists.
1227 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1229 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1230 TBUTTON_INFO
*btnPtr
;
1233 BOOL bWrap
, bButtonWrap
;
1235 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1236 /* no layout is necessary. Applications may use this style */
1237 /* to perform their own layout on the toolbar. */
1238 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1239 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1241 btnPtr
= infoPtr
->buttons
;
1242 x
= infoPtr
->nIndent
;
1244 /* this can get the parents width, to know how far we can extend
1245 * this toolbar. We cannot use its height, as there may be multiple
1246 * toolbars in a rebar control
1248 GetClientRect( GetParent(hwnd
), &rc
);
1249 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1250 bButtonWrap
= FALSE
;
1252 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1253 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1256 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1259 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1261 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1264 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1265 /* it is the actual width of the separator. This is used for */
1266 /* custom controls in toolbars. */
1268 /* BTNS_DROPDOWN separators are treated as buttons for */
1269 /* width. - GA 8/01 */
1270 if ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1271 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
))
1272 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1273 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1275 cx
= infoPtr
->nButtonWidth
;
1277 /* Two or more adjacent separators form a separator group. */
1278 /* The first separator in a group should be wrapped to the */
1279 /* next row if the previous wrapping is on a button. */
1281 (btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1282 (i
+ 1 < infoPtr
->nNumButtons
) &&
1283 (btnPtr
[i
+ 1].fsStyle
& BTNS_SEP
) )
1285 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1286 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1287 x
= infoPtr
->nIndent
;
1289 bButtonWrap
= FALSE
;
1293 /* The layout makes sure the bitmap is visible, but not the button. */
1294 /* Test added to also wrap after a button that starts a row but */
1295 /* is bigger than the area. - GA 8/01 */
1296 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1297 > infoPtr
->nWidth
) ||
1298 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1300 BOOL bFound
= FALSE
;
1302 /* If the current button is a separator and not hidden, */
1303 /* go to the next until it reaches a non separator. */
1304 /* Wrap the last separator if it is before a button. */
1305 while( ( ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1306 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
)) ||
1307 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1308 i
< infoPtr
->nNumButtons
)
1314 if( bFound
&& i
< infoPtr
->nNumButtons
)
1317 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1318 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1319 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1320 x
= infoPtr
->nIndent
;
1321 bButtonWrap
= FALSE
;
1324 else if ( i
>= infoPtr
->nNumButtons
)
1327 /* If the current button is not a separator, find the last */
1328 /* separator and wrap it. */
1329 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1331 if ((btnPtr
[j
].fsStyle
& BTNS_SEP
) &&
1332 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1336 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1337 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1338 x
= infoPtr
->nIndent
;
1339 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1340 bButtonWrap
= FALSE
;
1345 /* If no separator available for wrapping, wrap one of */
1346 /* non-hidden previous button. */
1350 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1352 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1357 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1358 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1359 x
= infoPtr
->nIndent
;
1360 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1366 /* If all above failed, wrap the current button. */
1369 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1370 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1371 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1373 x
= infoPtr
->nIndent
;
1374 if (btnPtr
[i
].fsStyle
& BTNS_SEP
)
1375 bButtonWrap
= FALSE
;
1381 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1382 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1389 /***********************************************************************
1390 * TOOLBAR_MeasureButton
1392 * Calculates the width and height required for a button. Used in
1393 * TOOLBAR_CalcToolbar to set the all-button width and height and also for
1394 * the width of buttons that are autosized.
1396 * Note that it would have been rather elegant to use one piece of code for
1397 * both the laying out of the toolbar and for controlling where button parts
1398 * are drawn, but the native control has inconsistencies between the two that
1399 * prevent this from being effectively. These inconsistencies can be seen as
1400 * artefacts where parts of the button appear outside of the bounding button
1403 * There are several cases for the calculation of the button dimensions and
1404 * button part positioning:
1411 * +--------------------------------------------------------+ ^
1413 * | | pad.cy / 2 | centred | |
1414 * | pad.cx/2 + cxedge +--------------+ +------------+ | | DEFPAD_CY +
1415 * |<----------------->| nBitmapWidth | | Text | | | max(nBitmapHeight, szText.cy)
1416 * | |<------------>| | | | |
1417 * | +--------------+ +------------+ | |
1418 * |<-------------------------------------->| | |
1419 * | cxedge + iListGap + nBitmapWidth + 2 |<-----------> | |
1421 * +--------------------------------------------------------+ -
1422 * <-------------------------------------------------------->
1423 * 2*cxedge + nBitmapWidth + iListGap + szText.cx + pad.cx
1425 * Without Bitmap (I_IMAGENONE):
1427 * +-----------------------------------+ ^
1429 * | | centred | | LISTPAD_CY +
1430 * | +------------+ | | szText.cy
1433 * | +------------+ | |
1434 * |<----------------->| | |
1435 * | cxedge |<-----------> | |
1437 * +-----------------------------------+ -
1438 * <----------------------------------->
1439 * szText.cx + pad.cx
1443 * +--------------------------------------+ ^
1445 * | | padding.cy/2 | | DEFPAD_CY +
1446 * | +------------+ | | nBitmapHeight
1449 * | +------------+ | |
1450 * |<------------------->| | |
1451 * | cxedge + iListGap/2 |<-----------> | |
1452 * | nBitmapWidth | |
1453 * +--------------------------------------+ -
1454 * <-------------------------------------->
1455 * 2*cxedge + nBitmapWidth + iListGap
1462 * +-----------------------------------+ ^
1464 * | | pad.cy / 2 | | nBitmapHeight +
1465 * | - | | szText.cy +
1466 * | +------------+ | | DEFPAD_CY + 1
1467 * | centred | Bitmap | | |
1468 * |<----------------->| | | |
1469 * | +------------+ | |
1473 * | centred +---------------+ | |
1474 * |<--------------->| Text | | |
1475 * | +---------------+ | |
1476 * +-----------------------------------+ -
1477 * <----------------------------------->
1478 * pad.cx + max(nBitmapWidth, szText.cx)
1480 * Without bitmaps (NULL imagelist or ImageList_GetImageCount() = 0):
1482 * +---------------------------------------+ ^
1484 * | | 2 + pad.cy / 2 | |
1485 * | - | | szText.cy +
1486 * | centred +-----------------+ | | pad.cy + 2
1487 * |<--------------->| Text | | |
1488 * | +-----------------+ | |
1490 * +---------------------------------------+ -
1491 * <--------------------------------------->
1492 * 2*cxedge + pad.cx + szText.cx
1495 * As for with bitmaps, but with szText.cx zero.
1497 static inline SIZE
TOOLBAR_MeasureButton(TOOLBAR_INFO
*infoPtr
, SIZE sizeString
, BOOL bHasBitmap
, BOOL bValidImageList
)
1500 if (infoPtr
->dwStyle
& TBSTYLE_LIST
)
1502 /* set button height from bitmap / text height... */
1503 sizeButton
.cy
= max((bHasBitmap
? infoPtr
->nBitmapHeight
: 0),
1506 /* ... add on the necessary padding */
1507 if (bValidImageList
)
1510 sizeButton
.cy
+= DEFPAD_CY
;
1512 sizeButton
.cy
+= LISTPAD_CY
;
1515 sizeButton
.cy
+= infoPtr
->szPadding
.cy
;
1517 /* calculate button width */
1520 sizeButton
.cx
= 2*GetSystemMetrics(SM_CXEDGE
) +
1521 infoPtr
->nBitmapWidth
+ infoPtr
->iListGap
;
1522 if (sizeString
.cx
> 0)
1523 sizeButton
.cx
+= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1526 sizeButton
.cx
= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1532 sizeButton
.cy
= infoPtr
->nBitmapHeight
+ 1 +
1533 sizeString
.cy
+ DEFPAD_CY
;
1534 sizeButton
.cx
= infoPtr
->szPadding
.cx
+
1535 max(sizeString
.cx
, infoPtr
->nBitmapWidth
);
1539 sizeButton
.cy
= sizeString
.cy
+ infoPtr
->szPadding
.cy
+
1540 NONLIST_NOTEXT_OFFSET
;
1541 sizeButton
.cx
= 2*GetSystemMetrics(SM_CXEDGE
) +
1542 infoPtr
->szPadding
.cx
+ sizeString
.cx
;
1549 /***********************************************************************
1550 * TOOLBAR_CalcToolbar
1552 * This function calculates button and separator placement. It first
1553 * calculates the button sizes, gets the toolbar window width and then
1554 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1555 * on. It assigns a new location to each item and sends this location to
1556 * the tooltip window if appropriate. Finally, it updates the rcBound
1557 * rect and calculates the new required toolbar window height.
1560 TOOLBAR_CalcToolbar (HWND hwnd
)
1562 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1563 DWORD dwStyle
= infoPtr
->dwStyle
;
1564 TBUTTON_INFO
*btnPtr
;
1565 INT i
, nRows
, nSepRows
;
1567 SIZE sizeString
, sizeButton
;
1569 BOOL validImageList
= FALSE
;
1570 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1572 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1574 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1576 if (TOOLBAR_IsValidImageList(infoPtr
, 0))
1577 validImageList
= TRUE
;
1578 sizeButton
= TOOLBAR_MeasureButton(infoPtr
, sizeString
, TRUE
, validImageList
);
1579 infoPtr
->nButtonWidth
= sizeButton
.cx
;
1580 infoPtr
->nButtonHeight
= sizeButton
.cy
;
1582 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1583 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1584 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1585 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1587 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1589 x
= infoPtr
->nIndent
;
1590 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
1595 /* from above, minimum is a button, and possible text */
1596 cx
= infoPtr
->nButtonWidth
;
1598 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1600 cy
= infoPtr
->nHeight
;
1602 nRows
= nSepRows
= 0;
1604 infoPtr
->rcBound
.top
= y
;
1605 infoPtr
->rcBound
.left
= x
;
1606 infoPtr
->rcBound
.bottom
= y
+ cy
;
1607 infoPtr
->rcBound
.right
= x
;
1609 btnPtr
= infoPtr
->buttons
;
1611 TRACE("cy=%d\n", cy
);
1613 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1616 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1618 SetRectEmpty (&btnPtr
->rect
);
1622 cy
= infoPtr
->nHeight
;
1624 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1625 /* it is the actual width of the separator. This is used for */
1626 /* custom controls in toolbars. */
1627 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1628 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
) {
1629 cy
= (btnPtr
->iBitmap
> 0) ?
1630 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1631 cx
= infoPtr
->nButtonWidth
;
1634 cx
= (btnPtr
->iBitmap
> 0) ?
1635 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1641 else if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1642 (btnPtr
->fsStyle
& BTNS_AUTOSIZE
))
1649 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1651 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1653 SelectObject (hdc
, hOldFont
);
1654 ReleaseDC (hwnd
, hdc
);
1656 sizeButton
= TOOLBAR_MeasureButton(infoPtr
, sz
,
1657 TOOLBAR_IsValidBitmapIndex(infoPtr
, infoPtr
->buttons
[i
].iBitmap
),
1662 cx
= infoPtr
->nButtonWidth
;
1664 /* if size has been set manually then don't add on extra space
1665 * for the drop down arrow */
1666 if (!btnPtr
->cx
&& hasDropDownArrows
&&
1667 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) || (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)))
1668 cx
+= DDARROW_WIDTH
;
1670 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1673 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1675 if (infoPtr
->rcBound
.left
> x
)
1676 infoPtr
->rcBound
.left
= x
;
1677 if (infoPtr
->rcBound
.right
< x
+ cx
)
1678 infoPtr
->rcBound
.right
= x
+ cx
;
1679 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1680 infoPtr
->rcBound
.bottom
= y
+ cy
;
1682 /* Set the toolTip only for non-hidden, non-separator button */
1683 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& BTNS_SEP
))
1687 ZeroMemory (&ti
, sizeof(ti
));
1688 ti
.cbSize
= sizeof(ti
);
1690 ti
.uId
= btnPtr
->idCommand
;
1691 ti
.rect
= btnPtr
->rect
;
1692 SendMessageW (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTW
,
1696 /* btnPtr->nRow is zero based. The space between the rows is */
1697 /* also considered as a row. */
1698 btnPtr
->nRow
= nRows
+ nSepRows
;
1700 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1701 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1706 if ( !(btnPtr
->fsStyle
& BTNS_SEP
) )
1710 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1711 /* it is the actual width of the separator. This is used for */
1712 /* custom controls in toolbars. */
1713 if ( !(btnPtr
->fsStyle
& BTNS_DROPDOWN
))
1714 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1715 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1719 /* nSepRows is used to calculate the extra height follwoing */
1723 x
= infoPtr
->nIndent
;
1725 /* Increment row number unless this is the last button */
1726 /* and it has Wrap set. */
1727 if (i
!= infoPtr
->nNumButtons
-1)
1734 /* infoPtr->nRows is the number of rows on the toolbar */
1735 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1738 /********************************************************************
1739 * The following while interesting, does not match the values *
1740 * created above for the button rectangles, nor the rcBound rect. *
1741 * We will comment it out and remove it later. *
1743 * The problem showed up as heights in the pager control that was *
1745 ********************************************************************/
1747 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1749 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1750 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1751 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1755 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1757 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1762 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1764 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1765 TBUTTON_INFO
*btnPtr
;
1768 btnPtr
= infoPtr
->buttons
;
1769 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1770 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1773 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1774 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1775 TRACE(" ON SEPARATOR %d!\n", i
);
1780 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1781 TRACE(" ON BUTTON %d!\n", i
);
1787 TRACE(" NOWHERE!\n");
1788 return TOOLBAR_NOWHERE
;
1793 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1795 TBUTTON_INFO
*btnPtr
;
1798 if (CommandIsIndex
) {
1799 TRACE("command is really index command=%d\n", idCommand
);
1800 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1803 btnPtr
= infoPtr
->buttons
;
1804 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1805 if (btnPtr
->idCommand
== idCommand
) {
1806 TRACE("command=%d index=%d\n", idCommand
, i
);
1810 TRACE("no index found for command=%d\n", idCommand
);
1816 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1818 TBUTTON_INFO
*btnPtr
;
1821 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1824 /* check index button */
1825 btnPtr
= &infoPtr
->buttons
[nIndex
];
1826 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1827 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1831 /* check previous buttons */
1832 nRunIndex
= nIndex
- 1;
1833 while (nRunIndex
>= 0) {
1834 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1835 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1836 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1844 /* check next buttons */
1845 nRunIndex
= nIndex
+ 1;
1846 while (nRunIndex
< infoPtr
->nNumButtons
) {
1847 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1848 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1849 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1862 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1863 WPARAM wParam
, LPARAM lParam
)
1869 msg
.wParam
= wParam
;
1870 msg
.lParam
= lParam
;
1871 msg
.time
= GetMessageTime ();
1872 msg
.pt
.x
= LOWORD(GetMessagePos ());
1873 msg
.pt
.y
= HIWORD(GetMessagePos ());
1875 SendMessageW (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1878 /* keeps available button list box sorted by button id */
1879 static void TOOLBAR_Cust_InsertAvailButton(HWND hwnd
, PCUSTOMBUTTON btnInfoNew
)
1883 PCUSTOMBUTTON btnInfo
;
1884 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1886 TRACE("button %s, idCommand %d\n", debugstr_w(btnInfoNew
->text
), btnInfoNew
->btn
.idCommand
);
1888 count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1890 /* position 0 is always separator */
1891 for (i
= 1; i
< count
; i
++)
1893 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, i
, 0);
1894 if (btnInfoNew
->btn
.idCommand
< btnInfo
->btn
.idCommand
)
1896 i
= SendMessageW(hwndAvail
, LB_INSERTSTRING
, i
, 0);
1897 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1901 /* id higher than all others add to end */
1902 i
= SendMessageW(hwndAvail
, LB_ADDSTRING
, 0, 0);
1903 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1906 static void TOOLBAR_Cust_MoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexFrom
, INT nIndexTo
)
1910 TRACE("index from %d, index to %d\n", nIndexFrom
, nIndexTo
);
1912 if (nIndexFrom
== nIndexTo
)
1915 /* MSDN states that iItem is the index of the button, rather than the
1916 * command ID as used by every other NMTOOLBAR notification */
1917 nmtb
.iItem
= nIndexFrom
;
1918 if (TOOLBAR_SendNotify(&nmtb
.hdr
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1920 PCUSTOMBUTTON btnInfo
;
1922 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1923 int count
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1925 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, nIndexFrom
, 0);
1927 SendMessageW(hwndList
, LB_DELETESTRING
, nIndexFrom
, 0);
1928 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1929 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1930 SendMessageW(hwndList
, LB_SETCURSEL
, nIndexTo
, 0);
1933 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1935 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1937 /* last item is always separator, so -2 instead of -1 */
1938 if (nIndexTo
>= (count
- 2))
1939 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1941 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1943 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, nIndexFrom
, 0);
1944 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1946 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1950 static void TOOLBAR_Cust_AddButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexAvail
, INT nIndexTo
)
1954 TRACE("Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail
, nIndexTo
);
1956 /* MSDN states that iItem is the index of the button, rather than the
1957 * command ID as used by every other NMTOOLBAR notification */
1958 nmtb
.iItem
= nIndexAvail
;
1959 if (TOOLBAR_SendNotify(&nmtb
.hdr
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1961 PCUSTOMBUTTON btnInfo
;
1963 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1964 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1965 int count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1967 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, nIndexAvail
, 0);
1969 if (nIndexAvail
!= 0) /* index == 0 indicates separator */
1971 /* remove from 'available buttons' list */
1972 SendMessageW(hwndAvail
, LB_DELETESTRING
, nIndexAvail
, 0);
1973 if (nIndexAvail
== count
-1)
1974 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
-1 , 0);
1976 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
, 0);
1980 PCUSTOMBUTTON btnNew
;
1982 /* duplicate 'separator' button */
1983 btnNew
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1984 memcpy(btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
1988 /* insert into 'toolbar button' list */
1989 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1990 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1992 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1994 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1998 static void TOOLBAR_Cust_RemoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT index
)
2000 PCUSTOMBUTTON btnInfo
;
2001 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
2003 TRACE("Remove: index %d\n", index
);
2005 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, index
, 0);
2007 /* send TBN_QUERYDELETE notification */
2008 if (TOOLBAR_IsButtonRemovable(custInfo
->tbInfo
, index
, btnInfo
))
2012 SendMessageW(hwndList
, LB_DELETESTRING
, index
, 0);
2013 SendMessageW(hwndList
, LB_SETCURSEL
, index
, 0);
2015 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2017 /* insert into 'available button' list */
2018 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
2019 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
2023 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
2027 /* drag list notification function for toolbar buttons list box */
2028 static LRESULT
TOOLBAR_Cust_ToolbarDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
2030 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
2031 switch (pDLI
->uNotification
)
2035 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2036 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2037 /* no dragging for last item (separator) */
2038 if (nCurrentItem
>= (nCount
- 1)) return FALSE
;
2043 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2044 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2045 /* no dragging past last item (separator) */
2046 if ((nCurrentItem
>= 0) && (nCurrentItem
< (nCount
- 1)))
2048 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
2049 /* FIXME: native uses "move button" cursor */
2050 return DL_COPYCURSOR
;
2053 /* not over toolbar buttons list */
2054 if (nCurrentItem
< 0)
2056 POINT ptWindow
= pDLI
->ptCursor
;
2057 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2058 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2059 /* over available buttons list? */
2060 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2061 /* FIXME: native uses "move button" cursor */
2062 return DL_COPYCURSOR
;
2064 /* clear drag arrow */
2065 DrawInsert(hwnd
, hwndList
, -1);
2066 return DL_STOPCURSOR
;
2070 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2071 INT nIndexFrom
= SendMessageW(hwndList
, LB_GETCURSEL
, 0, 0);
2072 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2073 if ((nIndexTo
>= 0) && (nIndexTo
< (nCount
- 1)))
2075 /* clear drag arrow */
2076 DrawInsert(hwnd
, hwndList
, -1);
2078 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
2080 /* not over toolbar buttons list */
2083 POINT ptWindow
= pDLI
->ptCursor
;
2084 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2085 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2086 /* over available buttons list? */
2087 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2088 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, nIndexFrom
);
2093 /* Clear drag arrow */
2094 DrawInsert(hwnd
, hwndList
, -1);
2101 /* drag list notification function for available buttons list box */
2102 static LRESULT
TOOLBAR_Cust_AvailDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
2104 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
2105 switch (pDLI
->uNotification
)
2111 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2112 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2113 /* no dragging past last item (separator) */
2114 if ((nCurrentItem
>= 0) && (nCurrentItem
< nCount
))
2116 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
2117 /* FIXME: native uses "move button" cursor */
2118 return DL_COPYCURSOR
;
2121 /* not over toolbar buttons list */
2122 if (nCurrentItem
< 0)
2124 POINT ptWindow
= pDLI
->ptCursor
;
2125 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2126 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2127 /* over available buttons list? */
2128 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2129 /* FIXME: native uses "move button" cursor */
2130 return DL_COPYCURSOR
;
2132 /* clear drag arrow */
2133 DrawInsert(hwnd
, hwndList
, -1);
2134 return DL_STOPCURSOR
;
2138 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2139 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2140 INT nIndexFrom
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2141 if ((nIndexTo
>= 0) && (nIndexTo
< nCount
))
2143 /* clear drag arrow */
2144 DrawInsert(hwnd
, hwndList
, -1);
2146 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
2150 /* Clear drag arrow */
2151 DrawInsert(hwnd
, hwndList
, -1);
2157 extern UINT uDragListMessage
;
2159 /***********************************************************************
2160 * TOOLBAR_CustomizeDialogProc
2161 * This function implements the toolbar customization dialog.
2163 static INT_PTR CALLBACK
2164 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2166 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongPtrW (hwnd
, DWLP_USER
);
2167 PCUSTOMBUTTON btnInfo
;
2169 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
2174 custInfo
= (PCUSTDLG_INFO
)lParam
;
2175 SetWindowLongPtrW (hwnd
, DWLP_USER
, (LONG_PTR
)custInfo
);
2183 infoPtr
= custInfo
->tbInfo
;
2185 /* send TBN_QUERYINSERT notification */
2186 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
2188 if (!TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYINSERT
))
2191 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
2192 /* FIXME: this hack won't work on 64-bit - we need to declare a structure for this */
2193 nmtb
.iItem
= (int)hwnd
;
2194 /* Send TBN_INITCUSTOMIZE notification */
2195 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_INITCUSTOMIZE
) ==
2198 TRACE("TBNRF_HIDEHELP requested\n");
2199 ShowWindow(GetDlgItem(hwnd
, IDC_HELP_BTN
), SW_HIDE
);
2202 /* add items to 'toolbar buttons' list and check if removable */
2203 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
2205 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2206 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2207 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2208 btnInfo
->bVirtual
= FALSE
;
2209 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2211 /* send TBN_QUERYDELETE notification */
2212 btnInfo
->bRemovable
= TOOLBAR_IsButtonRemovable(infoPtr
, i
, btnInfo
);
2214 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2215 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2218 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2220 /* insert separator button into 'available buttons' list */
2221 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2222 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2223 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2224 btnInfo
->bVirtual
= FALSE
;
2225 btnInfo
->bRemovable
= TRUE
;
2226 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2227 index
= (int)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2228 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2230 /* insert all buttons into dsa */
2233 /* send TBN_GETBUTTONINFO notification */
2236 nmtb
.pszText
= Buffer
;
2239 /* Clear previous button's text */
2240 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
2242 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
2245 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
2246 nmtb
.tbButton
.fsStyle
, i
,
2247 nmtb
.tbButton
.idCommand
,
2248 nmtb
.tbButton
.iString
,
2249 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
2252 /* insert button into the apropriate list */
2253 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
2256 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2257 btnInfo
->bVirtual
= FALSE
;
2258 btnInfo
->bRemovable
= TRUE
;
2262 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
,
2263 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2266 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
2267 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
2269 if (lstrlenW(nmtb
.pszText
))
2270 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
2271 else if (nmtb
.tbButton
.iString
>= 0 &&
2272 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
2274 lstrcpyW(btnInfo
->text
,
2275 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
2280 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
2283 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2285 /* select first item in the 'available' list */
2286 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
2288 /* append 'virtual' separator button to the 'toolbar buttons' list */
2289 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2290 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2291 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2292 btnInfo
->bVirtual
= TRUE
;
2293 btnInfo
->bRemovable
= FALSE
;
2294 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2295 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2296 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2298 /* select last item in the 'toolbar' list */
2299 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2300 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
2302 MakeDragList(GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
));
2303 MakeDragList(GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
));
2305 /* set focus and disable buttons */
2306 PostMessageW (hwnd
, WM_USER
, 0, 0);
2311 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2312 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2313 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
2314 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
2318 EndDialog(hwnd
, FALSE
);
2322 switch (LOWORD(wParam
))
2324 case IDC_TOOLBARBTN_LBOX
:
2325 if (HIWORD(wParam
) == LBN_SELCHANGE
)
2327 PCUSTOMBUTTON btnInfo
;
2332 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2333 index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2335 /* send TBN_QUERYINSERT notification */
2337 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYINSERT
);
2339 /* get list box item */
2340 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2342 if (index
== (count
- 1))
2344 /* last item (virtual separator) */
2345 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2346 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2348 else if (index
== (count
- 2))
2350 /* second last item (last non-virtual item) */
2351 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2352 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2354 else if (index
== 0)
2357 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2358 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2362 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2363 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2366 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
2370 case IDC_MOVEUP_BTN
:
2372 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2373 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
-1);
2377 case IDC_MOVEDN_BTN
: /* move down */
2379 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2380 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
+1);
2384 case IDC_REMOVE_BTN
: /* remove button */
2386 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2388 if (LB_ERR
== index
)
2391 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, index
);
2395 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2398 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2401 case IDOK
: /* Add button */
2406 index
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2407 indexto
= SendDlgItemMessageW(hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2409 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, index
, indexto
);
2414 EndDialog(hwnd
, FALSE
);
2424 /* delete items from 'toolbar buttons' listbox*/
2425 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2426 for (i
= 0; i
< count
; i
++)
2428 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2430 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2432 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2435 /* delete items from 'available buttons' listbox*/
2436 count
= SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2437 for (i
= 0; i
< count
; i
++)
2439 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2441 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2443 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2448 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2450 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2455 COLORREF oldText
= 0;
2459 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2460 if (btnInfo
== NULL
)
2462 FIXME("btnInfo invalid!\n");
2466 /* set colors and select objects */
2467 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2468 if (btnInfo
->bVirtual
)
2469 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2471 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2472 hPen
= CreatePen( PS_SOLID
, 1,
2473 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2474 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2475 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2477 /* fill background rectangle */
2478 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2479 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2481 /* calculate button and text rectangles */
2482 CopyRect (&rcButton
, &lpdis
->rcItem
);
2483 InflateRect (&rcButton
, -1, -1);
2484 CopyRect (&rcText
, &rcButton
);
2485 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2486 rcText
.left
= rcButton
.right
+ 2;
2488 /* draw focus rectangle */
2489 if (lpdis
->itemState
& ODS_FOCUS
)
2490 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2493 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
2494 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2496 /* draw image and text */
2497 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2498 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2499 btnInfo
->btn
.iBitmap
));
2500 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2501 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2503 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2504 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2506 /* delete objects and reset colors */
2507 SelectObject (lpdis
->hDC
, hOldBrush
);
2508 SelectObject (lpdis
->hDC
, hOldPen
);
2509 SetBkColor (lpdis
->hDC
, oldBk
);
2510 SetTextColor (lpdis
->hDC
, oldText
);
2511 DeleteObject( hPen
);
2516 case WM_MEASUREITEM
:
2517 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2519 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2521 lpmis
->itemHeight
= 15 + 8; /* default height */
2528 if (uDragListMessage
&& (uMsg
== uDragListMessage
))
2530 if (wParam
== IDC_TOOLBARBTN_LBOX
)
2532 LRESULT res
= TOOLBAR_Cust_ToolbarDragListNotification(
2533 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2534 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2537 else if (wParam
== IDC_AVAILBTN_LBOX
)
2539 LRESULT res
= TOOLBAR_Cust_AvailDragListNotification(
2540 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2541 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2550 /***********************************************************************
2551 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2555 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2557 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2558 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2559 INT nIndex
= 0, nButtons
, nCount
;
2563 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2567 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2569 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2571 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2573 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2578 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2580 /* Windows resize all the buttons to the size of a newly added standard image */
2581 if (lpAddBmp
->nID
& 1)
2584 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2585 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2587 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2588 MAKELPARAM((WORD
)24, (WORD
)24));
2589 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2590 MAKELPARAM((WORD
)31, (WORD
)30));
2595 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2596 MAKELPARAM((WORD
)16, (WORD
)16));
2597 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2598 MAKELPARAM((WORD
)22, (WORD
)22));
2601 TOOLBAR_CalcToolbar (hwnd
);
2605 nButtons
= (INT
)wParam
;
2609 TRACE ("adding %d bitmaps!\n", nButtons
);
2612 if (!infoPtr
->cimlDef
) {
2613 /* create new default image list */
2614 TRACE ("creating default image list!\n");
2616 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2617 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2618 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2619 infoPtr
->himlInt
= himlDef
;
2622 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2626 WARN("No default image list available\n");
2630 nCount
= ImageList_GetImageCount(himlDef
);
2632 /* Add bitmaps to the default image list */
2633 if (lpAddBmp
->hInst
== NULL
)
2636 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2637 HDC hdcImage
, hdcBitmap
;
2639 /* copy the bitmap before adding it so that the user's bitmap
2640 * doesn't get modified.
2642 GetObjectW ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2644 hdcImage
= CreateCompatibleDC(0);
2645 hdcBitmap
= CreateCompatibleDC(0);
2647 /* create new bitmap */
2648 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2649 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2650 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2652 /* Copy the user's image */
2653 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2654 hdcBitmap
, 0, 0, SRCCOPY
);
2656 SelectObject (hdcImage
, hOldBitmapLoad
);
2657 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2658 DeleteDC (hdcImage
);
2659 DeleteDC (hdcBitmap
);
2661 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2662 DeleteObject (hbmLoad
);
2664 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2666 /* Add system bitmaps */
2667 switch (lpAddBmp
->nID
)
2669 case IDB_STD_SMALL_COLOR
:
2670 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2671 MAKEINTRESOURCEW(IDB_STD_SMALL
));
2672 nIndex
= ImageList_AddMasked (himlDef
,
2673 hbmLoad
, comctl32_color
.clrBtnFace
);
2674 DeleteObject (hbmLoad
);
2677 case IDB_STD_LARGE_COLOR
:
2678 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2679 MAKEINTRESOURCEW(IDB_STD_LARGE
));
2680 nIndex
= ImageList_AddMasked (himlDef
,
2681 hbmLoad
, comctl32_color
.clrBtnFace
);
2682 DeleteObject (hbmLoad
);
2685 case IDB_VIEW_SMALL_COLOR
:
2686 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2687 MAKEINTRESOURCEW(IDB_VIEW_SMALL
));
2688 nIndex
= ImageList_AddMasked (himlDef
,
2689 hbmLoad
, comctl32_color
.clrBtnFace
);
2690 DeleteObject (hbmLoad
);
2693 case IDB_VIEW_LARGE_COLOR
:
2694 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2695 MAKEINTRESOURCEW(IDB_VIEW_LARGE
));
2696 nIndex
= ImageList_AddMasked (himlDef
,
2697 hbmLoad
, comctl32_color
.clrBtnFace
);
2698 DeleteObject (hbmLoad
);
2701 case IDB_HIST_SMALL_COLOR
:
2702 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2703 MAKEINTRESOURCEW(IDB_HIST_SMALL
));
2704 nIndex
= ImageList_AddMasked (himlDef
,
2705 hbmLoad
, comctl32_color
.clrBtnFace
);
2706 DeleteObject (hbmLoad
);
2709 case IDB_HIST_LARGE_COLOR
:
2710 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2711 MAKEINTRESOURCEW(IDB_HIST_LARGE
));
2712 nIndex
= ImageList_AddMasked (himlDef
,
2713 hbmLoad
, comctl32_color
.clrBtnFace
);
2714 DeleteObject (hbmLoad
);
2718 nIndex
= ImageList_GetImageCount (himlDef
);
2719 ERR ("invalid imagelist!\n");
2725 hbmLoad
= LoadBitmapW (lpAddBmp
->hInst
, (LPWSTR
)lpAddBmp
->nID
);
2726 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2727 DeleteObject (hbmLoad
);
2730 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2732 if (infoPtr
->nNumBitmapInfos
== 0)
2734 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2738 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2739 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2740 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
* sizeof(TBITMAP_INFO
));
2743 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2744 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2745 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2747 infoPtr
->nNumBitmapInfos
++;
2748 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2752 INT imagecount
= ImageList_GetImageCount(himlDef
);
2754 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2756 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",
2757 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2758 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2760 infoPtr
->nNumBitmaps
= imagecount
;
2763 infoPtr
->nNumBitmaps
+= nButtons
;
2766 InvalidateRect(hwnd
, NULL
, TRUE
);
2773 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2775 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2776 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2777 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2779 TRACE("adding %d buttons!\n", wParam
);
2781 nAddButtons
= (UINT
)wParam
;
2782 nOldButtons
= infoPtr
->nNumButtons
;
2783 nNewButtons
= nOldButtons
+ nAddButtons
;
2785 if (infoPtr
->nNumButtons
== 0) {
2787 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2790 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2792 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2793 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2794 nOldButtons
* sizeof(TBUTTON_INFO
));
2798 infoPtr
->nNumButtons
= nNewButtons
;
2800 /* insert new button data */
2801 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2802 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2803 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2804 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2805 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2806 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2807 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2808 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2809 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2811 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2812 btnPtr
->bHot
= FALSE
;
2814 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2817 ZeroMemory (&ti
, sizeof(ti
));
2818 ti
.cbSize
= sizeof(ti
);
2820 ti
.uId
= btnPtr
->idCommand
;
2822 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2824 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2829 TOOLBAR_CalcToolbar (hwnd
);
2830 TOOLBAR_AutoSize (hwnd
);
2832 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2834 InvalidateRect(hwnd
, NULL
, TRUE
);
2841 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2843 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2844 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2845 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2847 TRACE("adding %d buttons!\n", wParam
);
2849 nAddButtons
= (UINT
)wParam
;
2850 nOldButtons
= infoPtr
->nNumButtons
;
2851 nNewButtons
= nOldButtons
+ nAddButtons
;
2853 if (infoPtr
->nNumButtons
== 0) {
2855 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2858 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2860 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2861 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2862 nOldButtons
* sizeof(TBUTTON_INFO
));
2866 infoPtr
->nNumButtons
= nNewButtons
;
2868 /* insert new button data */
2869 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2870 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2871 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2872 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2873 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2874 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2875 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2876 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2877 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2879 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2880 btnPtr
->bHot
= FALSE
;
2882 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2885 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2886 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2888 ti
.uId
= btnPtr
->idCommand
;
2890 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2893 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2898 TOOLBAR_CalcToolbar (hwnd
);
2899 TOOLBAR_AutoSize (hwnd
);
2901 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2903 InvalidateRect(hwnd
, NULL
, TRUE
);
2910 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2912 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2915 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2918 TRACE("adding string from resource!\n");
2920 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
, szString
, sizeof(szString
));
2922 TRACE("len=%d \"%s\"\n", len
, szString
);
2923 nIndex
= infoPtr
->nNumStrings
;
2924 if (infoPtr
->nNumStrings
== 0) {
2926 Alloc (sizeof(LPWSTR
));
2929 LPWSTR
*oldStrings
= infoPtr
->strings
;
2931 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2932 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2933 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2937 /*Alloc zeros out the allocated memory*/
2938 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2939 infoPtr
->nNumStrings
++;
2942 LPSTR p
= (LPSTR
)lParam
;
2947 TRACE("adding string(s) from array!\n");
2949 nIndex
= infoPtr
->nNumStrings
;
2952 TRACE("len=%d \"%s\"\n", len
, p
);
2954 if (infoPtr
->nNumStrings
== 0) {
2956 Alloc (sizeof(LPWSTR
));
2959 LPWSTR
*oldStrings
= infoPtr
->strings
;
2961 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2962 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2963 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2967 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2968 infoPtr
->nNumStrings
++;
2979 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2981 #define MAX_RESOURCE_STRING_LENGTH 512
2982 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2985 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2986 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2988 TRACE("adding string from resource!\n");
2990 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2991 szString
, MAX_RESOURCE_STRING_LENGTH
);
2993 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2994 TRACE("First char: 0x%x\n", *szString
);
2995 if (szString
[0] == L
'|')
2997 PWSTR p
= szString
+ 1;
2999 nIndex
= infoPtr
->nNumStrings
;
3000 while (*p
!= L
'|' && *p
!= L
'\0') {
3003 if (infoPtr
->nNumStrings
== 0) {
3004 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
3008 LPWSTR
*oldStrings
= infoPtr
->strings
;
3009 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
3010 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
3011 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
3015 np
=strchrW (p
, '|');
3023 TRACE("len=%d %s\n", len
, debugstr_w(p
));
3024 infoPtr
->strings
[infoPtr
->nNumStrings
] =
3025 Alloc (sizeof(WCHAR
)*(len
+1));
3026 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
3027 infoPtr
->nNumStrings
++;
3034 nIndex
= infoPtr
->nNumStrings
;
3035 if (infoPtr
->nNumStrings
== 0) {
3037 Alloc (sizeof(LPWSTR
));
3040 LPWSTR
*oldStrings
= infoPtr
->strings
;
3042 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
3043 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
3044 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
3048 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
3049 infoPtr
->nNumStrings
++;
3053 LPWSTR p
= (LPWSTR
)lParam
;
3058 TRACE("adding string(s) from array!\n");
3059 nIndex
= infoPtr
->nNumStrings
;
3063 TRACE("len=%d %s\n", len
, debugstr_w(p
));
3064 if (infoPtr
->nNumStrings
== 0) {
3066 Alloc (sizeof(LPWSTR
));
3069 LPWSTR
*oldStrings
= infoPtr
->strings
;
3071 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
3072 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
3073 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
3077 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
3078 infoPtr
->nNumStrings
++;
3089 TOOLBAR_AutoSize (HWND hwnd
)
3091 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3097 UINT uPosFlags
= SWP_NOZORDER
;
3099 TRACE("resize forced, style=%lx!\n", infoPtr
->dwStyle
);
3101 parent
= GetParent (hwnd
);
3102 GetClientRect(parent
, &parent_rect
);
3104 x
= parent_rect
.left
;
3105 y
= parent_rect
.top
;
3107 /* FIXME: we should be able to early out if nothing */
3108 /* has changed with nWidth != parent_rect width */
3110 if (infoPtr
->dwStyle
& CCS_NORESIZE
) {
3111 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
3114 TOOLBAR_CalcToolbar (hwnd
);
3117 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
3118 TOOLBAR_CalcToolbar (hwnd
);
3119 InvalidateRect( hwnd
, NULL
, TRUE
);
3120 cy
= infoPtr
->nHeight
;
3121 cx
= infoPtr
->nWidth
;
3123 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
3124 GetWindowRect(hwnd
, &window_rect
);
3125 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
3126 y
= window_rect
.top
;
3128 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
3129 GetWindowRect(hwnd
, &window_rect
);
3130 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
3134 if (infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)
3135 uPosFlags
|= SWP_NOMOVE
;
3137 if (!(infoPtr
->dwStyle
& CCS_NODIVIDER
))
3138 cy
+= GetSystemMetrics(SM_CYEDGE
);
3140 if (infoPtr
->dwStyle
& WS_BORDER
)
3143 cy
+= GetSystemMetrics(SM_CYEDGE
);
3144 cx
+= GetSystemMetrics(SM_CXEDGE
);
3147 infoPtr
->bAutoSize
= TRUE
;
3148 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
3149 /* The following line makes sure that the infoPtr->bAutoSize is turned off
3150 * after the setwindowpos calls */
3151 infoPtr
->bAutoSize
= FALSE
;
3158 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3160 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3162 return infoPtr
->nNumButtons
;
3167 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3169 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3171 infoPtr
->dwStructSize
= (DWORD
)wParam
;
3178 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3180 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3181 TBUTTON_INFO
*btnPtr
;
3184 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
3186 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3190 btnPtr
= &infoPtr
->buttons
[nIndex
];
3191 btnPtr
->iBitmap
= LOWORD(lParam
);
3193 /* we HAVE to erase the background, the new bitmap could be */
3195 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3202 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3204 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3205 TBUTTON_INFO
*btnPtr
;
3208 BOOL bChecked
= FALSE
;
3210 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3212 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
3217 btnPtr
= &infoPtr
->buttons
[nIndex
];
3219 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
3221 if (LOWORD(lParam
) == FALSE
)
3222 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
3224 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
3226 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
3227 if (nOldIndex
== nIndex
)
3229 if (nOldIndex
!= -1)
3230 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
3232 btnPtr
->fsState
|= TBSTATE_CHECKED
;
3235 if( bChecked
!= LOWORD(lParam
) )
3237 if (nOldIndex
!= -1)
3238 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
3239 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3242 /* FIXME: Send a WM_NOTIFY?? */
3249 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3251 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3253 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3258 TOOLBAR_Customize (HWND hwnd
)
3260 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3261 CUSTDLG_INFO custInfo
;
3267 custInfo
.tbInfo
= infoPtr
;
3268 custInfo
.tbHwnd
= hwnd
;
3270 /* send TBN_BEGINADJUST notification */
3271 TOOLBAR_SendNotify (&nmhdr
, infoPtr
, TBN_BEGINADJUST
);
3273 if (!(hRes
= FindResourceW (COMCTL32_hModule
,
3274 MAKEINTRESOURCEW(IDD_TBCUSTOMIZE
),
3275 (LPWSTR
)RT_DIALOG
)))
3278 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
3281 ret
= DialogBoxIndirectParamW ((HINSTANCE
)GetWindowLongPtrW(hwnd
, GWLP_HINSTANCE
),
3282 (LPDLGTEMPLATEW
)template,
3284 TOOLBAR_CustomizeDialogProc
,
3287 /* send TBN_ENDADJUST notification */
3288 TOOLBAR_SendNotify (&nmhdr
, infoPtr
, TBN_ENDADJUST
);
3295 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3297 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3298 INT nIndex
= (INT
)wParam
;
3300 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nIndex
];
3302 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3305 memset(&nmtb
, 0, sizeof(nmtb
));
3306 nmtb
.iItem
= btnPtr
->idCommand
;
3307 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
3308 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
3309 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
3310 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
3311 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
3312 nmtb
.tbButton
.iString
= btnPtr
->iString
;
3313 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_DELETINGBUTTON
);
3315 if ((infoPtr
->hwndToolTip
) &&
3316 !(btnPtr
->fsStyle
& BTNS_SEP
)) {
3319 ZeroMemory (&ti
, sizeof(ti
));
3320 ti
.cbSize
= sizeof(ti
);
3322 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3324 SendMessageW (infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
3327 if (infoPtr
->nNumButtons
== 1) {
3328 TRACE(" simple delete!\n");
3329 Free (infoPtr
->buttons
);
3330 infoPtr
->buttons
= NULL
;
3331 infoPtr
->nNumButtons
= 0;
3334 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3335 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3337 infoPtr
->nNumButtons
--;
3338 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3340 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3341 nIndex
* sizeof(TBUTTON_INFO
));
3344 if (nIndex
< infoPtr
->nNumButtons
) {
3345 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3346 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3352 TOOLBAR_CalcToolbar (hwnd
);
3354 InvalidateRect (hwnd
, NULL
, TRUE
);
3361 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3363 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3364 TBUTTON_INFO
*btnPtr
;
3368 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3370 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3375 btnPtr
= &infoPtr
->buttons
[nIndex
];
3377 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3379 /* update the toolbar button state */
3380 if(LOWORD(lParam
) == FALSE
) {
3381 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3383 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3386 /* redraw the button only if the state of the button changed */
3387 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3388 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3394 static inline LRESULT
3395 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3397 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3399 return infoPtr
->bAnchor
;
3404 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3406 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3409 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3413 return infoPtr
->buttons
[nIndex
].iBitmap
;
3417 static inline LRESULT
3418 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3420 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3425 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3427 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3428 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3429 INT nIndex
= (INT
)wParam
;
3430 TBUTTON_INFO
*btnPtr
;
3435 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3438 btnPtr
= &infoPtr
->buttons
[nIndex
];
3439 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3440 lpTbb
->idCommand
= btnPtr
->idCommand
;
3441 lpTbb
->fsState
= btnPtr
->fsState
;
3442 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3443 lpTbb
->bReserved
[0] = 0;
3444 lpTbb
->bReserved
[1] = 0;
3445 lpTbb
->dwData
= btnPtr
->dwData
;
3446 lpTbb
->iString
= btnPtr
->iString
;
3453 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3455 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3456 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3457 TBUTTON_INFO
*btnPtr
;
3460 if (lpTbInfo
== NULL
)
3462 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3465 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3466 lpTbInfo
->dwMask
& 0x80000000);
3470 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3472 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3473 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3474 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3475 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3476 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3477 lpTbInfo
->lParam
= btnPtr
->dwData
;
3478 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3479 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3480 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3481 lpTbInfo
->fsState
= btnPtr
->fsState
;
3482 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3483 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3484 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3485 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3486 can't use TOOLBAR_GetText here */
3488 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3489 lpText
= (LPWSTR
)btnPtr
->iString
;
3490 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3492 lpTbInfo
->pszText
[0] = '\0';
3499 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3501 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3502 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3503 TBUTTON_INFO
*btnPtr
;
3506 if (lpTbInfo
== NULL
)
3508 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3511 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3512 lpTbInfo
->dwMask
& 0x80000000);
3516 btnPtr
= &infoPtr
->buttons
[nIndex
];
3521 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3522 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3523 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3524 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3525 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3526 lpTbInfo
->lParam
= btnPtr
->dwData
;
3527 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3528 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3529 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3530 lpTbInfo
->fsState
= btnPtr
->fsState
;
3531 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3532 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3533 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3534 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3535 can't use TOOLBAR_GetText here */
3537 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3538 lpText
= (LPWSTR
)btnPtr
->iString
;
3539 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3541 lpTbInfo
->pszText
[0] = '\0';
3549 TOOLBAR_GetButtonSize (HWND hwnd
)
3551 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3553 if (infoPtr
->nNumButtons
> 0)
3554 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3555 (WORD
)infoPtr
->nButtonHeight
);
3557 return MAKELONG(23,22);
3562 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3564 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3571 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3575 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3577 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3578 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3583 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3585 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3590 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3594 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3598 ret
= strlenW (lpText
);
3601 strcpyW ((LPWSTR
)lParam
, lpText
);
3609 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3611 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3612 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3613 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3617 inline static LRESULT
3618 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3620 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3624 return infoPtr
->dwExStyle
;
3629 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3631 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3632 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3633 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3638 TOOLBAR_GetHotItem (HWND hwnd
)
3640 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3642 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
3645 if (infoPtr
->nHotItem
< 0)
3648 return (LRESULT
)infoPtr
->nHotItem
;
3653 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3655 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3656 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3657 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3662 TOOLBAR_GetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3664 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3665 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
3667 TRACE("hwnd = %p, lptbim = %p\n", hwnd
, lptbim
);
3669 *lptbim
= infoPtr
->tbim
;
3676 TOOLBAR_GetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3678 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3680 TRACE("hwnd = %p\n", hwnd
);
3682 return (LRESULT
)infoPtr
->clrInsertMark
;
3687 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3689 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3690 TBUTTON_INFO
*btnPtr
;
3694 nIndex
= (INT
)wParam
;
3695 btnPtr
= &infoPtr
->buttons
[nIndex
];
3696 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3698 lpRect
= (LPRECT
)lParam
;
3701 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3704 lpRect
->left
= btnPtr
->rect
.left
;
3705 lpRect
->right
= btnPtr
->rect
.right
;
3706 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3707 lpRect
->top
= btnPtr
->rect
.top
;
3714 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3716 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3717 LPSIZE lpSize
= (LPSIZE
)lParam
;
3722 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3723 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3725 TRACE("maximum size %ld x %ld\n",
3726 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3727 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3733 /* << TOOLBAR_GetObject >> */
3737 TOOLBAR_GetPadding (HWND hwnd
)
3739 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3742 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3743 return (LRESULT
) oldPad
;
3748 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3750 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3751 TBUTTON_INFO
*btnPtr
;
3755 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3756 btnPtr
= &infoPtr
->buttons
[nIndex
];
3757 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3759 lpRect
= (LPRECT
)lParam
;
3763 lpRect
->left
= btnPtr
->rect
.left
;
3764 lpRect
->right
= btnPtr
->rect
.right
;
3765 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3766 lpRect
->top
= btnPtr
->rect
.top
;
3773 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3775 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3777 if (infoPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
3778 return infoPtr
->nRows
;
3785 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3787 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3790 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3794 return infoPtr
->buttons
[nIndex
].fsState
;
3799 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3801 return GetWindowLongW(hwnd
, GWL_STYLE
);
3806 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3808 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3810 return infoPtr
->nMaxTextRows
;
3815 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3817 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3819 return (LRESULT
)infoPtr
->hwndToolTip
;
3824 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3826 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3828 TRACE("%s hwnd=%p\n",
3829 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3831 return infoPtr
->bUnicode
;
3835 inline static LRESULT
3836 TOOLBAR_GetVersion (HWND hwnd
)
3838 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3839 return infoPtr
->iVersion
;
3844 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3846 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3847 TBUTTON_INFO
*btnPtr
;
3852 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3856 btnPtr
= &infoPtr
->buttons
[nIndex
];
3857 if (LOWORD(lParam
) == FALSE
)
3858 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3860 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3862 TOOLBAR_CalcToolbar (hwnd
);
3864 InvalidateRect (hwnd
, NULL
, TRUE
);
3870 inline static LRESULT
3871 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3873 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3878 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3880 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3881 TBUTTON_INFO
*btnPtr
;
3885 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3889 btnPtr
= &infoPtr
->buttons
[nIndex
];
3890 oldState
= btnPtr
->fsState
;
3891 if (LOWORD(lParam
) == FALSE
)
3892 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3894 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3896 if(oldState
!= btnPtr
->fsState
)
3897 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3904 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3906 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3907 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3908 INT nIndex
= (INT
)wParam
;
3909 TBUTTON_INFO
*oldButtons
;
3914 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3917 /* EPP: this seems to be an undocumented call (from my IE4)
3918 * I assume in that case that:
3919 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3920 * - index of insertion is at the end of existing buttons
3921 * I only see this happen with nIndex == -1, but it could have a special
3922 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3924 nIndex
= infoPtr
->nNumButtons
;
3926 } else if (nIndex
< 0)
3929 /* If the string passed is not an index, assume address of string
3930 and do our own AddString */
3931 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3935 TRACE("string %s passed instead of index, adding string\n",
3936 debugstr_a((LPSTR
)lpTbb
->iString
));
3937 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3939 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3940 ptr
[len
- 1] = 0; /* ended by two '\0' */
3941 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3945 TRACE("inserting button index=%d\n", nIndex
);
3946 if (nIndex
> infoPtr
->nNumButtons
) {
3947 nIndex
= infoPtr
->nNumButtons
;
3948 TRACE("adjust index=%d\n", nIndex
);
3951 oldButtons
= infoPtr
->buttons
;
3952 infoPtr
->nNumButtons
++;
3953 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3954 /* pre insert copy */
3956 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3957 nIndex
* sizeof(TBUTTON_INFO
));
3960 /* insert new button */
3961 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3962 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3963 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3964 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3965 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3966 /* if passed string and not index, then add string */
3967 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3968 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3971 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3973 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3976 ZeroMemory (&ti
, sizeof(ti
));
3977 ti
.cbSize
= sizeof (ti
);
3979 ti
.uId
= lpTbb
->idCommand
;
3981 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3983 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3987 /* post insert copy */
3988 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3989 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3990 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3995 TOOLBAR_CalcToolbar (hwnd
);
3996 TOOLBAR_AutoSize (hwnd
);
3998 InvalidateRect (hwnd
, NULL
, TRUE
);
4005 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4007 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4008 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
4009 INT nIndex
= (INT
)wParam
;
4010 TBUTTON_INFO
*oldButtons
;
4015 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
4018 /* EPP: this seems to be an undocumented call (from my IE4)
4019 * I assume in that case that:
4020 * - lpTbb->iString is a string pointer (not a string index in strings[] table
4021 * - index of insertion is at the end of existing buttons
4022 * I only see this happen with nIndex == -1, but it could have a special
4023 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
4025 nIndex
= infoPtr
->nNumButtons
;
4027 } else if (nIndex
< 0)
4030 /* If the string passed is not an index, assume address of string
4031 and do our own AddString */
4032 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
4036 TRACE("string %s passed instead of index, adding string\n",
4037 debugstr_w((LPWSTR
)lpTbb
->iString
));
4038 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
4039 ptr
= Alloc(len
*sizeof(WCHAR
));
4040 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
4041 ptr
[len
- 1] = 0; /* ended by two '\0' */
4042 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
4046 TRACE("inserting button index=%d\n", nIndex
);
4047 if (nIndex
> infoPtr
->nNumButtons
) {
4048 nIndex
= infoPtr
->nNumButtons
;
4049 TRACE("adjust index=%d\n", nIndex
);
4052 oldButtons
= infoPtr
->buttons
;
4053 infoPtr
->nNumButtons
++;
4054 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
4055 /* pre insert copy */
4057 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
4058 nIndex
* sizeof(TBUTTON_INFO
));
4061 /* insert new button */
4062 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
4063 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
4064 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
4065 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
4066 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
4067 /* if passed string and not index, then add string */
4068 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
4069 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
4072 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
4074 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
4077 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
4078 ti
.cbSize
= sizeof (TTTOOLINFOW
);
4080 ti
.uId
= lpTbb
->idCommand
;
4082 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
4084 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
4088 /* post insert copy */
4089 if (nIndex
< infoPtr
->nNumButtons
- 1) {
4090 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
4091 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
4096 TOOLBAR_CalcToolbar (hwnd
);
4097 TOOLBAR_AutoSize (hwnd
);
4099 InvalidateRect (hwnd
, NULL
, TRUE
);
4105 /* << TOOLBAR_InsertMarkHitTest >> */
4109 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4111 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4114 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4118 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
4123 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4125 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4128 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4132 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
4137 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4139 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4142 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4146 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
4151 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4153 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4156 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4160 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
4165 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4167 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4170 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4174 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
4179 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4181 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4184 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4188 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
4193 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4196 tbab
.hInst
= (HINSTANCE
)lParam
;
4197 tbab
.nID
= (UINT_PTR
)wParam
;
4199 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
4201 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
4206 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4208 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4209 WCHAR wAccel
= (WCHAR
)wParam
;
4210 UINT
* pIDButton
= (UINT
*)lParam
;
4211 WCHAR wszAccel
[] = {'&',wAccel
,0};
4214 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
4215 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
4217 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4219 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
4220 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
4221 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
4223 int iLen
= strlenW(wszAccel
);
4224 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
4231 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
4236 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
4238 *pIDButton
= btnPtr
->idCommand
;
4250 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4252 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4255 TBUTTON_INFO
*btnPtr
;
4257 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
4259 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4263 btnPtr
= &infoPtr
->buttons
[nIndex
];
4264 oldState
= btnPtr
->fsState
;
4267 btnPtr
->fsState
|= TBSTATE_MARKED
;
4269 btnPtr
->fsState
&= ~TBSTATE_MARKED
;
4271 if(oldState
!= btnPtr
->fsState
)
4272 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4278 /* fixes up an index of a button affected by a move */
4279 inline static void TOOLBAR_MoveFixupIndex(INT
* pIndex
, INT nIndex
, INT nMoveIndex
, BOOL bMoveUp
)
4283 if (*pIndex
> nIndex
&& *pIndex
<= nMoveIndex
)
4285 else if (*pIndex
== nIndex
)
4286 *pIndex
= nMoveIndex
;
4290 if (*pIndex
>= nMoveIndex
&& *pIndex
< nIndex
)
4292 else if (*pIndex
== nIndex
)
4293 *pIndex
= nMoveIndex
;
4299 TOOLBAR_MoveButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4301 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4304 INT nMoveIndex
= (INT
)lParam
;
4305 TBUTTON_INFO button
;
4307 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4309 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, TRUE
);
4310 if ((nIndex
== -1) || (nMoveIndex
< 0))
4313 if (nMoveIndex
> infoPtr
->nNumButtons
- 1)
4314 nMoveIndex
= infoPtr
->nNumButtons
- 1;
4316 button
= infoPtr
->buttons
[nIndex
];
4318 /* move button right */
4319 if (nIndex
< nMoveIndex
)
4321 nCount
= nMoveIndex
- nIndex
;
4322 memmove(&infoPtr
->buttons
[nIndex
], &infoPtr
->buttons
[nIndex
+1], nCount
*sizeof(TBUTTON_INFO
));
4323 infoPtr
->buttons
[nMoveIndex
] = button
;
4325 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, TRUE
);
4326 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, TRUE
);
4327 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, TRUE
);
4328 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, TRUE
);
4330 else if (nIndex
> nMoveIndex
) /* move button left */
4332 nCount
= nIndex
- nMoveIndex
;
4333 memmove(&infoPtr
->buttons
[nMoveIndex
+1], &infoPtr
->buttons
[nMoveIndex
], nCount
*sizeof(TBUTTON_INFO
));
4334 infoPtr
->buttons
[nMoveIndex
] = button
;
4336 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, FALSE
);
4337 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, FALSE
);
4338 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, FALSE
);
4339 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, FALSE
);
4342 TOOLBAR_CalcToolbar(hwnd
);
4343 InvalidateRect(hwnd
, NULL
, TRUE
);
4350 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4352 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4353 TBUTTON_INFO
*btnPtr
;
4357 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4361 btnPtr
= &infoPtr
->buttons
[nIndex
];
4362 oldState
= btnPtr
->fsState
;
4363 if (LOWORD(lParam
) == FALSE
)
4364 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4366 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4368 if(oldState
!= btnPtr
->fsState
)
4369 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4374 /* FIXME: there might still be some confusion her between number of buttons
4375 * and number of bitmaps */
4377 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4379 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4380 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
4382 HBITMAP hbmLoad
= NULL
;
4383 int i
= 0, nOldButtons
= 0, pos
= 0;
4384 int nOldBitmaps
, nNewBitmaps
= 0;
4385 HIMAGELIST himlDef
= 0;
4387 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
4388 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
4389 lpReplace
->nButtons
);
4391 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4393 FIXME("changing standard bitmaps not implemented\n");
4396 else if (lpReplace
->hInstOld
!= 0)
4397 FIXME("resources not in the current module not implemented\n");
4399 if (lpReplace
->hInstNew
)
4401 hbmLoad
= LoadBitmapW(lpReplace
->hInstNew
,(LPWSTR
)lpReplace
->nIDNew
);
4406 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4409 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4410 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4411 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4412 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4413 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4415 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4416 nOldButtons
= tbi
->nButtons
;
4417 tbi
->nButtons
= lpReplace
->nButtons
;
4418 tbi
->hInst
= lpReplace
->hInstNew
;
4419 tbi
->nID
= lpReplace
->nIDNew
;
4420 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4423 pos
+= tbi
->nButtons
;
4426 if (nOldButtons
== 0)
4428 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4430 DeleteObject (hbmLoad
);
4434 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4435 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4437 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4439 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4440 ImageList_Remove(himlDef
, i
);
4445 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4446 HDC hdcImage
, hdcBitmap
;
4448 /* copy the bitmap before adding it so that the user's bitmap
4449 * doesn't get modified.
4451 GetObjectW (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4453 hdcImage
= CreateCompatibleDC(0);
4454 hdcBitmap
= CreateCompatibleDC(0);
4456 /* create new bitmap */
4457 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4458 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4459 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4461 /* Copy the user's image */
4462 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4463 hdcBitmap
, 0, 0, SRCCOPY
);
4465 SelectObject (hdcImage
, hOldBitmapLoad
);
4466 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4467 DeleteDC (hdcImage
);
4468 DeleteDC (hdcBitmap
);
4470 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4471 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4472 DeleteObject (hbmLoad
);
4475 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4477 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4478 pos
, nOldBitmaps
, nNewBitmaps
);
4480 InvalidateRect(hwnd
, NULL
, TRUE
);
4483 DeleteObject (hbmLoad
);
4488 /* helper for TOOLBAR_SaveRestoreW */
4490 TOOLBAR_Save(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4492 FIXME("save to %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4493 debugstr_w(lpSave
->pszValueName
));
4499 /* helper for TOOLBAR_Restore */
4501 TOOLBAR_DeleteAllButtons(TOOLBAR_INFO
*infoPtr
)
4506 ZeroMemory(&ti
, sizeof(ti
));
4507 ti
.cbSize
= sizeof(ti
);
4508 ti
.hwnd
= infoPtr
->hwndSelf
;
4510 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4512 if ((infoPtr
->hwndToolTip
) &&
4513 !(infoPtr
->buttons
[i
].fsStyle
& BTNS_SEP
))
4515 ti
.uId
= infoPtr
->buttons
[i
].idCommand
;
4516 SendMessageW(infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
4520 Free(infoPtr
->buttons
);
4521 infoPtr
->buttons
= NULL
;
4522 infoPtr
->nNumButtons
= 0;
4526 /* helper for TOOLBAR_SaveRestoreW */
4528 TOOLBAR_Restore(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4537 /* restore toolbar information */
4538 TRACE("restore from %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4539 debugstr_w(lpSave
->pszValueName
));
4541 memset(&nmtbr
, 0, sizeof(nmtbr
));
4543 res
= RegOpenKeyExW(lpSave
->hkr
, lpSave
->pszSubKey
, 0,
4544 KEY_QUERY_VALUE
, &hkey
);
4546 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4548 if (!res
&& dwType
!= REG_BINARY
)
4549 res
= ERROR_FILE_NOT_FOUND
;
4552 nmtbr
.pData
= Alloc(dwSize
);
4553 nmtbr
.cbData
= (UINT
)dwSize
;
4554 if (!nmtbr
.pData
) res
= ERROR_OUTOFMEMORY
;
4557 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4558 (LPBYTE
)nmtbr
.pData
, &dwSize
);
4561 nmtbr
.pCurrent
= nmtbr
.pData
;
4563 nmtbr
.cbBytesPerRecord
= sizeof(DWORD
);
4564 nmtbr
.cButtons
= nmtbr
.cbData
/ nmtbr
.cbBytesPerRecord
;
4566 if (!TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
))
4570 /* remove all existing buttons as this function is designed to
4571 * restore the toolbar to a previously saved state */
4572 TOOLBAR_DeleteAllButtons(infoPtr
);
4574 for (i
= 0; i
< nmtbr
.cButtons
; i
++)
4577 nmtbr
.tbButton
.iBitmap
= -1;
4578 nmtbr
.tbButton
.fsState
= 0;
4579 nmtbr
.tbButton
.fsStyle
= 0;
4580 nmtbr
.tbButton
.idCommand
= 0;
4581 if (*nmtbr
.pCurrent
== (DWORD
)-1)
4584 nmtbr
.tbButton
.fsStyle
= TBSTYLE_SEP
;
4585 nmtbr
.tbButton
.iBitmap
= SEPARATOR_WIDTH
;
4587 else if (*nmtbr
.pCurrent
== (DWORD
)-2)
4589 nmtbr
.tbButton
.fsState
= TBSTATE_HIDDEN
;
4591 nmtbr
.tbButton
.idCommand
= (int)*nmtbr
.pCurrent
;
4595 TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
);
4597 /* can't contain real string as we don't know whether
4598 * the client put an ANSI or Unicode string in there */
4599 if (HIWORD(nmtbr
.tbButton
.iString
))
4600 nmtbr
.tbButton
.iString
= 0;
4602 TOOLBAR_InsertButtonW(infoPtr
->hwndSelf
, -1,
4603 (LPARAM
)&nmtbr
.tbButton
);
4606 /* do legacy notifications */
4607 if (infoPtr
->iVersion
< 5)
4609 /* FIXME: send TBN_BEGINADJUST */
4610 FIXME("send TBN_GETBUTTONINFO for each button\n");
4611 /* FIXME: send TBN_ENDADJUST */
4614 /* remove all uninitialised buttons
4615 * note: loop backwards to avoid having to fixup i on a
4617 for (i
= infoPtr
->nNumButtons
- 1; i
>= 0; i
--)
4618 if (infoPtr
->buttons
[i
].iBitmap
== -1)
4619 TOOLBAR_DeleteButton(infoPtr
->hwndSelf
, i
, 0);
4621 /* only indicate success if at least one button survived */
4622 if (infoPtr
->nNumButtons
> 0) ret
= TRUE
;
4633 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSW lpSave
)
4635 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4637 if (lpSave
== NULL
) return 0;
4640 return TOOLBAR_Save(infoPtr
, lpSave
);
4642 return TOOLBAR_Restore(infoPtr
, lpSave
);
4647 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSA lpSave
)
4649 LPWSTR pszValueName
= 0, pszSubKey
= 0;
4650 TBSAVEPARAMSW SaveW
;
4654 if (lpSave
== NULL
) return 0;
4656 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, NULL
, 0);
4657 pszSubKey
= Alloc(len
* sizeof(WCHAR
));
4658 if (pszSubKey
) goto exit
;
4659 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, pszSubKey
, len
);
4661 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, NULL
, 0);
4662 pszValueName
= Alloc(len
* sizeof(WCHAR
));
4663 if (!pszValueName
) goto exit
;
4664 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, pszValueName
, len
);
4666 SaveW
.pszValueName
= pszValueName
;
4667 SaveW
.pszSubKey
= pszSubKey
;
4668 SaveW
.hkr
= lpSave
->hkr
;
4669 result
= TOOLBAR_SaveRestoreW(hwnd
, wParam
, &SaveW
);
4672 Free (pszValueName
);
4680 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4682 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4683 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4685 TRACE("hwnd=%p, bAnchor = %s\n", hwnd
, wParam
? "TRUE" : "FALSE");
4687 infoPtr
->bAnchor
= (BOOL
)wParam
;
4689 /* Native does not remove the hot effect from an already hot button */
4691 return (LRESULT
)bOldAnchor
;
4696 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4698 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4699 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4701 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4704 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4706 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4709 if (infoPtr
->nNumButtons
> 0)
4710 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4711 infoPtr
->nNumButtons
,
4712 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4713 LOWORD(lParam
), HIWORD(lParam
));
4715 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4716 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4719 if ((himlDef
== infoPtr
->himlInt
) &&
4720 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4722 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4723 infoPtr
->nBitmapHeight
);
4731 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4733 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4734 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4735 TBUTTON_INFO
*btnPtr
;
4741 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4744 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4745 lptbbi
->dwMask
& 0x80000000);
4749 btnPtr
= &infoPtr
->buttons
[nIndex
];
4750 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4751 btnPtr
->idCommand
= lptbbi
->idCommand
;
4752 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4753 btnPtr
->iBitmap
= lptbbi
->iImage
;
4754 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4755 btnPtr
->dwData
= lptbbi
->lParam
;
4756 if (lptbbi
->dwMask
& TBIF_SIZE
)
4757 btnPtr
->cx
= lptbbi
->cx
;
4758 if (lptbbi
->dwMask
& TBIF_STATE
)
4759 btnPtr
->fsState
= lptbbi
->fsState
;
4760 if (lptbbi
->dwMask
& TBIF_STYLE
)
4761 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4763 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4764 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4765 /* iString is index, zero it to make Str_SetPtr succeed */
4768 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4771 /* save the button rect to see if we need to redraw the whole toolbar */
4772 oldBtnRect
= btnPtr
->rect
;
4773 TOOLBAR_CalcToolbar(hwnd
);
4775 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4776 InvalidateRect(hwnd
, NULL
, TRUE
);
4778 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4785 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4787 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4788 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4789 TBUTTON_INFO
*btnPtr
;
4795 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4798 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4799 lptbbi
->dwMask
& 0x80000000);
4803 btnPtr
= &infoPtr
->buttons
[nIndex
];
4804 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4805 btnPtr
->idCommand
= lptbbi
->idCommand
;
4806 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4807 btnPtr
->iBitmap
= lptbbi
->iImage
;
4808 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4809 btnPtr
->dwData
= lptbbi
->lParam
;
4810 if (lptbbi
->dwMask
& TBIF_SIZE
)
4811 btnPtr
->cx
= lptbbi
->cx
;
4812 if (lptbbi
->dwMask
& TBIF_STATE
)
4813 btnPtr
->fsState
= lptbbi
->fsState
;
4814 if (lptbbi
->dwMask
& TBIF_STYLE
)
4815 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4817 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4818 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4819 /* iString is index, zero it to make Str_SetPtr succeed */
4821 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4824 /* save the button rect to see if we need to redraw the whole toolbar */
4825 oldBtnRect
= btnPtr
->rect
;
4826 TOOLBAR_CalcToolbar(hwnd
);
4828 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4829 InvalidateRect(hwnd
, NULL
, TRUE
);
4831 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4838 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4840 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4841 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4843 if ((cx
< 0) || (cy
< 0))
4845 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4849 TRACE("%p, cx = %d, cy = %d\n", hwnd
, cx
, cy
);
4851 /* The documentation claims you can only change the button size before
4852 * any button has been added. But this is wrong.
4853 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4854 * it to the toolbar, and it checks that the return value is nonzero - mjm
4855 * Further testing shows that we must actually perform the change too.
4858 * The documentation also does not mention that if 0 is supplied for
4859 * either size, the system changes it to the default of 24 wide and
4860 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4862 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4863 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4869 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4871 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4873 /* if setting to current values, ignore */
4874 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4875 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4876 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4877 infoPtr
->cxMin
, infoPtr
->cxMax
);
4881 /* save new values */
4882 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4883 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4885 /* if both values are 0 then we are done */
4887 TRACE("setting both min and max to 0, norecalc\n");
4891 /* otherwise we need to recalc the toolbar and in some cases
4892 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4893 which doesn't actually draw - GA). */
4894 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4895 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4897 TOOLBAR_CalcToolbar (hwnd
);
4899 InvalidateRect (hwnd
, NULL
, TRUE
);
4906 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4908 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4909 INT nIndex
= (INT
)wParam
;
4911 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4914 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4916 if (infoPtr
->hwndToolTip
) {
4918 FIXME("change tool tip!\n");
4927 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4929 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4930 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4931 HIMAGELIST himlTemp
;
4934 if (infoPtr
->iVersion
>= 5)
4937 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4938 &infoPtr
->cimlDis
, himl
, id
);
4940 /* FIXME: redraw ? */
4942 return (LRESULT
)himlTemp
;
4947 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4949 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4952 TRACE("hwnd = %p, dwMask = 0x%08lx, dwDTFlags = 0x%08lx\n", hwnd
, (DWORD
)wParam
, (DWORD
)lParam
);
4954 dwTemp
= infoPtr
->dwDTFlags
;
4955 infoPtr
->dwDTFlags
=
4956 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4958 return (LRESULT
)dwTemp
;
4961 /* This function differs a bit from what MSDN says it does:
4962 * 1. lParam contains extended style flags to OR with current style
4963 * (MSDN isn't clear on the OR bit)
4964 * 2. wParam appears to contain extended style flags to be reset
4965 * (MSDN says that this parameter is reserved)
4968 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4970 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4973 dwTemp
= infoPtr
->dwExStyle
;
4974 infoPtr
->dwExStyle
&= ~wParam
;
4975 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4977 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4979 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4980 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4981 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4983 TOOLBAR_CalcToolbar (hwnd
);
4985 TOOLBAR_AutoSize(hwnd
);
4987 InvalidateRect(hwnd
, NULL
, TRUE
);
4989 return (LRESULT
)dwTemp
;
4994 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4996 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4997 HIMAGELIST himlTemp
;
4998 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
5001 if (infoPtr
->iVersion
>= 5)
5004 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
5006 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
5007 &infoPtr
->cimlHot
, himl
, id
);
5009 /* FIXME: redraw ? */
5011 return (LRESULT
)himlTemp
;
5015 /* Makes previous hot button no longer hot, makes the specified
5016 * button hot and sends appropriate notifications. dwReason is one or
5017 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
5018 * NOTE 1: this function does not validate nHit
5019 * NOTE 2: the name of this function is completely made up and
5020 * not based on any documentation from Microsoft. */
5022 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
5024 if (infoPtr
->nHotItem
!= nHit
)
5026 NMTBHOTITEM nmhotitem
;
5027 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
5028 LRESULT no_highlight
;
5030 /* Remove the effect of an old hot button if the button was
5031 drawn with the hot button effect */
5032 if(infoPtr
->nHotItem
>= 0)
5034 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
5035 oldBtnPtr
->bHot
= FALSE
;
5038 infoPtr
->nHotItem
= nHit
;
5040 /* It's not a separator or in nowhere. It's a hot button. */
5042 btnPtr
= &infoPtr
->buttons
[nHit
];
5044 nmhotitem
.dwFlags
= dwReason
;
5046 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
5048 nmhotitem
.dwFlags
|= HICF_ENTERING
;
5050 nmhotitem
.idNew
= btnPtr
->idCommand
;
5052 nmhotitem
.dwFlags
|= HICF_LEAVING
;
5054 no_highlight
= TOOLBAR_SendNotify(&nmhotitem
.hdr
, infoPtr
, TBN_HOTITEMCHANGE
);
5056 /* now invalidate the old and new buttons so they will be painted,
5057 * but only if they are enabled - disabled buttons cannot become hot */
5058 if (oldBtnPtr
&& (oldBtnPtr
->fsState
& TBSTATE_ENABLED
))
5059 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
5060 if (btnPtr
&& !no_highlight
&& (btnPtr
->fsState
& TBSTATE_ENABLED
))
5062 btnPtr
->bHot
= TRUE
;
5063 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
5069 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
5071 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5072 INT nOldHotItem
= infoPtr
->nHotItem
;
5074 TRACE("hwnd = %p, nHit = %d\n", hwnd
, (INT
)wParam
);
5076 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
5079 /* NOTE: an application can still remove the hot item even if anchor
5080 * highlighting is enabled */
5082 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
5083 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
5085 if (nOldHotItem
< 0)
5088 return (LRESULT
)nOldHotItem
;
5093 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5095 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5096 HIMAGELIST himlTemp
;
5097 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
5100 if (infoPtr
->iVersion
>= 5)
5103 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
5104 &infoPtr
->cimlDef
, himl
, id
);
5106 infoPtr
->nNumBitmaps
= 0;
5107 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
5108 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
5110 if (!ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
5111 &infoPtr
->nBitmapHeight
))
5113 infoPtr
->nBitmapWidth
= 1;
5114 infoPtr
->nBitmapHeight
= 1;
5117 TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n",
5118 hwnd
, infoPtr
->himlDef
, id
, infoPtr
->nNumBitmaps
,
5119 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
5121 InvalidateRect(hwnd
, NULL
, TRUE
);
5123 return (LRESULT
)himlTemp
;
5128 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5130 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5132 infoPtr
->nIndent
= (INT
)wParam
;
5136 /* process only on indent changing */
5137 if(infoPtr
->nIndent
!= (INT
)wParam
)
5139 infoPtr
->nIndent
= (INT
)wParam
;
5140 TOOLBAR_CalcToolbar (hwnd
);
5141 InvalidateRect(hwnd
, NULL
, FALSE
);
5149 TOOLBAR_SetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5151 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5152 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
5154 TRACE("hwnd = %p, lptbim = { %d, 0x%08lx}\n", hwnd
, lptbim
->iButton
, lptbim
->dwFlags
);
5156 if ((lptbim
->dwFlags
& ~TBIMHT_AFTER
) != 0)
5158 FIXME("Unrecognized flag(s): 0x%08lx\n", (lptbim
->dwFlags
& ~TBIMHT_AFTER
));
5162 if ((lptbim
->iButton
== -1) ||
5163 ((lptbim
->iButton
< infoPtr
->nNumButtons
) &&
5164 (lptbim
->iButton
>= 0)))
5166 infoPtr
->tbim
= *lptbim
;
5167 /* FIXME: don't need to update entire toolbar */
5168 InvalidateRect(hwnd
, NULL
, TRUE
);
5171 ERR("Invalid button index %d\n", lptbim
->iButton
);
5178 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5180 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5182 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
5184 /* FIXME: don't need to update entire toolbar */
5185 InvalidateRect(hwnd
, NULL
, TRUE
);
5192 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5194 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5196 infoPtr
->nMaxTextRows
= (INT
)wParam
;
5198 TOOLBAR_CalcToolbar(hwnd
);
5203 /* MSDN gives slightly wrong info on padding.
5204 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
5205 * 2. It is not used to create a blank area between the edge of the button
5206 * and the text or image if TBSTYLE_LIST is set. It is used to control
5207 * the gap between the image and text.
5208 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
5209 * to control the bottom and right borders [with the border being
5210 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
5211 * is shared evenly on both sides of the button.
5212 * See blueprints in comments above TOOLBAR_MeasureButton for more info.
5215 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5217 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5220 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5221 infoPtr
->szPadding
.cx
= min(LOWORD((DWORD
)lParam
), GetSystemMetrics(SM_CXEDGE
));
5222 infoPtr
->szPadding
.cy
= min(HIWORD((DWORD
)lParam
), GetSystemMetrics(SM_CYEDGE
));
5223 TRACE("cx=%ld, cy=%ld\n",
5224 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5225 return (LRESULT
) oldPad
;
5230 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5232 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5237 hwndOldNotify
= infoPtr
->hwndNotify
;
5238 infoPtr
->hwndNotify
= (HWND
)wParam
;
5240 return (LRESULT
)hwndOldNotify
;
5245 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5247 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5248 LPRECT lprc
= (LPRECT
)lParam
;
5252 if (LOWORD(wParam
) > 1) {
5253 FIXME("multiple rows not supported!\n");
5256 if(infoPtr
->nRows
!= LOWORD(wParam
))
5258 infoPtr
->nRows
= LOWORD(wParam
);
5260 /* recalculate toolbar */
5261 TOOLBAR_CalcToolbar (hwnd
);
5263 /* repaint toolbar */
5264 InvalidateRect(hwnd
, NULL
, TRUE
);
5267 /* return bounding rectangle */
5269 lprc
->left
= infoPtr
->rcBound
.left
;
5270 lprc
->right
= infoPtr
->rcBound
.right
;
5271 lprc
->top
= infoPtr
->rcBound
.top
;
5272 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
5280 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5282 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5283 TBUTTON_INFO
*btnPtr
;
5286 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
5290 btnPtr
= &infoPtr
->buttons
[nIndex
];
5292 /* if hidden state has changed the invalidate entire window and recalc */
5293 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
5294 btnPtr
->fsState
= LOWORD(lParam
);
5295 TOOLBAR_CalcToolbar (hwnd
);
5296 InvalidateRect(hwnd
, 0, TRUE
);
5300 /* process state changing if current state doesn't match new state */
5301 if(btnPtr
->fsState
!= LOWORD(lParam
))
5303 btnPtr
->fsState
= LOWORD(lParam
);
5304 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5312 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5314 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
5320 inline static LRESULT
5321 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5323 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5325 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
5327 infoPtr
->hwndToolTip
= (HWND
)wParam
;
5333 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5335 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5338 TRACE("%s hwnd=%p\n",
5339 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
5341 bTemp
= infoPtr
->bUnicode
;
5342 infoPtr
->bUnicode
= (BOOL
)wParam
;
5349 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5351 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5353 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
5354 comctl32_color
.clrBtnHighlight
:
5355 infoPtr
->clrBtnHighlight
;
5356 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
5357 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
5363 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5365 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5367 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
5368 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
5369 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
5371 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
5372 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
5373 InvalidateRect(hwnd
, NULL
, TRUE
);
5379 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
5381 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5382 INT iOldVersion
= infoPtr
->iVersion
;
5384 infoPtr
->iVersion
= iVersion
;
5386 if (infoPtr
->iVersion
>= 5)
5387 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
5394 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5396 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5397 WORD iString
= HIWORD(wParam
);
5398 WORD buffersize
= LOWORD(wParam
);
5399 LPSTR str
= (LPSTR
)lParam
;
5402 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
5404 if (iString
< infoPtr
->nNumStrings
)
5406 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
5408 TRACE("returning %s\n", debugstr_a(str
));
5411 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5418 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5420 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5421 WORD iString
= HIWORD(wParam
);
5422 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
5423 LPWSTR str
= (LPWSTR
)lParam
;
5426 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
5428 if (iString
< infoPtr
->nNumStrings
)
5430 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
5431 ret
= (len
+1)*sizeof(WCHAR
);
5432 memcpy(str
, infoPtr
->strings
[iString
], ret
);
5435 TRACE("returning %s\n", debugstr_w(str
));
5438 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5443 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
5444 * is the maximum size of the toolbar? */
5445 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5447 SIZE
* pSize
= (SIZE
*)lParam
;
5448 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
5453 /* UNDOCUMENTED MESSAGE: This is an extended version of the
5454 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
5455 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
5458 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5460 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5461 INT nOldHotItem
= infoPtr
->nHotItem
;
5463 TRACE("old item=%d, new item=%d, flags=%08lx\n",
5464 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
5466 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
5469 /* NOTE: an application can still remove the hot item even if anchor
5470 * highlighting is enabled */
5472 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
5476 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
5479 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
5480 * which controls the amount of spacing between the image and the text
5481 * of buttons for TBSTYLE_LIST toolbars. */
5482 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5484 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5486 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
5489 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
5491 infoPtr
->iListGap
= (INT
)wParam
;
5493 InvalidateRect(hwnd
, NULL
, TRUE
);
5498 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
5499 * of image lists associated with the various states. */
5500 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5502 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5504 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5506 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
5510 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5512 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5513 LPSIZE lpsize
= (LPSIZE
)lParam
;
5519 * Testing shows the following:
5520 * wParam = 0 adjust cx value
5521 * = 1 set cy value to max size.
5522 * lParam pointer to SIZE structure
5525 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
5526 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
5530 if (lpsize
->cx
== -1) {
5531 /* **** this is wrong, native measures each button and sets it */
5532 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5534 else if(HIWORD(lpsize
->cx
)) {
5536 HWND hwndParent
= GetParent(hwnd
);
5538 GetWindowRect(hwnd
, &rc
);
5539 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
5540 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
5541 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5542 lpsize
->cx
= max(rc
.right
-rc
.left
,
5543 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
5546 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5550 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5551 /* lpsize->cy = infoPtr->nHeight; */
5554 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
5558 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
5559 lpsize
->cx
, lpsize
->cy
);
5563 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5565 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5567 InvalidateRect(hwnd
, NULL
, TRUE
);
5573 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5575 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5576 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
5579 TRACE("hwnd = %p\n", hwnd
);
5581 /* initialize info structure */
5582 infoPtr
->nButtonHeight
= 22;
5583 infoPtr
->nButtonWidth
= 24;
5584 infoPtr
->nBitmapHeight
= 15;
5585 infoPtr
->nBitmapWidth
= 16;
5587 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5588 infoPtr
->nMaxTextRows
= 1;
5589 infoPtr
->cxMin
= -1;
5590 infoPtr
->cxMax
= -1;
5591 infoPtr
->nNumBitmaps
= 0;
5592 infoPtr
->nNumStrings
= 0;
5594 infoPtr
->bCaptured
= FALSE
;
5595 infoPtr
->nButtonDown
= -1;
5596 infoPtr
->nButtonDrag
= -1;
5597 infoPtr
->nOldHit
= -1;
5598 infoPtr
->nHotItem
= -1;
5599 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5600 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5601 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
: DT_CENTER
| DT_END_ELLIPSIS
;
5602 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5603 infoPtr
->bDragOutSent
= FALSE
;
5604 infoPtr
->iVersion
= 0;
5605 infoPtr
->hwndSelf
= hwnd
;
5606 infoPtr
->bDoRedraw
= TRUE
;
5607 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5608 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5609 infoPtr
->szPadding
.cx
= DEFPAD_CX
;
5610 infoPtr
->szPadding
.cy
= DEFPAD_CY
;
5611 infoPtr
->iListGap
= DEFLISTGAP
;
5612 infoPtr
->dwStyle
= dwStyle
;
5613 infoPtr
->tbim
.iButton
= -1;
5614 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5615 infoPtr
->bUnicode
= infoPtr
->hwndNotify
&&
5616 (NFR_UNICODE
== SendMessageW(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
));
5618 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5619 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectW (&logFont
);
5621 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5622 /* Create tooltip control */
5623 infoPtr
->hwndToolTip
=
5624 CreateWindowExW (0, TOOLTIPS_CLASSW
, NULL
, 0,
5625 CW_USEDEFAULT
, CW_USEDEFAULT
,
5626 CW_USEDEFAULT
, CW_USEDEFAULT
,
5629 /* Send NM_TOOLTIPSCREATED notification */
5630 if (infoPtr
->hwndToolTip
)
5632 NMTOOLTIPSCREATED nmttc
;
5634 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5636 TOOLBAR_SendNotify (&nmttc
.hdr
, infoPtr
, NM_TOOLTIPSCREATED
);
5640 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5642 TOOLBAR_CalcToolbar(hwnd
);
5649 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5651 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5653 /* delete tooltip control */
5654 if (infoPtr
->hwndToolTip
)
5655 DestroyWindow (infoPtr
->hwndToolTip
);
5657 /* delete temporary buffer for tooltip text */
5658 Free (infoPtr
->pszTooltipText
);
5660 /* delete button data */
5661 if (infoPtr
->buttons
)
5662 Free (infoPtr
->buttons
);
5664 /* delete strings */
5665 if (infoPtr
->strings
) {
5667 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5668 if (infoPtr
->strings
[i
])
5669 Free (infoPtr
->strings
[i
]);
5671 Free (infoPtr
->strings
);
5674 /* destroy internal image list */
5675 if (infoPtr
->himlInt
)
5676 ImageList_Destroy (infoPtr
->himlInt
);
5678 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5679 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5680 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5682 /* delete default font */
5684 DeleteObject (infoPtr
->hDefaultFont
);
5686 /* free toolbar info data */
5688 SetWindowLongPtrW (hwnd
, 0, 0);
5695 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5697 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5698 NMTBCUSTOMDRAW tbcd
;
5702 /* the app has told us not to redraw the toolbar */
5703 if (!infoPtr
->bDoRedraw
)
5706 if (infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) {
5707 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5708 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5709 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5710 ntfret
= TOOLBAR_SendNotify (&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
5711 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5713 /* FIXME: in general the return flags *can* be or'ed together */
5714 switch (infoPtr
->dwBaseCustDraw
)
5716 case CDRF_DODEFAULT
:
5718 case CDRF_SKIPDEFAULT
:
5721 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5726 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5727 * to my parent for processing.
5729 if (infoPtr
->dwStyle
& TBSTYLE_TRANSPARENT
) {
5731 HDC hdc
= (HDC
)wParam
;
5736 parent
= GetParent(hwnd
);
5737 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5738 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5739 ret
= SendMessageW (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5740 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5743 ret
= DefWindowProcW (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5745 if ((infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5746 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5747 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5748 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5749 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5750 ntfret
= TOOLBAR_SendNotify (&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
5751 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5752 switch (infoPtr
->dwBaseCustDraw
)
5754 case CDRF_DODEFAULT
:
5756 case CDRF_SKIPDEFAULT
:
5759 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_POSTERASE)\n",
5768 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5770 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5772 return (LRESULT
)infoPtr
->hFont
;
5777 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5782 pt
.x
= (INT
)LOWORD(lParam
);
5783 pt
.y
= (INT
)HIWORD(lParam
);
5784 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5787 TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5788 else if (GetWindowLongW (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5789 TOOLBAR_Customize (hwnd
);
5796 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5798 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5799 TBUTTON_INFO
*btnPtr
;
5804 BOOL bDragKeyPressed
;
5808 if (infoPtr
->dwStyle
& TBSTYLE_ALTDRAG
)
5809 bDragKeyPressed
= (GetKeyState(VK_MENU
) < 0);
5811 bDragKeyPressed
= (wParam
& MK_SHIFT
);
5813 if (infoPtr
->hwndToolTip
)
5814 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5815 WM_LBUTTONDOWN
, wParam
, lParam
);
5817 pt
.x
= (INT
)LOWORD(lParam
);
5818 pt
.y
= (INT
)HIWORD(lParam
);
5819 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5821 btnPtr
= &infoPtr
->buttons
[nHit
];
5823 if ((nHit
>= 0) && bDragKeyPressed
&& (infoPtr
->dwStyle
& CCS_ADJUSTABLE
))
5825 infoPtr
->nButtonDrag
= nHit
;
5828 /* If drag cursor has not been loaded, load it.
5829 * Note: it doesn't need to be freed */
5831 hCursorDrag
= LoadCursorW(COMCTL32_hModule
, (LPCWSTR
)IDC_MOVEBUTTON
);
5832 SetCursor(hCursorDrag
);
5837 infoPtr
->nOldHit
= nHit
;
5839 CopyRect(&arrowRect
, &btnPtr
->rect
);
5840 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5842 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5843 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5844 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5845 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5846 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5847 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5851 /* draw in pressed state */
5852 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5853 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5855 btnPtr
->bDropDownPressed
= TRUE
;
5856 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5857 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5859 memset(&nmtb
, 0, sizeof(nmtb
));
5860 nmtb
.iItem
= btnPtr
->idCommand
;
5861 nmtb
.rcButton
= btnPtr
->rect
;
5862 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5864 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5866 if (res
!= TBDDRET_TREATPRESSED
)
5870 /* redraw button in unpressed state */
5871 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5872 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5874 btnPtr
->bDropDownPressed
= FALSE
;
5875 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5877 /* find and set hot item
5878 * NOTE: native doesn't do this, but that is a bug */
5880 ScreenToClient(hwnd
, &pt
);
5881 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5882 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5883 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5885 /* remove any left mouse button down or double-click messages
5886 * so that we can get a toggle effect on the button */
5887 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
) ||
5888 PeekMessageW(&msg
, hwnd
, WM_LBUTTONDBLCLK
, WM_LBUTTONDBLCLK
, PM_REMOVE
))
5893 /* otherwise drop through and process as pushed */
5895 infoPtr
->bCaptured
= TRUE
;
5896 infoPtr
->nButtonDown
= nHit
;
5897 infoPtr
->bDragOutSent
= FALSE
;
5899 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5901 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5903 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5904 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5911 memset(&nmtb
, 0, sizeof(nmtb
));
5912 nmtb
.iItem
= btnPtr
->idCommand
;
5913 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_BEGINDRAG
);
5916 nmmouse
.dwHitInfo
= nHit
;
5918 /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
5920 nmmouse
.dwItemSpec
= -1;
5923 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5924 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5927 ClientToScreen(hwnd
, &pt
);
5930 if (!TOOLBAR_SendNotify(&nmmouse
.hdr
, infoPtr
, NM_LDOWN
))
5931 return DefWindowProcW(hwnd
, WM_LBUTTONDOWN
, wParam
, lParam
);
5937 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5939 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5940 TBUTTON_INFO
*btnPtr
;
5944 BOOL bSendMessage
= TRUE
;
5949 if (infoPtr
->hwndToolTip
)
5950 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5951 WM_LBUTTONUP
, wParam
, lParam
);
5953 pt
.x
= (INT
)LOWORD(lParam
);
5954 pt
.y
= (INT
)HIWORD(lParam
);
5955 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5957 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5958 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5960 if (infoPtr
->nButtonDrag
>= 0) {
5964 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDrag
];
5967 SetCursor(LoadCursorW(NULL
, (LPCWSTR
)IDC_ARROW
));
5969 GetClientRect(hwnd
, &rcClient
);
5970 if (PtInRect(&rcClient
, pt
))
5977 else if ((nHit
== -1) && PtInRect(&infoPtr
->buttons
[-nHit
].rect
, pt
))
5980 if (nButton
== infoPtr
->nButtonDrag
)
5982 /* if the button is moved sightly left and we have a
5983 * separator there then remove it */
5984 if (pt
.x
< (btnPtr
->rect
.left
+ (btnPtr
->rect
.right
- btnPtr
->rect
.left
)/2))
5986 if ((nButton
> 0) && (infoPtr
->buttons
[nButton
-1].fsStyle
& BTNS_SEP
))
5987 TOOLBAR_DeleteButton(hwnd
, nButton
- 1, 0);
5989 else /* else insert a separator before the dragged button */
5992 memset(&tbb
, 0, sizeof(tbb
));
5993 tbb
.fsStyle
= BTNS_SEP
;
5995 TOOLBAR_InsertButtonW(hwnd
, nButton
, (LPARAM
)&tbb
);
6002 if ((infoPtr
->nNumButtons
> 0) && (pt
.x
< infoPtr
->buttons
[0].rect
.left
))
6003 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, 0);
6005 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, infoPtr
->nNumButtons
);
6008 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, nButton
);
6013 TRACE("button %d dragged out of toolbar\n", infoPtr
->nButtonDrag
);
6014 TOOLBAR_DeleteButton(hwnd
, (WPARAM
)infoPtr
->nButtonDrag
, 0);
6017 /* button under cursor changed so need to re-set hot item */
6018 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
6019 infoPtr
->nButtonDrag
= -1;
6021 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
6023 else if (infoPtr
->nButtonDown
>= 0) {
6024 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6025 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6027 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
6028 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
6029 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
6031 if (nOldIndex
== nHit
)
6032 bSendMessage
= FALSE
;
6033 if ((nOldIndex
!= nHit
) &&
6035 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
6036 btnPtr
->fsState
|= TBSTATE_CHECKED
;
6039 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
6040 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
6042 btnPtr
->fsState
|= TBSTATE_CHECKED
;
6046 if (nOldIndex
!= -1)
6047 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
6050 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
6051 * that resets bCaptured and btn TBSTATE_PRESSED flags,
6052 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
6054 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
6056 infoPtr
->nButtonDown
= -1;
6058 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
6059 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
6060 NM_RELEASEDCAPTURE
);
6062 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
6065 memset(&nmtb
, 0, sizeof(nmtb
));
6066 nmtb
.iItem
= btnPtr
->idCommand
;
6067 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
6070 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
6072 SendMessageW (infoPtr
->hwndNotify
, WM_COMMAND
,
6073 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
6077 /* !!! Undocumented - toolbar at 4.71 level and above sends
6078 * NM_CLICK with the NMMOUSE structure. */
6079 nmmouse
.dwHitInfo
= nHit
;
6081 if (nmmouse
.dwHitInfo
< 0)
6082 nmmouse
.dwItemSpec
= -1;
6085 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
6086 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
6089 ClientToScreen(hwnd
, &pt
);
6092 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_CLICK
))
6093 return DefWindowProcW(hwnd
, WM_LBUTTONUP
, wParam
, lParam
);
6099 TOOLBAR_RButtonUp( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6101 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6106 pt
.x
= LOWORD(lParam
);
6107 pt
.y
= HIWORD(lParam
);
6109 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
6110 nmmouse
.dwHitInfo
= nHit
;
6113 nmmouse
.dwItemSpec
= -1;
6115 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
6116 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
6119 ClientToScreen(hwnd
, &pt
);
6122 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_RCLICK
))
6123 return DefWindowProcW(hwnd
, WM_RBUTTONUP
, wParam
, lParam
);
6129 TOOLBAR_RButtonDblClk( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6131 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6134 if (!TOOLBAR_SendNotify(&nmhdr
, infoPtr
, NM_RDBLCLK
))
6135 return DefWindowProcW(hwnd
, WM_RBUTTONDBLCLK
, wParam
, lParam
);
6141 TOOLBAR_CaptureChanged(HWND hwnd
)
6143 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6144 TBUTTON_INFO
*btnPtr
;
6146 infoPtr
->bCaptured
= FALSE
;
6148 if (infoPtr
->nButtonDown
>= 0)
6150 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6151 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6153 infoPtr
->nOldHit
= -1;
6155 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
6156 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6162 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6164 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6165 TBUTTON_INFO
*hotBtnPtr
;
6167 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
6169 /* don't remove hot effects when in anchor highlighting mode or when a
6170 * drop-down button is pressed */
6171 if (!infoPtr
->bAnchor
&& (infoPtr
->nOldHit
< 0 || !hotBtnPtr
->bDropDownPressed
))
6172 TOOLBAR_SetHotItemEx(infoPtr
, TOOLBAR_NOWHERE
, HICF_MOUSE
);
6174 if (infoPtr
->nOldHit
< 0)
6177 /* If the last button we were over is depressed then make it not */
6178 /* depressed and redraw it */
6179 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
6181 TBUTTON_INFO
*btnPtr
;
6184 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6186 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6188 rc1
= hotBtnPtr
->rect
;
6189 InflateRect (&rc1
, 1, 1);
6190 InvalidateRect (hwnd
, &rc1
, TRUE
);
6193 if (infoPtr
->bCaptured
&& !infoPtr
->bDragOutSent
)
6196 ZeroMemory(&nmt
, sizeof(nmt
));
6197 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6198 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6199 infoPtr
->bDragOutSent
= TRUE
;
6202 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
6208 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6210 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6212 TRACKMOUSEEVENT trackinfo
;
6214 TBUTTON_INFO
*btnPtr
;
6216 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
) {
6217 /* fill in the TRACKMOUSEEVENT struct */
6218 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
6219 trackinfo
.dwFlags
= TME_QUERY
;
6220 trackinfo
.hwndTrack
= hwnd
;
6221 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
6223 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
6224 _TrackMouseEvent(&trackinfo
);
6226 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
6227 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
6228 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
6230 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
6231 /* and can properly deactivate the hot toolbar button */
6232 _TrackMouseEvent(&trackinfo
);
6236 if (infoPtr
->hwndToolTip
)
6237 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
6238 WM_MOUSEMOVE
, wParam
, lParam
);
6240 pt
.x
= (INT
)LOWORD(lParam
);
6241 pt
.y
= (INT
)HIWORD(lParam
);
6243 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
6245 if ((infoPtr
->dwStyle
& TBSTYLE_FLAT
) && (!infoPtr
->bAnchor
|| (nHit
>= 0)))
6246 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
6248 if (infoPtr
->nOldHit
!= nHit
)
6250 if (infoPtr
->bCaptured
)
6252 if (!infoPtr
->bDragOutSent
)
6255 ZeroMemory(&nmt
, sizeof(nmt
));
6256 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6257 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6258 infoPtr
->bDragOutSent
= TRUE
;
6261 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6262 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
6263 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6264 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6266 else if (nHit
== infoPtr
->nButtonDown
) {
6267 btnPtr
->fsState
|= TBSTATE_PRESSED
;
6268 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6270 infoPtr
->nOldHit
= nHit
;
6278 inline static LRESULT
6279 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6281 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
6282 return DefWindowProcW (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
6284 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
6288 inline static LRESULT
6289 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6291 if (!(GetWindowLongW(hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
6292 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
6294 return DefWindowProcW (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
6299 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6301 TOOLBAR_INFO
*infoPtr
;
6302 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
6305 /* allocate memory for info structure */
6306 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
6307 SetWindowLongPtrW (hwnd
, 0, (LONG_PTR
)infoPtr
);
6310 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
6313 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
6314 if (!GetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
)) {
6315 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW (GetParent (hwnd
), GWLP_HINSTANCE
);
6316 SetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
, (LONG_PTR
)hInst
);
6319 /* native control does:
6320 * Get a lot of colors and brushes
6322 * SystemParametersInfoW(0x1f, 0x3c, adr1, 0)
6323 * CreateFontIndirectW(adr1)
6324 * CreateBitmap(0x27, 0x24, 1, 1, 0)
6325 * hdc = GetDC(toolbar)
6326 * GetSystemMetrics(0x48)
6327 * fnt2=CreateFontW(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
6328 * 0, 0, 0, 0, "MARLETT")
6329 * oldfnt = SelectObject(hdc, fnt2)
6330 * GetCharWidthW(hdc, 0x36, 0x36, adr2)
6331 * GetTextMetricsW(hdc, adr3)
6332 * SelectObject(hdc, oldfnt)
6333 * DeleteObject(fnt2)
6335 * InvalidateRect(toolbar, 0, 1)
6336 * SetWindowLongW(toolbar, 0, addr)
6337 * SetWindowLongW(toolbar, -16, xxx) **sometimes**
6340 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
6341 * ie 2 0x4600094c 0x4600094c 0x4600894d
6342 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
6343 * rebar 0x50008844 0x40008844 0x50008845
6344 * pager 0x50000844 0x40000844 0x50008845
6345 * IC35mgr 0x5400084e **nochange**
6346 * on entry to _NCCREATE 0x5400084e
6347 * rowlist 0x5400004e **nochange**
6348 * on entry to _NCCREATE 0x5400004e
6352 /* I think the code below is a bug, but it is the way that the native
6353 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
6354 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
6355 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
6356 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
6357 * Somehow, the only cases of this seem to be MFC programs.
6359 * Note also that the addition of _TRANSPARENT occurs *only* here. It
6360 * does not occur in the WM_STYLECHANGING routine.
6361 * (Guy Albertelli 9/2001)
6364 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
6365 styleadd
|= TBSTYLE_TRANSPARENT
;
6366 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
6367 styleadd
|= CCS_TOP
; /* default to top */
6368 SetWindowLongW (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
6371 return DefWindowProcW (hwnd
, WM_NCCREATE
, wParam
, lParam
);
6376 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6378 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
6382 if (dwStyle
& WS_MINIMIZE
)
6383 return 0; /* Nothing to do */
6385 DefWindowProcW (hwnd
, WM_NCPAINT
, wParam
, lParam
);
6387 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
6390 if (!(dwStyle
& CCS_NODIVIDER
))
6392 GetWindowRect (hwnd
, &rcWindow
);
6393 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
6394 if( dwStyle
& WS_BORDER
)
6395 OffsetRect (&rcWindow
, 1, 1);
6396 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
6399 ReleaseDC( hwnd
, hdc
);
6405 /* handles requests from the tooltip control on what text to display */
6406 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
6408 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
6410 TRACE("button index = %d\n", index
);
6412 Free (infoPtr
->pszTooltipText
);
6413 infoPtr
->pszTooltipText
= NULL
;
6418 if (infoPtr
->bUnicode
)
6420 WCHAR wszBuffer
[INFOTIPSIZE
+1];
6421 NMTBGETINFOTIPW tbgit
;
6422 unsigned int len
; /* in chars */
6424 wszBuffer
[0] = '\0';
6425 wszBuffer
[INFOTIPSIZE
] = '\0';
6427 tbgit
.pszText
= wszBuffer
;
6428 tbgit
.cchTextMax
= INFOTIPSIZE
;
6429 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6430 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6432 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
6434 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
6436 len
= strlenW(tbgit
.pszText
);
6437 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6439 /* need to allocate temporary buffer in infoPtr as there
6440 * isn't enough space in buffer passed to us by the
6441 * tooltip control */
6442 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6443 if (infoPtr
->pszTooltipText
)
6445 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6446 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6452 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6458 CHAR szBuffer
[INFOTIPSIZE
+1];
6459 NMTBGETINFOTIPA tbgit
;
6460 unsigned int len
; /* in chars */
6463 szBuffer
[INFOTIPSIZE
] = '\0';
6465 tbgit
.pszText
= szBuffer
;
6466 tbgit
.cchTextMax
= INFOTIPSIZE
;
6467 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6468 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6470 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
6472 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
6474 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
6475 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6477 /* need to allocate temporary buffer in infoPtr as there
6478 * isn't enough space in buffer passed to us by the
6479 * tooltip control */
6480 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6481 if (infoPtr
->pszTooltipText
)
6483 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
6484 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6490 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
6495 /* if button has text, but it is not shown then automatically
6496 * use that text as tooltip */
6497 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
6498 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
6500 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
6501 unsigned int len
= pszText
? strlenW(pszText
) : 0;
6503 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
6505 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6507 /* need to allocate temporary buffer in infoPtr as there
6508 * isn't enough space in buffer passed to us by the
6509 * tooltip control */
6510 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6511 if (infoPtr
->pszTooltipText
)
6513 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
6514 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6520 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
6525 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
6527 /* last resort: send notification on to app */
6528 /* FIXME: find out what is really used here */
6529 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
6533 inline static LRESULT
6534 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6536 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6537 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
6539 switch (lpnmh
->code
)
6543 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
6545 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
6546 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
6547 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
6551 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
6552 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
6560 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
6562 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
6563 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
6564 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
6565 lppgs
->iScroll
, lppgs
->iDir
);
6569 case TTN_GETDISPINFOW
:
6570 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
6572 case TTN_GETDISPINFOA
:
6573 FIXME("TTN_GETDISPINFOA - should not be received; please report\n");
6583 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
6587 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
6589 if (lParam
== NF_QUERY
)
6592 if (lParam
== NF_REQUERY
) {
6593 format
= SendMessageW(infoPtr
->hwndNotify
,
6594 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
6595 if ((format
!= NFR_ANSI
) && (format
!= NFR_UNICODE
)) {
6596 ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n",
6607 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
6609 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6613 /* fill ps.rcPaint with a default rect */
6614 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
6616 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
6618 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
6619 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
6620 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
6622 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
6623 if (!wParam
) EndPaint (hwnd
, &ps
);
6630 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6631 /*****************************************************
6634 * Handles the WM_SETREDRAW message.
6637 * According to testing V4.71 of COMCTL32 returns the
6638 * *previous* status of the redraw flag (either 0 or 1)
6639 * instead of the MSDN documented value of 0 if handled.
6640 * (For laughs see the "consistency" with same function
6643 *****************************************************/
6645 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6646 BOOL oldredraw
= infoPtr
->bDoRedraw
;
6648 TRACE("set to %s\n",
6649 (wParam
) ? "TRUE" : "FALSE");
6650 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
6652 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
6654 return (oldredraw
) ? 1 : 0;
6659 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6661 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6662 DWORD dwStyle
= infoPtr
->dwStyle
;
6671 /* Resize deadlock check */
6672 if (infoPtr
->bAutoSize
) {
6673 infoPtr
->bAutoSize
= FALSE
;
6677 /* FIXME: optimize to only update size if the new size doesn't */
6678 /* match the current size */
6680 flags
= (INT
) wParam
;
6682 /* FIXME for flags =
6683 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
6686 TRACE("sizing toolbar!\n");
6688 if (flags
== SIZE_RESTORED
) {
6689 /* width and height don't apply */
6690 parent
= GetParent (hwnd
);
6691 GetClientRect(parent
, &parent_rect
);
6692 x
= parent_rect
.left
;
6693 y
= parent_rect
.top
;
6695 if (dwStyle
& CCS_NORESIZE
) {
6696 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
6699 * this sets the working width of the toolbar, and
6700 * Calc Toolbar will not adjust it, only the height
6702 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6703 cy
= infoPtr
->nHeight
;
6704 cx
= infoPtr
->nWidth
;
6705 TOOLBAR_CalcToolbar (hwnd
);
6706 infoPtr
->nWidth
= cx
;
6707 infoPtr
->nHeight
= cy
;
6710 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6711 TOOLBAR_CalcToolbar (hwnd
);
6712 cy
= infoPtr
->nHeight
;
6713 cx
= infoPtr
->nWidth
;
6715 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
6716 GetWindowRect(hwnd
, &window_rect
);
6717 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
6718 y
= window_rect
.top
;
6720 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6721 GetWindowRect(hwnd
, &window_rect
);
6722 y
= parent_rect
.bottom
-
6723 ( window_rect
.bottom
- window_rect
.top
);
6727 if (dwStyle
& CCS_NOPARENTALIGN
) {
6728 uPosFlags
|= SWP_NOMOVE
;
6729 cy
= infoPtr
->nHeight
;
6730 cx
= infoPtr
->nWidth
;
6733 if (!(dwStyle
& CCS_NODIVIDER
))
6734 cy
+= GetSystemMetrics(SM_CYEDGE
);
6736 if (dwStyle
& WS_BORDER
)
6739 cy
+= GetSystemMetrics(SM_CYEDGE
);
6740 cx
+= GetSystemMetrics(SM_CXEDGE
);
6743 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6745 RECT delta_width
, delta_height
, client
, dummy
;
6746 DWORD min_x
, max_x
, min_y
, max_y
;
6747 TBUTTON_INFO
*btnPtr
;
6750 GetClientRect(hwnd
, &client
);
6751 if(client
.right
> infoPtr
->client_rect
.right
)
6753 min_x
= infoPtr
->client_rect
.right
;
6754 max_x
= client
.right
;
6758 max_x
= infoPtr
->client_rect
.right
;
6759 min_x
= client
.right
;
6761 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6763 min_y
= infoPtr
->client_rect
.bottom
;
6764 max_y
= client
.bottom
;
6768 max_y
= infoPtr
->client_rect
.bottom
;
6769 min_y
= client
.bottom
;
6772 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6773 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6775 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6776 btnPtr
= infoPtr
->buttons
;
6777 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6778 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6779 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6780 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6783 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) != (SWP_NOSIZE
| SWP_NOMOVE
))
6784 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6786 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6792 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6794 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6796 if (nType
== GWL_STYLE
)
6798 if (lpStyle
->styleNew
& TBSTYLE_LIST
)
6799 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
;
6801 infoPtr
->dwDTFlags
= DT_CENTER
| DT_END_ELLIPSIS
;
6803 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6804 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6805 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6807 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6809 infoPtr
->dwStyle
= lpStyle
->styleNew
;
6811 /* only resize if one of the CCS_* styles was changed */
6812 if ((infoPtr
->dwStyle
^ lpStyle
->styleNew
) & COMMON_STYLES
)
6814 TOOLBAR_AutoSize (hwnd
);
6816 InvalidateRect(hwnd
, NULL
, TRUE
);
6825 TOOLBAR_SysColorChange (HWND hwnd
)
6827 COMCTL32_RefreshSysColors();
6834 static LRESULT WINAPI
6835 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6837 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6839 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6840 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6842 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
6843 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
6848 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6850 case TB_ADDBUTTONSA
:
6851 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6853 case TB_ADDBUTTONSW
:
6854 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6857 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6860 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6863 return TOOLBAR_AutoSize (hwnd
);
6865 case TB_BUTTONCOUNT
:
6866 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6868 case TB_BUTTONSTRUCTSIZE
:
6869 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6871 case TB_CHANGEBITMAP
:
6872 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6874 case TB_CHECKBUTTON
:
6875 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6877 case TB_COMMANDTOINDEX
:
6878 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6881 return TOOLBAR_Customize (hwnd
);
6883 case TB_DELETEBUTTON
:
6884 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6886 case TB_ENABLEBUTTON
:
6887 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6889 case TB_GETANCHORHIGHLIGHT
:
6890 return TOOLBAR_GetAnchorHighlight (hwnd
);
6893 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6895 case TB_GETBITMAPFLAGS
:
6896 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6899 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6901 case TB_GETBUTTONINFOA
:
6902 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6904 case TB_GETBUTTONINFOW
:
6905 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6907 case TB_GETBUTTONSIZE
:
6908 return TOOLBAR_GetButtonSize (hwnd
);
6910 case TB_GETBUTTONTEXTA
:
6911 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6913 case TB_GETBUTTONTEXTW
:
6914 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6916 case TB_GETDISABLEDIMAGELIST
:
6917 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6919 case TB_GETEXTENDEDSTYLE
:
6920 return TOOLBAR_GetExtendedStyle (hwnd
);
6922 case TB_GETHOTIMAGELIST
:
6923 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6926 return TOOLBAR_GetHotItem (hwnd
);
6928 case TB_GETIMAGELIST
:
6929 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6931 case TB_GETINSERTMARK
:
6932 return TOOLBAR_GetInsertMark (hwnd
, wParam
, lParam
);
6934 case TB_GETINSERTMARKCOLOR
:
6935 return TOOLBAR_GetInsertMarkColor (hwnd
, wParam
, lParam
);
6937 case TB_GETITEMRECT
:
6938 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6941 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6943 /* case TB_GETOBJECT: */ /* 4.71 */
6946 return TOOLBAR_GetPadding (hwnd
);
6949 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6952 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6955 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6958 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6961 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6964 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6966 case TB_GETTEXTROWS
:
6967 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6969 case TB_GETTOOLTIPS
:
6970 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6972 case TB_GETUNICODEFORMAT
:
6973 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6976 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6979 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6981 case TB_INDETERMINATE
:
6982 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6984 case TB_INSERTBUTTONA
:
6985 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6987 case TB_INSERTBUTTONW
:
6988 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6990 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6992 case TB_ISBUTTONCHECKED
:
6993 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6995 case TB_ISBUTTONENABLED
:
6996 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6998 case TB_ISBUTTONHIDDEN
:
6999 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
7001 case TB_ISBUTTONHIGHLIGHTED
:
7002 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
7004 case TB_ISBUTTONINDETERMINATE
:
7005 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
7007 case TB_ISBUTTONPRESSED
:
7008 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
7011 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
7013 case TB_MAPACCELERATORA
:
7014 case TB_MAPACCELERATORW
:
7015 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
7018 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
7021 return TOOLBAR_MoveButton (hwnd
, wParam
, lParam
);
7023 case TB_PRESSBUTTON
:
7024 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
7026 case TB_REPLACEBITMAP
:
7027 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
7029 case TB_SAVERESTOREA
:
7030 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, (LPTBSAVEPARAMSA
)lParam
);
7032 case TB_SAVERESTOREW
:
7033 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, (LPTBSAVEPARAMSW
)lParam
);
7035 case TB_SETANCHORHIGHLIGHT
:
7036 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
7038 case TB_SETBITMAPSIZE
:
7039 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
7041 case TB_SETBUTTONINFOA
:
7042 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
7044 case TB_SETBUTTONINFOW
:
7045 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
7047 case TB_SETBUTTONSIZE
:
7048 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
7050 case TB_SETBUTTONWIDTH
:
7051 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
7054 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
7056 case TB_SETDISABLEDIMAGELIST
:
7057 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
7059 case TB_SETDRAWTEXTFLAGS
:
7060 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
7062 case TB_SETEXTENDEDSTYLE
:
7063 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
7065 case TB_SETHOTIMAGELIST
:
7066 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
7069 return TOOLBAR_SetHotItem (hwnd
, wParam
);
7071 case TB_SETIMAGELIST
:
7072 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
7075 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
7077 case TB_SETINSERTMARK
:
7078 return TOOLBAR_SetInsertMark (hwnd
, wParam
, lParam
);
7080 case TB_SETINSERTMARKCOLOR
:
7081 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
7083 case TB_SETMAXTEXTROWS
:
7084 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
7087 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
7090 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
7093 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
7096 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
7099 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
7101 case TB_SETTOOLTIPS
:
7102 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
7104 case TB_SETUNICODEFORMAT
:
7105 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
7108 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
7111 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
7114 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
7117 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
7120 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
7123 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
7125 /* Common Control Messages */
7127 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
7128 case CCM_GETCOLORSCHEME
:
7129 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7131 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
7132 case CCM_SETCOLORSCHEME
:
7133 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7135 case CCM_GETVERSION
:
7136 return TOOLBAR_GetVersion (hwnd
);
7138 case CCM_SETVERSION
:
7139 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
7145 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
7148 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
7151 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
7154 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
7156 /* case WM_KEYDOWN: */
7157 /* case WM_KILLFOCUS: */
7159 case WM_LBUTTONDBLCLK
:
7160 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
7162 case WM_LBUTTONDOWN
:
7163 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
7166 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
7169 return TOOLBAR_RButtonUp (hwnd
, wParam
, lParam
);
7171 case WM_RBUTTONDBLCLK
:
7172 return TOOLBAR_RButtonDblClk (hwnd
, wParam
, lParam
);
7175 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
7178 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
7180 case WM_CAPTURECHANGED
:
7181 return TOOLBAR_CaptureChanged(hwnd
);
7184 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
7187 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
7190 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
7193 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
7196 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
7198 case WM_NOTIFYFORMAT
:
7199 return TOOLBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
7202 return TOOLBAR_Paint (hwnd
, wParam
);
7205 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
7208 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
7210 case WM_STYLECHANGED
:
7211 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
7213 case WM_SYSCOLORCHANGE
:
7214 return TOOLBAR_SysColorChange (hwnd
);
7216 /* case WM_WININICHANGE: */
7221 case WM_MEASUREITEM
:
7223 return SendMessageW (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
7225 /* We see this in Outlook Express 5.x and just does DefWindowProc */
7226 case PGM_FORWARDMOUSE
:
7227 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7230 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
7231 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
7232 uMsg
, wParam
, lParam
);
7233 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7239 TOOLBAR_Register (void)
7243 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
7244 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
7245 wndClass
.lpfnWndProc
= ToolbarWindowProc
;
7246 wndClass
.cbClsExtra
= 0;
7247 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
7248 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
7249 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
7250 wndClass
.lpszClassName
= TOOLBARCLASSNAMEW
;
7252 RegisterClassW (&wndClass
);
7257 TOOLBAR_Unregister (void)
7259 UnregisterClassW (TOOLBARCLASSNAMEW
, NULL
);
7262 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
7267 /* Check if the entry already exists */
7268 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
7270 /* If this is a new entry we must create it and insert into the array */
7275 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
7278 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
7279 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
7294 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
7298 for (i
= 0; i
< *cies
; i
++)
7308 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
7316 for (i
= 0; i
< cies
; i
++)
7318 if (pies
[i
]->id
== id
)
7330 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
7332 HIMAGELIST himlDef
= 0;
7333 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
7336 himlDef
= pie
->himl
;
7342 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
7344 if (infoPtr
->bUnicode
)
7345 return TOOLBAR_SendNotify(&nmtb
->hdr
, infoPtr
, TBN_GETBUTTONINFOW
);
7352 nmtba
.iItem
= nmtb
->iItem
;
7353 nmtba
.pszText
= Buffer
;
7354 nmtba
.cchText
= 256;
7355 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
7357 if (TOOLBAR_SendNotify(&nmtba
.hdr
, infoPtr
, TBN_GETBUTTONINFOA
))
7359 int ccht
= strlen(nmtba
.pszText
);
7361 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
7362 nmtb
->pszText
, nmtb
->cchText
);
7364 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
7373 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
7374 int iItem
, PCUSTOMBUTTON btnInfo
)
7378 /* MSDN states that iItem is the index of the button, rather than the
7379 * command ID as used by every other NMTOOLBAR notification */
7381 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
7383 return TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYDELETE
);