4 * Copyright 1998,1999 Eric Kohl
5 * Copyright 2000 Eric Kohl for CodeWeavers
6 * Copyright 2004 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Differences between MSDN and actual native control operation:
25 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
26 * to the right of the bitmap. Otherwise, this style is
27 * identical to TBSTYLE_FLAT."
28 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
29 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
30 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
31 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
33 * This code was audited for completeness against the documented features
34 * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
36 * Unless otherwise noted, we believe this code to be complete, as per
37 * the specification mentioned above.
38 * If you discover missing features or bugs please note them below.
42 * - TBSTYLE_REGISTERDROP
43 * - TBSTYLE_EX_DOUBLEBUFFER
47 * - TB_INSERTMARKHITTEST
55 * - Button wrapping (under construction).
57 * - iListGap custom draw support.
60 * - Run tests using Waite Group Windows95 API Bible Volume 2.
61 * The second cdrom contains executables addstr.exe, btncount.exe,
62 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
63 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
64 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
65 * setparnt.exe, setrows.exe, toolwnd.exe.
66 * - Microsofts controlspy examples.
67 * - Charles Petzold's 'Programming Windows': gadgets.exe
78 #include "wine/unicode.h"
82 #include "wine/debug.h"
84 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
86 static HCURSOR hCursorDrag
= NULL
;
95 BYTE bDropDownPressed
;
100 INT cx
; /* manually set size */
114 } IMLENTRY
, *PIMLENTRY
;
118 DWORD dwStructSize
; /* size of TBBUTTON struct */
119 INT nHeight
; /* height of the toolbar */
120 INT nWidth
; /* width of the toolbar */
122 RECT rcBound
; /* bounding rectangle */
128 INT nRows
; /* number of button rows */
129 INT nMaxTextRows
; /* maximum number of text rows */
130 INT cxMin
; /* minimum button width */
131 INT cxMax
; /* maximum button width */
132 INT nNumButtons
; /* number of buttons */
133 INT nNumBitmaps
; /* number of bitmaps */
134 INT nNumStrings
; /* number of strings */
136 INT nButtonDown
; /* toolbar button being pressed or -1 if none */
137 INT nButtonDrag
; /* toolbar button being dragged or -1 if none */
139 INT nHotItem
; /* index of the "hot" item */
140 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
141 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
142 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
143 SIZE szPadding
; /* padding values around button */
144 INT iListGap
; /* default gap between text and image for toolbar with list style */
146 HFONT hFont
; /* text font */
147 HIMAGELIST himlInt
; /* image list created internally */
148 PIMLENTRY
*himlDef
; /* default image list array */
149 INT cimlDef
; /* default image list array count */
150 PIMLENTRY
*himlHot
; /* hot image list array */
151 INT cimlHot
; /* hot image list array count */
152 PIMLENTRY
*himlDis
; /* disabled image list array */
153 INT cimlDis
; /* disabled image list array count */
154 HWND hwndToolTip
; /* handle to tool tip control */
155 HWND hwndNotify
; /* handle to the window that gets notifications */
156 HWND hwndSelf
; /* my own handle */
157 BOOL bBtnTranspnt
; /* button transparency flag */
158 BOOL bAutoSize
; /* auto size deadlock indicator */
159 BOOL bAnchor
; /* anchor highlight enabled */
160 BOOL bNtfUnicode
; /* TRUE if NOTIFYs use {W} */
161 BOOL bDoRedraw
; /* Redraw status */
162 BOOL bDragOutSent
; /* has TBN_DRAGOUT notification been sent for this drag? */
163 BOOL bUnicode
; /* ASCII (FALSE) or Unicode (TRUE)? */
164 BOOL bCaptured
; /* mouse captured? */
165 DWORD dwStyle
; /* regular toolbar style */
166 DWORD dwExStyle
; /* extended toolbar style */
167 DWORD dwDTFlags
; /* DrawText flags */
169 COLORREF clrInsertMark
; /* insert mark color */
170 COLORREF clrBtnHighlight
; /* color for Flat Separator */
171 COLORREF clrBtnShadow
; /* color for Flag Separator */
173 LPWSTR pszTooltipText
; /* temporary store for a string > 80 characters
174 * for TTN_GETDISPINFOW notification */
175 TBINSERTMARK tbim
; /* info on insertion mark */
176 TBUTTON_INFO
*buttons
; /* pointer to button array */
177 LPWSTR
*strings
; /* pointer to string array */
178 TBITMAP_INFO
*bitmaps
;
179 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
182 /* used by customization dialog */
185 PTOOLBAR_INFO tbInfo
;
187 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
195 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
204 #define SEPARATOR_WIDTH 8
206 #define BOTTOM_BORDER 2
207 #define DDARROW_WIDTH 11
208 #define ARROW_HEIGHT 3
209 #define INSERTMARK_WIDTH 2
211 /* gap between border of button and text/image */
214 /* how wide to treat the bitmap if it isn't present */
215 #define LIST_IMAGE_ABSENT_WIDTH 2
217 #define TOOLBAR_NOWHERE (-1)
219 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongPtrW(hwnd,0))
220 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
221 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
223 static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO
*infoPtr
, INT iListGap
)
225 return GetSystemMetrics(SM_CXEDGE
) + iListGap
- infoPtr
->szPadding
.cx
/2;
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 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
235 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
236 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
237 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
238 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
240 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
241 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
242 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
243 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
244 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
245 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
246 static LRESULT
TOOLBAR_LButtonDown(HWND hwnd
, WPARAM wParam
, LPARAM lParam
);
247 static void TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
);
250 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
254 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
256 LPWSTR lpText
= NULL
;
258 /* NOTE: iString == -1 is undocumented */
259 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
260 lpText
= (LPWSTR
)btnPtr
->iString
;
261 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
262 lpText
= infoPtr
->strings
[btnPtr
->iString
];
268 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
270 if (TRACE_ON(toolbar
)){
271 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
272 btn_num
, bP
->idCommand
, GETIBITMAP(infoPtr
, bP
->iBitmap
),
273 bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
274 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
276 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
277 btn_num
, bP
->idCommand
,
278 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
279 bP
->rect
.left
, bP
->rect
.top
,
280 bP
->rect
.right
, bP
->rect
.bottom
);
286 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
288 if (TRACE_ON(toolbar
)) {
291 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
293 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
294 iP
->nNumStrings
, iP
->dwStyle
);
295 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
297 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
298 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
299 for(i
=0; i
<iP
->nNumButtons
; i
++) {
300 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
306 /***********************************************************************
309 * This function validates that the styles set are implemented and
310 * issues FIXME's warning of possible problems. In a perfect world this
311 * function should be null.
314 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
316 if (dwStyle
& TBSTYLE_REGISTERDROP
)
317 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd
);
322 TOOLBAR_SendNotify (NMHDR
*nmhdr
, TOOLBAR_INFO
*infoPtr
, UINT code
)
324 if(!IsWindow(infoPtr
->hwndSelf
))
325 return 0; /* we have just been destroyed */
327 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
328 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
331 TRACE("to window %p, code=%08x, %s\n", infoPtr
->hwndNotify
, code
,
332 (infoPtr
->bNtfUnicode
) ? "via Unicode" : "via ANSI");
334 if (infoPtr
->bNtfUnicode
)
335 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
336 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
338 return SendMessageA (infoPtr
->hwndNotify
, WM_NOTIFY
,
339 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
342 /***********************************************************************
343 * TOOLBAR_GetBitmapIndex
345 * This function returns the bitmap index associated with a button.
346 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
347 * is issued to retrieve the index.
350 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
352 INT ret
= btnPtr
->iBitmap
;
354 if (ret
== I_IMAGECALLBACK
) {
355 /* issue TBN_GETDISPINFO */
358 nmgd
.idCommand
= btnPtr
->idCommand
;
359 nmgd
.lParam
= btnPtr
->dwData
;
360 nmgd
.dwMask
= TBNF_IMAGE
;
361 TOOLBAR_SendNotify ((NMHDR
*) &nmgd
, infoPtr
,
362 (infoPtr
->bNtfUnicode
) ? TBN_GETDISPINFOW
:
364 if (nmgd
.dwMask
& TBNF_DI_SETITEM
) {
365 btnPtr
->iBitmap
= nmgd
.iImage
;
368 TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
369 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
372 if (ret
!= I_IMAGENONE
)
373 ret
= GETIBITMAP(infoPtr
, ret
);
380 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
383 INT id
= GETHIMLID(infoPtr
, index
);
384 INT iBitmap
= GETIBITMAP(infoPtr
, index
);
386 if (((himl
= GETDEFIMAGELIST(infoPtr
, id
)) &&
387 iBitmap
>= 0 && iBitmap
< ImageList_GetImageCount(himl
)) ||
388 (index
== I_IMAGECALLBACK
))
395 /***********************************************************************
396 * TOOLBAR_GetImageListForDrawing
398 * This function validates the bitmap index (including I_IMAGECALLBACK
399 * functionality) and returns the corresponding image list.
402 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
406 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
407 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
408 ERR("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
409 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
413 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
414 if ((*index
== I_IMAGECALLBACK
) ||
415 (*index
== I_IMAGENONE
)) return NULL
;
416 ERR("TBN_GETDISPINFO returned invalid index %d\n",
423 case IMAGE_LIST_DEFAULT
:
424 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
427 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
429 case IMAGE_LIST_DISABLED
:
430 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
434 FIXME("Shouldn't reach here\n");
438 TRACE("no image list\n");
444 /***********************************************************************
445 * TOOLBAR_TestImageExist
447 * This function is similar to TOOLBAR_GetImageListForDrawing, except it does not
448 * return the image list. The I_IMAGECALLBACK functionality is implemented.
451 TOOLBAR_TestImageExist (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
)
455 if (!himl
) return FALSE
;
457 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
458 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
459 ERR("index %d is not valid, max %d\n",
460 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
464 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
465 if ((index
== I_IMAGECALLBACK
) ||
466 (index
== I_IMAGENONE
)) return FALSE
;
467 ERR("TBN_GETDISPINFO returned invalid index %d\n",
476 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
479 COLORREF oldcolor
, newcolor
;
481 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
482 myrect
.right
= myrect
.left
+ 1;
483 myrect
.top
= lpRect
->top
+ 2;
484 myrect
.bottom
= lpRect
->bottom
- 2;
486 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
487 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
488 oldcolor
= SetBkColor (hdc
, newcolor
);
489 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
491 myrect
.left
= myrect
.right
;
492 myrect
.right
= myrect
.left
+ 1;
494 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
495 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
496 SetBkColor (hdc
, newcolor
);
497 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
499 SetBkColor (hdc
, oldcolor
);
503 /***********************************************************************
504 * TOOLBAR_DrawDDFlatSeparator
506 * This function draws the separator that was flagged as BTNS_DROPDOWN.
507 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
508 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
509 * are horizontal as opposed to the vertical separators for not dropdown
512 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
515 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
518 COLORREF oldcolor
, newcolor
;
520 myrect
.left
= lpRect
->left
;
521 myrect
.right
= lpRect
->right
;
522 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
523 myrect
.bottom
= myrect
.top
+ 1;
525 InflateRect (&myrect
, -2, 0);
527 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
528 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
530 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
531 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
532 oldcolor
= SetBkColor (hdc
, newcolor
);
533 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
535 myrect
.top
= myrect
.bottom
;
536 myrect
.bottom
= myrect
.top
+ 1;
538 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
539 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
540 SetBkColor (hdc
, newcolor
);
541 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
543 SetBkColor (hdc
, oldcolor
);
548 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
553 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
554 hOldPen
= SelectObject ( hdc
, hPen
);
557 MoveToEx (hdc
, x
, y
, NULL
);
558 LineTo (hdc
, x
+5, y
++); x
++;
559 MoveToEx (hdc
, x
, y
, NULL
);
560 LineTo (hdc
, x
+3, y
++); x
++;
561 MoveToEx (hdc
, x
, y
, NULL
);
562 LineTo (hdc
, x
+1, y
++);
563 SelectObject( hdc
, hOldPen
);
564 DeleteObject( hPen
);
568 * Draw the text string for this button.
569 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
570 * is non-zero, so we can simply check himlDef to see if we have
574 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
575 NMTBCUSTOMDRAW
*tbcd
)
577 HDC hdc
= tbcd
->nmcd
.hdc
;
580 COLORREF clrOldBk
= 0;
582 UINT state
= tbcd
->nmcd
.uItemState
;
586 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
587 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
589 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
590 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
591 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
593 else if (state
& CDIS_DISABLED
) {
594 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
595 OffsetRect (rcText
, 1, 1);
596 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
597 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
598 OffsetRect (rcText
, -1, -1);
600 else if (state
& CDIS_INDETERMINATE
) {
601 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
603 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
604 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
605 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
606 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
609 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
612 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
613 SetTextColor (hdc
, clrOld
);
614 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
616 SetBkColor (hdc
, clrOldBk
);
617 SetBkMode (hdc
, oldBkMode
);
619 SelectObject (hdc
, hOldFont
);
625 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
627 HDC hdc
= tbcd
->nmcd
.hdc
;
628 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
631 INT cx
= lpRect
->right
- lpRect
->left
;
632 INT cy
= lpRect
->bottom
- lpRect
->top
;
633 INT cxEdge
= GetSystemMetrics(SM_CXEDGE
);
634 INT cyEdge
= GetSystemMetrics(SM_CYEDGE
);
635 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
636 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
637 PatBlt (hdc
, lpRect
->left
+ cxEdge
, lpRect
->top
+ cyEdge
,
638 cx
- (2 * cxEdge
), cy
- (2 * cyEdge
), PATCOPY
);
639 SetBkColor(hdc
, clrBkOld
);
640 SetTextColor(hdc
, clrTextOld
);
641 SelectObject (hdc
, hbr
);
645 static void TOOLBAR_DrawMasked(HIMAGELIST himl
, int index
, HDC hdc
, INT x
, INT y
, UINT draw_flags
)
648 HBITMAP hbmMask
, hbmImage
;
649 HDC hdcMask
, hdcImage
;
651 ImageList_GetIconSize(himl
, &cx
, &cy
);
653 /* Create src image */
654 hdcImage
= CreateCompatibleDC(hdc
);
655 hbmImage
= CreateCompatibleBitmap(hdc
, cx
, cy
);
656 SelectObject(hdcImage
, hbmImage
);
657 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
658 RGB(0xff, 0xff, 0xff), RGB(0,0,0), draw_flags
);
661 hdcMask
= CreateCompatibleDC(0);
662 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
663 SelectObject(hdcMask
, hbmMask
);
665 /* Remove the background and all white pixels */
666 ImageList_DrawEx(himl
, index
, hdcMask
, 0, 0, cx
, cy
,
667 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_MASK
);
668 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
669 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
671 /* draw the new mask 'etched' to hdc */
672 SetBkColor(hdc
, RGB(255, 255, 255));
673 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
674 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
675 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
676 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
677 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
680 DeleteObject(hbmImage
);
682 DeleteObject (hbmMask
);
688 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
692 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
693 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
694 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
695 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
696 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
697 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
698 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
702 /* draws the image on a toolbar button */
704 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
706 HIMAGELIST himl
= NULL
;
707 BOOL draw_masked
= FALSE
;
710 UINT draw_flags
= ILD_TRANSPARENT
;
712 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
714 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
717 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
721 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (infoPtr
->dwStyle
& TBSTYLE_FLAT
))
723 /* if hot, attempt to draw with hot image list, if fails,
724 use default image list */
725 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
727 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
730 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
735 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
736 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
739 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
740 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
741 draw_flags
|= ILD_BLEND50
;
743 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
744 index
, himl
, left
, top
, offset
);
747 TOOLBAR_DrawMasked (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
749 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
752 /* draws a blank frame for a toolbar button */
754 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
)
756 HDC hdc
= tbcd
->nmcd
.hdc
;
757 RECT rc
= tbcd
->nmcd
.rc
;
758 /* if the state is disabled or indeterminate then the button
759 * cannot have an interactive look like pressed or hot */
760 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
761 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
762 BOOL pressed_look
= !non_interactive_state
&&
763 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
764 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
766 /* app don't want us to draw any edges */
767 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
773 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
774 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
775 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
780 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
782 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
783 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
788 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
, BOOL bDropDownPressed
)
790 HDC hdc
= tbcd
->nmcd
.hdc
;
792 BOOL pressed
= bDropDownPressed
||
793 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
));
795 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
798 DrawEdge (hdc
, rcArrow
, BDR_SUNKENOUTER
, BF_RECT
);
799 else if ( (tbcd
->nmcd
.uItemState
& CDIS_HOT
) &&
800 !(tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) &&
801 !(tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
))
802 DrawEdge (hdc
, rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
807 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
809 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
810 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
814 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
816 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
818 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+1, rcArrow
->top
+1 + (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
819 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
, rcArrow
->top
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
822 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+ offset
, rcArrow
->top
+ offset
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
825 /* draws a complete toolbar button */
827 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
829 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
830 DWORD dwStyle
= infoPtr
->dwStyle
;
831 BOOL hasDropDownArrow
= (TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
832 (btnPtr
->fsStyle
& BTNS_DROPDOWN
)) ||
833 (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
834 BOOL drawSepDropDownArrow
= hasDropDownArrow
&&
835 (~btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
836 RECT rc
, rcArrow
, rcBitmap
, rcText
;
837 LPWSTR lpText
= NULL
;
843 CopyRect (&rcArrow
, &rc
);
844 CopyRect(&rcBitmap
, &rc
);
846 /* get a pointer to the text */
847 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
849 if (hasDropDownArrow
)
853 if (dwStyle
& TBSTYLE_FLAT
)
854 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
856 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
858 if (drawSepDropDownArrow
)
861 rcArrow
.left
= right
;
864 /* copy text rect after adjusting for drop-down arrow
865 * so that text is centred in the rectangle not containing
867 CopyRect(&rcText
, &rc
);
869 /* Center the bitmap horizontally and vertically */
870 if (dwStyle
& TBSTYLE_LIST
)
871 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
);
873 rcBitmap
.left
+=(infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
876 rcBitmap
.top
+= GetSystemMetrics(SM_CYEDGE
);
878 rcBitmap
.top
+=(infoPtr
->nButtonHeight
- infoPtr
->nBitmapHeight
) / 2;
880 TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
881 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
882 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
883 TRACE ("iString: %x\n", btnPtr
->iString
);
884 TRACE ("Stringtext: %s\n", debugstr_w(lpText
));
888 rcText
.left
+= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
889 rcText
.right
-= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
890 if (GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,btnPtr
->iBitmap
)) &&
891 TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
))
893 if (dwStyle
& TBSTYLE_LIST
)
894 rcText
.left
+= infoPtr
->nBitmapWidth
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
896 rcText
.top
+= GetSystemMetrics(SM_CYEDGE
) + OFFSET_Y
+ infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
/2;
899 if (dwStyle
& TBSTYLE_LIST
)
900 rcText
.left
+= LIST_IMAGE_ABSENT_WIDTH
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
902 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
903 (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
)))
904 OffsetRect(&rcText
, 1, 1);
907 /* Initialize fields in all cases, because we use these later
908 * NOTE: applications can and do alter these to customize their
910 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
911 tbcd
.clrText
= comctl32_color
.clrBtnText
;
912 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
913 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
914 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
915 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
916 tbcd
.clrHighlightHotTrack
= 0;
917 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
918 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
919 /* MSDN says that this is the text rectangle.
920 * But (why always a but) tracing of v5.7 of native shows
921 * that this is really a *relative* rectangle based on the
922 * the nmcd.rc. Also the left and top are always 0 ignoring
923 * any bitmap that might be present. */
924 tbcd
.rcText
.left
= 0;
926 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
927 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
928 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
931 tbcd
.hbrMonoDither
= COMCTL32_hPattern55AABrush
;
933 /* FIXME: what are these used for? */
937 /* Issue Item Prepaint notify */
938 infoPtr
->dwItemCustDraw
= 0;
939 infoPtr
->dwItemCDFlag
= 0;
940 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
942 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
943 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
944 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
945 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
946 /* reset these fields so the user can't alter the behaviour like native */
950 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
951 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
952 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
954 /* save the only part of the rect that the user can change */
955 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
956 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
960 if (btnPtr
->fsStyle
& BTNS_SEP
) {
961 /* with the FLAT style, iBitmap is the width and has already */
962 /* been taken into consideration in calculating the width */
963 /* so now we need to draw the vertical separator */
964 /* empirical tests show that iBitmap can/will be non-zero */
965 /* when drawing the vertical bar... */
966 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
967 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
)
968 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
970 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
972 else if (btnPtr
->fsStyle
!= BTNS_SEP
) {
973 FIXME("Draw some kind of separator: fsStyle=%x\n",
979 if (!(tbcd
.nmcd
.uItemState
& CDIS_HOT
) &&
980 ((tbcd
.nmcd
.uItemState
& CDIS_CHECKED
) || (tbcd
.nmcd
.uItemState
& CDIS_INDETERMINATE
)))
981 TOOLBAR_DrawPattern (&rc
, &tbcd
);
983 if ((dwStyle
& TBSTYLE_FLAT
) && (tbcd
.nmcd
.uItemState
& CDIS_HOT
))
985 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
989 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
990 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
991 if (hasDropDownArrow
)
992 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
993 SetBkColor(hdc
, oldclr
);
997 TOOLBAR_DrawFrame(infoPtr
, dwStyle
& TBSTYLE_FLAT
, &tbcd
);
999 if (drawSepDropDownArrow
)
1000 TOOLBAR_DrawSepDDArrow(infoPtr
, &tbcd
, &rcArrow
, btnPtr
->bDropDownPressed
);
1002 if (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) || (btnPtr
->fsStyle
& BTNS_SHOWTEXT
))
1003 TOOLBAR_DrawString (infoPtr
, &rcText
, lpText
, &tbcd
);
1005 TOOLBAR_DrawImage(infoPtr
, btnPtr
, rcBitmap
.left
, rcBitmap
.top
, &tbcd
);
1007 if (hasDropDownArrow
&& !drawSepDropDownArrow
)
1009 if (tbcd
.nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
1011 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1 + (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
1012 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
1014 else if (tbcd
.nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
1016 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
1017 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+ offset
, rcArrow
.top
+ offset
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1020 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1024 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1026 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
1027 tbcd
.nmcd
.hdc
= hdc
;
1029 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
1030 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
1031 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
1032 tbcd
.rcText
= rcText
;
1033 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1034 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1035 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1042 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
1044 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1045 TBUTTON_INFO
*btnPtr
;
1046 INT i
, oldBKmode
= 0;
1047 RECT rcTemp
, rcClient
;
1048 NMTBCUSTOMDRAW tbcd
;
1051 /* the app has told us not to redraw the toolbar */
1052 if (!infoPtr
->bDoRedraw
)
1055 /* if imagelist belongs to the app, it can be changed
1056 by the app after setting it */
1057 if (GETDEFIMAGELIST(infoPtr
, 0) != infoPtr
->himlInt
)
1059 infoPtr
->nNumBitmaps
= 0;
1060 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
1061 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
1064 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1066 /* Send initial notify */
1067 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1068 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
1069 tbcd
.nmcd
.hdc
= hdc
;
1070 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1071 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1072 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
1074 if (infoPtr
->bBtnTranspnt
)
1075 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
1077 GetClientRect(hwnd
, &rcClient
);
1079 /* redraw necessary buttons */
1080 btnPtr
= infoPtr
->buttons
;
1081 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
1084 if (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
1086 IntersectRect(&rcTemp
, &rcClient
, &btnPtr
->rect
);
1087 bDraw
= EqualRect(&rcTemp
, &btnPtr
->rect
);
1091 bDraw
&= IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
));
1092 bDraw
= (btnPtr
->fsState
& TBSTATE_HIDDEN
) ? FALSE
: bDraw
;
1094 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
1097 /* draw insert mark if required */
1098 if (infoPtr
->tbim
.iButton
!= -1)
1100 RECT rcButton
= infoPtr
->buttons
[infoPtr
->tbim
.iButton
].rect
;
1102 rcInsertMark
.top
= rcButton
.top
;
1103 rcInsertMark
.bottom
= rcButton
.bottom
;
1104 if (infoPtr
->tbim
.dwFlags
& TBIMHT_AFTER
)
1105 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.right
;
1107 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.left
- INSERTMARK_WIDTH
;
1108 COMCTL32_DrawInsertMark(hdc
, &rcInsertMark
, infoPtr
->clrInsertMark
, FALSE
);
1111 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
1112 SetBkMode (hdc
, oldBKmode
);
1114 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1116 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1117 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
1118 tbcd
.nmcd
.hdc
= hdc
;
1119 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1120 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1124 /***********************************************************************
1125 * TOOLBAR_MeasureString
1127 * This function gets the width and height of a string in pixels. This
1128 * is done first by using GetTextExtentPoint to get the basic width
1129 * and height. The DrawText is called with DT_CALCRECT to get the exact
1130 * width. The reason is because the text may have more than one "&" (or
1131 * prefix characters as M$ likes to call them). The prefix character
1132 * indicates where the underline goes, except for the string "&&" which
1133 * is reduced to a single "&". GetTextExtentPoint does not process these
1134 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
1137 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
1138 HDC hdc
, LPSIZE lpSize
)
1145 if (infoPtr
->nMaxTextRows
> 0 &&
1146 !(btnPtr
->fsState
& TBSTATE_HIDDEN
) &&
1147 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1148 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
1150 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1152 if(lpText
!= NULL
) {
1153 /* first get size of all the text */
1154 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1156 /* feed above size into the rectangle for DrawText */
1157 myrect
.left
= myrect
.top
= 0;
1158 myrect
.right
= lpSize
->cx
;
1159 myrect
.bottom
= lpSize
->cy
;
1161 /* Use DrawText to get true size as drawn (less pesky "&") */
1162 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1163 DT_CALCRECT
| ((btnPtr
->fsStyle
& BTNS_NOPREFIX
) ?
1166 /* feed back to caller */
1167 lpSize
->cx
= myrect
.right
;
1168 lpSize
->cy
= myrect
.bottom
;
1172 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1175 /***********************************************************************
1176 * TOOLBAR_CalcStrings
1178 * This function walks through each string and measures it and returns
1179 * the largest height and width to caller.
1182 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1184 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1185 TBUTTON_INFO
*btnPtr
;
1194 if(infoPtr
->nMaxTextRows
== 0)
1198 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1200 btnPtr
= infoPtr
->buttons
;
1201 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1202 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1204 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1205 if (sz
.cx
> lpSize
->cx
)
1207 if (sz
.cy
> lpSize
->cy
)
1212 SelectObject (hdc
, hOldFont
);
1213 ReleaseDC (hwnd
, hdc
);
1215 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1218 /***********************************************************************
1219 * TOOLBAR_WrapToolbar
1221 * This function walks through the buttons and separators in the
1222 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1223 * wrapping should occur based on the width of the toolbar window.
1224 * It does *not* calculate button placement itself. That task
1225 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1226 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1227 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1229 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1230 * vertical toolbar lists.
1234 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1236 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1237 TBUTTON_INFO
*btnPtr
;
1240 BOOL bWrap
, bButtonWrap
;
1242 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1243 /* no layout is necessary. Applications may use this style */
1244 /* to perform their own layout on the toolbar. */
1245 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1246 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1248 btnPtr
= infoPtr
->buttons
;
1249 x
= infoPtr
->nIndent
;
1251 /* this can get the parents width, to know how far we can extend
1252 * this toolbar. We cannot use its height, as there may be multiple
1253 * toolbars in a rebar control
1255 GetClientRect( GetParent(hwnd
), &rc
);
1256 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1257 bButtonWrap
= FALSE
;
1259 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1260 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1263 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1266 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1268 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1271 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1272 /* it is the actual width of the separator. This is used for */
1273 /* custom controls in toolbars. */
1275 /* BTNS_DROPDOWN separators are treated as buttons for */
1276 /* width. - GA 8/01 */
1277 if ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1278 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
))
1279 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1280 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1282 cx
= infoPtr
->nButtonWidth
;
1284 /* Two or more adjacent separators form a separator group. */
1285 /* The first separator in a group should be wrapped to the */
1286 /* next row if the previous wrapping is on a button. */
1288 (btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1289 (i
+ 1 < infoPtr
->nNumButtons
) &&
1290 (btnPtr
[i
+ 1].fsStyle
& BTNS_SEP
) )
1292 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1293 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1294 x
= infoPtr
->nIndent
;
1296 bButtonWrap
= FALSE
;
1300 /* The layout makes sure the bitmap is visible, but not the button. */
1301 /* Test added to also wrap after a button that starts a row but */
1302 /* is bigger than the area. - GA 8/01 */
1303 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1304 > infoPtr
->nWidth
) ||
1305 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1307 BOOL bFound
= FALSE
;
1309 /* If the current button is a separator and not hidden, */
1310 /* go to the next until it reaches a non separator. */
1311 /* Wrap the last separator if it is before a button. */
1312 while( ( ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1313 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
)) ||
1314 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1315 i
< infoPtr
->nNumButtons
)
1321 if( bFound
&& i
< infoPtr
->nNumButtons
)
1324 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1325 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1326 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1327 x
= infoPtr
->nIndent
;
1328 bButtonWrap
= FALSE
;
1331 else if ( i
>= infoPtr
->nNumButtons
)
1334 /* If the current button is not a separator, find the last */
1335 /* separator and wrap it. */
1336 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1338 if ((btnPtr
[j
].fsStyle
& BTNS_SEP
) &&
1339 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1343 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1344 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1345 x
= infoPtr
->nIndent
;
1346 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1347 bButtonWrap
= FALSE
;
1352 /* If no separator available for wrapping, wrap one of */
1353 /* non-hidden previous button. */
1357 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1359 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1364 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1365 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1366 x
= infoPtr
->nIndent
;
1367 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1373 /* If all above failed, wrap the current button. */
1376 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1377 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1378 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1380 x
= infoPtr
->nIndent
;
1381 if (btnPtr
[i
].fsStyle
& BTNS_SEP
)
1382 bButtonWrap
= FALSE
;
1388 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1389 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1396 /***********************************************************************
1397 * TOOLBAR_CalcToolbar
1399 * This function calculates button and separator placement. It first
1400 * calculates the button sizes, gets the toolbar window width and then
1401 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1402 * on. It assigns a new location to each item and sends this location to
1403 * the tooltip window if appropriate. Finally, it updates the rcBound
1404 * rect and calculates the new required toolbar window height.
1408 TOOLBAR_CalcToolbar (HWND hwnd
)
1410 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1411 DWORD dwStyle
= infoPtr
->dwStyle
;
1412 TBUTTON_INFO
*btnPtr
;
1413 INT i
, nRows
, nSepRows
;
1417 BOOL usesBitmaps
= FALSE
;
1418 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1420 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1422 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1424 for (i
= 0; i
< infoPtr
->nNumButtons
&& !usesBitmaps
; i
++)
1426 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,infoPtr
->buttons
[i
].iBitmap
))
1429 if (dwStyle
& TBSTYLE_LIST
)
1431 infoPtr
->nButtonHeight
= max((usesBitmaps
) ? infoPtr
->nBitmapHeight
:
1432 0, sizeString
.cy
) + infoPtr
->szPadding
.cy
;
1433 infoPtr
->nButtonWidth
= ((usesBitmaps
) ? infoPtr
->nBitmapWidth
:
1434 LIST_IMAGE_ABSENT_WIDTH
) + sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1435 if (sizeString
.cx
> 0)
1436 infoPtr
->nButtonWidth
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1437 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1438 infoPtr
->nButtonWidth
, infoPtr
->nButtonHeight
, usesBitmaps
,
1439 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
1442 if (sizeString
.cy
> 0)
1445 infoPtr
->nButtonHeight
= sizeString
.cy
+
1446 infoPtr
->szPadding
.cy
/2 + /* this is the space to separate text from bitmap */
1447 infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1449 infoPtr
->nButtonHeight
= sizeString
.cy
+ infoPtr
->szPadding
.cy
;
1452 infoPtr
->nButtonHeight
= infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1454 if (sizeString
.cx
> infoPtr
->nBitmapWidth
)
1455 infoPtr
->nButtonWidth
= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1457 infoPtr
->nButtonWidth
= infoPtr
->nBitmapWidth
+ infoPtr
->szPadding
.cx
;
1460 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1461 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1462 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1463 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1465 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1467 x
= infoPtr
->nIndent
;
1470 /* from above, minimum is a button, and possible text */
1471 cx
= infoPtr
->nButtonWidth
;
1473 /* cannot use just ButtonHeight, we may have no buttons! */
1474 if (infoPtr
->nNumButtons
> 0)
1475 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1477 cy
= infoPtr
->nHeight
;
1479 nRows
= nSepRows
= 0;
1481 infoPtr
->rcBound
.top
= y
;
1482 infoPtr
->rcBound
.left
= x
;
1483 infoPtr
->rcBound
.bottom
= y
+ cy
;
1484 infoPtr
->rcBound
.right
= x
;
1486 btnPtr
= infoPtr
->buttons
;
1488 TRACE("cy=%d\n", cy
);
1490 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1493 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1495 SetRectEmpty (&btnPtr
->rect
);
1499 cy
= infoPtr
->nHeight
;
1501 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1502 /* it is the actual width of the separator. This is used for */
1503 /* custom controls in toolbars. */
1504 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1505 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
) {
1506 cy
= (btnPtr
->iBitmap
> 0) ?
1507 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1508 cx
= infoPtr
->nButtonWidth
;
1511 cx
= (btnPtr
->iBitmap
> 0) ?
1512 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1518 else if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1519 (btnPtr
->fsStyle
& BTNS_AUTOSIZE
))
1526 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1528 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1530 SelectObject (hdc
, hOldFont
);
1531 ReleaseDC (hwnd
, hdc
);
1533 /* add space on for button frame, etc */
1534 cx
= sz
.cx
+ infoPtr
->szPadding
.cx
;
1536 /* add list padding */
1537 if ((dwStyle
& TBSTYLE_LIST
) && sz
.cx
> 0)
1538 cx
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1540 if (TOOLBAR_TestImageExist (infoPtr
, btnPtr
, GETDEFIMAGELIST(infoPtr
,0)))
1542 if (dwStyle
& TBSTYLE_LIST
)
1543 cx
+= infoPtr
->nBitmapWidth
;
1544 else if (cx
< (infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
))
1545 cx
= infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
;
1547 else if (dwStyle
& TBSTYLE_LIST
)
1548 cx
+= LIST_IMAGE_ABSENT_WIDTH
;
1551 cx
= infoPtr
->nButtonWidth
;
1553 /* if size has been set manually then don't add on extra space
1554 * for the drop down arrow */
1555 if (!btnPtr
->cx
&& hasDropDownArrows
&&
1556 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) || (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)))
1557 cx
+= DDARROW_WIDTH
;
1559 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1562 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1564 if (infoPtr
->rcBound
.left
> x
)
1565 infoPtr
->rcBound
.left
= x
;
1566 if (infoPtr
->rcBound
.right
< x
+ cx
)
1567 infoPtr
->rcBound
.right
= x
+ cx
;
1568 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1569 infoPtr
->rcBound
.bottom
= y
+ cy
;
1571 /* Set the toolTip only for non-hidden, non-separator button */
1572 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& BTNS_SEP
))
1576 ZeroMemory (&ti
, sizeof(ti
));
1577 ti
.cbSize
= sizeof(ti
);
1579 ti
.uId
= btnPtr
->idCommand
;
1580 ti
.rect
= btnPtr
->rect
;
1581 SendMessageW (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTW
,
1585 /* btnPtr->nRow is zero based. The space between the rows is */
1586 /* also considered as a row. */
1587 btnPtr
->nRow
= nRows
+ nSepRows
;
1589 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1590 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1595 if ( !(btnPtr
->fsStyle
& BTNS_SEP
) )
1599 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1600 /* it is the actual width of the separator. This is used for */
1601 /* custom controls in toolbars. */
1602 if ( !(btnPtr
->fsStyle
& BTNS_DROPDOWN
))
1603 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1604 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1608 /* nSepRows is used to calculate the extra height follwoing */
1612 x
= infoPtr
->nIndent
;
1614 /* Increment row number unless this is the last button */
1615 /* and it has Wrap set. */
1616 if (i
!= infoPtr
->nNumButtons
-1)
1623 /* infoPtr->nRows is the number of rows on the toolbar */
1624 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1627 /********************************************************************
1628 * The following while interesting, does not match the values *
1629 * created above for the button rectangles, nor the rcBound rect. *
1630 * We will comment it out and remove it later. *
1632 * The problem showed up as heights in the pager control that was *
1634 ********************************************************************/
1636 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1638 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1639 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1640 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1644 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1646 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1651 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1653 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1654 TBUTTON_INFO
*btnPtr
;
1657 btnPtr
= infoPtr
->buttons
;
1658 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1659 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1662 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1663 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1664 TRACE(" ON SEPARATOR %d!\n", i
);
1669 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1670 TRACE(" ON BUTTON %d!\n", i
);
1676 TRACE(" NOWHERE!\n");
1677 return TOOLBAR_NOWHERE
;
1682 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1684 TBUTTON_INFO
*btnPtr
;
1687 if (CommandIsIndex
) {
1688 TRACE("command is really index command=%d\n", idCommand
);
1689 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1692 btnPtr
= infoPtr
->buttons
;
1693 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1694 if (btnPtr
->idCommand
== idCommand
) {
1695 TRACE("command=%d index=%d\n", idCommand
, i
);
1699 TRACE("no index found for command=%d\n", idCommand
);
1705 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1707 TBUTTON_INFO
*btnPtr
;
1710 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1713 /* check index button */
1714 btnPtr
= &infoPtr
->buttons
[nIndex
];
1715 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1716 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1720 /* check previous buttons */
1721 nRunIndex
= nIndex
- 1;
1722 while (nRunIndex
>= 0) {
1723 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1724 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1725 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1733 /* check next buttons */
1734 nRunIndex
= nIndex
+ 1;
1735 while (nRunIndex
< infoPtr
->nNumButtons
) {
1736 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1737 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1738 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1751 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1752 WPARAM wParam
, LPARAM lParam
)
1758 msg
.wParam
= wParam
;
1759 msg
.lParam
= lParam
;
1760 msg
.time
= GetMessageTime ();
1761 msg
.pt
.x
= LOWORD(GetMessagePos ());
1762 msg
.pt
.y
= HIWORD(GetMessagePos ());
1764 SendMessageW (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1767 /* keeps available button list box sorted by button id */
1768 static void TOOLBAR_Cust_InsertAvailButton(HWND hwnd
, PCUSTOMBUTTON btnInfoNew
)
1772 PCUSTOMBUTTON btnInfo
;
1773 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1775 TRACE("button %s, idCommand %d\n", debugstr_w(btnInfoNew
->text
), btnInfoNew
->btn
.idCommand
);
1777 count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1779 /* position 0 is always separator */
1780 for (i
= 1; i
< count
; i
++)
1782 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, i
, 0);
1783 if (btnInfoNew
->btn
.idCommand
< btnInfo
->btn
.idCommand
)
1785 i
= SendMessageW(hwndAvail
, LB_INSERTSTRING
, i
, 0);
1786 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1790 /* id higher than all others add to end */
1791 i
= SendMessageW(hwndAvail
, LB_ADDSTRING
, 0, 0);
1792 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1795 static void TOOLBAR_Cust_MoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexFrom
, INT nIndexTo
)
1799 TRACE("index from %d, index to %d\n", nIndexFrom
, nIndexTo
);
1801 if (nIndexFrom
== nIndexTo
)
1804 /* MSDN states that iItem is the index of the button, rather than the
1805 * command ID as used by every other NMTOOLBAR notification */
1806 nmtb
.iItem
= nIndexFrom
;
1807 if (TOOLBAR_SendNotify((NMHDR
*)&nmtb
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1809 PCUSTOMBUTTON btnInfo
;
1811 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1812 int count
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1814 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, nIndexFrom
, 0);
1816 SendMessageW(hwndList
, LB_DELETESTRING
, nIndexFrom
, 0);
1817 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1818 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1819 SendMessageW(hwndList
, LB_SETCURSEL
, nIndexTo
, 0);
1822 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1824 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1826 /* last item is always separator, so -2 instead of -1 */
1827 if (nIndexTo
>= (count
- 2))
1828 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1830 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1832 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, nIndexFrom
, 0);
1833 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1835 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1839 static void TOOLBAR_Cust_AddButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexAvail
, INT nIndexTo
)
1843 TRACE("Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail
, nIndexTo
);
1845 /* MSDN states that iItem is the index of the button, rather than the
1846 * command ID as used by every other NMTOOLBAR notification */
1847 nmtb
.iItem
= nIndexAvail
;
1848 if (TOOLBAR_SendNotify((NMHDR
*)&nmtb
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1850 PCUSTOMBUTTON btnInfo
;
1852 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1853 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1854 int count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1856 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, nIndexAvail
, 0);
1858 if (nIndexAvail
!= 0) /* index == 0 indicates separator */
1860 /* remove from 'available buttons' list */
1861 SendMessageW(hwndAvail
, LB_DELETESTRING
, nIndexAvail
, 0);
1862 if (nIndexAvail
== count
-1)
1863 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
-1 , 0);
1865 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
, 0);
1869 PCUSTOMBUTTON btnNew
;
1871 /* duplicate 'separator' button */
1872 btnNew
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1873 memcpy(btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
1877 /* insert into 'toolbar button' list */
1878 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1879 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1881 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1883 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1887 static void TOOLBAR_Cust_RemoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT index
)
1889 PCUSTOMBUTTON btnInfo
;
1890 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1892 TRACE("Remove: index %d\n", index
);
1894 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, index
, 0);
1896 /* send TBN_QUERYDELETE notification */
1897 if (TOOLBAR_IsButtonRemovable(custInfo
->tbInfo
, index
, btnInfo
))
1901 SendMessageW(hwndList
, LB_DELETESTRING
, index
, 0);
1902 SendMessageW(hwndList
, LB_SETCURSEL
, index
, 0);
1904 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1906 /* insert into 'available button' list */
1907 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
1908 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
1912 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1916 /* drag list notification function for toolbar buttons list box */
1917 static LRESULT
TOOLBAR_Cust_ToolbarDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
1919 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1920 switch (pDLI
->uNotification
)
1924 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
1925 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1926 /* no dragging for last item (separator) */
1927 if (nCurrentItem
>= (nCount
- 1)) return FALSE
;
1932 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
1933 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1934 /* no dragging past last item (separator) */
1935 if ((nCurrentItem
>= 0) && (nCurrentItem
< (nCount
- 1)))
1937 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
1938 /* FIXME: native uses "move button" cursor */
1939 return DL_COPYCURSOR
;
1942 /* not over toolbar buttons list */
1943 if (nCurrentItem
< 0)
1945 POINT ptWindow
= pDLI
->ptCursor
;
1946 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1947 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
1948 /* over available buttons list? */
1949 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
1950 /* FIXME: native uses "move button" cursor */
1951 return DL_COPYCURSOR
;
1953 /* clear drag arrow */
1954 DrawInsert(hwnd
, hwndList
, -1);
1955 return DL_STOPCURSOR
;
1959 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
1960 INT nIndexFrom
= SendMessageW(hwndList
, LB_GETCURSEL
, 0, 0);
1961 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1962 if ((nIndexTo
>= 0) && (nIndexTo
< (nCount
- 1)))
1964 /* clear drag arrow */
1965 DrawInsert(hwnd
, hwndList
, -1);
1967 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
1969 /* not over toolbar buttons list */
1972 POINT ptWindow
= pDLI
->ptCursor
;
1973 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1974 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
1975 /* over available buttons list? */
1976 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
1977 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, nIndexFrom
);
1982 /* Clear drag arrow */
1983 DrawInsert(hwnd
, hwndList
, -1);
1990 /* drag list notification function for available buttons list box */
1991 static LRESULT
TOOLBAR_Cust_AvailDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
1993 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1994 switch (pDLI
->uNotification
)
2000 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2001 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2002 /* no dragging past last item (separator) */
2003 if ((nCurrentItem
>= 0) && (nCurrentItem
< nCount
))
2005 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
2006 /* FIXME: native uses "move button" cursor */
2007 return DL_COPYCURSOR
;
2010 /* not over toolbar buttons list */
2011 if (nCurrentItem
< 0)
2013 POINT ptWindow
= pDLI
->ptCursor
;
2014 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2015 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2016 /* over available buttons list? */
2017 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2018 /* FIXME: native uses "move button" cursor */
2019 return DL_COPYCURSOR
;
2021 /* clear drag arrow */
2022 DrawInsert(hwnd
, hwndList
, -1);
2023 return DL_STOPCURSOR
;
2027 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2028 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2029 INT nIndexFrom
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2030 if ((nIndexTo
>= 0) && (nIndexTo
< nCount
))
2032 /* clear drag arrow */
2033 DrawInsert(hwnd
, hwndList
, -1);
2035 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
2039 /* Clear drag arrow */
2040 DrawInsert(hwnd
, hwndList
, -1);
2046 extern UINT uDragListMessage
;
2048 /***********************************************************************
2049 * TOOLBAR_CustomizeDialogProc
2050 * This function implements the toolbar customization dialog.
2052 static INT_PTR CALLBACK
2053 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2055 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongPtrW (hwnd
, DWLP_USER
);
2056 PCUSTOMBUTTON btnInfo
;
2058 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
2063 custInfo
= (PCUSTDLG_INFO
)lParam
;
2064 SetWindowLongPtrW (hwnd
, DWLP_USER
, (LONG_PTR
)custInfo
);
2072 infoPtr
= custInfo
->tbInfo
;
2074 /* send TBN_QUERYINSERT notification */
2075 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
2077 if (!TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYINSERT
))
2080 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
2081 nmtb
.iItem
= (int)hwnd
;
2082 /* Send TBN_INITCUSTOMIZE notification */
2083 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_INITCUSTOMIZE
) ==
2086 TRACE("TBNRF_HIDEHELP requested\n");
2087 ShowWindow(GetDlgItem(hwnd
, IDC_HELP_BTN
), SW_HIDE
);
2090 /* add items to 'toolbar buttons' list and check if removable */
2091 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
2093 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2094 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2095 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2096 btnInfo
->bVirtual
= FALSE
;
2097 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2099 /* send TBN_QUERYDELETE notification */
2100 btnInfo
->bRemovable
= TOOLBAR_IsButtonRemovable(infoPtr
, i
, btnInfo
);
2102 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2103 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2106 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2108 /* insert separator button into 'available buttons' list */
2109 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2110 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2111 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2112 btnInfo
->bVirtual
= FALSE
;
2113 btnInfo
->bRemovable
= TRUE
;
2114 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2115 index
= (int)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2116 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2118 /* insert all buttons into dsa */
2121 /* send TBN_GETBUTTONINFO notification */
2124 nmtb
.pszText
= Buffer
;
2127 /* Clear previous button's text */
2128 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
2130 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
2133 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
2134 nmtb
.tbButton
.fsStyle
, i
,
2135 nmtb
.tbButton
.idCommand
,
2136 nmtb
.tbButton
.iString
,
2137 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
2140 /* insert button into the apropriate list */
2141 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
2144 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2145 btnInfo
->bVirtual
= FALSE
;
2146 btnInfo
->bRemovable
= TRUE
;
2150 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
,
2151 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2154 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
2155 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
2157 if (lstrlenW(nmtb
.pszText
))
2158 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
2159 else if (nmtb
.tbButton
.iString
>= 0 &&
2160 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
2162 lstrcpyW(btnInfo
->text
,
2163 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
2168 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
2171 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2173 /* select first item in the 'available' list */
2174 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
2176 /* append 'virtual' separator button to the 'toolbar buttons' list */
2177 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2178 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2179 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2180 btnInfo
->bVirtual
= TRUE
;
2181 btnInfo
->bRemovable
= FALSE
;
2182 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2183 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2184 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2186 /* select last item in the 'toolbar' list */
2187 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2188 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
2190 MakeDragList(GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
));
2191 MakeDragList(GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
));
2193 /* set focus and disable buttons */
2194 PostMessageW (hwnd
, WM_USER
, 0, 0);
2199 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2200 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2201 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
2202 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
2206 EndDialog(hwnd
, FALSE
);
2210 switch (LOWORD(wParam
))
2212 case IDC_TOOLBARBTN_LBOX
:
2213 if (HIWORD(wParam
) == LBN_SELCHANGE
)
2215 PCUSTOMBUTTON btnInfo
;
2220 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2221 index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2223 /* send TBN_QUERYINSERT notification */
2225 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2228 /* get list box item */
2229 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2231 if (index
== (count
- 1))
2233 /* last item (virtual separator) */
2234 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2235 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2237 else if (index
== (count
- 2))
2239 /* second last item (last non-virtual item) */
2240 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2241 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2243 else if (index
== 0)
2246 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2247 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2251 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2252 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2255 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
2259 case IDC_MOVEUP_BTN
:
2261 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2262 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
-1);
2266 case IDC_MOVEDN_BTN
: /* move down */
2268 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2269 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
+1);
2273 case IDC_REMOVE_BTN
: /* remove button */
2275 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2277 if (LB_ERR
== index
)
2280 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, index
);
2284 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2287 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2290 case IDOK
: /* Add button */
2295 index
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2296 indexto
= SendDlgItemMessageW(hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2298 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, index
, indexto
);
2303 EndDialog(hwnd
, FALSE
);
2313 /* delete items from 'toolbar buttons' listbox*/
2314 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2315 for (i
= 0; i
< count
; i
++)
2317 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2319 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2321 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2324 /* delete items from 'available buttons' listbox*/
2325 count
= SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2326 for (i
= 0; i
< count
; i
++)
2328 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2330 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2332 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2337 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2339 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2344 COLORREF oldText
= 0;
2348 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2349 if (btnInfo
== NULL
)
2351 FIXME("btnInfo invalid!\n");
2355 /* set colors and select objects */
2356 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2357 if (btnInfo
->bVirtual
)
2358 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2360 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2361 hPen
= CreatePen( PS_SOLID
, 1,
2362 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2363 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2364 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2366 /* fill background rectangle */
2367 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2368 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2370 /* calculate button and text rectangles */
2371 CopyRect (&rcButton
, &lpdis
->rcItem
);
2372 InflateRect (&rcButton
, -1, -1);
2373 CopyRect (&rcText
, &rcButton
);
2374 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2375 rcText
.left
= rcButton
.right
+ 2;
2377 /* draw focus rectangle */
2378 if (lpdis
->itemState
& ODS_FOCUS
)
2379 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2382 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
2383 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2385 /* draw image and text */
2386 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2387 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2388 btnInfo
->btn
.iBitmap
));
2389 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2390 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2392 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2393 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2395 /* delete objects and reset colors */
2396 SelectObject (lpdis
->hDC
, hOldBrush
);
2397 SelectObject (lpdis
->hDC
, hOldPen
);
2398 SetBkColor (lpdis
->hDC
, oldBk
);
2399 SetTextColor (lpdis
->hDC
, oldText
);
2400 DeleteObject( hPen
);
2405 case WM_MEASUREITEM
:
2406 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2408 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2410 lpmis
->itemHeight
= 15 + 8; /* default height */
2417 if (uDragListMessage
&& (uMsg
== uDragListMessage
))
2419 if (wParam
== IDC_TOOLBARBTN_LBOX
)
2421 LRESULT res
= TOOLBAR_Cust_ToolbarDragListNotification(
2422 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2423 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2426 else if (wParam
== IDC_AVAILBTN_LBOX
)
2428 LRESULT res
= TOOLBAR_Cust_AvailDragListNotification(
2429 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2430 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2439 /***********************************************************************
2440 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2444 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2446 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2447 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2448 INT nIndex
= 0, nButtons
, nCount
;
2452 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2456 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2458 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2460 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2462 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2467 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2469 /* Windows resize all the buttons to the size of a newly added standard image */
2470 if (lpAddBmp
->nID
& 1)
2473 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2474 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2476 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2477 MAKELPARAM((WORD
)24, (WORD
)24));
2478 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2479 MAKELPARAM((WORD
)31, (WORD
)30));
2484 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2485 MAKELPARAM((WORD
)16, (WORD
)16));
2486 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2487 MAKELPARAM((WORD
)22, (WORD
)22));
2490 TOOLBAR_CalcToolbar (hwnd
);
2494 nButtons
= (INT
)wParam
;
2498 TRACE ("adding %d bitmaps!\n", nButtons
);
2501 if (!infoPtr
->cimlDef
) {
2502 /* create new default image list */
2503 TRACE ("creating default image list!\n");
2505 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2506 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2507 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2508 infoPtr
->himlInt
= himlDef
;
2511 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2515 WARN("No default image list available\n");
2519 nCount
= ImageList_GetImageCount(himlDef
);
2521 /* Add bitmaps to the default image list */
2522 if (lpAddBmp
->hInst
== NULL
)
2525 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2526 HDC hdcImage
, hdcBitmap
;
2528 /* copy the bitmap before adding it so that the user's bitmap
2529 * doesn't get modified.
2531 GetObjectA ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2533 hdcImage
= CreateCompatibleDC(0);
2534 hdcBitmap
= CreateCompatibleDC(0);
2536 /* create new bitmap */
2537 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2538 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2539 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2541 /* Copy the user's image */
2542 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2543 hdcBitmap
, 0, 0, SRCCOPY
);
2545 SelectObject (hdcImage
, hOldBitmapLoad
);
2546 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2547 DeleteDC (hdcImage
);
2548 DeleteDC (hdcBitmap
);
2550 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2551 DeleteObject (hbmLoad
);
2553 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2555 /* Add system bitmaps */
2556 switch (lpAddBmp
->nID
)
2558 case IDB_STD_SMALL_COLOR
:
2559 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2560 MAKEINTRESOURCEA(IDB_STD_SMALL
));
2561 nIndex
= ImageList_AddMasked (himlDef
,
2562 hbmLoad
, comctl32_color
.clrBtnFace
);
2563 DeleteObject (hbmLoad
);
2566 case IDB_STD_LARGE_COLOR
:
2567 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2568 MAKEINTRESOURCEA(IDB_STD_LARGE
));
2569 nIndex
= ImageList_AddMasked (himlDef
,
2570 hbmLoad
, comctl32_color
.clrBtnFace
);
2571 DeleteObject (hbmLoad
);
2574 case IDB_VIEW_SMALL_COLOR
:
2575 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2576 MAKEINTRESOURCEA(IDB_VIEW_SMALL
));
2577 nIndex
= ImageList_AddMasked (himlDef
,
2578 hbmLoad
, comctl32_color
.clrBtnFace
);
2579 DeleteObject (hbmLoad
);
2582 case IDB_VIEW_LARGE_COLOR
:
2583 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2584 MAKEINTRESOURCEA(IDB_VIEW_LARGE
));
2585 nIndex
= ImageList_AddMasked (himlDef
,
2586 hbmLoad
, comctl32_color
.clrBtnFace
);
2587 DeleteObject (hbmLoad
);
2590 case IDB_HIST_SMALL_COLOR
:
2591 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2592 MAKEINTRESOURCEA(IDB_HIST_SMALL
));
2593 nIndex
= ImageList_AddMasked (himlDef
,
2594 hbmLoad
, comctl32_color
.clrBtnFace
);
2595 DeleteObject (hbmLoad
);
2598 case IDB_HIST_LARGE_COLOR
:
2599 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2600 MAKEINTRESOURCEA(IDB_HIST_LARGE
));
2601 nIndex
= ImageList_AddMasked (himlDef
,
2602 hbmLoad
, comctl32_color
.clrBtnFace
);
2603 DeleteObject (hbmLoad
);
2607 nIndex
= ImageList_GetImageCount (himlDef
);
2608 ERR ("invalid imagelist!\n");
2614 hbmLoad
= LoadBitmapA (lpAddBmp
->hInst
, (LPSTR
)lpAddBmp
->nID
);
2615 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2616 DeleteObject (hbmLoad
);
2619 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2621 if (infoPtr
->nNumBitmapInfos
== 0)
2623 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2627 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2628 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2629 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
);
2632 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2633 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2634 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2636 infoPtr
->nNumBitmapInfos
++;
2637 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2641 INT imagecount
= ImageList_GetImageCount(himlDef
);
2643 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2645 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",
2646 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2647 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2649 infoPtr
->nNumBitmaps
= imagecount
;
2652 infoPtr
->nNumBitmaps
+= nButtons
;
2655 InvalidateRect(hwnd
, NULL
, TRUE
);
2662 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2664 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2665 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2666 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2668 TRACE("adding %d buttons!\n", wParam
);
2670 nAddButtons
= (UINT
)wParam
;
2671 nOldButtons
= infoPtr
->nNumButtons
;
2672 nNewButtons
= nOldButtons
+ nAddButtons
;
2674 if (infoPtr
->nNumButtons
== 0) {
2676 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2679 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2681 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2682 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2683 nOldButtons
* sizeof(TBUTTON_INFO
));
2687 infoPtr
->nNumButtons
= nNewButtons
;
2689 /* insert new button data */
2690 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2691 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2692 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2693 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2694 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2695 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2696 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2697 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2698 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2700 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2701 btnPtr
->bHot
= FALSE
;
2703 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2706 ZeroMemory (&ti
, sizeof(ti
));
2707 ti
.cbSize
= sizeof(ti
);
2709 ti
.uId
= btnPtr
->idCommand
;
2711 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2713 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2718 TOOLBAR_CalcToolbar (hwnd
);
2720 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2722 InvalidateRect(hwnd
, NULL
, TRUE
);
2729 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2731 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2732 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2733 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2735 TRACE("adding %d buttons!\n", wParam
);
2737 nAddButtons
= (UINT
)wParam
;
2738 nOldButtons
= infoPtr
->nNumButtons
;
2739 nNewButtons
= nOldButtons
+ nAddButtons
;
2741 if (infoPtr
->nNumButtons
== 0) {
2743 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2746 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2748 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2749 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2750 nOldButtons
* sizeof(TBUTTON_INFO
));
2754 infoPtr
->nNumButtons
= nNewButtons
;
2756 /* insert new button data */
2757 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2758 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2759 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2760 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2761 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2762 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2763 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2764 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2765 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2767 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2768 btnPtr
->bHot
= FALSE
;
2770 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2773 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2774 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2776 ti
.uId
= btnPtr
->idCommand
;
2778 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2781 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2786 TOOLBAR_CalcToolbar (hwnd
);
2788 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2790 InvalidateRect(hwnd
, NULL
, TRUE
);
2797 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2799 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2802 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2805 TRACE("adding string from resource!\n");
2807 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
,
2810 TRACE("len=%d \"%s\"\n", len
, szString
);
2811 nIndex
= infoPtr
->nNumStrings
;
2812 if (infoPtr
->nNumStrings
== 0) {
2814 Alloc (sizeof(LPWSTR
));
2817 LPWSTR
*oldStrings
= infoPtr
->strings
;
2819 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2820 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2821 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2825 /*Alloc zeros out the allocated memory*/
2826 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2827 infoPtr
->nNumStrings
++;
2830 LPSTR p
= (LPSTR
)lParam
;
2835 TRACE("adding string(s) from array!\n");
2837 nIndex
= infoPtr
->nNumStrings
;
2840 TRACE("len=%d \"%s\"\n", len
, p
);
2842 if (infoPtr
->nNumStrings
== 0) {
2844 Alloc (sizeof(LPWSTR
));
2847 LPWSTR
*oldStrings
= infoPtr
->strings
;
2849 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2850 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2851 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2855 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2856 infoPtr
->nNumStrings
++;
2867 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2869 #define MAX_RESOURCE_STRING_LENGTH 512
2870 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2873 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2874 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2876 TRACE("adding string from resource!\n");
2878 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2879 szString
, MAX_RESOURCE_STRING_LENGTH
);
2881 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2882 TRACE("First char: 0x%x\n", *szString
);
2883 if (szString
[0] == L
'|')
2885 PWSTR p
= szString
+ 1;
2887 nIndex
= infoPtr
->nNumStrings
;
2888 while (*p
!= L
'|' && *p
!= L
'\0') {
2891 if (infoPtr
->nNumStrings
== 0) {
2892 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
2896 LPWSTR
*oldStrings
= infoPtr
->strings
;
2897 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2898 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
2899 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2903 np
=strchrW (p
, '|');
2911 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2912 infoPtr
->strings
[infoPtr
->nNumStrings
] =
2913 Alloc (sizeof(WCHAR
)*(len
+1));
2914 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
2915 infoPtr
->nNumStrings
++;
2922 nIndex
= infoPtr
->nNumStrings
;
2923 if (infoPtr
->nNumStrings
== 0) {
2925 Alloc (sizeof(LPWSTR
));
2928 LPWSTR
*oldStrings
= infoPtr
->strings
;
2930 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2931 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2932 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2936 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2937 infoPtr
->nNumStrings
++;
2941 LPWSTR p
= (LPWSTR
)lParam
;
2946 TRACE("adding string(s) from array!\n");
2947 nIndex
= infoPtr
->nNumStrings
;
2951 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2952 if (infoPtr
->nNumStrings
== 0) {
2954 Alloc (sizeof(LPWSTR
));
2957 LPWSTR
*oldStrings
= infoPtr
->strings
;
2959 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2960 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2961 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2965 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2966 infoPtr
->nNumStrings
++;
2977 TOOLBAR_AutoSize (HWND hwnd
)
2979 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2985 UINT uPosFlags
= SWP_NOZORDER
;
2987 TRACE("resize forced, style=%lx!\n", infoPtr
->dwStyle
);
2989 parent
= GetParent (hwnd
);
2990 GetClientRect(parent
, &parent_rect
);
2992 x
= parent_rect
.left
;
2993 y
= parent_rect
.top
;
2995 /* FIXME: we should be able to early out if nothing */
2996 /* has changed with nWidth != parent_rect width */
2998 if (infoPtr
->dwStyle
& CCS_NORESIZE
) {
2999 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
3002 TOOLBAR_CalcToolbar (hwnd
);
3005 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
3006 TOOLBAR_CalcToolbar (hwnd
);
3007 InvalidateRect( hwnd
, NULL
, TRUE
);
3008 cy
= infoPtr
->nHeight
;
3009 cx
= infoPtr
->nWidth
;
3011 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
3012 GetWindowRect(hwnd
, &window_rect
);
3013 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
3014 y
= window_rect
.top
;
3016 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
3017 GetWindowRect(hwnd
, &window_rect
);
3018 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
3022 if (infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)
3023 uPosFlags
|= SWP_NOMOVE
;
3025 if (!(infoPtr
->dwStyle
& CCS_NODIVIDER
))
3026 cy
+= GetSystemMetrics(SM_CYEDGE
);
3028 if (infoPtr
->dwStyle
& WS_BORDER
)
3031 cy
+= GetSystemMetrics(SM_CYEDGE
);
3032 cx
+= GetSystemMetrics(SM_CYEDGE
);
3035 infoPtr
->bAutoSize
= TRUE
;
3036 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
3037 /* The following line makes sure that the infoPtr->bAutoSize is turned off
3038 * after the setwindowpos calls */
3039 infoPtr
->bAutoSize
= FALSE
;
3046 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3048 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3050 return infoPtr
->nNumButtons
;
3055 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3057 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3059 if (infoPtr
== NULL
) {
3060 ERR("(%p, 0x%x, 0x%lx)\n", hwnd
, wParam
, lParam
);
3061 ERR("infoPtr == NULL!\n");
3065 infoPtr
->dwStructSize
= (DWORD
)wParam
;
3072 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3074 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3075 TBUTTON_INFO
*btnPtr
;
3078 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
3080 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3084 btnPtr
= &infoPtr
->buttons
[nIndex
];
3085 btnPtr
->iBitmap
= LOWORD(lParam
);
3087 /* we HAVE to erase the background, the new bitmap could be */
3089 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3096 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3098 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3099 TBUTTON_INFO
*btnPtr
;
3102 BOOL bChecked
= FALSE
;
3104 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3106 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
3111 btnPtr
= &infoPtr
->buttons
[nIndex
];
3113 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
3115 if (LOWORD(lParam
) == FALSE
)
3116 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
3118 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
3120 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
3121 if (nOldIndex
== nIndex
)
3123 if (nOldIndex
!= -1)
3124 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
3126 btnPtr
->fsState
|= TBSTATE_CHECKED
;
3129 if( bChecked
!= LOWORD(lParam
) )
3131 if (nOldIndex
!= -1)
3132 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
3133 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3136 /* FIXME: Send a WM_NOTIFY?? */
3143 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3145 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3147 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3152 TOOLBAR_Customize (HWND hwnd
)
3154 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3155 CUSTDLG_INFO custInfo
;
3161 custInfo
.tbInfo
= infoPtr
;
3162 custInfo
.tbHwnd
= hwnd
;
3164 /* send TBN_BEGINADJUST notification */
3165 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
3168 if (!(hRes
= FindResourceW (COMCTL32_hModule
,
3169 MAKEINTRESOURCEW(IDD_TBCUSTOMIZE
),
3170 (LPWSTR
)RT_DIALOG
)))
3173 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
3176 ret
= DialogBoxIndirectParamW ((HINSTANCE
)GetWindowLongPtrW(hwnd
, GWLP_HINSTANCE
),
3177 (LPDLGTEMPLATEW
)template,
3179 TOOLBAR_CustomizeDialogProc
,
3182 /* send TBN_ENDADJUST notification */
3183 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
3191 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3193 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3194 INT nIndex
= (INT
)wParam
;
3196 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nIndex
];
3198 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3201 memset(&nmtb
, 0, sizeof(nmtb
));
3202 nmtb
.iItem
= btnPtr
->idCommand
;
3203 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
3204 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
3205 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
3206 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
3207 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
3208 nmtb
.tbButton
.iString
= btnPtr
->iString
;
3209 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_DELETINGBUTTON
);
3211 if ((infoPtr
->hwndToolTip
) &&
3212 !(btnPtr
->fsStyle
& BTNS_SEP
)) {
3215 ZeroMemory (&ti
, sizeof(ti
));
3216 ti
.cbSize
= sizeof(ti
);
3218 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3220 SendMessageW (infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
3223 if (infoPtr
->nNumButtons
== 1) {
3224 TRACE(" simple delete!\n");
3225 Free (infoPtr
->buttons
);
3226 infoPtr
->buttons
= NULL
;
3227 infoPtr
->nNumButtons
= 0;
3230 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3231 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3233 infoPtr
->nNumButtons
--;
3234 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3236 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3237 nIndex
* sizeof(TBUTTON_INFO
));
3240 if (nIndex
< infoPtr
->nNumButtons
) {
3241 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3242 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3248 TOOLBAR_CalcToolbar (hwnd
);
3250 InvalidateRect (hwnd
, NULL
, TRUE
);
3257 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3259 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3260 TBUTTON_INFO
*btnPtr
;
3264 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3266 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3271 btnPtr
= &infoPtr
->buttons
[nIndex
];
3273 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3275 /* update the toolbar button state */
3276 if(LOWORD(lParam
) == FALSE
) {
3277 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3279 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3282 /* redraw the button only if the state of the button changed */
3283 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3284 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3290 static inline LRESULT
3291 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3293 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3295 return infoPtr
->bAnchor
;
3300 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3302 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3305 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3309 return infoPtr
->buttons
[nIndex
].iBitmap
;
3313 static inline LRESULT
3314 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3316 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3321 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3323 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3324 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3325 INT nIndex
= (INT
)wParam
;
3326 TBUTTON_INFO
*btnPtr
;
3328 if (infoPtr
== NULL
)
3334 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3337 btnPtr
= &infoPtr
->buttons
[nIndex
];
3338 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3339 lpTbb
->idCommand
= btnPtr
->idCommand
;
3340 lpTbb
->fsState
= btnPtr
->fsState
;
3341 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3342 lpTbb
->bReserved
[0] = 0;
3343 lpTbb
->bReserved
[1] = 0;
3344 lpTbb
->dwData
= btnPtr
->dwData
;
3345 lpTbb
->iString
= btnPtr
->iString
;
3352 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3354 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3355 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3356 TBUTTON_INFO
*btnPtr
;
3359 if (infoPtr
== NULL
)
3361 if (lpTbInfo
== NULL
)
3363 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3366 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3367 lpTbInfo
->dwMask
& 0x80000000);
3371 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3373 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3374 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3375 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3376 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3377 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3378 lpTbInfo
->lParam
= btnPtr
->dwData
;
3379 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3380 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3381 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3382 lpTbInfo
->fsState
= btnPtr
->fsState
;
3383 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3384 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3385 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3386 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3387 can't use TOOLBAR_GetText here */
3389 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3390 lpText
= (LPWSTR
)btnPtr
->iString
;
3391 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3393 lpTbInfo
->pszText
[0] = '\0';
3400 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3402 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3403 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3404 TBUTTON_INFO
*btnPtr
;
3407 if (infoPtr
== NULL
)
3409 if (lpTbInfo
== NULL
)
3411 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3414 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3415 lpTbInfo
->dwMask
& 0x80000000);
3419 btnPtr
= &infoPtr
->buttons
[nIndex
];
3424 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3425 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3426 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3427 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3428 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3429 lpTbInfo
->lParam
= btnPtr
->dwData
;
3430 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3431 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3432 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3433 lpTbInfo
->fsState
= btnPtr
->fsState
;
3434 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3435 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3436 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3437 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3438 can't use TOOLBAR_GetText here */
3440 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3441 lpText
= (LPWSTR
)btnPtr
->iString
;
3442 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3444 lpTbInfo
->pszText
[0] = '\0';
3452 TOOLBAR_GetButtonSize (HWND hwnd
)
3454 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3456 if (infoPtr
->nNumButtons
> 0)
3457 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3458 (WORD
)infoPtr
->nButtonHeight
);
3460 return MAKELONG(8,7);
3465 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3467 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3474 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3478 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3480 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3481 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3486 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3488 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3493 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3497 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3501 ret
= strlenW (lpText
);
3504 strcpyW ((LPWSTR
)lParam
, lpText
);
3512 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3514 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3515 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3516 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3520 inline static LRESULT
3521 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3523 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3527 return infoPtr
->dwExStyle
;
3532 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3534 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3535 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3536 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3541 TOOLBAR_GetHotItem (HWND hwnd
)
3543 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3545 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
3548 if (infoPtr
->nHotItem
< 0)
3551 return (LRESULT
)infoPtr
->nHotItem
;
3556 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3558 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3559 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3560 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3565 TOOLBAR_GetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3567 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3568 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
3570 TRACE("hwnd = %p, lptbim = %p\n", hwnd
, lptbim
);
3572 *lptbim
= infoPtr
->tbim
;
3579 TOOLBAR_GetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3581 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3583 TRACE("hwnd = %p\n", hwnd
);
3585 return (LRESULT
)infoPtr
->clrInsertMark
;
3590 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3592 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3593 TBUTTON_INFO
*btnPtr
;
3597 if (infoPtr
== NULL
)
3599 nIndex
= (INT
)wParam
;
3600 btnPtr
= &infoPtr
->buttons
[nIndex
];
3601 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3603 lpRect
= (LPRECT
)lParam
;
3606 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3609 lpRect
->left
= btnPtr
->rect
.left
;
3610 lpRect
->right
= btnPtr
->rect
.right
;
3611 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3612 lpRect
->top
= btnPtr
->rect
.top
;
3619 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3621 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3622 LPSIZE lpSize
= (LPSIZE
)lParam
;
3627 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3628 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3630 TRACE("maximum size %ld x %ld\n",
3631 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3632 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3638 /* << TOOLBAR_GetObject >> */
3642 TOOLBAR_GetPadding (HWND hwnd
)
3644 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3647 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3648 return (LRESULT
) oldPad
;
3653 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3655 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3656 TBUTTON_INFO
*btnPtr
;
3660 if (infoPtr
== NULL
)
3662 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3663 btnPtr
= &infoPtr
->buttons
[nIndex
];
3664 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3666 lpRect
= (LPRECT
)lParam
;
3670 lpRect
->left
= btnPtr
->rect
.left
;
3671 lpRect
->right
= btnPtr
->rect
.right
;
3672 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3673 lpRect
->top
= btnPtr
->rect
.top
;
3680 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3682 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3684 if (infoPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
3685 return infoPtr
->nRows
;
3692 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3694 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3697 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3701 return infoPtr
->buttons
[nIndex
].fsState
;
3706 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3708 return GetWindowLongW(hwnd
, GWL_STYLE
);
3713 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3715 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3717 if (infoPtr
== NULL
)
3720 return infoPtr
->nMaxTextRows
;
3725 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3727 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3729 if (infoPtr
== NULL
)
3731 return (LRESULT
)infoPtr
->hwndToolTip
;
3736 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3738 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3740 TRACE("%s hwnd=%p\n",
3741 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3743 return infoPtr
->bUnicode
;
3747 inline static LRESULT
3748 TOOLBAR_GetVersion (HWND hwnd
)
3750 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3751 return infoPtr
->iVersion
;
3756 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3758 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3759 TBUTTON_INFO
*btnPtr
;
3764 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3768 btnPtr
= &infoPtr
->buttons
[nIndex
];
3769 if (LOWORD(lParam
) == FALSE
)
3770 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3772 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3774 TOOLBAR_CalcToolbar (hwnd
);
3776 InvalidateRect (hwnd
, NULL
, TRUE
);
3782 inline static LRESULT
3783 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3785 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3790 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3792 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3793 TBUTTON_INFO
*btnPtr
;
3797 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3801 btnPtr
= &infoPtr
->buttons
[nIndex
];
3802 oldState
= btnPtr
->fsState
;
3803 if (LOWORD(lParam
) == FALSE
)
3804 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3806 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3808 if(oldState
!= btnPtr
->fsState
)
3809 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3816 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3818 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3819 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3820 INT nIndex
= (INT
)wParam
;
3821 TBUTTON_INFO
*oldButtons
;
3826 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3829 /* EPP: this seems to be an undocumented call (from my IE4)
3830 * I assume in that case that:
3831 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3832 * - index of insertion is at the end of existing buttons
3833 * I only see this happen with nIndex == -1, but it could have a special
3834 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3836 nIndex
= infoPtr
->nNumButtons
;
3838 } else if (nIndex
< 0)
3841 /* If the string passed is not an index, assume address of string
3842 and do our own AddString */
3843 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3847 TRACE("string %s passed instead of index, adding string\n",
3848 debugstr_a((LPSTR
)lpTbb
->iString
));
3849 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3851 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3852 ptr
[len
- 1] = 0; /* ended by two '\0' */
3853 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3857 TRACE("inserting button index=%d\n", nIndex
);
3858 if (nIndex
> infoPtr
->nNumButtons
) {
3859 nIndex
= infoPtr
->nNumButtons
;
3860 TRACE("adjust index=%d\n", nIndex
);
3863 oldButtons
= infoPtr
->buttons
;
3864 infoPtr
->nNumButtons
++;
3865 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3866 /* pre insert copy */
3868 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3869 nIndex
* sizeof(TBUTTON_INFO
));
3872 /* insert new button */
3873 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3874 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3875 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3876 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3877 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3878 /* if passed string and not index, then add string */
3879 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3880 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3883 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3885 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3888 ZeroMemory (&ti
, sizeof(ti
));
3889 ti
.cbSize
= sizeof (ti
);
3891 ti
.uId
= lpTbb
->idCommand
;
3893 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3895 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3899 /* post insert copy */
3900 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3901 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3902 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3907 TOOLBAR_CalcToolbar (hwnd
);
3909 InvalidateRect (hwnd
, NULL
, TRUE
);
3916 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3918 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3919 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3920 INT nIndex
= (INT
)wParam
;
3921 TBUTTON_INFO
*oldButtons
;
3926 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3929 /* EPP: this seems to be an undocumented call (from my IE4)
3930 * I assume in that case that:
3931 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3932 * - index of insertion is at the end of existing buttons
3933 * I only see this happen with nIndex == -1, but it could have a special
3934 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3936 nIndex
= infoPtr
->nNumButtons
;
3938 } else if (nIndex
< 0)
3941 /* If the string passed is not an index, assume address of string
3942 and do our own AddString */
3943 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3947 TRACE("string %s passed instead of index, adding string\n",
3948 debugstr_w((LPWSTR
)lpTbb
->iString
));
3949 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
3950 ptr
= Alloc(len
*sizeof(WCHAR
));
3951 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
3952 ptr
[len
- 1] = 0; /* ended by two '\0' */
3953 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
3957 TRACE("inserting button index=%d\n", nIndex
);
3958 if (nIndex
> infoPtr
->nNumButtons
) {
3959 nIndex
= infoPtr
->nNumButtons
;
3960 TRACE("adjust index=%d\n", nIndex
);
3963 oldButtons
= infoPtr
->buttons
;
3964 infoPtr
->nNumButtons
++;
3965 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3966 /* pre insert copy */
3968 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3969 nIndex
* sizeof(TBUTTON_INFO
));
3972 /* insert new button */
3973 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3974 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3975 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3976 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3977 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3978 /* if passed string and not index, then add string */
3979 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3980 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
3983 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3985 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3988 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
3989 ti
.cbSize
= sizeof (TTTOOLINFOW
);
3991 ti
.uId
= lpTbb
->idCommand
;
3993 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3995 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3999 /* post insert copy */
4000 if (nIndex
< infoPtr
->nNumButtons
- 1) {
4001 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
4002 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
4007 TOOLBAR_CalcToolbar (hwnd
);
4009 InvalidateRect (hwnd
, NULL
, TRUE
);
4015 /* << TOOLBAR_InsertMarkHitTest >> */
4019 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4021 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4024 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4028 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
4033 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4035 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4038 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4042 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
4047 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4049 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4052 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4056 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
4061 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4063 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4066 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4070 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
4075 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4077 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4080 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4084 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
4089 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4091 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4094 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4098 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
4103 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4106 tbab
.hInst
= (HINSTANCE
)lParam
;
4107 tbab
.nID
= (UINT_PTR
)wParam
;
4109 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
4111 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
4116 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4118 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4119 WCHAR wAccel
= (WCHAR
)wParam
;
4120 UINT
* pIDButton
= (UINT
*)lParam
;
4121 WCHAR wszAccel
[] = {'&',wAccel
,0};
4124 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
4125 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
4127 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4129 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
4130 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
4131 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
4133 int iLen
= strlenW(wszAccel
);
4134 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
4141 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
4146 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
4148 *pIDButton
= btnPtr
->idCommand
;
4160 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4162 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4165 TBUTTON_INFO
*btnPtr
;
4167 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
4169 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4173 btnPtr
= &infoPtr
->buttons
[nIndex
];
4174 oldState
= btnPtr
->fsState
;
4177 btnPtr
->fsState
|= TBSTATE_MARKED
;
4179 btnPtr
->fsState
&= ~TBSTATE_MARKED
;
4181 if(oldState
!= btnPtr
->fsState
)
4182 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4188 /* fixes up an index of a button affected by a move */
4189 inline static void TOOLBAR_MoveFixupIndex(INT
* pIndex
, INT nIndex
, INT nMoveIndex
, BOOL bMoveUp
)
4193 if (*pIndex
> nIndex
&& *pIndex
<= nMoveIndex
)
4195 else if (*pIndex
== nIndex
)
4196 *pIndex
= nMoveIndex
;
4200 if (*pIndex
>= nMoveIndex
&& *pIndex
< nIndex
)
4202 else if (*pIndex
== nIndex
)
4203 *pIndex
= nMoveIndex
;
4209 TOOLBAR_MoveButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4211 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4214 INT nMoveIndex
= (INT
)lParam
;
4215 TBUTTON_INFO button
;
4217 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4219 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, TRUE
);
4220 if ((nIndex
== -1) || (nMoveIndex
< 0))
4223 if (nMoveIndex
> infoPtr
->nNumButtons
- 1)
4224 nMoveIndex
= infoPtr
->nNumButtons
- 1;
4226 button
= infoPtr
->buttons
[nIndex
];
4228 /* move button right */
4229 if (nIndex
< nMoveIndex
)
4231 nCount
= nMoveIndex
- nIndex
;
4232 memmove(&infoPtr
->buttons
[nIndex
], &infoPtr
->buttons
[nIndex
+1], nCount
*sizeof(TBUTTON_INFO
));
4233 infoPtr
->buttons
[nMoveIndex
] = button
;
4235 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, TRUE
);
4236 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, TRUE
);
4237 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, TRUE
);
4238 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, TRUE
);
4240 else if (nIndex
> nMoveIndex
) /* move button left */
4242 nCount
= nIndex
- nMoveIndex
;
4243 memmove(&infoPtr
->buttons
[nMoveIndex
+1], &infoPtr
->buttons
[nMoveIndex
], nCount
*sizeof(TBUTTON_INFO
));
4244 infoPtr
->buttons
[nMoveIndex
] = button
;
4246 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, FALSE
);
4247 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, FALSE
);
4248 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, FALSE
);
4249 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, FALSE
);
4252 TOOLBAR_CalcToolbar(hwnd
);
4253 InvalidateRect(hwnd
, NULL
, TRUE
);
4260 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4262 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4263 TBUTTON_INFO
*btnPtr
;
4267 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4271 btnPtr
= &infoPtr
->buttons
[nIndex
];
4272 oldState
= btnPtr
->fsState
;
4273 if (LOWORD(lParam
) == FALSE
)
4274 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4276 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4278 if(oldState
!= btnPtr
->fsState
)
4279 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4284 /* FIXME: there might still be some confusion her between number of buttons
4285 * and number of bitmaps */
4287 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4289 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4290 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
4292 int i
= 0, nOldButtons
= 0, pos
= 0;
4293 int nOldBitmaps
, nNewBitmaps
;
4294 HIMAGELIST himlDef
= 0;
4296 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
4297 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
4298 lpReplace
->nButtons
);
4300 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4302 FIXME("changing standard bitmaps not implemented\n");
4305 else if (lpReplace
->hInstOld
!= 0)
4307 FIXME("resources not in the current module not implemented\n");
4312 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4315 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4316 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4317 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4318 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4319 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4321 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4322 nOldButtons
= tbi
->nButtons
;
4323 tbi
->nButtons
= lpReplace
->nButtons
;
4324 tbi
->hInst
= lpReplace
->hInstNew
;
4325 tbi
->nID
= lpReplace
->nIDNew
;
4326 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4329 pos
+= tbi
->nButtons
;
4332 if (nOldButtons
== 0)
4334 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4338 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4339 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4341 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4343 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4344 ImageList_Remove(himlDef
, i
);
4348 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4349 HDC hdcImage
, hdcBitmap
;
4351 /* copy the bitmap before adding it so that the user's bitmap
4352 * doesn't get modified.
4354 GetObjectA (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4356 hdcImage
= CreateCompatibleDC(0);
4357 hdcBitmap
= CreateCompatibleDC(0);
4359 /* create new bitmap */
4360 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4361 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4362 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4364 /* Copy the user's image */
4365 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4366 hdcBitmap
, 0, 0, SRCCOPY
);
4368 SelectObject (hdcImage
, hOldBitmapLoad
);
4369 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4370 DeleteDC (hdcImage
);
4371 DeleteDC (hdcBitmap
);
4373 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4374 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4375 DeleteObject (hbmLoad
);
4378 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4380 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4381 pos
, nOldBitmaps
, nNewBitmaps
);
4383 InvalidateRect(hwnd
, NULL
, TRUE
);
4389 /* helper for TOOLBAR_SaveRestoreW */
4391 TOOLBAR_Save(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4393 FIXME("save to %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4394 debugstr_w(lpSave
->pszValueName
));
4400 /* helper for TOOLBAR_Restore */
4402 TOOLBAR_DeleteAllButtons(TOOLBAR_INFO
*infoPtr
)
4407 ZeroMemory(&ti
, sizeof(ti
));
4408 ti
.cbSize
= sizeof(ti
);
4409 ti
.hwnd
= infoPtr
->hwndSelf
;
4411 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4413 if ((infoPtr
->hwndToolTip
) &&
4414 !(infoPtr
->buttons
[i
].fsStyle
& BTNS_SEP
))
4416 ti
.uId
= infoPtr
->buttons
[i
].idCommand
;
4417 SendMessageW(infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
4421 Free(infoPtr
->buttons
);
4422 infoPtr
->buttons
= NULL
;
4423 infoPtr
->nNumButtons
= 0;
4427 /* helper for TOOLBAR_SaveRestoreW */
4429 TOOLBAR_Restore(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4438 /* restore toolbar information */
4439 TRACE("restore from %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4440 debugstr_w(lpSave
->pszValueName
));
4442 memset(&nmtbr
, 0, sizeof(nmtbr
));
4444 res
= RegOpenKeyExW(lpSave
->hkr
, lpSave
->pszSubKey
, 0,
4445 KEY_QUERY_VALUE
, &hkey
);
4447 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4449 if (!res
&& dwType
!= REG_BINARY
)
4450 res
= ERROR_FILE_NOT_FOUND
;
4453 nmtbr
.pData
= HeapAlloc(GetProcessHeap(), 0, dwSize
);
4454 nmtbr
.cbData
= (UINT
)dwSize
;
4455 if (!nmtbr
.pData
) res
= ERROR_OUTOFMEMORY
;
4458 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4459 (LPBYTE
)nmtbr
.pData
, &dwSize
);
4462 nmtbr
.pCurrent
= nmtbr
.pData
;
4464 nmtbr
.cbBytesPerRecord
= sizeof(DWORD
);
4465 nmtbr
.cButtons
= nmtbr
.cbData
/ nmtbr
.cbBytesPerRecord
;
4467 if (!TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
))
4471 /* remove all existing buttons as this function is designed to
4472 * restore the toolbar to a previously saved state */
4473 TOOLBAR_DeleteAllButtons(infoPtr
);
4475 for (i
= 0; i
< nmtbr
.cButtons
; i
++)
4478 nmtbr
.tbButton
.iBitmap
= -1;
4479 nmtbr
.tbButton
.fsState
= 0;
4480 nmtbr
.tbButton
.fsStyle
= 0;
4481 nmtbr
.tbButton
.idCommand
= 0;
4482 if (*nmtbr
.pCurrent
== (DWORD
)-1)
4485 nmtbr
.tbButton
.fsStyle
= TBSTYLE_SEP
;
4486 nmtbr
.tbButton
.iBitmap
= SEPARATOR_WIDTH
;
4488 else if (*nmtbr
.pCurrent
== (DWORD
)-2)
4490 nmtbr
.tbButton
.fsState
= TBSTATE_HIDDEN
;
4492 nmtbr
.tbButton
.idCommand
= (int)*nmtbr
.pCurrent
;
4496 TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
);
4498 /* can't contain real string as we don't know whether
4499 * the client put an ANSI or Unicode string in there */
4500 if (HIWORD(nmtbr
.tbButton
.iString
))
4501 nmtbr
.tbButton
.iString
= 0;
4503 TOOLBAR_InsertButtonW(infoPtr
->hwndSelf
, -1,
4504 (LPARAM
)&nmtbr
.tbButton
);
4507 /* do legacy notifications */
4508 if (infoPtr
->iVersion
< 5)
4510 /* FIXME: send TBN_BEGINADJUST */
4511 FIXME("send TBN_GETBUTTONINFO for each button\n");
4512 /* FIXME: send TBN_ENDADJUST */
4515 /* remove all uninitialised buttons
4516 * note: loop backwards to avoid having to fixup i on a
4518 for (i
= infoPtr
->nNumButtons
- 1; i
>= 0; i
--)
4519 if (infoPtr
->buttons
[i
].iBitmap
== -1)
4520 TOOLBAR_DeleteButton(infoPtr
->hwndSelf
, i
, 0);
4522 /* only indicate success if at least one button survived */
4523 if (infoPtr
->nNumButtons
> 0) ret
= TRUE
;
4526 HeapFree(GetProcessHeap(), 0, nmtbr
.pData
);
4534 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSW lpSave
)
4536 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4538 if (lpSave
== NULL
) return 0;
4541 return TOOLBAR_Save(infoPtr
, lpSave
);
4543 return TOOLBAR_Restore(infoPtr
, lpSave
);
4548 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSA lpSave
)
4550 TBSAVEPARAMSW SaveW
;
4553 if (lpSave
== NULL
) return 0;
4555 SaveW
.hkr
= lpSave
->hkr
;
4557 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, NULL
, 0);
4558 SaveW
.pszSubKey
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
4559 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, (LPWSTR
)SaveW
.pszSubKey
, len
);
4561 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, NULL
, 0);
4562 SaveW
.pszValueName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
4563 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, (LPWSTR
)SaveW
.pszValueName
, len
);
4565 return TOOLBAR_SaveRestoreW(hwnd
, wParam
, &SaveW
);
4570 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4572 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4573 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4575 TRACE("hwnd=%p, bAnchor = %s\n", hwnd
, wParam
? "TRUE" : "FALSE");
4577 infoPtr
->bAnchor
= (BOOL
)wParam
;
4579 /* Native does not remove the hot effect from an already hot button */
4581 return (LRESULT
)bOldAnchor
;
4586 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4588 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4589 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4591 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4594 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4596 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4599 if (infoPtr
->nNumButtons
> 0)
4600 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4601 infoPtr
->nNumButtons
,
4602 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4603 LOWORD(lParam
), HIWORD(lParam
));
4605 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4606 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4609 if ((himlDef
== infoPtr
->himlInt
) &&
4610 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4612 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4613 infoPtr
->nBitmapHeight
);
4621 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4623 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4624 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4625 TBUTTON_INFO
*btnPtr
;
4631 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4634 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4635 lptbbi
->dwMask
& 0x80000000);
4639 btnPtr
= &infoPtr
->buttons
[nIndex
];
4640 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4641 btnPtr
->idCommand
= lptbbi
->idCommand
;
4642 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4643 btnPtr
->iBitmap
= lptbbi
->iImage
;
4644 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4645 btnPtr
->dwData
= lptbbi
->lParam
;
4646 if (lptbbi
->dwMask
& TBIF_SIZE
)
4647 btnPtr
->cx
= lptbbi
->cx
;
4648 if (lptbbi
->dwMask
& TBIF_STATE
)
4649 btnPtr
->fsState
= lptbbi
->fsState
;
4650 if (lptbbi
->dwMask
& TBIF_STYLE
)
4651 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4653 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4654 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4655 /* iString is index, zero it to make Str_SetPtr succeed */
4658 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4661 /* save the button rect to see if we need to redraw the whole toolbar */
4662 oldBtnRect
= btnPtr
->rect
;
4663 TOOLBAR_CalcToolbar(hwnd
);
4665 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4666 InvalidateRect(hwnd
, NULL
, TRUE
);
4668 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4675 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4677 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4678 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4679 TBUTTON_INFO
*btnPtr
;
4685 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4688 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4689 lptbbi
->dwMask
& 0x80000000);
4693 btnPtr
= &infoPtr
->buttons
[nIndex
];
4694 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4695 btnPtr
->idCommand
= lptbbi
->idCommand
;
4696 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4697 btnPtr
->iBitmap
= lptbbi
->iImage
;
4698 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4699 btnPtr
->dwData
= lptbbi
->lParam
;
4700 if (lptbbi
->dwMask
& TBIF_SIZE
)
4701 btnPtr
->cx
= lptbbi
->cx
;
4702 if (lptbbi
->dwMask
& TBIF_STATE
)
4703 btnPtr
->fsState
= lptbbi
->fsState
;
4704 if (lptbbi
->dwMask
& TBIF_STYLE
)
4705 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4707 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4708 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4709 /* iString is index, zero it to make Str_SetPtr succeed */
4711 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4714 /* save the button rect to see if we need to redraw the whole toolbar */
4715 oldBtnRect
= btnPtr
->rect
;
4716 TOOLBAR_CalcToolbar(hwnd
);
4718 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4719 InvalidateRect(hwnd
, NULL
, TRUE
);
4721 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4728 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4730 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4731 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4733 if ((cx
< 0) || (cy
< 0))
4735 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4739 /* The documentation claims you can only change the button size before
4740 * any button has been added. But this is wrong.
4741 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4742 * it to the toolbar, and it checks that the return value is nonzero - mjm
4743 * Further testing shows that we must actually perform the change too.
4746 * The documentation also does not mention that if 0 is supplied for
4747 * either size, the system changes it to the default of 24 wide and
4748 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4750 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4751 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4757 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4759 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4761 if (infoPtr
== NULL
) {
4762 TRACE("Toolbar not initialized yet?????\n");
4766 /* if setting to current values, ignore */
4767 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4768 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4769 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4770 infoPtr
->cxMin
, infoPtr
->cxMax
);
4774 /* save new values */
4775 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4776 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4778 /* if both values are 0 then we are done */
4780 TRACE("setting both min and max to 0, norecalc\n");
4784 /* otherwise we need to recalc the toolbar and in some cases
4785 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4786 which doesn't actually draw - GA). */
4787 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4788 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4790 TOOLBAR_CalcToolbar (hwnd
);
4792 InvalidateRect (hwnd
, NULL
, TRUE
);
4799 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4801 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4802 INT nIndex
= (INT
)wParam
;
4804 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4807 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4809 if (infoPtr
->hwndToolTip
) {
4811 FIXME("change tool tip!\n");
4820 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4822 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4823 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4824 HIMAGELIST himlTemp
;
4827 if (infoPtr
->iVersion
>= 5)
4830 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4831 &infoPtr
->cimlDis
, himl
, id
);
4833 /* FIXME: redraw ? */
4835 return (LRESULT
)himlTemp
;
4840 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4842 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4845 TRACE("hwnd = %p, dwMask = 0x%08lx, dwDTFlags = 0x%08lx\n", hwnd
, (DWORD
)wParam
, (DWORD
)lParam
);
4847 dwTemp
= infoPtr
->dwDTFlags
;
4848 infoPtr
->dwDTFlags
=
4849 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4851 return (LRESULT
)dwTemp
;
4854 /* This function differs a bit from what MSDN says it does:
4855 * 1. lParam contains extended style flags to OR with current style
4856 * (MSDN isn't clear on the OR bit)
4857 * 2. wParam appears to contain extended style flags to be reset
4858 * (MSDN says that this parameter is reserved)
4861 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4863 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4866 dwTemp
= infoPtr
->dwExStyle
;
4867 infoPtr
->dwExStyle
&= ~wParam
;
4868 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4870 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4872 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4873 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4874 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4876 TOOLBAR_CalcToolbar (hwnd
);
4878 TOOLBAR_AutoSize(hwnd
);
4880 InvalidateRect(hwnd
, NULL
, TRUE
);
4882 return (LRESULT
)dwTemp
;
4887 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4889 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4890 HIMAGELIST himlTemp
;
4891 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4894 if (infoPtr
->iVersion
>= 5)
4897 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
4899 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
4900 &infoPtr
->cimlHot
, himl
, id
);
4902 /* FIXME: redraw ? */
4904 return (LRESULT
)himlTemp
;
4908 /* Makes previous hot button no longer hot, makes the specified
4909 * button hot and sends appropriate notifications. dwReason is one or
4910 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
4911 * NOTE 1: this function does not validate nHit
4912 * NOTE 2: the name of this function is completely made up and
4913 * not based on any documentation from Microsoft. */
4915 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
4917 if (infoPtr
->nHotItem
!= nHit
)
4919 NMTBHOTITEM nmhotitem
;
4920 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
4921 LRESULT no_highlight
;
4923 /* Remove the effect of an old hot button if the button was
4924 drawn with the hot button effect */
4925 if(infoPtr
->nHotItem
>= 0)
4927 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
4928 oldBtnPtr
->bHot
= FALSE
;
4931 infoPtr
->nHotItem
= nHit
;
4933 /* It's not a separator or in nowhere. It's a hot button. */
4935 btnPtr
= &infoPtr
->buttons
[nHit
];
4937 nmhotitem
.dwFlags
= dwReason
;
4939 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
4941 nmhotitem
.dwFlags
|= HICF_ENTERING
;
4943 nmhotitem
.idNew
= btnPtr
->idCommand
;
4945 nmhotitem
.dwFlags
|= HICF_LEAVING
;
4947 no_highlight
= TOOLBAR_SendNotify((NMHDR
*)&nmhotitem
, infoPtr
, TBN_HOTITEMCHANGE
);
4949 /* now invalidate the old and new buttons so they will be painted */
4951 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
4952 if (btnPtr
&& !no_highlight
)
4954 btnPtr
->bHot
= TRUE
;
4955 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
4961 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
4963 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4964 INT nOldHotItem
= infoPtr
->nHotItem
;
4966 TRACE("hwnd = %p, nHit = %d\n", hwnd
, (INT
)wParam
);
4968 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4971 /* NOTE: an application can still remove the hot item even if anchor
4972 * highlighting is enabled */
4974 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
4975 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
4977 if (nOldHotItem
< 0)
4980 return (LRESULT
)nOldHotItem
;
4985 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4987 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4988 HIMAGELIST himlTemp
;
4989 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4992 if (infoPtr
->iVersion
>= 5)
4995 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
4996 &infoPtr
->cimlDef
, himl
, id
);
4998 infoPtr
->nNumBitmaps
= 0;
4999 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
5000 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
5002 ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
5003 &infoPtr
->nBitmapHeight
);
5004 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
5005 hwnd
, (INT
)infoPtr
->himlDef
, infoPtr
->nNumBitmaps
,
5006 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
5008 InvalidateRect(hwnd
, NULL
, TRUE
);
5010 return (LRESULT
)himlTemp
;
5015 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5017 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5019 infoPtr
->nIndent
= (INT
)wParam
;
5023 /* process only on indent changing */
5024 if(infoPtr
->nIndent
!= (INT
)wParam
)
5026 infoPtr
->nIndent
= (INT
)wParam
;
5027 TOOLBAR_CalcToolbar (hwnd
);
5028 InvalidateRect(hwnd
, NULL
, FALSE
);
5036 TOOLBAR_SetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5038 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5039 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
5041 TRACE("hwnd = %p, lptbim = { %d, 0x%08lx}\n", hwnd
, lptbim
->iButton
, lptbim
->dwFlags
);
5043 if ((lptbim
->dwFlags
& ~TBIMHT_AFTER
) != 0)
5045 FIXME("Unrecognized flag(s): 0x%08lx\n", (lptbim
->dwFlags
& ~TBIMHT_AFTER
));
5049 if ((lptbim
->iButton
== -1) ||
5050 ((lptbim
->iButton
< infoPtr
->nNumButtons
) &&
5051 (lptbim
->iButton
>= 0)))
5053 infoPtr
->tbim
= *lptbim
;
5054 /* FIXME: don't need to update entire toolbar */
5055 InvalidateRect(hwnd
, NULL
, TRUE
);
5058 ERR("Invalid button index %d\n", lptbim
->iButton
);
5065 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5067 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5069 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
5071 /* FIXME: don't need to update entire toolbar */
5072 InvalidateRect(hwnd
, NULL
, TRUE
);
5079 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5081 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5083 if (infoPtr
== NULL
)
5086 infoPtr
->nMaxTextRows
= (INT
)wParam
;
5088 TOOLBAR_CalcToolbar(hwnd
);
5093 /* MSDN gives slightly wrong info on padding.
5094 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
5095 * 2. It is not used to create a blank area between the edge of the button
5096 * and the text or image if TBSTYLE_LIST is set. It is used to control
5097 * the gap between the image and text.
5098 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
5099 * to control the bottom and right borders [with the border being
5100 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
5101 * is shared evenly on both sides of the button.
5104 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5106 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5109 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5110 infoPtr
->szPadding
.cx
= LOWORD((DWORD
)lParam
);
5111 infoPtr
->szPadding
.cy
= HIWORD((DWORD
)lParam
);
5112 TRACE("cx=%ld, cy=%ld\n",
5113 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5114 return (LRESULT
) oldPad
;
5119 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5121 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5126 if (infoPtr
== NULL
)
5128 hwndOldNotify
= infoPtr
->hwndNotify
;
5129 infoPtr
->hwndNotify
= (HWND
)wParam
;
5131 return (LRESULT
)hwndOldNotify
;
5136 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5138 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5139 LPRECT lprc
= (LPRECT
)lParam
;
5143 if (LOWORD(wParam
) > 1) {
5144 FIXME("multiple rows not supported!\n");
5147 if(infoPtr
->nRows
!= LOWORD(wParam
))
5149 infoPtr
->nRows
= LOWORD(wParam
);
5151 /* recalculate toolbar */
5152 TOOLBAR_CalcToolbar (hwnd
);
5154 /* repaint toolbar */
5155 InvalidateRect(hwnd
, NULL
, TRUE
);
5158 /* return bounding rectangle */
5160 lprc
->left
= infoPtr
->rcBound
.left
;
5161 lprc
->right
= infoPtr
->rcBound
.right
;
5162 lprc
->top
= infoPtr
->rcBound
.top
;
5163 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
5171 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5173 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5174 TBUTTON_INFO
*btnPtr
;
5177 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
5181 btnPtr
= &infoPtr
->buttons
[nIndex
];
5183 /* if hidden state has changed the invalidate entire window and recalc */
5184 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
5185 btnPtr
->fsState
= LOWORD(lParam
);
5186 TOOLBAR_CalcToolbar (hwnd
);
5187 InvalidateRect(hwnd
, 0, TRUE
);
5191 /* process state changing if current state doesn't match new state */
5192 if(btnPtr
->fsState
!= LOWORD(lParam
))
5194 btnPtr
->fsState
= LOWORD(lParam
);
5195 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5203 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5205 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
5211 inline static LRESULT
5212 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5214 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5216 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
5218 if (infoPtr
== NULL
)
5220 infoPtr
->hwndToolTip
= (HWND
)wParam
;
5226 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5228 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5231 TRACE("%s hwnd=%p\n",
5232 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
5234 bTemp
= infoPtr
->bUnicode
;
5235 infoPtr
->bUnicode
= (BOOL
)wParam
;
5242 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5244 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5246 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
5247 comctl32_color
.clrBtnHighlight
:
5248 infoPtr
->clrBtnHighlight
;
5249 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
5250 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
5256 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5258 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5260 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
5261 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
5262 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
5264 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
5265 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
5266 InvalidateRect(hwnd
, NULL
, TRUE
);
5272 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
5274 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5275 INT iOldVersion
= infoPtr
->iVersion
;
5277 infoPtr
->iVersion
= iVersion
;
5279 if (infoPtr
->iVersion
>= 5)
5280 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
5287 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5289 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5290 WORD iString
= HIWORD(wParam
);
5291 WORD buffersize
= LOWORD(wParam
);
5292 LPSTR str
= (LPSTR
)lParam
;
5295 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
5297 if (iString
< infoPtr
->nNumStrings
)
5299 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
5301 TRACE("returning %s\n", debugstr_a(str
));
5304 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5311 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5313 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5314 WORD iString
= HIWORD(wParam
);
5315 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
5316 LPWSTR str
= (LPWSTR
)lParam
;
5319 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
5321 if (iString
< infoPtr
->nNumStrings
)
5323 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
5324 ret
= (len
+1)*sizeof(WCHAR
);
5325 memcpy(str
, infoPtr
->strings
[iString
], ret
);
5328 TRACE("returning %s\n", debugstr_w(str
));
5331 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5336 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
5337 * is the maximum size of the toolbar? */
5338 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5340 SIZE
* pSize
= (SIZE
*)lParam
;
5341 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
5346 /* UNDOCUMENTED MESSAGE: This is an extended version of the
5347 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
5348 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
5351 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5353 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5354 INT nOldHotItem
= infoPtr
->nHotItem
;
5356 TRACE("old item=%d, new item=%d, flags=%08lx\n",
5357 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
5359 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
5362 /* NOTE: an application can still remove the hot item even if anchor
5363 * highlighting is enabled */
5365 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
5369 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
5372 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
5373 * which controls the amount of spacing between the image and the text
5374 * of buttons for TBSTYLE_LIST toolbars. */
5375 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5377 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5379 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
5382 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
5384 infoPtr
->iListGap
= (INT
)wParam
;
5386 InvalidateRect(hwnd
, NULL
, TRUE
);
5391 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
5392 * of image lists associated with the various states. */
5393 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5395 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5397 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5399 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
5403 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5405 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5406 LPSIZE lpsize
= (LPSIZE
)lParam
;
5412 * Testing shows the following:
5413 * wParam = 0 adjust cx value
5414 * = 1 set cy value to max size.
5415 * lParam pointer to SIZE structure
5418 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
5419 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
5423 if (lpsize
->cx
== -1) {
5424 /* **** this is wrong, native measures each button and sets it */
5425 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5427 else if(HIWORD(lpsize
->cx
)) {
5429 HWND hwndParent
= GetParent(hwnd
);
5431 GetWindowRect(hwnd
, &rc
);
5432 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
5433 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
5434 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5435 lpsize
->cx
= max(rc
.right
-rc
.left
,
5436 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
5439 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5443 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5444 /* lpsize->cy = infoPtr->nHeight; */
5447 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
5451 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
5452 lpsize
->cx
, lpsize
->cy
);
5456 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5458 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5460 InvalidateRect(hwnd
, NULL
, TRUE
);
5466 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5468 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5469 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
5472 TRACE("hwnd = %p\n", hwnd
);
5474 /* initialize info structure */
5475 infoPtr
->nButtonHeight
= 22;
5476 infoPtr
->nButtonWidth
= 24;
5477 infoPtr
->nBitmapHeight
= 15;
5478 infoPtr
->nBitmapWidth
= 16;
5480 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5481 infoPtr
->nMaxTextRows
= 1;
5482 infoPtr
->cxMin
= -1;
5483 infoPtr
->cxMax
= -1;
5484 infoPtr
->nNumBitmaps
= 0;
5485 infoPtr
->nNumStrings
= 0;
5487 infoPtr
->bCaptured
= FALSE
;
5488 infoPtr
->nButtonDown
= -1;
5489 infoPtr
->nButtonDrag
= -1;
5490 infoPtr
->nOldHit
= -1;
5491 infoPtr
->nHotItem
= -1;
5492 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5493 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5494 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
: DT_CENTER
| DT_END_ELLIPSIS
;
5495 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5496 infoPtr
->bDragOutSent
= FALSE
;
5497 infoPtr
->iVersion
= 0;
5498 infoPtr
->hwndSelf
= hwnd
;
5499 infoPtr
->bDoRedraw
= TRUE
;
5500 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5501 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5502 /* not sure where the +1 comes from, but this comes to the same value
5503 * as native so this is probably correct */
5504 infoPtr
->szPadding
.cx
= 2*(GetSystemMetrics(SM_CXEDGE
)+OFFSET_X
) + 1;
5505 infoPtr
->szPadding
.cy
= 2*(GetSystemMetrics(SM_CYEDGE
)+OFFSET_Y
);
5506 infoPtr
->iListGap
= infoPtr
->szPadding
.cx
/ 2;
5507 infoPtr
->dwStyle
= dwStyle
;
5508 infoPtr
->tbim
.iButton
= -1;
5509 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5510 infoPtr
->bUnicode
= infoPtr
->hwndNotify
&&
5511 (NFR_UNICODE
== SendMessageW(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
));
5513 SystemParametersInfoA (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5514 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectA (&logFont
);
5516 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5517 /* Create tooltip control */
5518 infoPtr
->hwndToolTip
=
5519 CreateWindowExA (0, TOOLTIPS_CLASSA
, NULL
, 0,
5520 CW_USEDEFAULT
, CW_USEDEFAULT
,
5521 CW_USEDEFAULT
, CW_USEDEFAULT
,
5524 /* Send NM_TOOLTIPSCREATED notification */
5525 if (infoPtr
->hwndToolTip
) {
5526 NMTOOLTIPSCREATED nmttc
;
5528 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5530 TOOLBAR_SendNotify ((NMHDR
*) &nmttc
, infoPtr
,
5531 NM_TOOLTIPSCREATED
);
5535 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5537 TOOLBAR_CalcToolbar(hwnd
);
5544 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5546 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5548 /* delete tooltip control */
5549 if (infoPtr
->hwndToolTip
)
5550 DestroyWindow (infoPtr
->hwndToolTip
);
5552 /* delete temporary buffer for tooltip text */
5553 if (infoPtr
->pszTooltipText
)
5554 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5556 /* delete button data */
5557 if (infoPtr
->buttons
)
5558 Free (infoPtr
->buttons
);
5560 /* delete strings */
5561 if (infoPtr
->strings
) {
5563 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5564 if (infoPtr
->strings
[i
])
5565 Free (infoPtr
->strings
[i
]);
5567 Free (infoPtr
->strings
);
5570 /* destroy internal image list */
5571 if (infoPtr
->himlInt
)
5572 ImageList_Destroy (infoPtr
->himlInt
);
5574 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5575 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5576 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5578 /* delete default font */
5580 DeleteObject (infoPtr
->hDefaultFont
);
5582 /* free toolbar info data */
5584 SetWindowLongPtrW (hwnd
, 0, 0);
5591 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5593 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5594 NMTBCUSTOMDRAW tbcd
;
5598 /* the app has told us not to redraw the toolbar */
5599 if (!infoPtr
->bDoRedraw
)
5602 if (infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) {
5603 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5604 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5605 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5606 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5607 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5609 /* FIXME: in general the return flags *can* be or'ed together */
5610 switch (infoPtr
->dwBaseCustDraw
)
5612 case CDRF_DODEFAULT
:
5614 case CDRF_SKIPDEFAULT
:
5617 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5622 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5623 * to my parent for processing.
5625 if (infoPtr
->dwStyle
& TBSTYLE_TRANSPARENT
) {
5627 HDC hdc
= (HDC
)wParam
;
5632 parent
= GetParent(hwnd
);
5633 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5634 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5635 ret
= SendMessageW (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5636 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5639 ret
= DefWindowProcW (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5641 if ((infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5642 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5643 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5644 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5645 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5646 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5647 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5648 switch (infoPtr
->dwBaseCustDraw
)
5650 case CDRF_DODEFAULT
:
5652 case CDRF_SKIPDEFAULT
:
5655 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_POSTERASE)\n",
5664 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5666 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5668 return (LRESULT
)infoPtr
->hFont
;
5673 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5678 pt
.x
= (INT
)LOWORD(lParam
);
5679 pt
.y
= (INT
)HIWORD(lParam
);
5680 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5683 TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5684 else if (GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5685 TOOLBAR_Customize (hwnd
);
5692 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5694 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5695 TBUTTON_INFO
*btnPtr
;
5700 BOOL bDragKeyPressed
;
5704 if (infoPtr
->dwStyle
& TBSTYLE_ALTDRAG
)
5705 bDragKeyPressed
= (GetKeyState(VK_MENU
) < 0);
5707 bDragKeyPressed
= (wParam
& MK_SHIFT
);
5709 if (infoPtr
->hwndToolTip
)
5710 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5711 WM_LBUTTONDOWN
, wParam
, lParam
);
5713 pt
.x
= (INT
)LOWORD(lParam
);
5714 pt
.y
= (INT
)HIWORD(lParam
);
5715 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5717 btnPtr
= &infoPtr
->buttons
[nHit
];
5719 if ((nHit
>= 0) && bDragKeyPressed
&& (infoPtr
->dwStyle
& CCS_ADJUSTABLE
))
5721 infoPtr
->nButtonDrag
= nHit
;
5724 /* If drag cursor has not been loaded, load it.
5725 * Note: it doesn't need to be freed */
5727 hCursorDrag
= LoadCursorW(COMCTL32_hModule
, (LPCWSTR
)IDC_MOVEBUTTON
);
5728 SetCursor(hCursorDrag
);
5733 infoPtr
->nOldHit
= nHit
;
5735 CopyRect(&arrowRect
, &btnPtr
->rect
);
5736 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5738 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5739 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5740 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5741 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5742 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5743 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5747 /* draw in pressed state */
5748 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5749 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5751 btnPtr
->bDropDownPressed
= TRUE
;
5752 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5753 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5755 memset(&nmtb
, 0, sizeof(nmtb
));
5756 nmtb
.iItem
= btnPtr
->idCommand
;
5757 nmtb
.rcButton
= btnPtr
->rect
;
5758 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5760 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5762 if (res
!= TBDDRET_TREATPRESSED
)
5766 /* redraw button in unpressed state */
5767 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5768 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5770 btnPtr
->bDropDownPressed
= FALSE
;
5771 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5773 /* find and set hot item
5774 * NOTE: native doesn't do this, but that is a bug */
5776 ScreenToClient(hwnd
, &pt
);
5777 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5778 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5779 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5781 /* remove any left mouse button down or double-click messages
5782 * so that we can get a toggle effect on the button */
5783 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
) ||
5784 PeekMessageW(&msg
, hwnd
, WM_LBUTTONDBLCLK
, WM_LBUTTONDBLCLK
, PM_REMOVE
))
5789 /* otherwise drop through and process as pushed */
5791 infoPtr
->bCaptured
= TRUE
;
5792 infoPtr
->nButtonDown
= nHit
;
5793 infoPtr
->bDragOutSent
= FALSE
;
5795 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5797 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5799 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5800 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5807 memset(&nmtb
, 0, sizeof(nmtb
));
5808 nmtb
.iItem
= btnPtr
->idCommand
;
5809 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_BEGINDRAG
);
5812 nmmouse
.dwHitInfo
= nHit
;
5814 /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
5816 nmmouse
.dwItemSpec
= -1;
5819 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5820 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5823 ClientToScreen(hwnd
, &pt
);
5826 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_LDOWN
))
5827 return DefWindowProcW(hwnd
, WM_LBUTTONDOWN
, wParam
, lParam
);
5833 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5835 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5836 TBUTTON_INFO
*btnPtr
;
5840 BOOL bSendMessage
= TRUE
;
5845 if (infoPtr
->hwndToolTip
)
5846 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5847 WM_LBUTTONUP
, wParam
, lParam
);
5849 pt
.x
= (INT
)LOWORD(lParam
);
5850 pt
.y
= (INT
)HIWORD(lParam
);
5851 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5853 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5854 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5856 if (infoPtr
->nButtonDrag
>= 0) {
5860 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDrag
];
5863 SetCursor(LoadCursorW(NULL
, (LPCWSTR
)IDC_ARROW
));
5865 GetClientRect(hwnd
, &rcClient
);
5866 if (PtInRect(&rcClient
, pt
))
5873 else if ((nHit
== -1) && PtInRect(&infoPtr
->buttons
[-nHit
].rect
, pt
))
5876 if (nButton
== infoPtr
->nButtonDrag
)
5878 /* if the button is moved sightly left and we have a
5879 * separator there then remove it */
5880 if (pt
.x
< (btnPtr
->rect
.left
+ (btnPtr
->rect
.right
- btnPtr
->rect
.left
)/2))
5882 if ((nButton
> 0) && (infoPtr
->buttons
[nButton
-1].fsStyle
& BTNS_SEP
))
5883 TOOLBAR_DeleteButton(hwnd
, nButton
- 1, 0);
5885 else /* else insert a separator before the dragged button */
5888 memset(&tbb
, 0, sizeof(tbb
));
5889 tbb
.fsStyle
= BTNS_SEP
;
5891 TOOLBAR_InsertButtonW(hwnd
, nButton
, (LPARAM
)&tbb
);
5898 if ((infoPtr
->nNumButtons
> 0) && (pt
.x
< infoPtr
->buttons
[0].rect
.left
))
5899 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, 0);
5901 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, infoPtr
->nNumButtons
);
5904 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, nButton
);
5909 TRACE("button %d dragged out of toolbar\n", infoPtr
->nButtonDrag
);
5910 TOOLBAR_DeleteButton(hwnd
, (WPARAM
)infoPtr
->nButtonDrag
, 0);
5913 /* button under cursor changed so need to re-set hot item */
5914 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5915 infoPtr
->nButtonDrag
= -1;
5917 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
5919 else if (infoPtr
->nButtonDown
>= 0) {
5920 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5921 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5923 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
5924 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
5925 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
5927 if (nOldIndex
== nHit
)
5928 bSendMessage
= FALSE
;
5929 if ((nOldIndex
!= nHit
) &&
5931 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
5932 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5935 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
5936 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
5938 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5942 if (nOldIndex
!= -1)
5943 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
5946 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5947 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5948 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5950 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
5952 infoPtr
->nButtonDown
= -1;
5954 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5955 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
5956 NM_RELEASEDCAPTURE
);
5958 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5961 memset(&nmtb
, 0, sizeof(nmtb
));
5962 nmtb
.iItem
= btnPtr
->idCommand
;
5963 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5966 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5968 SendMessageW (infoPtr
->hwndNotify
, WM_COMMAND
,
5969 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
5973 /* !!! Undocumented - toolbar at 4.71 level and above sends
5974 * NM_CLICK with the NMMOUSE structure. */
5975 nmmouse
.dwHitInfo
= nHit
;
5977 if (nmmouse
.dwHitInfo
< 0)
5978 nmmouse
.dwItemSpec
= -1;
5981 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5982 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5985 ClientToScreen(hwnd
, &pt
);
5988 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_CLICK
))
5989 return DefWindowProcW(hwnd
, WM_LBUTTONUP
, wParam
, lParam
);
5995 TOOLBAR_RButtonUp( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5997 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6002 pt
.x
= LOWORD(lParam
);
6003 pt
.y
= HIWORD(lParam
);
6005 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
6006 nmmouse
.dwHitInfo
= nHit
;
6009 nmmouse
.dwItemSpec
= -1;
6011 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
6012 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
6015 ClientToScreen(hwnd
, &pt
);
6018 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_RCLICK
))
6019 return DefWindowProcW(hwnd
, WM_RBUTTONUP
, wParam
, lParam
);
6025 TOOLBAR_RButtonDblClk( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6027 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6030 if (!TOOLBAR_SendNotify(&nmhdr
, infoPtr
, NM_RDBLCLK
))
6031 return DefWindowProcW(hwnd
, WM_RBUTTONDBLCLK
, wParam
, lParam
);
6037 TOOLBAR_CaptureChanged(HWND hwnd
)
6039 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6040 TBUTTON_INFO
*btnPtr
;
6042 infoPtr
->bCaptured
= FALSE
;
6044 if (infoPtr
->nButtonDown
>= 0)
6046 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6047 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6049 infoPtr
->nOldHit
= -1;
6051 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
6052 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6058 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6060 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6061 TBUTTON_INFO
*hotBtnPtr
;
6063 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
6065 /* don't remove hot effects when in anchor highlighting mode or when a
6066 * drop-down button is pressed */
6067 if (!infoPtr
->bAnchor
&& (infoPtr
->nOldHit
< 0 || !hotBtnPtr
->bDropDownPressed
))
6068 TOOLBAR_SetHotItemEx(infoPtr
, TOOLBAR_NOWHERE
, HICF_MOUSE
);
6070 if (infoPtr
->nOldHit
< 0)
6073 /* If the last button we were over is depressed then make it not */
6074 /* depressed and redraw it */
6075 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
6077 TBUTTON_INFO
*btnPtr
;
6080 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6082 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6084 rc1
= hotBtnPtr
->rect
;
6085 InflateRect (&rc1
, 1, 1);
6086 InvalidateRect (hwnd
, &rc1
, TRUE
);
6089 if (infoPtr
->bCaptured
&& !infoPtr
->bDragOutSent
)
6092 ZeroMemory(&nmt
, sizeof(nmt
));
6093 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6094 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6095 infoPtr
->bDragOutSent
= TRUE
;
6098 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
6104 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6106 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6108 TRACKMOUSEEVENT trackinfo
;
6110 TBUTTON_INFO
*btnPtr
;
6112 /* fill in the TRACKMOUSEEVENT struct */
6113 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
6114 trackinfo
.dwFlags
= TME_QUERY
;
6115 trackinfo
.hwndTrack
= hwnd
;
6116 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
6118 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
6119 _TrackMouseEvent(&trackinfo
);
6121 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
6122 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
6123 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
6125 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
6126 /* and can properly deactivate the hot toolbar button */
6127 _TrackMouseEvent(&trackinfo
);
6130 if (infoPtr
->hwndToolTip
)
6131 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
6132 WM_MOUSEMOVE
, wParam
, lParam
);
6134 pt
.x
= (INT
)LOWORD(lParam
);
6135 pt
.y
= (INT
)HIWORD(lParam
);
6137 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
6139 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
6140 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
6142 if (infoPtr
->nOldHit
!= nHit
)
6144 if (infoPtr
->bCaptured
)
6146 if (!infoPtr
->bDragOutSent
)
6149 ZeroMemory(&nmt
, sizeof(nmt
));
6150 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6151 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6152 infoPtr
->bDragOutSent
= TRUE
;
6155 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6156 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
6157 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6158 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6160 else if (nHit
== infoPtr
->nButtonDown
) {
6161 btnPtr
->fsState
|= TBSTATE_PRESSED
;
6162 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6164 infoPtr
->nOldHit
= nHit
;
6172 inline static LRESULT
6173 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6175 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
6176 return DefWindowProcW (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
6178 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
6182 inline static LRESULT
6183 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6185 if (!(GetWindowLongW(hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
6186 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
6188 return DefWindowProcW (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
6193 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6195 TOOLBAR_INFO
*infoPtr
;
6196 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
6199 /* allocate memory for info structure */
6200 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
6201 SetWindowLongPtrW (hwnd
, 0, (LONG_PTR
)infoPtr
);
6204 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
6207 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
6208 if (!GetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
)) {
6209 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW (GetParent (hwnd
), GWLP_HINSTANCE
);
6210 SetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
, (LONG_PTR
)hInst
);
6213 /* native control does:
6214 * Get a lot of colors and brushes
6216 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
6217 * CreateFontIndirectA(adr1)
6218 * CreateBitmap(0x27, 0x24, 1, 1, 0)
6219 * hdc = GetDC(toolbar)
6220 * GetSystemMetrics(0x48)
6221 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
6222 * 0, 0, 0, 0, "MARLETT")
6223 * oldfnt = SelectObject(hdc, fnt2)
6224 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
6225 * GetTextMetricsA(hdc, adr3)
6226 * SelectObject(hdc, oldfnt)
6227 * DeleteObject(fnt2)
6229 * InvalidateRect(toolbar, 0, 1)
6230 * SetWindowLongA(toolbar, 0, addr)
6231 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
6234 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
6235 * ie 2 0x4600094c 0x4600094c 0x4600894d
6236 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
6237 * rebar 0x50008844 0x40008844 0x50008845
6238 * pager 0x50000844 0x40000844 0x50008845
6239 * IC35mgr 0x5400084e **nochange**
6240 * on entry to _NCCREATE 0x5400084e
6241 * rowlist 0x5400004e **nochange**
6242 * on entry to _NCCREATE 0x5400004e
6246 /* I think the code below is a bug, but it is the way that the native
6247 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
6248 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
6249 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
6250 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
6251 * Some how, the only cases of this seem to be MFC programs.
6253 * Note also that the addition of _TRANSPARENT occurs *only* here. It
6254 * does not occur in the WM_STYLECHANGING routine.
6255 * (Guy Albertelli 9/2001)
6258 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
6259 styleadd
|= TBSTYLE_TRANSPARENT
;
6260 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
6261 styleadd
|= CCS_TOP
; /* default to top */
6262 SetWindowLongW (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
6265 return DefWindowProcW (hwnd
, WM_NCCREATE
, wParam
, lParam
);
6270 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6272 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
6276 if (dwStyle
& WS_MINIMIZE
)
6277 return 0; /* Nothing to do */
6279 DefWindowProcW (hwnd
, WM_NCPAINT
, wParam
, lParam
);
6281 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
6284 if (!(dwStyle
& CCS_NODIVIDER
))
6286 GetWindowRect (hwnd
, &rcWindow
);
6287 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
6288 if( dwStyle
& WS_BORDER
)
6289 OffsetRect (&rcWindow
, 1, 1);
6290 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
6293 ReleaseDC( hwnd
, hdc
);
6299 /* handles requests from the tooltip control on what text to display */
6300 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
6302 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
6304 TRACE("button index = %d\n", index
);
6306 if (infoPtr
->pszTooltipText
)
6308 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
6309 infoPtr
->pszTooltipText
= NULL
;
6315 if (infoPtr
->bNtfUnicode
)
6317 WCHAR wszBuffer
[INFOTIPSIZE
+1];
6318 NMTBGETINFOTIPW tbgit
;
6319 unsigned int len
; /* in chars */
6321 wszBuffer
[0] = '\0';
6322 wszBuffer
[INFOTIPSIZE
] = '\0';
6324 tbgit
.pszText
= wszBuffer
;
6325 tbgit
.cchTextMax
= INFOTIPSIZE
;
6326 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6327 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6329 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
6331 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
6333 len
= strlenW(tbgit
.pszText
);
6334 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6336 /* need to allocate temporary buffer in infoPtr as there
6337 * isn't enough space in buffer passed to us by the
6338 * tooltip control */
6339 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
6340 if (infoPtr
->pszTooltipText
)
6342 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6343 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6349 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6355 CHAR szBuffer
[INFOTIPSIZE
+1];
6356 NMTBGETINFOTIPA tbgit
;
6357 unsigned int len
; /* in chars */
6360 szBuffer
[INFOTIPSIZE
] = '\0';
6362 tbgit
.pszText
= szBuffer
;
6363 tbgit
.cchTextMax
= INFOTIPSIZE
;
6364 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6365 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6367 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
6369 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
6371 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
6372 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6374 /* need to allocate temporary buffer in infoPtr as there
6375 * isn't enough space in buffer passed to us by the
6376 * tooltip control */
6377 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
6378 if (infoPtr
->pszTooltipText
)
6380 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
6381 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6387 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
6392 /* if button has text, but it is not shown then automatically
6393 * use that text as tooltip */
6394 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
6395 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
6397 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
6398 unsigned int len
= pszText
? strlenW(pszText
) : 0;
6400 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
6402 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6404 /* need to allocate temporary buffer in infoPtr as there
6405 * isn't enough space in buffer passed to us by the
6406 * tooltip control */
6407 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
6408 if (infoPtr
->pszTooltipText
)
6410 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
6411 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6417 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
6422 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
6424 /* last resort: send notification on to app */
6425 /* FIXME: find out what is really used here */
6426 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
6430 inline static LRESULT
6431 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6433 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6434 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
6436 switch (lpnmh
->code
)
6440 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
6442 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
6443 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
6444 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
6448 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
6449 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
6457 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
6459 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
6460 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
6461 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
6462 lppgs
->iScroll
, lppgs
->iDir
);
6466 case TTN_GETDISPINFOW
:
6467 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
6469 case TTN_GETDISPINFOA
:
6470 FIXME("TTN_GETDISPINFOA - stub\n");
6480 TOOLBAR_NotifyFormatFake(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6482 /* remove this routine when Toolbar is improved to pass infoPtr
6483 * around instead of hwnd.
6485 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6486 return TOOLBAR_NotifyFormat(infoPtr
, wParam
, lParam
);
6491 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
6495 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
6497 if (lParam
== NF_QUERY
)
6500 if (lParam
== NF_REQUERY
) {
6501 format
= SendMessageW(infoPtr
->hwndNotify
,
6502 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
6503 if ((format
!= NFR_ANSI
) && (format
!= NFR_UNICODE
)) {
6504 ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n",
6515 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
6517 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6521 /* fill ps.rcPaint with a default rect */
6522 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
6524 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
6526 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
6527 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
6528 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
6530 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
6531 if (!wParam
) EndPaint (hwnd
, &ps
);
6538 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6539 /*****************************************************
6542 * Handles the WM_SETREDRAW message.
6545 * According to testing V4.71 of COMCTL32 returns the
6546 * *previous* status of the redraw flag (either 0 or 1)
6547 * instead of the MSDN documented value of 0 if handled.
6548 * (For laughs see the "consistency" with same function
6551 *****************************************************/
6553 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6554 BOOL oldredraw
= infoPtr
->bDoRedraw
;
6556 TRACE("set to %s\n",
6557 (wParam
) ? "TRUE" : "FALSE");
6558 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
6560 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
6562 return (oldredraw
) ? 1 : 0;
6567 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6569 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6570 DWORD dwStyle
= infoPtr
->dwStyle
;
6579 /* Resize deadlock check */
6580 if (infoPtr
->bAutoSize
) {
6581 infoPtr
->bAutoSize
= FALSE
;
6585 /* FIXME: optimize to only update size if the new size doesn't */
6586 /* match the current size */
6588 flags
= (INT
) wParam
;
6590 /* FIXME for flags =
6591 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
6594 TRACE("sizing toolbar!\n");
6596 if (flags
== SIZE_RESTORED
) {
6597 /* width and height don't apply */
6598 parent
= GetParent (hwnd
);
6599 GetClientRect(parent
, &parent_rect
);
6600 x
= parent_rect
.left
;
6601 y
= parent_rect
.top
;
6603 if (dwStyle
& CCS_NORESIZE
) {
6604 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
6607 * this sets the working width of the toolbar, and
6608 * Calc Toolbar will not adjust it, only the height
6610 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6611 cy
= infoPtr
->nHeight
;
6612 cx
= infoPtr
->nWidth
;
6613 TOOLBAR_CalcToolbar (hwnd
);
6614 infoPtr
->nWidth
= cx
;
6615 infoPtr
->nHeight
= cy
;
6618 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6619 TOOLBAR_CalcToolbar (hwnd
);
6620 cy
= infoPtr
->nHeight
;
6621 cx
= infoPtr
->nWidth
;
6623 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
6624 GetWindowRect(hwnd
, &window_rect
);
6625 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
6626 y
= window_rect
.top
;
6628 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6629 GetWindowRect(hwnd
, &window_rect
);
6630 y
= parent_rect
.bottom
-
6631 ( window_rect
.bottom
- window_rect
.top
);
6635 if (dwStyle
& CCS_NOPARENTALIGN
) {
6636 uPosFlags
|= SWP_NOMOVE
;
6637 cy
= infoPtr
->nHeight
;
6638 cx
= infoPtr
->nWidth
;
6641 if (!(dwStyle
& CCS_NODIVIDER
))
6642 cy
+= GetSystemMetrics(SM_CYEDGE
);
6644 if (dwStyle
& WS_BORDER
)
6647 cy
+= GetSystemMetrics(SM_CYEDGE
);
6648 cx
+= GetSystemMetrics(SM_CYEDGE
);
6651 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6653 RECT delta_width
, delta_height
, client
, dummy
;
6654 DWORD min_x
, max_x
, min_y
, max_y
;
6655 TBUTTON_INFO
*btnPtr
;
6658 GetClientRect(hwnd
, &client
);
6659 if(client
.right
> infoPtr
->client_rect
.right
)
6661 min_x
= infoPtr
->client_rect
.right
;
6662 max_x
= client
.right
;
6666 max_x
= infoPtr
->client_rect
.right
;
6667 min_x
= client
.right
;
6669 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6671 min_y
= infoPtr
->client_rect
.bottom
;
6672 max_y
= client
.bottom
;
6676 max_y
= infoPtr
->client_rect
.bottom
;
6677 min_y
= client
.bottom
;
6680 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6681 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6683 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6684 btnPtr
= infoPtr
->buttons
;
6685 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6686 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6687 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6688 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6691 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) != (SWP_NOSIZE
| SWP_NOMOVE
))
6692 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6694 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6700 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6702 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6704 if (nType
== GWL_STYLE
) {
6705 if (lpStyle
->styleNew
& TBSTYLE_LIST
) {
6706 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
;
6709 infoPtr
->dwDTFlags
= DT_CENTER
| DT_END_ELLIPSIS
;
6711 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6712 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6713 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6715 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6717 infoPtr
->dwStyle
= lpStyle
->styleNew
;
6720 TOOLBAR_CalcToolbar(hwnd
);
6722 TOOLBAR_AutoSize (hwnd
);
6724 InvalidateRect(hwnd
, NULL
, TRUE
);
6731 TOOLBAR_SysColorChange (HWND hwnd
)
6733 COMCTL32_RefreshSysColors();
6740 static LRESULT WINAPI
6741 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6743 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6745 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6746 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6748 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
6749 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
6754 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6756 case TB_ADDBUTTONSA
:
6757 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6759 case TB_ADDBUTTONSW
:
6760 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6763 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6766 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6769 return TOOLBAR_AutoSize (hwnd
);
6771 case TB_BUTTONCOUNT
:
6772 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6774 case TB_BUTTONSTRUCTSIZE
:
6775 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6777 case TB_CHANGEBITMAP
:
6778 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6780 case TB_CHECKBUTTON
:
6781 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6783 case TB_COMMANDTOINDEX
:
6784 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6787 return TOOLBAR_Customize (hwnd
);
6789 case TB_DELETEBUTTON
:
6790 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6792 case TB_ENABLEBUTTON
:
6793 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6795 case TB_GETANCHORHIGHLIGHT
:
6796 return TOOLBAR_GetAnchorHighlight (hwnd
);
6799 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6801 case TB_GETBITMAPFLAGS
:
6802 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6805 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6807 case TB_GETBUTTONINFOA
:
6808 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6810 case TB_GETBUTTONINFOW
:
6811 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6813 case TB_GETBUTTONSIZE
:
6814 return TOOLBAR_GetButtonSize (hwnd
);
6816 case TB_GETBUTTONTEXTA
:
6817 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6819 case TB_GETBUTTONTEXTW
:
6820 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6822 case TB_GETDISABLEDIMAGELIST
:
6823 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6825 case TB_GETEXTENDEDSTYLE
:
6826 return TOOLBAR_GetExtendedStyle (hwnd
);
6828 case TB_GETHOTIMAGELIST
:
6829 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6832 return TOOLBAR_GetHotItem (hwnd
);
6834 case TB_GETIMAGELIST
:
6835 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6837 case TB_GETINSERTMARK
:
6838 return TOOLBAR_GetInsertMark (hwnd
, wParam
, lParam
);
6840 case TB_GETINSERTMARKCOLOR
:
6841 return TOOLBAR_GetInsertMarkColor (hwnd
, wParam
, lParam
);
6843 case TB_GETITEMRECT
:
6844 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6847 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6849 /* case TB_GETOBJECT: */ /* 4.71 */
6852 return TOOLBAR_GetPadding (hwnd
);
6855 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6858 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6861 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6864 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6867 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6870 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6872 case TB_GETTEXTROWS
:
6873 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6875 case TB_GETTOOLTIPS
:
6876 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6878 case TB_GETUNICODEFORMAT
:
6879 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6882 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6885 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6887 case TB_INDETERMINATE
:
6888 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6890 case TB_INSERTBUTTONA
:
6891 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6893 case TB_INSERTBUTTONW
:
6894 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6896 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6898 case TB_ISBUTTONCHECKED
:
6899 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6901 case TB_ISBUTTONENABLED
:
6902 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6904 case TB_ISBUTTONHIDDEN
:
6905 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
6907 case TB_ISBUTTONHIGHLIGHTED
:
6908 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
6910 case TB_ISBUTTONINDETERMINATE
:
6911 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
6913 case TB_ISBUTTONPRESSED
:
6914 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
6917 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
6919 case TB_MAPACCELERATORA
:
6920 case TB_MAPACCELERATORW
:
6921 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
6924 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
6927 return TOOLBAR_MoveButton (hwnd
, wParam
, lParam
);
6929 case TB_PRESSBUTTON
:
6930 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
6932 case TB_REPLACEBITMAP
:
6933 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
6935 case TB_SAVERESTOREA
:
6936 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, (LPTBSAVEPARAMSA
)lParam
);
6938 case TB_SAVERESTOREW
:
6939 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, (LPTBSAVEPARAMSW
)lParam
);
6941 case TB_SETANCHORHIGHLIGHT
:
6942 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
6944 case TB_SETBITMAPSIZE
:
6945 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
6947 case TB_SETBUTTONINFOA
:
6948 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
6950 case TB_SETBUTTONINFOW
:
6951 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
6953 case TB_SETBUTTONSIZE
:
6954 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
6956 case TB_SETBUTTONWIDTH
:
6957 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
6960 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
6962 case TB_SETDISABLEDIMAGELIST
:
6963 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
6965 case TB_SETDRAWTEXTFLAGS
:
6966 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
6968 case TB_SETEXTENDEDSTYLE
:
6969 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
6971 case TB_SETHOTIMAGELIST
:
6972 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
6975 return TOOLBAR_SetHotItem (hwnd
, wParam
);
6977 case TB_SETIMAGELIST
:
6978 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
6981 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
6983 case TB_SETINSERTMARK
:
6984 return TOOLBAR_SetInsertMark (hwnd
, wParam
, lParam
);
6986 case TB_SETINSERTMARKCOLOR
:
6987 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
6989 case TB_SETMAXTEXTROWS
:
6990 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
6993 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
6996 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
6999 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
7002 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
7005 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
7007 case TB_SETTOOLTIPS
:
7008 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
7010 case TB_SETUNICODEFORMAT
:
7011 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
7014 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
7017 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
7020 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
7023 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
7026 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
7029 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
7031 /* Common Control Messages */
7033 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
7034 case CCM_GETCOLORSCHEME
:
7035 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7037 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
7038 case CCM_SETCOLORSCHEME
:
7039 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7041 case CCM_GETVERSION
:
7042 return TOOLBAR_GetVersion (hwnd
);
7044 case CCM_SETVERSION
:
7045 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
7051 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
7054 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
7057 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
7060 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
7062 /* case WM_KEYDOWN: */
7063 /* case WM_KILLFOCUS: */
7065 case WM_LBUTTONDBLCLK
:
7066 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
7068 case WM_LBUTTONDOWN
:
7069 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
7072 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
7075 return TOOLBAR_RButtonUp (hwnd
, wParam
, lParam
);
7077 case WM_RBUTTONDBLCLK
:
7078 return TOOLBAR_RButtonDblClk (hwnd
, wParam
, lParam
);
7081 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
7084 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
7086 case WM_CAPTURECHANGED
:
7087 return TOOLBAR_CaptureChanged(hwnd
);
7090 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
7093 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
7096 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
7099 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
7102 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
7104 case WM_NOTIFYFORMAT
:
7105 return TOOLBAR_NotifyFormatFake (hwnd
, wParam
, lParam
);
7108 return TOOLBAR_Paint (hwnd
, wParam
);
7111 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
7114 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
7116 case WM_STYLECHANGED
:
7117 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
7119 case WM_SYSCOLORCHANGE
:
7120 return TOOLBAR_SysColorChange (hwnd
);
7122 /* case WM_WININICHANGE: */
7127 case WM_MEASUREITEM
:
7129 return SendMessageW (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
7131 /* We see this in Outlook Express 5.x and just does DefWindowProc */
7132 case PGM_FORWARDMOUSE
:
7133 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7136 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
7137 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
7138 uMsg
, wParam
, lParam
);
7139 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7146 TOOLBAR_Register (void)
7150 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
7151 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
7152 wndClass
.lpfnWndProc
= ToolbarWindowProc
;
7153 wndClass
.cbClsExtra
= 0;
7154 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
7155 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
7156 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
7157 wndClass
.lpszClassName
= TOOLBARCLASSNAMEW
;
7159 RegisterClassW (&wndClass
);
7164 TOOLBAR_Unregister (void)
7166 UnregisterClassW (TOOLBARCLASSNAMEW
, NULL
);
7169 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
7174 /* Check if the entry already exists */
7175 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
7177 /* If this is a new entry we must create it and insert into the array */
7182 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
7185 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
7186 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
7201 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
7205 for (i
= 0; i
< *cies
; i
++)
7215 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
7223 for (i
= 0; i
< cies
; i
++)
7225 if (pies
[i
]->id
== id
)
7237 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
7239 HIMAGELIST himlDef
= 0;
7240 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
7243 himlDef
= pie
->himl
;
7249 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
7251 if (infoPtr
->bUnicode
)
7252 return TOOLBAR_SendNotify ((NMHDR
*) nmtb
, infoPtr
, TBN_GETBUTTONINFOW
);
7259 nmtba
.iItem
= nmtb
->iItem
;
7260 nmtba
.pszText
= Buffer
;
7261 nmtba
.cchText
= 256;
7262 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
7264 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtba
, infoPtr
, TBN_GETBUTTONINFOA
))
7266 int ccht
= strlen(nmtba
.pszText
);
7268 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
7269 nmtb
->pszText
, nmtb
->cchText
);
7271 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
7280 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
7281 int iItem
, PCUSTOMBUTTON btnInfo
)
7285 /* MSDN states that iItem is the index of the button, rather than the
7286 * command ID as used by every other NMTOOLBAR notification */
7288 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
7290 return TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYDELETE
);