4 * Copyright 1998,1999 Eric Kohl
5 * Copyright 2000 Eric Kohl for CodeWeavers
6 * Copyright 2004 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * This code was audited for completeness against the documented features
25 * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
27 * Unless otherwise noted, we believe this code to be complete, as per
28 * the specification mentioned above.
29 * If you discover missing features or bugs please note them below.
33 * - TBSTYLE_REGISTERDROP
34 * - TBSTYLE_EX_DOUBLEBUFFER
38 * - TB_INSERTMARKHITTEST
47 * - Button wrapping (under construction).
49 * - iListGap custom draw support.
52 * - Run tests using Waite Group Windows95 API Bible Volume 2.
53 * The second cdrom contains executables addstr.exe, btncount.exe,
54 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
55 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
56 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
57 * setparnt.exe, setrows.exe, toolwnd.exe.
58 * - Microsoft's controlspy examples.
59 * - Charles Petzold's 'Programming Windows': gadgets.exe
61 * Differences between MSDN and actual native control operation:
62 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
63 * to the right of the bitmap. Otherwise, this style is
64 * identical to TBSTYLE_FLAT."
65 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
66 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
67 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
68 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
80 #include "wine/unicode.h"
84 #include "wine/debug.h"
86 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
88 static HCURSOR hCursorDrag
= NULL
;
97 BYTE bDropDownPressed
;
102 INT cx
; /* manually set size */
116 } IMLENTRY
, *PIMLENTRY
;
120 DWORD dwStructSize
; /* size of TBBUTTON struct */
121 INT nHeight
; /* height of the toolbar */
122 INT nWidth
; /* width of the toolbar */
124 RECT rcBound
; /* bounding rectangle */
130 INT nRows
; /* number of button rows */
131 INT nMaxTextRows
; /* maximum number of text rows */
132 INT cxMin
; /* minimum button width */
133 INT cxMax
; /* maximum button width */
134 INT nNumButtons
; /* number of buttons */
135 INT nNumBitmaps
; /* number of bitmaps */
136 INT nNumStrings
; /* number of strings */
138 INT nButtonDown
; /* toolbar button being pressed or -1 if none */
139 INT nButtonDrag
; /* toolbar button being dragged or -1 if none */
141 INT nHotItem
; /* index of the "hot" item */
142 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
143 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
144 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
145 SIZE szPadding
; /* padding values around button */
146 INT iListGap
; /* default gap between text and image for toolbar with list style */
148 HFONT hFont
; /* text font */
149 HIMAGELIST himlInt
; /* image list created internally */
150 PIMLENTRY
*himlDef
; /* default image list array */
151 INT cimlDef
; /* default image list array count */
152 PIMLENTRY
*himlHot
; /* hot image list array */
153 INT cimlHot
; /* hot image list array count */
154 PIMLENTRY
*himlDis
; /* disabled image list array */
155 INT cimlDis
; /* disabled image list array count */
156 HWND hwndToolTip
; /* handle to tool tip control */
157 HWND hwndNotify
; /* handle to the window that gets notifications */
158 HWND hwndSelf
; /* my own handle */
159 BOOL bBtnTranspnt
; /* button transparency flag */
160 BOOL bAutoSize
; /* auto size deadlock indicator */
161 BOOL bAnchor
; /* anchor highlight enabled */
162 BOOL bDoRedraw
; /* Redraw status */
163 BOOL bDragOutSent
; /* has TBN_DRAGOUT notification been sent for this drag? */
164 BOOL bUnicode
; /* Notifications are ASCII (FALSE) or Unicode (TRUE)? */
165 BOOL bCaptured
; /* mouse captured? */
166 DWORD dwStyle
; /* regular toolbar style */
167 DWORD dwExStyle
; /* extended toolbar style */
168 DWORD dwDTFlags
; /* DrawText flags */
170 COLORREF clrInsertMark
; /* insert mark color */
171 COLORREF clrBtnHighlight
; /* color for Flat Separator */
172 COLORREF clrBtnShadow
; /* color for Flag Separator */
174 LPWSTR pszTooltipText
; /* temporary store for a string > 80 characters
175 * for TTN_GETDISPINFOW notification */
176 TBINSERTMARK tbim
; /* info on insertion mark */
177 TBUTTON_INFO
*buttons
; /* pointer to button array */
178 LPWSTR
*strings
; /* pointer to string array */
179 TBITMAP_INFO
*bitmaps
;
180 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
183 /* used by customization dialog */
186 PTOOLBAR_INFO tbInfo
;
188 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
196 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
205 #define SEPARATOR_WIDTH 8
207 #define BOTTOM_BORDER 2
208 #define DDARROW_WIDTH 11
209 #define ARROW_HEIGHT 3
210 #define INSERTMARK_WIDTH 2
216 /* vertical padding used in list mode when image is present */
219 /* how wide to treat the bitmap if it isn't present */
220 #define NONLIST_NOTEXT_OFFSET 2
222 #define TOOLBAR_NOWHERE (-1)
224 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongPtrW(hwnd,0))
225 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
226 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
228 /* Used to find undocumented extended styles */
229 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
230 TBSTYLE_EX_UNDOC1 | \
231 TBSTYLE_EX_MIXEDBUTTONS | \
232 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
234 /* all of the CCS_ styles */
235 #define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \
236 CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT)
238 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
239 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
240 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
241 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
242 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
244 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
245 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
246 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
247 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
248 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
249 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
250 static LRESULT
TOOLBAR_LButtonDown(HWND hwnd
, WPARAM wParam
, LPARAM lParam
);
251 static void TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
);
254 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
258 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
260 LPWSTR lpText
= NULL
;
262 /* NOTE: iString == -1 is undocumented */
263 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
264 lpText
= (LPWSTR
)btnPtr
->iString
;
265 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
266 lpText
= infoPtr
->strings
[btnPtr
->iString
];
272 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
274 if (TRACE_ON(toolbar
)){
275 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
276 btn_num
, bP
->idCommand
, GETIBITMAP(infoPtr
, bP
->iBitmap
),
277 bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
278 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
280 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
281 btn_num
, bP
->idCommand
,
282 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
283 bP
->rect
.left
, bP
->rect
.top
,
284 bP
->rect
.right
, bP
->rect
.bottom
);
290 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
292 if (TRACE_ON(toolbar
)) {
295 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
297 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
298 iP
->nNumStrings
, iP
->dwStyle
);
299 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
301 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
302 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
303 for(i
=0; i
<iP
->nNumButtons
; i
++) {
304 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
310 /***********************************************************************
313 * This function validates that the styles set are implemented and
314 * issues FIXME's warning of possible problems. In a perfect world this
315 * function should be null.
318 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
320 if (dwStyle
& TBSTYLE_REGISTERDROP
)
321 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd
);
326 TOOLBAR_SendNotify (NMHDR
*nmhdr
, TOOLBAR_INFO
*infoPtr
, UINT code
)
328 if(!IsWindow(infoPtr
->hwndSelf
))
329 return 0; /* we have just been destroyed */
331 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
332 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
335 TRACE("to window %p, code=%08x, %s\n", infoPtr
->hwndNotify
, code
,
336 (infoPtr
->bUnicode
) ? "via Unicode" : "via ANSI");
338 return SendMessageW(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
)
356 /* issue TBN_GETDISPINFO */
359 memset(&nmgd
, 0, sizeof(nmgd
));
360 nmgd
.idCommand
= btnPtr
->idCommand
;
361 nmgd
.lParam
= btnPtr
->dwData
;
362 nmgd
.dwMask
= TBNF_IMAGE
;
363 TOOLBAR_SendNotify(&nmgd
.hdr
, infoPtr
,
364 infoPtr
->bUnicode
? TBN_GETDISPINFOW
: TBN_GETDISPINFOA
);
365 if (nmgd
.dwMask
& TBNF_DI_SETITEM
)
366 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
))
396 TOOLBAR_IsValidImageList(TOOLBAR_INFO
*infoPtr
, INT index
)
398 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, index
));
399 return (himl
!= NULL
) && (ImageList_GetImageCount(himl
) > 0);
403 /***********************************************************************
404 * TOOLBAR_GetImageListForDrawing
406 * This function validates the bitmap index (including I_IMAGECALLBACK
407 * functionality) and returns the corresponding image list.
410 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
414 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
415 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
416 ERR("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
417 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
421 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
422 if ((*index
== I_IMAGECALLBACK
) ||
423 (*index
== I_IMAGENONE
)) return NULL
;
424 ERR("TBN_GETDISPINFO returned invalid index %d\n",
431 case IMAGE_LIST_DEFAULT
:
432 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
435 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
437 case IMAGE_LIST_DISABLED
:
438 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
442 FIXME("Shouldn't reach here\n");
446 TRACE("no image list\n");
453 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
456 COLORREF oldcolor
, newcolor
;
458 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
459 myrect
.right
= myrect
.left
+ 1;
460 myrect
.top
= lpRect
->top
+ 2;
461 myrect
.bottom
= lpRect
->bottom
- 2;
463 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
464 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
465 oldcolor
= SetBkColor (hdc
, newcolor
);
466 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
468 myrect
.left
= myrect
.right
;
469 myrect
.right
= myrect
.left
+ 1;
471 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
472 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
473 SetBkColor (hdc
, newcolor
);
474 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
476 SetBkColor (hdc
, oldcolor
);
480 /***********************************************************************
481 * TOOLBAR_DrawDDFlatSeparator
483 * This function draws the separator that was flagged as BTNS_DROPDOWN.
484 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
485 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
486 * are horizontal as opposed to the vertical separators for not dropdown
489 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
492 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
495 COLORREF oldcolor
, newcolor
;
497 myrect
.left
= lpRect
->left
;
498 myrect
.right
= lpRect
->right
;
499 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
500 myrect
.bottom
= myrect
.top
+ 1;
502 InflateRect (&myrect
, -2, 0);
504 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
505 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
507 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
508 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
509 oldcolor
= SetBkColor (hdc
, newcolor
);
510 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
512 myrect
.top
= myrect
.bottom
;
513 myrect
.bottom
= myrect
.top
+ 1;
515 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
516 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
517 SetBkColor (hdc
, newcolor
);
518 ExtTextOutW (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
520 SetBkColor (hdc
, oldcolor
);
525 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
530 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
531 hOldPen
= SelectObject ( hdc
, hPen
);
534 MoveToEx (hdc
, x
, y
, NULL
);
535 LineTo (hdc
, x
+5, y
++); x
++;
536 MoveToEx (hdc
, x
, y
, NULL
);
537 LineTo (hdc
, x
+3, y
++); x
++;
538 MoveToEx (hdc
, x
, y
, NULL
);
539 LineTo (hdc
, x
+1, y
++);
540 SelectObject( hdc
, hOldPen
);
541 DeleteObject( hPen
);
545 * Draw the text string for this button.
546 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
547 * is non-zero, so we can simply check himlDef to see if we have
551 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
552 NMTBCUSTOMDRAW
*tbcd
)
554 HDC hdc
= tbcd
->nmcd
.hdc
;
557 COLORREF clrOldBk
= 0;
559 UINT state
= tbcd
->nmcd
.uItemState
;
563 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
564 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
566 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
567 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
568 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
570 else if (state
& CDIS_DISABLED
) {
571 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
572 OffsetRect (rcText
, 1, 1);
573 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
574 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
575 OffsetRect (rcText
, -1, -1);
577 else if (state
& CDIS_INDETERMINATE
) {
578 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
580 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
581 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
582 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
583 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
586 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
589 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
590 SetTextColor (hdc
, clrOld
);
591 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
593 SetBkColor (hdc
, clrOldBk
);
594 SetBkMode (hdc
, oldBkMode
);
596 SelectObject (hdc
, hOldFont
);
602 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
604 HDC hdc
= tbcd
->nmcd
.hdc
;
605 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
608 INT cx
= lpRect
->right
- lpRect
->left
;
609 INT cy
= lpRect
->bottom
- lpRect
->top
;
610 INT cxEdge
= GetSystemMetrics(SM_CXEDGE
);
611 INT cyEdge
= GetSystemMetrics(SM_CYEDGE
);
612 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
613 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
614 PatBlt (hdc
, lpRect
->left
+ cxEdge
, lpRect
->top
+ cyEdge
,
615 cx
- (2 * cxEdge
), cy
- (2 * cyEdge
), PATCOPY
);
616 SetBkColor(hdc
, clrBkOld
);
617 SetTextColor(hdc
, clrTextOld
);
618 SelectObject (hdc
, hbr
);
622 static void TOOLBAR_DrawMasked(HIMAGELIST himl
, int index
, HDC hdc
, INT x
, INT y
, UINT draw_flags
)
625 HBITMAP hbmMask
, hbmImage
;
626 HDC hdcMask
, hdcImage
;
628 ImageList_GetIconSize(himl
, &cx
, &cy
);
630 /* Create src image */
631 hdcImage
= CreateCompatibleDC(hdc
);
632 hbmImage
= CreateCompatibleBitmap(hdc
, cx
, cy
);
633 SelectObject(hdcImage
, hbmImage
);
634 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
635 RGB(0xff, 0xff, 0xff), RGB(0,0,0), draw_flags
);
638 hdcMask
= CreateCompatibleDC(0);
639 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
640 SelectObject(hdcMask
, hbmMask
);
642 /* Remove the background and all white pixels */
643 ImageList_DrawEx(himl
, index
, hdcMask
, 0, 0, cx
, cy
,
644 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_MASK
);
645 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
646 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
648 /* draw the new mask 'etched' to hdc */
649 SetBkColor(hdc
, RGB(255, 255, 255));
650 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
651 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
652 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
653 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
654 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
657 DeleteObject(hbmImage
);
659 DeleteObject (hbmMask
);
665 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
669 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
670 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
671 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
672 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
673 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
674 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
675 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
679 /* draws the image on a toolbar button */
681 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
683 HIMAGELIST himl
= NULL
;
684 BOOL draw_masked
= FALSE
;
687 UINT draw_flags
= ILD_TRANSPARENT
;
689 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
691 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
694 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
698 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (infoPtr
->dwStyle
& TBSTYLE_FLAT
))
700 /* if hot, attempt to draw with hot image list, if fails,
701 use default image list */
702 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
704 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
707 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
712 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
713 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
716 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
717 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
718 draw_flags
|= ILD_BLEND50
;
720 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
721 index
, himl
, left
, top
, offset
);
724 TOOLBAR_DrawMasked (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
726 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
729 /* draws a blank frame for a toolbar button */
731 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
)
733 HDC hdc
= tbcd
->nmcd
.hdc
;
734 RECT rc
= tbcd
->nmcd
.rc
;
735 /* if the state is disabled or indeterminate then the button
736 * cannot have an interactive look like pressed or hot */
737 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
738 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
739 BOOL pressed_look
= !non_interactive_state
&&
740 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
741 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
743 /* app don't want us to draw any edges */
744 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
747 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
750 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
751 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
752 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
757 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
759 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
760 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
765 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
, BOOL bDropDownPressed
)
767 HDC hdc
= tbcd
->nmcd
.hdc
;
769 BOOL pressed
= bDropDownPressed
||
770 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
));
772 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
775 DrawEdge (hdc
, rcArrow
, BDR_SUNKENOUTER
, BF_RECT
);
776 else if ( (tbcd
->nmcd
.uItemState
& CDIS_HOT
) &&
777 !(tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) &&
778 !(tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
))
779 DrawEdge (hdc
, rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
784 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
786 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
787 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
791 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
793 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
795 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+1, rcArrow
->top
+1 + (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
796 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
, rcArrow
->top
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
799 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+ offset
, rcArrow
->top
+ offset
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
802 /* draws a complete toolbar button */
804 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
806 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
807 DWORD dwStyle
= infoPtr
->dwStyle
;
808 BOOL hasDropDownArrow
= (TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
809 (btnPtr
->fsStyle
& BTNS_DROPDOWN
)) ||
810 (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
811 BOOL drawSepDropDownArrow
= hasDropDownArrow
&&
812 (~btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
813 RECT rc
, rcArrow
, rcBitmap
, rcText
;
814 LPWSTR lpText
= NULL
;
820 CopyRect (&rcArrow
, &rc
);
822 /* get a pointer to the text */
823 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
825 if (hasDropDownArrow
)
829 if (dwStyle
& TBSTYLE_FLAT
)
830 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
832 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
834 if (drawSepDropDownArrow
)
837 rcArrow
.left
= right
;
840 /* copy text & bitmap rects after adjusting for drop-down arrow
841 * so that text & bitmap is centred in the rectangle not containing
843 CopyRect(&rcText
, &rc
);
844 CopyRect(&rcBitmap
, &rc
);
846 /* Center the bitmap horizontally and vertically */
847 if (dwStyle
& TBSTYLE_LIST
)
850 infoPtr
->nMaxTextRows
> 0 &&
851 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
852 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
853 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
) + infoPtr
->szPadding
.cx
/ 2;
855 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
) + infoPtr
->iListGap
/ 2;
858 rcBitmap
.left
+= (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
860 rcBitmap
.top
+= infoPtr
->szPadding
.cy
/ 2;
862 TRACE("iBitmap=%d, start=(%ld,%ld) w=%d, h=%d\n",
863 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
864 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
865 TRACE("Text=%s\n", debugstr_w(lpText
));
866 TRACE("iListGap=%d, padding = { %ld, %ld }\n", infoPtr
->iListGap
, infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
868 /* calculate text position */
871 rcText
.left
+= GetSystemMetrics(SM_CXEDGE
);
872 rcText
.right
-= GetSystemMetrics(SM_CXEDGE
);
873 if (dwStyle
& TBSTYLE_LIST
)
875 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
))
876 rcText
.left
+= infoPtr
->nBitmapWidth
+ infoPtr
->iListGap
+ 2;
880 if (ImageList_GetImageCount(GETDEFIMAGELIST(infoPtr
, 0)) > 0)
881 rcText
.top
+= infoPtr
->szPadding
.cy
/2 + infoPtr
->nBitmapHeight
+ 1;
883 rcText
.top
+= infoPtr
->szPadding
.cy
/2 + 2;
887 /* Initialize fields in all cases, because we use these later
888 * NOTE: applications can and do alter these to customize their
890 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
891 tbcd
.clrText
= comctl32_color
.clrBtnText
;
892 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
893 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
894 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
895 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
896 tbcd
.clrHighlightHotTrack
= 0;
897 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
898 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
899 /* MSDN says that this is the text rectangle.
900 * But (why always a but) tracing of v5.7 of native shows
901 * that this is really a *relative* rectangle based on the
902 * the nmcd.rc. Also the left and top are always 0 ignoring
903 * any bitmap that might be present. */
904 tbcd
.rcText
.left
= 0;
906 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
907 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
908 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
911 tbcd
.hbrMonoDither
= COMCTL32_hPattern55AABrush
;
913 /* FIXME: what are these used for? */
917 /* Issue Item Prepaint notify */
918 infoPtr
->dwItemCustDraw
= 0;
919 infoPtr
->dwItemCDFlag
= 0;
920 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
922 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
923 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
924 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
925 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
926 /* reset these fields so the user can't alter the behaviour like native */
930 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
931 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
932 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
934 /* save the only part of the rect that the user can change */
935 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
936 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
940 if (btnPtr
->fsStyle
& BTNS_SEP
) {
941 /* with the FLAT style, iBitmap is the width and has already */
942 /* been taken into consideration in calculating the width */
943 /* so now we need to draw the vertical separator */
944 /* empirical tests show that iBitmap can/will be non-zero */
945 /* when drawing the vertical bar... */
946 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
947 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
)
948 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
950 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
952 else if (btnPtr
->fsStyle
!= BTNS_SEP
) {
953 FIXME("Draw some kind of separator: fsStyle=%x\n",
959 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
960 (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
)))
961 OffsetRect(&rcText
, 1, 1);
963 if (!(tbcd
.nmcd
.uItemState
& CDIS_HOT
) &&
964 ((tbcd
.nmcd
.uItemState
& CDIS_CHECKED
) || (tbcd
.nmcd
.uItemState
& CDIS_INDETERMINATE
)))
965 TOOLBAR_DrawPattern (&rc
, &tbcd
);
967 if ((dwStyle
& TBSTYLE_FLAT
) && (tbcd
.nmcd
.uItemState
& CDIS_HOT
))
969 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
973 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
974 ExtTextOutW(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
975 if (hasDropDownArrow
)
976 ExtTextOutW(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
977 SetBkColor(hdc
, oldclr
);
981 TOOLBAR_DrawFrame(infoPtr
, &tbcd
);
983 if (drawSepDropDownArrow
)
984 TOOLBAR_DrawSepDDArrow(infoPtr
, &tbcd
, &rcArrow
, btnPtr
->bDropDownPressed
);
986 if (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) || (btnPtr
->fsStyle
& BTNS_SHOWTEXT
))
987 TOOLBAR_DrawString (infoPtr
, &rcText
, lpText
, &tbcd
);
989 TOOLBAR_DrawImage(infoPtr
, btnPtr
, rcBitmap
.left
, rcBitmap
.top
, &tbcd
);
991 if (hasDropDownArrow
&& !drawSepDropDownArrow
)
993 if (tbcd
.nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
995 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1 + (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
996 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
998 else if (tbcd
.nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
1000 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
1001 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+ offset
, rcArrow
.top
+ offset
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1004 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1008 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1010 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
1011 tbcd
.nmcd
.hdc
= hdc
;
1013 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
1014 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
1015 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
1016 tbcd
.rcText
= rcText
;
1017 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1018 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1019 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1026 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
1028 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1029 TBUTTON_INFO
*btnPtr
;
1030 INT i
, oldBKmode
= 0;
1031 RECT rcTemp
, rcClient
;
1032 NMTBCUSTOMDRAW tbcd
;
1035 /* the app has told us not to redraw the toolbar */
1036 if (!infoPtr
->bDoRedraw
)
1039 /* if imagelist belongs to the app, it can be changed
1040 by the app after setting it */
1041 if (GETDEFIMAGELIST(infoPtr
, 0) != infoPtr
->himlInt
)
1043 infoPtr
->nNumBitmaps
= 0;
1044 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
1045 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
1048 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1050 /* Send initial notify */
1051 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1052 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
1053 tbcd
.nmcd
.hdc
= hdc
;
1054 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1055 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1056 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
1058 if (infoPtr
->bBtnTranspnt
)
1059 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
1061 GetClientRect(hwnd
, &rcClient
);
1063 /* redraw necessary buttons */
1064 btnPtr
= infoPtr
->buttons
;
1065 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
1068 if (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
1070 IntersectRect(&rcTemp
, &rcClient
, &btnPtr
->rect
);
1071 bDraw
= EqualRect(&rcTemp
, &btnPtr
->rect
);
1075 bDraw
&= IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
));
1076 bDraw
= (btnPtr
->fsState
& TBSTATE_HIDDEN
) ? FALSE
: bDraw
;
1078 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
1081 /* draw insert mark if required */
1082 if (infoPtr
->tbim
.iButton
!= -1)
1084 RECT rcButton
= infoPtr
->buttons
[infoPtr
->tbim
.iButton
].rect
;
1086 rcInsertMark
.top
= rcButton
.top
;
1087 rcInsertMark
.bottom
= rcButton
.bottom
;
1088 if (infoPtr
->tbim
.dwFlags
& TBIMHT_AFTER
)
1089 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.right
;
1091 rcInsertMark
.left
= rcInsertMark
.right
= rcButton
.left
- INSERTMARK_WIDTH
;
1092 COMCTL32_DrawInsertMark(hdc
, &rcInsertMark
, infoPtr
->clrInsertMark
, FALSE
);
1095 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
1096 SetBkMode (hdc
, oldBKmode
);
1098 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1100 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1101 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
1102 tbcd
.nmcd
.hdc
= hdc
;
1103 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1104 ntfret
= TOOLBAR_SendNotify(&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
1108 /***********************************************************************
1109 * TOOLBAR_MeasureString
1111 * This function gets the width and height of a string in pixels. This
1112 * is done first by using GetTextExtentPoint to get the basic width
1113 * and height. The DrawText is called with DT_CALCRECT to get the exact
1114 * width. The reason is because the text may have more than one "&" (or
1115 * prefix characters as M$ likes to call them). The prefix character
1116 * indicates where the underline goes, except for the string "&&" which
1117 * is reduced to a single "&". GetTextExtentPoint does not process these
1118 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
1121 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
1122 HDC hdc
, LPSIZE lpSize
)
1129 if (infoPtr
->nMaxTextRows
> 0 &&
1130 !(btnPtr
->fsState
& TBSTATE_HIDDEN
) &&
1131 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1132 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
1134 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1136 if(lpText
!= NULL
) {
1137 /* first get size of all the text */
1138 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1140 /* feed above size into the rectangle for DrawText */
1141 myrect
.left
= myrect
.top
= 0;
1142 myrect
.right
= lpSize
->cx
;
1143 myrect
.bottom
= lpSize
->cy
;
1145 /* Use DrawText to get true size as drawn (less pesky "&") */
1146 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1147 DT_CALCRECT
| ((btnPtr
->fsStyle
& BTNS_NOPREFIX
) ?
1150 /* feed back to caller */
1151 lpSize
->cx
= myrect
.right
;
1152 lpSize
->cy
= myrect
.bottom
;
1156 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1159 /***********************************************************************
1160 * TOOLBAR_CalcStrings
1162 * This function walks through each string and measures it and returns
1163 * the largest height and width to caller.
1166 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1168 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1169 TBUTTON_INFO
*btnPtr
;
1178 if(infoPtr
->nMaxTextRows
== 0)
1182 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1184 btnPtr
= infoPtr
->buttons
;
1185 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1186 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1188 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1189 if (sz
.cx
> lpSize
->cx
)
1191 if (sz
.cy
> lpSize
->cy
)
1196 SelectObject (hdc
, hOldFont
);
1197 ReleaseDC (hwnd
, hdc
);
1199 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1202 /***********************************************************************
1203 * TOOLBAR_WrapToolbar
1205 * This function walks through the buttons and separators in the
1206 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1207 * wrapping should occur based on the width of the toolbar window.
1208 * It does *not* calculate button placement itself. That task
1209 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1210 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1211 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1213 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1214 * vertical toolbar lists.
1218 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1220 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1221 TBUTTON_INFO
*btnPtr
;
1224 BOOL bWrap
, bButtonWrap
;
1226 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1227 /* no layout is necessary. Applications may use this style */
1228 /* to perform their own layout on the toolbar. */
1229 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1230 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1232 btnPtr
= infoPtr
->buttons
;
1233 x
= infoPtr
->nIndent
;
1235 /* this can get the parents width, to know how far we can extend
1236 * this toolbar. We cannot use its height, as there may be multiple
1237 * toolbars in a rebar control
1239 GetClientRect( GetParent(hwnd
), &rc
);
1240 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1241 bButtonWrap
= FALSE
;
1243 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1244 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1247 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1250 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1252 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1255 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1256 /* it is the actual width of the separator. This is used for */
1257 /* custom controls in toolbars. */
1259 /* BTNS_DROPDOWN separators are treated as buttons for */
1260 /* width. - GA 8/01 */
1261 if ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1262 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
))
1263 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1264 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1266 cx
= infoPtr
->nButtonWidth
;
1268 /* Two or more adjacent separators form a separator group. */
1269 /* The first separator in a group should be wrapped to the */
1270 /* next row if the previous wrapping is on a button. */
1272 (btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1273 (i
+ 1 < infoPtr
->nNumButtons
) &&
1274 (btnPtr
[i
+ 1].fsStyle
& BTNS_SEP
) )
1276 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1277 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1278 x
= infoPtr
->nIndent
;
1280 bButtonWrap
= FALSE
;
1284 /* The layout makes sure the bitmap is visible, but not the button. */
1285 /* Test added to also wrap after a button that starts a row but */
1286 /* is bigger than the area. - GA 8/01 */
1287 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1288 > infoPtr
->nWidth
) ||
1289 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1291 BOOL bFound
= FALSE
;
1293 /* If the current button is a separator and not hidden, */
1294 /* go to the next until it reaches a non separator. */
1295 /* Wrap the last separator if it is before a button. */
1296 while( ( ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1297 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
)) ||
1298 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1299 i
< infoPtr
->nNumButtons
)
1305 if( bFound
&& i
< infoPtr
->nNumButtons
)
1308 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1309 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1310 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1311 x
= infoPtr
->nIndent
;
1312 bButtonWrap
= FALSE
;
1315 else if ( i
>= infoPtr
->nNumButtons
)
1318 /* If the current button is not a separator, find the last */
1319 /* separator and wrap it. */
1320 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1322 if ((btnPtr
[j
].fsStyle
& BTNS_SEP
) &&
1323 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1327 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1328 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1329 x
= infoPtr
->nIndent
;
1330 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1331 bButtonWrap
= FALSE
;
1336 /* If no separator available for wrapping, wrap one of */
1337 /* non-hidden previous button. */
1341 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1343 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1348 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1349 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1350 x
= infoPtr
->nIndent
;
1351 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1357 /* If all above failed, wrap the current button. */
1360 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1361 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1362 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1364 x
= infoPtr
->nIndent
;
1365 if (btnPtr
[i
].fsStyle
& BTNS_SEP
)
1366 bButtonWrap
= FALSE
;
1372 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1373 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1380 /***********************************************************************
1381 * TOOLBAR_MeasureButton
1383 * Calculates the width and height required for a button. Used in
1384 * TOOLBAR_CalcToolbar to set the all-button width and height and also for
1385 * the width of buttons that are autosized.
1387 * Note that it would have been rather elegant to use one piece of code for
1388 * both the laying out of the toolbar and for controlling where button parts
1389 * are drawn, but the native control has inconsistencies between the two that
1390 * prevent this from being effectively. These inconsistencies can be seen as
1391 * artefacts where parts of the button appear outside of the bounding button
1394 * There are several cases for the calculation of the button dimensions and
1395 * button part positioning:
1402 * +--------------------------------------------------------+ ^
1404 * | | pad.cy / 2 | centred | |
1405 * | pad.cx/2 + cxedge +--------------+ +------------+ | | DEFPAD_CY +
1406 * |<----------------->| nBitmapWidth | | Text | | | max(nBitmapHeight, szText.cy)
1407 * | |<------------>| | | | |
1408 * | +--------------+ +------------+ | |
1409 * |<-------------------------------------->| | |
1410 * | cxedge + iListGap + nBitmapWidth + 2 |<-----------> | |
1412 * +--------------------------------------------------------+ -
1413 * <-------------------------------------------------------->
1414 * 2*cxedge + nBitmapWidth + iListGap + szText.cx + pad.cx
1416 * Without Bitmap (I_IMAGENONE):
1418 * +-----------------------------------+ ^
1420 * | | centred | | LISTPAD_CY +
1421 * | +------------+ | | szText.cy
1424 * | +------------+ | |
1425 * |<----------------->| | |
1426 * | cxedge |<-----------> | |
1428 * +-----------------------------------+ -
1429 * <----------------------------------->
1430 * szText.cx + pad.cx
1434 * +--------------------------------------+ ^
1436 * | | padding.cy/2 | | DEFPAD_CY +
1437 * | +------------+ | | nBitmapHeight
1440 * | +------------+ | |
1441 * |<------------------->| | |
1442 * | cxedge + iListGap/2 |<-----------> | |
1443 * | nBitmapWidth | |
1444 * +--------------------------------------+ -
1445 * <-------------------------------------->
1446 * 2*cxedge + nBitmapWidth + iListGap
1453 * +-----------------------------------+ ^
1455 * | | pad.cy / 2 | | nBitmapHeight +
1456 * | - | | szText.cy +
1457 * | +------------+ | | DEFPAD_CY + 1
1458 * | centred | Bitmap | | |
1459 * |<----------------->| | | |
1460 * | +------------+ | |
1464 * | centred +---------------+ | |
1465 * |<--------------->| Text | | |
1466 * | +---------------+ | |
1467 * +-----------------------------------+ -
1468 * <----------------------------------->
1469 * pad.cx + max(nBitmapWidth, szText.cx)
1471 * Without bitmaps (NULL imagelist or ImageList_GetImageCount() = 0):
1473 * +---------------------------------------+ ^
1475 * | | 2 + pad.cy / 2 | |
1476 * | - | | szText.cy +
1477 * | centred +-----------------+ | | pad.cy + 2
1478 * |<--------------->| Text | | |
1479 * | +-----------------+ | |
1481 * +---------------------------------------+ -
1482 * <--------------------------------------->
1483 * 2*cxedge + pad.cx + szText.cx
1486 * As for with bitmaps, but with szText.cx zero.
1488 static inline SIZE
TOOLBAR_MeasureButton(TOOLBAR_INFO
*infoPtr
, SIZE sizeString
, BOOL bHasBitmap
, BOOL bValidImageList
)
1491 if (infoPtr
->dwStyle
& TBSTYLE_LIST
)
1493 /* set button height from bitmap / text height... */
1494 sizeButton
.cy
= max((bHasBitmap
? infoPtr
->nBitmapHeight
: 0),
1497 /* ... add on the necessary padding */
1498 if (bValidImageList
)
1501 sizeButton
.cy
+= DEFPAD_CY
;
1503 sizeButton
.cy
+= LISTPAD_CY
;
1506 sizeButton
.cy
+= infoPtr
->szPadding
.cy
;
1508 /* calculate button width */
1511 sizeButton
.cx
= 2*GetSystemMetrics(SM_CXEDGE
) +
1512 infoPtr
->nBitmapWidth
+ infoPtr
->iListGap
;
1513 if (sizeString
.cx
> 0)
1514 sizeButton
.cx
+= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1517 sizeButton
.cx
= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1523 sizeButton
.cy
= infoPtr
->nBitmapHeight
+ 1 +
1524 sizeString
.cy
+ DEFPAD_CY
;
1525 sizeButton
.cx
= infoPtr
->szPadding
.cx
+
1526 max(sizeString
.cx
, infoPtr
->nBitmapWidth
);
1530 sizeButton
.cy
= sizeString
.cy
+ infoPtr
->szPadding
.cy
+
1531 NONLIST_NOTEXT_OFFSET
;
1532 sizeButton
.cx
= 2*GetSystemMetrics(SM_CXEDGE
) +
1533 infoPtr
->szPadding
.cx
+ sizeString
.cx
;
1540 /***********************************************************************
1541 * TOOLBAR_CalcToolbar
1543 * This function calculates button and separator placement. It first
1544 * calculates the button sizes, gets the toolbar window width and then
1545 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1546 * on. It assigns a new location to each item and sends this location to
1547 * the tooltip window if appropriate. Finally, it updates the rcBound
1548 * rect and calculates the new required toolbar window height.
1551 TOOLBAR_CalcToolbar (HWND hwnd
)
1553 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1554 DWORD dwStyle
= infoPtr
->dwStyle
;
1555 TBUTTON_INFO
*btnPtr
;
1556 INT i
, nRows
, nSepRows
;
1558 SIZE sizeString
, sizeButton
;
1560 BOOL usesBitmaps
= FALSE
;
1561 BOOL validImageList
= FALSE
;
1562 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1564 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1566 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1568 for (i
= 0; i
< infoPtr
->nNumButtons
&& !usesBitmaps
; i
++)
1570 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,infoPtr
->buttons
[i
].iBitmap
))
1573 if (TOOLBAR_IsValidImageList(infoPtr
, 0))
1574 validImageList
= TRUE
;
1575 sizeButton
= TOOLBAR_MeasureButton(infoPtr
, sizeString
, usesBitmaps
, validImageList
);
1576 infoPtr
->nButtonWidth
= sizeButton
.cx
;
1577 infoPtr
->nButtonHeight
= sizeButton
.cy
;
1579 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1580 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1581 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1582 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1584 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1586 x
= infoPtr
->nIndent
;
1589 /* from above, minimum is a button, and possible text */
1590 cx
= infoPtr
->nButtonWidth
;
1592 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1594 cy
= infoPtr
->nHeight
;
1596 nRows
= nSepRows
= 0;
1598 infoPtr
->rcBound
.top
= y
;
1599 infoPtr
->rcBound
.left
= x
;
1600 infoPtr
->rcBound
.bottom
= y
+ cy
;
1601 infoPtr
->rcBound
.right
= x
;
1603 btnPtr
= infoPtr
->buttons
;
1605 TRACE("cy=%d\n", cy
);
1607 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1610 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1612 SetRectEmpty (&btnPtr
->rect
);
1616 cy
= infoPtr
->nHeight
;
1618 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1619 /* it is the actual width of the separator. This is used for */
1620 /* custom controls in toolbars. */
1621 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1622 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
) {
1623 cy
= (btnPtr
->iBitmap
> 0) ?
1624 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1625 cx
= infoPtr
->nButtonWidth
;
1628 cx
= (btnPtr
->iBitmap
> 0) ?
1629 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1635 else if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1636 (btnPtr
->fsStyle
& BTNS_AUTOSIZE
))
1643 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1645 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1647 SelectObject (hdc
, hOldFont
);
1648 ReleaseDC (hwnd
, hdc
);
1650 sizeButton
= TOOLBAR_MeasureButton(infoPtr
, sz
,
1651 TOOLBAR_IsValidBitmapIndex(infoPtr
, infoPtr
->buttons
[i
].iBitmap
),
1656 cx
= infoPtr
->nButtonWidth
;
1658 /* if size has been set manually then don't add on extra space
1659 * for the drop down arrow */
1660 if (!btnPtr
->cx
&& hasDropDownArrows
&&
1661 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) || (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)))
1662 cx
+= DDARROW_WIDTH
;
1664 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1667 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1669 if (infoPtr
->rcBound
.left
> x
)
1670 infoPtr
->rcBound
.left
= x
;
1671 if (infoPtr
->rcBound
.right
< x
+ cx
)
1672 infoPtr
->rcBound
.right
= x
+ cx
;
1673 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1674 infoPtr
->rcBound
.bottom
= y
+ cy
;
1676 /* Set the toolTip only for non-hidden, non-separator button */
1677 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& BTNS_SEP
))
1681 ZeroMemory (&ti
, sizeof(ti
));
1682 ti
.cbSize
= sizeof(ti
);
1684 ti
.uId
= btnPtr
->idCommand
;
1685 ti
.rect
= btnPtr
->rect
;
1686 SendMessageW (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTW
,
1690 /* btnPtr->nRow is zero based. The space between the rows is */
1691 /* also considered as a row. */
1692 btnPtr
->nRow
= nRows
+ nSepRows
;
1694 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1695 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1700 if ( !(btnPtr
->fsStyle
& BTNS_SEP
) )
1704 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1705 /* it is the actual width of the separator. This is used for */
1706 /* custom controls in toolbars. */
1707 if ( !(btnPtr
->fsStyle
& BTNS_DROPDOWN
))
1708 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1709 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1713 /* nSepRows is used to calculate the extra height follwoing */
1717 x
= infoPtr
->nIndent
;
1719 /* Increment row number unless this is the last button */
1720 /* and it has Wrap set. */
1721 if (i
!= infoPtr
->nNumButtons
-1)
1728 /* infoPtr->nRows is the number of rows on the toolbar */
1729 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1732 /********************************************************************
1733 * The following while interesting, does not match the values *
1734 * created above for the button rectangles, nor the rcBound rect. *
1735 * We will comment it out and remove it later. *
1737 * The problem showed up as heights in the pager control that was *
1739 ********************************************************************/
1741 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1743 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1744 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1745 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1749 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1751 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1756 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1758 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1759 TBUTTON_INFO
*btnPtr
;
1762 btnPtr
= infoPtr
->buttons
;
1763 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1764 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1767 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1768 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1769 TRACE(" ON SEPARATOR %d!\n", i
);
1774 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1775 TRACE(" ON BUTTON %d!\n", i
);
1781 TRACE(" NOWHERE!\n");
1782 return TOOLBAR_NOWHERE
;
1787 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1789 TBUTTON_INFO
*btnPtr
;
1792 if (CommandIsIndex
) {
1793 TRACE("command is really index command=%d\n", idCommand
);
1794 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1797 btnPtr
= infoPtr
->buttons
;
1798 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1799 if (btnPtr
->idCommand
== idCommand
) {
1800 TRACE("command=%d index=%d\n", idCommand
, i
);
1804 TRACE("no index found for command=%d\n", idCommand
);
1810 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1812 TBUTTON_INFO
*btnPtr
;
1815 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1818 /* check index button */
1819 btnPtr
= &infoPtr
->buttons
[nIndex
];
1820 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1821 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1825 /* check previous buttons */
1826 nRunIndex
= nIndex
- 1;
1827 while (nRunIndex
>= 0) {
1828 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1829 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1830 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1838 /* check next buttons */
1839 nRunIndex
= nIndex
+ 1;
1840 while (nRunIndex
< infoPtr
->nNumButtons
) {
1841 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1842 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1843 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1856 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1857 WPARAM wParam
, LPARAM lParam
)
1863 msg
.wParam
= wParam
;
1864 msg
.lParam
= lParam
;
1865 msg
.time
= GetMessageTime ();
1866 msg
.pt
.x
= LOWORD(GetMessagePos ());
1867 msg
.pt
.y
= HIWORD(GetMessagePos ());
1869 SendMessageW (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1872 /* keeps available button list box sorted by button id */
1873 static void TOOLBAR_Cust_InsertAvailButton(HWND hwnd
, PCUSTOMBUTTON btnInfoNew
)
1877 PCUSTOMBUTTON btnInfo
;
1878 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1880 TRACE("button %s, idCommand %d\n", debugstr_w(btnInfoNew
->text
), btnInfoNew
->btn
.idCommand
);
1882 count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1884 /* position 0 is always separator */
1885 for (i
= 1; i
< count
; i
++)
1887 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, i
, 0);
1888 if (btnInfoNew
->btn
.idCommand
< btnInfo
->btn
.idCommand
)
1890 i
= SendMessageW(hwndAvail
, LB_INSERTSTRING
, i
, 0);
1891 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1895 /* id higher than all others add to end */
1896 i
= SendMessageW(hwndAvail
, LB_ADDSTRING
, 0, 0);
1897 SendMessageW(hwndAvail
, LB_SETITEMDATA
, i
, (LPARAM
)btnInfoNew
);
1900 static void TOOLBAR_Cust_MoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexFrom
, INT nIndexTo
)
1904 TRACE("index from %d, index to %d\n", nIndexFrom
, nIndexTo
);
1906 if (nIndexFrom
== nIndexTo
)
1909 /* MSDN states that iItem is the index of the button, rather than the
1910 * command ID as used by every other NMTOOLBAR notification */
1911 nmtb
.iItem
= nIndexFrom
;
1912 if (TOOLBAR_SendNotify(&nmtb
.hdr
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1914 PCUSTOMBUTTON btnInfo
;
1916 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1917 int count
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
1919 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, nIndexFrom
, 0);
1921 SendMessageW(hwndList
, LB_DELETESTRING
, nIndexFrom
, 0);
1922 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1923 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1924 SendMessageW(hwndList
, LB_SETCURSEL
, nIndexTo
, 0);
1927 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1929 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1931 /* last item is always separator, so -2 instead of -1 */
1932 if (nIndexTo
>= (count
- 2))
1933 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1935 EnableWindow(GetDlgItem(hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1937 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, nIndexFrom
, 0);
1938 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1940 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1944 static void TOOLBAR_Cust_AddButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT nIndexAvail
, INT nIndexTo
)
1948 TRACE("Add: nIndexAvail %d, nIndexTo %d\n", nIndexAvail
, nIndexTo
);
1950 /* MSDN states that iItem is the index of the button, rather than the
1951 * command ID as used by every other NMTOOLBAR notification */
1952 nmtb
.iItem
= nIndexAvail
;
1953 if (TOOLBAR_SendNotify(&nmtb
.hdr
, custInfo
->tbInfo
, TBN_QUERYINSERT
))
1955 PCUSTOMBUTTON btnInfo
;
1957 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1958 HWND hwndAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
1959 int count
= SendMessageW(hwndAvail
, LB_GETCOUNT
, 0, 0);
1961 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndAvail
, LB_GETITEMDATA
, nIndexAvail
, 0);
1963 if (nIndexAvail
!= 0) /* index == 0 indicates separator */
1965 /* remove from 'available buttons' list */
1966 SendMessageW(hwndAvail
, LB_DELETESTRING
, nIndexAvail
, 0);
1967 if (nIndexAvail
== count
-1)
1968 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
-1 , 0);
1970 SendMessageW(hwndAvail
, LB_SETCURSEL
, nIndexAvail
, 0);
1974 PCUSTOMBUTTON btnNew
;
1976 /* duplicate 'separator' button */
1977 btnNew
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1978 memcpy(btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
1982 /* insert into 'toolbar button' list */
1983 SendMessageW(hwndList
, LB_INSERTSTRING
, nIndexTo
, 0);
1984 SendMessageW(hwndList
, LB_SETITEMDATA
, nIndexTo
, (LPARAM
)btnInfo
);
1986 SendMessageW(custInfo
->tbHwnd
, TB_INSERTBUTTONW
, nIndexTo
, (LPARAM
)&(btnInfo
->btn
));
1988 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
1992 static void TOOLBAR_Cust_RemoveButton(PCUSTDLG_INFO custInfo
, HWND hwnd
, INT index
)
1994 PCUSTOMBUTTON btnInfo
;
1995 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
1997 TRACE("Remove: index %d\n", index
);
1999 btnInfo
= (PCUSTOMBUTTON
)SendMessageW(hwndList
, LB_GETITEMDATA
, index
, 0);
2001 /* send TBN_QUERYDELETE notification */
2002 if (TOOLBAR_IsButtonRemovable(custInfo
->tbInfo
, index
, btnInfo
))
2006 SendMessageW(hwndList
, LB_DELETESTRING
, index
, 0);
2007 SendMessageW(hwndList
, LB_SETCURSEL
, index
, 0);
2009 SendMessageW(custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2011 /* insert into 'available button' list */
2012 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
2013 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
2017 TOOLBAR_SendNotify(&hdr
, custInfo
->tbInfo
, TBN_TOOLBARCHANGE
);
2021 /* drag list notification function for toolbar buttons list box */
2022 static LRESULT
TOOLBAR_Cust_ToolbarDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
2024 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
2025 switch (pDLI
->uNotification
)
2029 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2030 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2031 /* no dragging for last item (separator) */
2032 if (nCurrentItem
>= (nCount
- 1)) return FALSE
;
2037 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2038 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2039 /* no dragging past last item (separator) */
2040 if ((nCurrentItem
>= 0) && (nCurrentItem
< (nCount
- 1)))
2042 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
2043 /* FIXME: native uses "move button" cursor */
2044 return DL_COPYCURSOR
;
2047 /* not over toolbar buttons list */
2048 if (nCurrentItem
< 0)
2050 POINT ptWindow
= pDLI
->ptCursor
;
2051 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2052 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2053 /* over available buttons list? */
2054 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2055 /* FIXME: native uses "move button" cursor */
2056 return DL_COPYCURSOR
;
2058 /* clear drag arrow */
2059 DrawInsert(hwnd
, hwndList
, -1);
2060 return DL_STOPCURSOR
;
2064 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2065 INT nIndexFrom
= SendMessageW(hwndList
, LB_GETCURSEL
, 0, 0);
2066 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2067 if ((nIndexTo
>= 0) && (nIndexTo
< (nCount
- 1)))
2069 /* clear drag arrow */
2070 DrawInsert(hwnd
, hwndList
, -1);
2072 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
2074 /* not over toolbar buttons list */
2077 POINT ptWindow
= pDLI
->ptCursor
;
2078 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2079 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2080 /* over available buttons list? */
2081 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2082 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, nIndexFrom
);
2087 /* Clear drag arrow */
2088 DrawInsert(hwnd
, hwndList
, -1);
2095 /* drag list notification function for available buttons list box */
2096 static LRESULT
TOOLBAR_Cust_AvailDragListNotification(PCUSTDLG_INFO custInfo
, HWND hwnd
, DRAGLISTINFO
*pDLI
)
2098 HWND hwndList
= GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
);
2099 switch (pDLI
->uNotification
)
2105 INT nCurrentItem
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2106 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2107 /* no dragging past last item (separator) */
2108 if ((nCurrentItem
>= 0) && (nCurrentItem
< nCount
))
2110 DrawInsert(hwnd
, hwndList
, nCurrentItem
);
2111 /* FIXME: native uses "move button" cursor */
2112 return DL_COPYCURSOR
;
2115 /* not over toolbar buttons list */
2116 if (nCurrentItem
< 0)
2118 POINT ptWindow
= pDLI
->ptCursor
;
2119 HWND hwndListAvail
= GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
);
2120 MapWindowPoints(NULL
, hwnd
, &ptWindow
, 1);
2121 /* over available buttons list? */
2122 if (ChildWindowFromPoint(hwnd
, ptWindow
) == hwndListAvail
)
2123 /* FIXME: native uses "move button" cursor */
2124 return DL_COPYCURSOR
;
2126 /* clear drag arrow */
2127 DrawInsert(hwnd
, hwndList
, -1);
2128 return DL_STOPCURSOR
;
2132 INT nIndexTo
= LBItemFromPt(hwndList
, pDLI
->ptCursor
, TRUE
);
2133 INT nCount
= SendMessageW(hwndList
, LB_GETCOUNT
, 0, 0);
2134 INT nIndexFrom
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2135 if ((nIndexTo
>= 0) && (nIndexTo
< nCount
))
2137 /* clear drag arrow */
2138 DrawInsert(hwnd
, hwndList
, -1);
2140 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, nIndexFrom
, nIndexTo
);
2144 /* Clear drag arrow */
2145 DrawInsert(hwnd
, hwndList
, -1);
2151 extern UINT uDragListMessage
;
2153 /***********************************************************************
2154 * TOOLBAR_CustomizeDialogProc
2155 * This function implements the toolbar customization dialog.
2157 static INT_PTR CALLBACK
2158 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
2160 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongPtrW (hwnd
, DWLP_USER
);
2161 PCUSTOMBUTTON btnInfo
;
2163 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
2168 custInfo
= (PCUSTDLG_INFO
)lParam
;
2169 SetWindowLongPtrW (hwnd
, DWLP_USER
, (LONG_PTR
)custInfo
);
2177 infoPtr
= custInfo
->tbInfo
;
2179 /* send TBN_QUERYINSERT notification */
2180 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
2182 if (!TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYINSERT
))
2185 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
2186 /* FIXME: this hack won't work on 64-bit - we need to declare a structure for this */
2187 nmtb
.iItem
= (int)hwnd
;
2188 /* Send TBN_INITCUSTOMIZE notification */
2189 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_INITCUSTOMIZE
) ==
2192 TRACE("TBNRF_HIDEHELP requested\n");
2193 ShowWindow(GetDlgItem(hwnd
, IDC_HELP_BTN
), SW_HIDE
);
2196 /* add items to 'toolbar buttons' list and check if removable */
2197 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
2199 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2200 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2201 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2202 btnInfo
->bVirtual
= FALSE
;
2203 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2205 /* send TBN_QUERYDELETE notification */
2206 btnInfo
->bRemovable
= TOOLBAR_IsButtonRemovable(infoPtr
, i
, btnInfo
);
2208 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2209 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2212 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2214 /* insert separator button into 'available buttons' list */
2215 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2216 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2217 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2218 btnInfo
->bVirtual
= FALSE
;
2219 btnInfo
->bRemovable
= TRUE
;
2220 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2221 index
= (int)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2222 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2224 /* insert all buttons into dsa */
2227 /* send TBN_GETBUTTONINFO notification */
2230 nmtb
.pszText
= Buffer
;
2233 /* Clear previous button's text */
2234 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
2236 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
2239 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
2240 nmtb
.tbButton
.fsStyle
, i
,
2241 nmtb
.tbButton
.idCommand
,
2242 nmtb
.tbButton
.iString
,
2243 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
2246 /* insert button into the apropriate list */
2247 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
2250 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2251 btnInfo
->bVirtual
= FALSE
;
2252 btnInfo
->bRemovable
= TRUE
;
2256 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
,
2257 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2260 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
2261 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
2263 if (lstrlenW(nmtb
.pszText
))
2264 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
2265 else if (nmtb
.tbButton
.iString
>= 0 &&
2266 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
2268 lstrcpyW(btnInfo
->text
,
2269 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
2274 TOOLBAR_Cust_InsertAvailButton(hwnd
, btnInfo
);
2277 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
2279 /* select first item in the 'available' list */
2280 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
2282 /* append 'virtual' separator button to the 'toolbar buttons' list */
2283 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
2284 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
2285 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
2286 btnInfo
->bVirtual
= TRUE
;
2287 btnInfo
->bRemovable
= FALSE
;
2288 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
2289 index
= (int)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
2290 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2292 /* select last item in the 'toolbar' list */
2293 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2294 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
2296 MakeDragList(GetDlgItem(hwnd
, IDC_TOOLBARBTN_LBOX
));
2297 MakeDragList(GetDlgItem(hwnd
, IDC_AVAILBTN_LBOX
));
2299 /* set focus and disable buttons */
2300 PostMessageW (hwnd
, WM_USER
, 0, 0);
2305 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2306 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2307 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
2308 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
2312 EndDialog(hwnd
, FALSE
);
2316 switch (LOWORD(wParam
))
2318 case IDC_TOOLBARBTN_LBOX
:
2319 if (HIWORD(wParam
) == LBN_SELCHANGE
)
2321 PCUSTOMBUTTON btnInfo
;
2326 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2327 index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2329 /* send TBN_QUERYINSERT notification */
2331 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYINSERT
);
2333 /* get list box item */
2334 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2336 if (index
== (count
- 1))
2338 /* last item (virtual separator) */
2339 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2340 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2342 else if (index
== (count
- 2))
2344 /* second last item (last non-virtual item) */
2345 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2346 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2348 else if (index
== 0)
2351 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
2352 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2356 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2357 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
2360 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
2364 case IDC_MOVEUP_BTN
:
2366 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2367 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
-1);
2371 case IDC_MOVEDN_BTN
: /* move down */
2373 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2374 TOOLBAR_Cust_MoveButton(custInfo
, hwnd
, index
, index
+1);
2378 case IDC_REMOVE_BTN
: /* remove button */
2380 int index
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2382 if (LB_ERR
== index
)
2385 TOOLBAR_Cust_RemoveButton(custInfo
, hwnd
, index
);
2389 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2392 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2395 case IDOK
: /* Add button */
2400 index
= SendDlgItemMessageW(hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2401 indexto
= SendDlgItemMessageW(hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2403 TOOLBAR_Cust_AddButton(custInfo
, hwnd
, index
, indexto
);
2408 EndDialog(hwnd
, FALSE
);
2418 /* delete items from 'toolbar buttons' listbox*/
2419 count
= SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2420 for (i
= 0; i
< count
; i
++)
2422 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2424 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2426 SendDlgItemMessageW (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2429 /* delete items from 'available buttons' listbox*/
2430 count
= SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2431 for (i
= 0; i
< count
; i
++)
2433 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2435 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2437 SendDlgItemMessageW (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2442 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2444 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2449 COLORREF oldText
= 0;
2453 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageW (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2454 if (btnInfo
== NULL
)
2456 FIXME("btnInfo invalid!\n");
2460 /* set colors and select objects */
2461 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2462 if (btnInfo
->bVirtual
)
2463 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2465 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2466 hPen
= CreatePen( PS_SOLID
, 1,
2467 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2468 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2469 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2471 /* fill background rectangle */
2472 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2473 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2475 /* calculate button and text rectangles */
2476 CopyRect (&rcButton
, &lpdis
->rcItem
);
2477 InflateRect (&rcButton
, -1, -1);
2478 CopyRect (&rcText
, &rcButton
);
2479 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2480 rcText
.left
= rcButton
.right
+ 2;
2482 /* draw focus rectangle */
2483 if (lpdis
->itemState
& ODS_FOCUS
)
2484 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2487 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
2488 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2490 /* draw image and text */
2491 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2492 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2493 btnInfo
->btn
.iBitmap
));
2494 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2495 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2497 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2498 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2500 /* delete objects and reset colors */
2501 SelectObject (lpdis
->hDC
, hOldBrush
);
2502 SelectObject (lpdis
->hDC
, hOldPen
);
2503 SetBkColor (lpdis
->hDC
, oldBk
);
2504 SetTextColor (lpdis
->hDC
, oldText
);
2505 DeleteObject( hPen
);
2510 case WM_MEASUREITEM
:
2511 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2513 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2515 lpmis
->itemHeight
= 15 + 8; /* default height */
2522 if (uDragListMessage
&& (uMsg
== uDragListMessage
))
2524 if (wParam
== IDC_TOOLBARBTN_LBOX
)
2526 LRESULT res
= TOOLBAR_Cust_ToolbarDragListNotification(
2527 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2528 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2531 else if (wParam
== IDC_AVAILBTN_LBOX
)
2533 LRESULT res
= TOOLBAR_Cust_AvailDragListNotification(
2534 custInfo
, hwnd
, (DRAGLISTINFO
*)lParam
);
2535 SetWindowLongPtrW(hwnd
, DWLP_MSGRESULT
, res
);
2544 /***********************************************************************
2545 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2549 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2551 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2552 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2553 INT nIndex
= 0, nButtons
, nCount
;
2557 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2561 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2563 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2565 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2567 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2572 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2574 /* Windows resize all the buttons to the size of a newly added standard image */
2575 if (lpAddBmp
->nID
& 1)
2578 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2579 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2581 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2582 MAKELPARAM((WORD
)24, (WORD
)24));
2583 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2584 MAKELPARAM((WORD
)31, (WORD
)30));
2589 SendMessageW (hwnd
, TB_SETBITMAPSIZE
, 0,
2590 MAKELPARAM((WORD
)16, (WORD
)16));
2591 SendMessageW (hwnd
, TB_SETBUTTONSIZE
, 0,
2592 MAKELPARAM((WORD
)22, (WORD
)22));
2595 TOOLBAR_CalcToolbar (hwnd
);
2599 nButtons
= (INT
)wParam
;
2603 TRACE ("adding %d bitmaps!\n", nButtons
);
2606 if (!infoPtr
->cimlDef
) {
2607 /* create new default image list */
2608 TRACE ("creating default image list!\n");
2610 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2611 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2612 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2613 infoPtr
->himlInt
= himlDef
;
2616 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2620 WARN("No default image list available\n");
2624 nCount
= ImageList_GetImageCount(himlDef
);
2626 /* Add bitmaps to the default image list */
2627 if (lpAddBmp
->hInst
== NULL
)
2630 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2631 HDC hdcImage
, hdcBitmap
;
2633 /* copy the bitmap before adding it so that the user's bitmap
2634 * doesn't get modified.
2636 GetObjectW ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2638 hdcImage
= CreateCompatibleDC(0);
2639 hdcBitmap
= CreateCompatibleDC(0);
2641 /* create new bitmap */
2642 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2643 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2644 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2646 /* Copy the user's image */
2647 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2648 hdcBitmap
, 0, 0, SRCCOPY
);
2650 SelectObject (hdcImage
, hOldBitmapLoad
);
2651 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2652 DeleteDC (hdcImage
);
2653 DeleteDC (hdcBitmap
);
2655 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2656 DeleteObject (hbmLoad
);
2658 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2660 /* Add system bitmaps */
2661 switch (lpAddBmp
->nID
)
2663 case IDB_STD_SMALL_COLOR
:
2664 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2665 MAKEINTRESOURCEW(IDB_STD_SMALL
));
2666 nIndex
= ImageList_AddMasked (himlDef
,
2667 hbmLoad
, comctl32_color
.clrBtnFace
);
2668 DeleteObject (hbmLoad
);
2671 case IDB_STD_LARGE_COLOR
:
2672 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2673 MAKEINTRESOURCEW(IDB_STD_LARGE
));
2674 nIndex
= ImageList_AddMasked (himlDef
,
2675 hbmLoad
, comctl32_color
.clrBtnFace
);
2676 DeleteObject (hbmLoad
);
2679 case IDB_VIEW_SMALL_COLOR
:
2680 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2681 MAKEINTRESOURCEW(IDB_VIEW_SMALL
));
2682 nIndex
= ImageList_AddMasked (himlDef
,
2683 hbmLoad
, comctl32_color
.clrBtnFace
);
2684 DeleteObject (hbmLoad
);
2687 case IDB_VIEW_LARGE_COLOR
:
2688 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2689 MAKEINTRESOURCEW(IDB_VIEW_LARGE
));
2690 nIndex
= ImageList_AddMasked (himlDef
,
2691 hbmLoad
, comctl32_color
.clrBtnFace
);
2692 DeleteObject (hbmLoad
);
2695 case IDB_HIST_SMALL_COLOR
:
2696 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2697 MAKEINTRESOURCEW(IDB_HIST_SMALL
));
2698 nIndex
= ImageList_AddMasked (himlDef
,
2699 hbmLoad
, comctl32_color
.clrBtnFace
);
2700 DeleteObject (hbmLoad
);
2703 case IDB_HIST_LARGE_COLOR
:
2704 hbmLoad
= LoadBitmapW (COMCTL32_hModule
,
2705 MAKEINTRESOURCEW(IDB_HIST_LARGE
));
2706 nIndex
= ImageList_AddMasked (himlDef
,
2707 hbmLoad
, comctl32_color
.clrBtnFace
);
2708 DeleteObject (hbmLoad
);
2712 nIndex
= ImageList_GetImageCount (himlDef
);
2713 ERR ("invalid imagelist!\n");
2719 hbmLoad
= LoadBitmapW (lpAddBmp
->hInst
, (LPWSTR
)lpAddBmp
->nID
);
2720 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2721 DeleteObject (hbmLoad
);
2724 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2726 if (infoPtr
->nNumBitmapInfos
== 0)
2728 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2732 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2733 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2734 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
);
2737 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2738 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2739 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2741 infoPtr
->nNumBitmapInfos
++;
2742 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2746 INT imagecount
= ImageList_GetImageCount(himlDef
);
2748 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2750 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",
2751 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2752 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2754 infoPtr
->nNumBitmaps
= imagecount
;
2757 infoPtr
->nNumBitmaps
+= nButtons
;
2760 InvalidateRect(hwnd
, NULL
, TRUE
);
2767 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2769 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2770 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2771 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2773 TRACE("adding %d buttons!\n", wParam
);
2775 nAddButtons
= (UINT
)wParam
;
2776 nOldButtons
= infoPtr
->nNumButtons
;
2777 nNewButtons
= nOldButtons
+ nAddButtons
;
2779 if (infoPtr
->nNumButtons
== 0) {
2781 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2784 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2786 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2787 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2788 nOldButtons
* sizeof(TBUTTON_INFO
));
2792 infoPtr
->nNumButtons
= nNewButtons
;
2794 /* insert new button data */
2795 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2796 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2797 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2798 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2799 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2800 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2801 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2802 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2803 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2805 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2806 btnPtr
->bHot
= FALSE
;
2808 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2811 ZeroMemory (&ti
, sizeof(ti
));
2812 ti
.cbSize
= sizeof(ti
);
2814 ti
.uId
= btnPtr
->idCommand
;
2816 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2818 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2823 TOOLBAR_CalcToolbar (hwnd
);
2825 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2827 InvalidateRect(hwnd
, NULL
, TRUE
);
2834 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2836 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2837 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2838 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2840 TRACE("adding %d buttons!\n", wParam
);
2842 nAddButtons
= (UINT
)wParam
;
2843 nOldButtons
= infoPtr
->nNumButtons
;
2844 nNewButtons
= nOldButtons
+ nAddButtons
;
2846 if (infoPtr
->nNumButtons
== 0) {
2848 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2851 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2853 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2854 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2855 nOldButtons
* sizeof(TBUTTON_INFO
));
2859 infoPtr
->nNumButtons
= nNewButtons
;
2861 /* insert new button data */
2862 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2863 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2864 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2865 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2866 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2867 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2868 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2869 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2870 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2872 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2873 btnPtr
->bHot
= FALSE
;
2875 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2878 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2879 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2881 ti
.uId
= btnPtr
->idCommand
;
2883 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2886 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2891 TOOLBAR_CalcToolbar (hwnd
);
2893 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2895 InvalidateRect(hwnd
, NULL
, TRUE
);
2902 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2904 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2907 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2910 TRACE("adding string from resource!\n");
2912 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
, szString
, sizeof(szString
));
2914 TRACE("len=%d \"%s\"\n", len
, szString
);
2915 nIndex
= infoPtr
->nNumStrings
;
2916 if (infoPtr
->nNumStrings
== 0) {
2918 Alloc (sizeof(LPWSTR
));
2921 LPWSTR
*oldStrings
= infoPtr
->strings
;
2923 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2924 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2925 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2929 /*Alloc zeros out the allocated memory*/
2930 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2931 infoPtr
->nNumStrings
++;
2934 LPSTR p
= (LPSTR
)lParam
;
2939 TRACE("adding string(s) from array!\n");
2941 nIndex
= infoPtr
->nNumStrings
;
2944 TRACE("len=%d \"%s\"\n", len
, p
);
2946 if (infoPtr
->nNumStrings
== 0) {
2948 Alloc (sizeof(LPWSTR
));
2951 LPWSTR
*oldStrings
= infoPtr
->strings
;
2953 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2954 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2955 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2959 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2960 infoPtr
->nNumStrings
++;
2971 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2973 #define MAX_RESOURCE_STRING_LENGTH 512
2974 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2977 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2978 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2980 TRACE("adding string from resource!\n");
2982 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2983 szString
, MAX_RESOURCE_STRING_LENGTH
);
2985 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2986 TRACE("First char: 0x%x\n", *szString
);
2987 if (szString
[0] == L
'|')
2989 PWSTR p
= szString
+ 1;
2991 nIndex
= infoPtr
->nNumStrings
;
2992 while (*p
!= L
'|' && *p
!= L
'\0') {
2995 if (infoPtr
->nNumStrings
== 0) {
2996 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
3000 LPWSTR
*oldStrings
= infoPtr
->strings
;
3001 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
3002 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
3003 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
3007 np
=strchrW (p
, '|');
3015 TRACE("len=%d %s\n", len
, debugstr_w(p
));
3016 infoPtr
->strings
[infoPtr
->nNumStrings
] =
3017 Alloc (sizeof(WCHAR
)*(len
+1));
3018 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
3019 infoPtr
->nNumStrings
++;
3026 nIndex
= infoPtr
->nNumStrings
;
3027 if (infoPtr
->nNumStrings
== 0) {
3029 Alloc (sizeof(LPWSTR
));
3032 LPWSTR
*oldStrings
= infoPtr
->strings
;
3034 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
3035 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
3036 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
3040 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
3041 infoPtr
->nNumStrings
++;
3045 LPWSTR p
= (LPWSTR
)lParam
;
3050 TRACE("adding string(s) from array!\n");
3051 nIndex
= infoPtr
->nNumStrings
;
3055 TRACE("len=%d %s\n", len
, debugstr_w(p
));
3056 if (infoPtr
->nNumStrings
== 0) {
3058 Alloc (sizeof(LPWSTR
));
3061 LPWSTR
*oldStrings
= infoPtr
->strings
;
3063 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
3064 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
3065 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
3069 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
3070 infoPtr
->nNumStrings
++;
3081 TOOLBAR_AutoSize (HWND hwnd
)
3083 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3089 UINT uPosFlags
= SWP_NOZORDER
;
3091 TRACE("resize forced, style=%lx!\n", infoPtr
->dwStyle
);
3093 parent
= GetParent (hwnd
);
3094 GetClientRect(parent
, &parent_rect
);
3096 x
= parent_rect
.left
;
3097 y
= parent_rect
.top
;
3099 /* FIXME: we should be able to early out if nothing */
3100 /* has changed with nWidth != parent_rect width */
3102 if (infoPtr
->dwStyle
& CCS_NORESIZE
) {
3103 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
3106 TOOLBAR_CalcToolbar (hwnd
);
3109 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
3110 TOOLBAR_CalcToolbar (hwnd
);
3111 InvalidateRect( hwnd
, NULL
, TRUE
);
3112 cy
= infoPtr
->nHeight
;
3113 cx
= infoPtr
->nWidth
;
3115 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
3116 GetWindowRect(hwnd
, &window_rect
);
3117 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
3118 y
= window_rect
.top
;
3120 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
3121 GetWindowRect(hwnd
, &window_rect
);
3122 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
3126 if (infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)
3127 uPosFlags
|= SWP_NOMOVE
;
3129 if (!(infoPtr
->dwStyle
& CCS_NODIVIDER
))
3130 cy
+= GetSystemMetrics(SM_CYEDGE
);
3132 if (infoPtr
->dwStyle
& WS_BORDER
)
3135 cy
+= GetSystemMetrics(SM_CYEDGE
);
3136 cx
+= GetSystemMetrics(SM_CXEDGE
);
3139 infoPtr
->bAutoSize
= TRUE
;
3140 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
3141 /* The following line makes sure that the infoPtr->bAutoSize is turned off
3142 * after the setwindowpos calls */
3143 infoPtr
->bAutoSize
= FALSE
;
3150 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3152 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3154 return infoPtr
->nNumButtons
;
3159 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3161 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3163 infoPtr
->dwStructSize
= (DWORD
)wParam
;
3170 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3172 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3173 TBUTTON_INFO
*btnPtr
;
3176 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
3178 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3182 btnPtr
= &infoPtr
->buttons
[nIndex
];
3183 btnPtr
->iBitmap
= LOWORD(lParam
);
3185 /* we HAVE to erase the background, the new bitmap could be */
3187 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3194 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3196 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3197 TBUTTON_INFO
*btnPtr
;
3200 BOOL bChecked
= FALSE
;
3202 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3204 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
3209 btnPtr
= &infoPtr
->buttons
[nIndex
];
3211 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
3213 if (LOWORD(lParam
) == FALSE
)
3214 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
3216 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
3218 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
3219 if (nOldIndex
== nIndex
)
3221 if (nOldIndex
!= -1)
3222 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
3224 btnPtr
->fsState
|= TBSTATE_CHECKED
;
3227 if( bChecked
!= LOWORD(lParam
) )
3229 if (nOldIndex
!= -1)
3230 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
3231 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3234 /* FIXME: Send a WM_NOTIFY?? */
3241 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3243 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3245 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3250 TOOLBAR_Customize (HWND hwnd
)
3252 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3253 CUSTDLG_INFO custInfo
;
3259 custInfo
.tbInfo
= infoPtr
;
3260 custInfo
.tbHwnd
= hwnd
;
3262 /* send TBN_BEGINADJUST notification */
3263 TOOLBAR_SendNotify (&nmhdr
, infoPtr
, TBN_BEGINADJUST
);
3265 if (!(hRes
= FindResourceW (COMCTL32_hModule
,
3266 MAKEINTRESOURCEW(IDD_TBCUSTOMIZE
),
3267 (LPWSTR
)RT_DIALOG
)))
3270 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
3273 ret
= DialogBoxIndirectParamW ((HINSTANCE
)GetWindowLongPtrW(hwnd
, GWLP_HINSTANCE
),
3274 (LPDLGTEMPLATEW
)template,
3276 TOOLBAR_CustomizeDialogProc
,
3279 /* send TBN_ENDADJUST notification */
3280 TOOLBAR_SendNotify (&nmhdr
, infoPtr
, TBN_ENDADJUST
);
3287 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3289 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3290 INT nIndex
= (INT
)wParam
;
3292 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nIndex
];
3294 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3297 memset(&nmtb
, 0, sizeof(nmtb
));
3298 nmtb
.iItem
= btnPtr
->idCommand
;
3299 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
3300 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
3301 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
3302 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
3303 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
3304 nmtb
.tbButton
.iString
= btnPtr
->iString
;
3305 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_DELETINGBUTTON
);
3307 if ((infoPtr
->hwndToolTip
) &&
3308 !(btnPtr
->fsStyle
& BTNS_SEP
)) {
3311 ZeroMemory (&ti
, sizeof(ti
));
3312 ti
.cbSize
= sizeof(ti
);
3314 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3316 SendMessageW (infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
3319 if (infoPtr
->nNumButtons
== 1) {
3320 TRACE(" simple delete!\n");
3321 Free (infoPtr
->buttons
);
3322 infoPtr
->buttons
= NULL
;
3323 infoPtr
->nNumButtons
= 0;
3326 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3327 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3329 infoPtr
->nNumButtons
--;
3330 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3332 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3333 nIndex
* sizeof(TBUTTON_INFO
));
3336 if (nIndex
< infoPtr
->nNumButtons
) {
3337 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3338 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3344 TOOLBAR_CalcToolbar (hwnd
);
3346 InvalidateRect (hwnd
, NULL
, TRUE
);
3353 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3355 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3356 TBUTTON_INFO
*btnPtr
;
3360 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3362 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3367 btnPtr
= &infoPtr
->buttons
[nIndex
];
3369 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3371 /* update the toolbar button state */
3372 if(LOWORD(lParam
) == FALSE
) {
3373 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3375 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3378 /* redraw the button only if the state of the button changed */
3379 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3380 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3386 static inline LRESULT
3387 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3389 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3391 return infoPtr
->bAnchor
;
3396 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3398 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3401 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3405 return infoPtr
->buttons
[nIndex
].iBitmap
;
3409 static inline LRESULT
3410 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3412 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3417 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3419 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3420 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3421 INT nIndex
= (INT
)wParam
;
3422 TBUTTON_INFO
*btnPtr
;
3427 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3430 btnPtr
= &infoPtr
->buttons
[nIndex
];
3431 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3432 lpTbb
->idCommand
= btnPtr
->idCommand
;
3433 lpTbb
->fsState
= btnPtr
->fsState
;
3434 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3435 lpTbb
->bReserved
[0] = 0;
3436 lpTbb
->bReserved
[1] = 0;
3437 lpTbb
->dwData
= btnPtr
->dwData
;
3438 lpTbb
->iString
= btnPtr
->iString
;
3445 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3447 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3448 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3449 TBUTTON_INFO
*btnPtr
;
3452 if (lpTbInfo
== NULL
)
3454 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3457 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3458 lpTbInfo
->dwMask
& 0x80000000);
3462 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3464 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3465 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3466 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3467 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3468 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3469 lpTbInfo
->lParam
= btnPtr
->dwData
;
3470 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3471 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3472 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3473 lpTbInfo
->fsState
= btnPtr
->fsState
;
3474 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3475 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3476 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3477 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3478 can't use TOOLBAR_GetText here */
3480 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3481 lpText
= (LPWSTR
)btnPtr
->iString
;
3482 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3484 lpTbInfo
->pszText
[0] = '\0';
3491 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3493 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3494 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3495 TBUTTON_INFO
*btnPtr
;
3498 if (lpTbInfo
== NULL
)
3500 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3503 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3504 lpTbInfo
->dwMask
& 0x80000000);
3508 btnPtr
= &infoPtr
->buttons
[nIndex
];
3513 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3514 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3515 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3516 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3517 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3518 lpTbInfo
->lParam
= btnPtr
->dwData
;
3519 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3520 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3521 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3522 lpTbInfo
->fsState
= btnPtr
->fsState
;
3523 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3524 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3525 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3526 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3527 can't use TOOLBAR_GetText here */
3529 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3530 lpText
= (LPWSTR
)btnPtr
->iString
;
3531 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3533 lpTbInfo
->pszText
[0] = '\0';
3541 TOOLBAR_GetButtonSize (HWND hwnd
)
3543 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3545 if (infoPtr
->nNumButtons
> 0)
3546 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3547 (WORD
)infoPtr
->nButtonHeight
);
3549 return MAKELONG(23,22);
3554 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3556 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3563 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3567 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3569 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3570 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3575 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3577 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3582 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3586 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3590 ret
= strlenW (lpText
);
3593 strcpyW ((LPWSTR
)lParam
, lpText
);
3601 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3603 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3604 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3605 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3609 inline static LRESULT
3610 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3612 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3616 return infoPtr
->dwExStyle
;
3621 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3623 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3624 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3625 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3630 TOOLBAR_GetHotItem (HWND hwnd
)
3632 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3634 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
3637 if (infoPtr
->nHotItem
< 0)
3640 return (LRESULT
)infoPtr
->nHotItem
;
3645 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3647 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3648 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3649 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3654 TOOLBAR_GetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3656 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3657 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
3659 TRACE("hwnd = %p, lptbim = %p\n", hwnd
, lptbim
);
3661 *lptbim
= infoPtr
->tbim
;
3668 TOOLBAR_GetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3670 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3672 TRACE("hwnd = %p\n", hwnd
);
3674 return (LRESULT
)infoPtr
->clrInsertMark
;
3679 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3681 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3682 TBUTTON_INFO
*btnPtr
;
3686 nIndex
= (INT
)wParam
;
3687 btnPtr
= &infoPtr
->buttons
[nIndex
];
3688 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3690 lpRect
= (LPRECT
)lParam
;
3693 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3696 lpRect
->left
= btnPtr
->rect
.left
;
3697 lpRect
->right
= btnPtr
->rect
.right
;
3698 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3699 lpRect
->top
= btnPtr
->rect
.top
;
3706 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3708 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3709 LPSIZE lpSize
= (LPSIZE
)lParam
;
3714 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3715 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3717 TRACE("maximum size %ld x %ld\n",
3718 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3719 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3725 /* << TOOLBAR_GetObject >> */
3729 TOOLBAR_GetPadding (HWND hwnd
)
3731 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3734 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3735 return (LRESULT
) oldPad
;
3740 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3742 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3743 TBUTTON_INFO
*btnPtr
;
3747 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3748 btnPtr
= &infoPtr
->buttons
[nIndex
];
3749 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3751 lpRect
= (LPRECT
)lParam
;
3755 lpRect
->left
= btnPtr
->rect
.left
;
3756 lpRect
->right
= btnPtr
->rect
.right
;
3757 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3758 lpRect
->top
= btnPtr
->rect
.top
;
3765 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3767 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3769 if (infoPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
3770 return infoPtr
->nRows
;
3777 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3779 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3782 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3786 return infoPtr
->buttons
[nIndex
].fsState
;
3791 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3793 return GetWindowLongW(hwnd
, GWL_STYLE
);
3798 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3800 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3802 return infoPtr
->nMaxTextRows
;
3807 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3809 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3811 return (LRESULT
)infoPtr
->hwndToolTip
;
3816 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3818 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3820 TRACE("%s hwnd=%p\n",
3821 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3823 return infoPtr
->bUnicode
;
3827 inline static LRESULT
3828 TOOLBAR_GetVersion (HWND hwnd
)
3830 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3831 return infoPtr
->iVersion
;
3836 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3838 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3839 TBUTTON_INFO
*btnPtr
;
3844 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3848 btnPtr
= &infoPtr
->buttons
[nIndex
];
3849 if (LOWORD(lParam
) == FALSE
)
3850 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3852 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3854 TOOLBAR_CalcToolbar (hwnd
);
3856 InvalidateRect (hwnd
, NULL
, TRUE
);
3862 inline static LRESULT
3863 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3865 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3870 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3872 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3873 TBUTTON_INFO
*btnPtr
;
3877 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3881 btnPtr
= &infoPtr
->buttons
[nIndex
];
3882 oldState
= btnPtr
->fsState
;
3883 if (LOWORD(lParam
) == FALSE
)
3884 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3886 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3888 if(oldState
!= btnPtr
->fsState
)
3889 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3896 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3898 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3899 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3900 INT nIndex
= (INT
)wParam
;
3901 TBUTTON_INFO
*oldButtons
;
3906 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3909 /* EPP: this seems to be an undocumented call (from my IE4)
3910 * I assume in that case that:
3911 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3912 * - index of insertion is at the end of existing buttons
3913 * I only see this happen with nIndex == -1, but it could have a special
3914 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3916 nIndex
= infoPtr
->nNumButtons
;
3918 } else if (nIndex
< 0)
3921 /* If the string passed is not an index, assume address of string
3922 and do our own AddString */
3923 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3927 TRACE("string %s passed instead of index, adding string\n",
3928 debugstr_a((LPSTR
)lpTbb
->iString
));
3929 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3931 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3932 ptr
[len
- 1] = 0; /* ended by two '\0' */
3933 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3937 TRACE("inserting button index=%d\n", nIndex
);
3938 if (nIndex
> infoPtr
->nNumButtons
) {
3939 nIndex
= infoPtr
->nNumButtons
;
3940 TRACE("adjust index=%d\n", nIndex
);
3943 oldButtons
= infoPtr
->buttons
;
3944 infoPtr
->nNumButtons
++;
3945 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3946 /* pre insert copy */
3948 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3949 nIndex
* sizeof(TBUTTON_INFO
));
3952 /* insert new button */
3953 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3954 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3955 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3956 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3957 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3958 /* if passed string and not index, then add string */
3959 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3960 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3963 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3965 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3968 ZeroMemory (&ti
, sizeof(ti
));
3969 ti
.cbSize
= sizeof (ti
);
3971 ti
.uId
= lpTbb
->idCommand
;
3973 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3975 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3979 /* post insert copy */
3980 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3981 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3982 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3987 TOOLBAR_CalcToolbar (hwnd
);
3989 InvalidateRect (hwnd
, NULL
, TRUE
);
3996 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3998 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3999 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
4000 INT nIndex
= (INT
)wParam
;
4001 TBUTTON_INFO
*oldButtons
;
4006 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
4009 /* EPP: this seems to be an undocumented call (from my IE4)
4010 * I assume in that case that:
4011 * - lpTbb->iString is a string pointer (not a string index in strings[] table
4012 * - index of insertion is at the end of existing buttons
4013 * I only see this happen with nIndex == -1, but it could have a special
4014 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
4016 nIndex
= infoPtr
->nNumButtons
;
4018 } else if (nIndex
< 0)
4021 /* If the string passed is not an index, assume address of string
4022 and do our own AddString */
4023 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
4027 TRACE("string %s passed instead of index, adding string\n",
4028 debugstr_w((LPWSTR
)lpTbb
->iString
));
4029 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
4030 ptr
= Alloc(len
*sizeof(WCHAR
));
4031 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
4032 ptr
[len
- 1] = 0; /* ended by two '\0' */
4033 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
4037 TRACE("inserting button index=%d\n", nIndex
);
4038 if (nIndex
> infoPtr
->nNumButtons
) {
4039 nIndex
= infoPtr
->nNumButtons
;
4040 TRACE("adjust index=%d\n", nIndex
);
4043 oldButtons
= infoPtr
->buttons
;
4044 infoPtr
->nNumButtons
++;
4045 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
4046 /* pre insert copy */
4048 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
4049 nIndex
* sizeof(TBUTTON_INFO
));
4052 /* insert new button */
4053 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
4054 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
4055 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
4056 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
4057 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
4058 /* if passed string and not index, then add string */
4059 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
4060 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
4063 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
4065 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
4068 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
4069 ti
.cbSize
= sizeof (TTTOOLINFOW
);
4071 ti
.uId
= lpTbb
->idCommand
;
4073 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
4075 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
4079 /* post insert copy */
4080 if (nIndex
< infoPtr
->nNumButtons
- 1) {
4081 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
4082 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
4087 TOOLBAR_CalcToolbar (hwnd
);
4089 InvalidateRect (hwnd
, NULL
, TRUE
);
4095 /* << TOOLBAR_InsertMarkHitTest >> */
4099 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4101 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4104 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4108 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
4113 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4115 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4118 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4122 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
4127 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4129 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4132 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4136 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
4141 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4143 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4146 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4150 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
4155 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4157 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4160 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4164 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
4169 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4171 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4174 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4178 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
4183 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4186 tbab
.hInst
= (HINSTANCE
)lParam
;
4187 tbab
.nID
= (UINT_PTR
)wParam
;
4189 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
4191 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
4196 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4198 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4199 WCHAR wAccel
= (WCHAR
)wParam
;
4200 UINT
* pIDButton
= (UINT
*)lParam
;
4201 WCHAR wszAccel
[] = {'&',wAccel
,0};
4204 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
4205 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
4207 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4209 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
4210 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
4211 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
4213 int iLen
= strlenW(wszAccel
);
4214 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
4221 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
4226 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
4228 *pIDButton
= btnPtr
->idCommand
;
4240 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4242 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4245 TBUTTON_INFO
*btnPtr
;
4247 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
4249 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4253 btnPtr
= &infoPtr
->buttons
[nIndex
];
4254 oldState
= btnPtr
->fsState
;
4257 btnPtr
->fsState
|= TBSTATE_MARKED
;
4259 btnPtr
->fsState
&= ~TBSTATE_MARKED
;
4261 if(oldState
!= btnPtr
->fsState
)
4262 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4268 /* fixes up an index of a button affected by a move */
4269 inline static void TOOLBAR_MoveFixupIndex(INT
* pIndex
, INT nIndex
, INT nMoveIndex
, BOOL bMoveUp
)
4273 if (*pIndex
> nIndex
&& *pIndex
<= nMoveIndex
)
4275 else if (*pIndex
== nIndex
)
4276 *pIndex
= nMoveIndex
;
4280 if (*pIndex
>= nMoveIndex
&& *pIndex
< nIndex
)
4282 else if (*pIndex
== nIndex
)
4283 *pIndex
= nMoveIndex
;
4289 TOOLBAR_MoveButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4291 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4294 INT nMoveIndex
= (INT
)lParam
;
4295 TBUTTON_INFO button
;
4297 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4299 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, TRUE
);
4300 if ((nIndex
== -1) || (nMoveIndex
< 0))
4303 if (nMoveIndex
> infoPtr
->nNumButtons
- 1)
4304 nMoveIndex
= infoPtr
->nNumButtons
- 1;
4306 button
= infoPtr
->buttons
[nIndex
];
4308 /* move button right */
4309 if (nIndex
< nMoveIndex
)
4311 nCount
= nMoveIndex
- nIndex
;
4312 memmove(&infoPtr
->buttons
[nIndex
], &infoPtr
->buttons
[nIndex
+1], nCount
*sizeof(TBUTTON_INFO
));
4313 infoPtr
->buttons
[nMoveIndex
] = button
;
4315 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, TRUE
);
4316 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, TRUE
);
4317 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, TRUE
);
4318 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, TRUE
);
4320 else if (nIndex
> nMoveIndex
) /* move button left */
4322 nCount
= nIndex
- nMoveIndex
;
4323 memmove(&infoPtr
->buttons
[nMoveIndex
+1], &infoPtr
->buttons
[nMoveIndex
], nCount
*sizeof(TBUTTON_INFO
));
4324 infoPtr
->buttons
[nMoveIndex
] = button
;
4326 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, FALSE
);
4327 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, FALSE
);
4328 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, FALSE
);
4329 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, FALSE
);
4332 TOOLBAR_CalcToolbar(hwnd
);
4333 InvalidateRect(hwnd
, NULL
, TRUE
);
4340 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4342 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4343 TBUTTON_INFO
*btnPtr
;
4347 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4351 btnPtr
= &infoPtr
->buttons
[nIndex
];
4352 oldState
= btnPtr
->fsState
;
4353 if (LOWORD(lParam
) == FALSE
)
4354 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4356 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4358 if(oldState
!= btnPtr
->fsState
)
4359 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4364 /* FIXME: there might still be some confusion her between number of buttons
4365 * and number of bitmaps */
4367 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4369 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4370 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
4372 int i
= 0, nOldButtons
= 0, pos
= 0;
4373 int nOldBitmaps
, nNewBitmaps
= 0;
4374 HIMAGELIST himlDef
= 0;
4376 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
4377 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
4378 lpReplace
->nButtons
);
4380 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4382 FIXME("changing standard bitmaps not implemented\n");
4385 else if (lpReplace
->hInstOld
!= 0)
4387 FIXME("resources not in the current module not implemented\n");
4392 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4395 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4396 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4397 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4398 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4399 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4401 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4402 nOldButtons
= tbi
->nButtons
;
4403 tbi
->nButtons
= lpReplace
->nButtons
;
4404 tbi
->hInst
= lpReplace
->hInstNew
;
4405 tbi
->nID
= lpReplace
->nIDNew
;
4406 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4409 pos
+= tbi
->nButtons
;
4412 if (nOldButtons
== 0)
4414 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4418 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4419 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4421 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4423 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4424 ImageList_Remove(himlDef
, i
);
4429 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4430 HDC hdcImage
, hdcBitmap
;
4432 /* copy the bitmap before adding it so that the user's bitmap
4433 * doesn't get modified.
4435 GetObjectW (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4437 hdcImage
= CreateCompatibleDC(0);
4438 hdcBitmap
= CreateCompatibleDC(0);
4440 /* create new bitmap */
4441 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4442 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4443 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4445 /* Copy the user's image */
4446 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4447 hdcBitmap
, 0, 0, SRCCOPY
);
4449 SelectObject (hdcImage
, hOldBitmapLoad
);
4450 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4451 DeleteDC (hdcImage
);
4452 DeleteDC (hdcBitmap
);
4454 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4455 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4456 DeleteObject (hbmLoad
);
4459 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4461 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4462 pos
, nOldBitmaps
, nNewBitmaps
);
4464 InvalidateRect(hwnd
, NULL
, TRUE
);
4470 /* helper for TOOLBAR_SaveRestoreW */
4472 TOOLBAR_Save(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4474 FIXME("save to %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4475 debugstr_w(lpSave
->pszValueName
));
4481 /* helper for TOOLBAR_Restore */
4483 TOOLBAR_DeleteAllButtons(TOOLBAR_INFO
*infoPtr
)
4488 ZeroMemory(&ti
, sizeof(ti
));
4489 ti
.cbSize
= sizeof(ti
);
4490 ti
.hwnd
= infoPtr
->hwndSelf
;
4492 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
4494 if ((infoPtr
->hwndToolTip
) &&
4495 !(infoPtr
->buttons
[i
].fsStyle
& BTNS_SEP
))
4497 ti
.uId
= infoPtr
->buttons
[i
].idCommand
;
4498 SendMessageW(infoPtr
->hwndToolTip
, TTM_DELTOOLW
, 0, (LPARAM
)&ti
);
4502 Free(infoPtr
->buttons
);
4503 infoPtr
->buttons
= NULL
;
4504 infoPtr
->nNumButtons
= 0;
4508 /* helper for TOOLBAR_SaveRestoreW */
4510 TOOLBAR_Restore(TOOLBAR_INFO
*infoPtr
, LPTBSAVEPARAMSW lpSave
)
4519 /* restore toolbar information */
4520 TRACE("restore from %s %s\n", debugstr_w(lpSave
->pszSubKey
),
4521 debugstr_w(lpSave
->pszValueName
));
4523 memset(&nmtbr
, 0, sizeof(nmtbr
));
4525 res
= RegOpenKeyExW(lpSave
->hkr
, lpSave
->pszSubKey
, 0,
4526 KEY_QUERY_VALUE
, &hkey
);
4528 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4530 if (!res
&& dwType
!= REG_BINARY
)
4531 res
= ERROR_FILE_NOT_FOUND
;
4534 nmtbr
.pData
= Alloc(dwSize
);
4535 nmtbr
.cbData
= (UINT
)dwSize
;
4536 if (!nmtbr
.pData
) res
= ERROR_OUTOFMEMORY
;
4539 res
= RegQueryValueExW(hkey
, lpSave
->pszValueName
, NULL
, &dwType
,
4540 (LPBYTE
)nmtbr
.pData
, &dwSize
);
4543 nmtbr
.pCurrent
= nmtbr
.pData
;
4545 nmtbr
.cbBytesPerRecord
= sizeof(DWORD
);
4546 nmtbr
.cButtons
= nmtbr
.cbData
/ nmtbr
.cbBytesPerRecord
;
4548 if (!TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
))
4552 /* remove all existing buttons as this function is designed to
4553 * restore the toolbar to a previously saved state */
4554 TOOLBAR_DeleteAllButtons(infoPtr
);
4556 for (i
= 0; i
< nmtbr
.cButtons
; i
++)
4559 nmtbr
.tbButton
.iBitmap
= -1;
4560 nmtbr
.tbButton
.fsState
= 0;
4561 nmtbr
.tbButton
.fsStyle
= 0;
4562 nmtbr
.tbButton
.idCommand
= 0;
4563 if (*nmtbr
.pCurrent
== (DWORD
)-1)
4566 nmtbr
.tbButton
.fsStyle
= TBSTYLE_SEP
;
4567 nmtbr
.tbButton
.iBitmap
= SEPARATOR_WIDTH
;
4569 else if (*nmtbr
.pCurrent
== (DWORD
)-2)
4571 nmtbr
.tbButton
.fsState
= TBSTATE_HIDDEN
;
4573 nmtbr
.tbButton
.idCommand
= (int)*nmtbr
.pCurrent
;
4577 TOOLBAR_SendNotify(&nmtbr
.hdr
, infoPtr
, TBN_RESTORE
);
4579 /* can't contain real string as we don't know whether
4580 * the client put an ANSI or Unicode string in there */
4581 if (HIWORD(nmtbr
.tbButton
.iString
))
4582 nmtbr
.tbButton
.iString
= 0;
4584 TOOLBAR_InsertButtonW(infoPtr
->hwndSelf
, -1,
4585 (LPARAM
)&nmtbr
.tbButton
);
4588 /* do legacy notifications */
4589 if (infoPtr
->iVersion
< 5)
4591 /* FIXME: send TBN_BEGINADJUST */
4592 FIXME("send TBN_GETBUTTONINFO for each button\n");
4593 /* FIXME: send TBN_ENDADJUST */
4596 /* remove all uninitialised buttons
4597 * note: loop backwards to avoid having to fixup i on a
4599 for (i
= infoPtr
->nNumButtons
- 1; i
>= 0; i
--)
4600 if (infoPtr
->buttons
[i
].iBitmap
== -1)
4601 TOOLBAR_DeleteButton(infoPtr
->hwndSelf
, i
, 0);
4603 /* only indicate success if at least one button survived */
4604 if (infoPtr
->nNumButtons
> 0) ret
= TRUE
;
4615 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSW lpSave
)
4617 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4619 if (lpSave
== NULL
) return 0;
4622 return TOOLBAR_Save(infoPtr
, lpSave
);
4624 return TOOLBAR_Restore(infoPtr
, lpSave
);
4629 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPTBSAVEPARAMSA lpSave
)
4631 LPWSTR pszValueName
= 0, pszSubKey
= 0;
4632 TBSAVEPARAMSW SaveW
;
4636 if (lpSave
== NULL
) return 0;
4638 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, NULL
, 0);
4639 pszSubKey
= Alloc(len
* sizeof(WCHAR
));
4640 if (pszSubKey
) goto exit
;
4641 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszSubKey
, -1, pszSubKey
, len
);
4643 len
= MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, NULL
, 0);
4644 pszValueName
= Alloc(len
* sizeof(WCHAR
));
4645 if (!pszValueName
) goto exit
;
4646 MultiByteToWideChar(CP_ACP
, 0, lpSave
->pszValueName
, -1, pszValueName
, len
);
4648 SaveW
.pszValueName
= pszValueName
;
4649 SaveW
.pszSubKey
= pszSubKey
;
4650 SaveW
.hkr
= lpSave
->hkr
;
4651 result
= TOOLBAR_SaveRestoreW(hwnd
, wParam
, &SaveW
);
4654 Free (pszValueName
);
4662 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4664 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4665 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4667 TRACE("hwnd=%p, bAnchor = %s\n", hwnd
, wParam
? "TRUE" : "FALSE");
4669 infoPtr
->bAnchor
= (BOOL
)wParam
;
4671 /* Native does not remove the hot effect from an already hot button */
4673 return (LRESULT
)bOldAnchor
;
4678 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4680 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4681 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4683 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4686 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4688 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4691 if (infoPtr
->nNumButtons
> 0)
4692 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4693 infoPtr
->nNumButtons
,
4694 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4695 LOWORD(lParam
), HIWORD(lParam
));
4697 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4698 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4701 if ((himlDef
== infoPtr
->himlInt
) &&
4702 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4704 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4705 infoPtr
->nBitmapHeight
);
4713 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4715 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4716 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4717 TBUTTON_INFO
*btnPtr
;
4723 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4726 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4727 lptbbi
->dwMask
& 0x80000000);
4731 btnPtr
= &infoPtr
->buttons
[nIndex
];
4732 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4733 btnPtr
->idCommand
= lptbbi
->idCommand
;
4734 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4735 btnPtr
->iBitmap
= lptbbi
->iImage
;
4736 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4737 btnPtr
->dwData
= lptbbi
->lParam
;
4738 if (lptbbi
->dwMask
& TBIF_SIZE
)
4739 btnPtr
->cx
= lptbbi
->cx
;
4740 if (lptbbi
->dwMask
& TBIF_STATE
)
4741 btnPtr
->fsState
= lptbbi
->fsState
;
4742 if (lptbbi
->dwMask
& TBIF_STYLE
)
4743 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4745 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4746 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4747 /* iString is index, zero it to make Str_SetPtr succeed */
4750 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4753 /* save the button rect to see if we need to redraw the whole toolbar */
4754 oldBtnRect
= btnPtr
->rect
;
4755 TOOLBAR_CalcToolbar(hwnd
);
4757 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4758 InvalidateRect(hwnd
, NULL
, TRUE
);
4760 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4767 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4769 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4770 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4771 TBUTTON_INFO
*btnPtr
;
4777 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4780 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4781 lptbbi
->dwMask
& 0x80000000);
4785 btnPtr
= &infoPtr
->buttons
[nIndex
];
4786 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4787 btnPtr
->idCommand
= lptbbi
->idCommand
;
4788 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4789 btnPtr
->iBitmap
= lptbbi
->iImage
;
4790 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4791 btnPtr
->dwData
= lptbbi
->lParam
;
4792 if (lptbbi
->dwMask
& TBIF_SIZE
)
4793 btnPtr
->cx
= lptbbi
->cx
;
4794 if (lptbbi
->dwMask
& TBIF_STATE
)
4795 btnPtr
->fsState
= lptbbi
->fsState
;
4796 if (lptbbi
->dwMask
& TBIF_STYLE
)
4797 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4799 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4800 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4801 /* iString is index, zero it to make Str_SetPtr succeed */
4803 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4806 /* save the button rect to see if we need to redraw the whole toolbar */
4807 oldBtnRect
= btnPtr
->rect
;
4808 TOOLBAR_CalcToolbar(hwnd
);
4810 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4811 InvalidateRect(hwnd
, NULL
, TRUE
);
4813 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4820 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4822 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4823 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4825 if ((cx
< 0) || (cy
< 0))
4827 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4831 TRACE("%p, cx = %d, cy = %d\n", hwnd
, cx
, cy
);
4833 /* The documentation claims you can only change the button size before
4834 * any button has been added. But this is wrong.
4835 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4836 * it to the toolbar, and it checks that the return value is nonzero - mjm
4837 * Further testing shows that we must actually perform the change too.
4840 * The documentation also does not mention that if 0 is supplied for
4841 * either size, the system changes it to the default of 24 wide and
4842 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4844 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4845 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4851 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4853 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4855 /* if setting to current values, ignore */
4856 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4857 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4858 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4859 infoPtr
->cxMin
, infoPtr
->cxMax
);
4863 /* save new values */
4864 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4865 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4867 /* if both values are 0 then we are done */
4869 TRACE("setting both min and max to 0, norecalc\n");
4873 /* otherwise we need to recalc the toolbar and in some cases
4874 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4875 which doesn't actually draw - GA). */
4876 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4877 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4879 TOOLBAR_CalcToolbar (hwnd
);
4881 InvalidateRect (hwnd
, NULL
, TRUE
);
4888 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4890 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4891 INT nIndex
= (INT
)wParam
;
4893 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4896 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4898 if (infoPtr
->hwndToolTip
) {
4900 FIXME("change tool tip!\n");
4909 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4911 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4912 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4913 HIMAGELIST himlTemp
;
4916 if (infoPtr
->iVersion
>= 5)
4919 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4920 &infoPtr
->cimlDis
, himl
, id
);
4922 /* FIXME: redraw ? */
4924 return (LRESULT
)himlTemp
;
4929 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4931 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4934 TRACE("hwnd = %p, dwMask = 0x%08lx, dwDTFlags = 0x%08lx\n", hwnd
, (DWORD
)wParam
, (DWORD
)lParam
);
4936 dwTemp
= infoPtr
->dwDTFlags
;
4937 infoPtr
->dwDTFlags
=
4938 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4940 return (LRESULT
)dwTemp
;
4943 /* This function differs a bit from what MSDN says it does:
4944 * 1. lParam contains extended style flags to OR with current style
4945 * (MSDN isn't clear on the OR bit)
4946 * 2. wParam appears to contain extended style flags to be reset
4947 * (MSDN says that this parameter is reserved)
4950 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4952 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4955 dwTemp
= infoPtr
->dwExStyle
;
4956 infoPtr
->dwExStyle
&= ~wParam
;
4957 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4959 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4961 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4962 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4963 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4965 TOOLBAR_CalcToolbar (hwnd
);
4967 TOOLBAR_AutoSize(hwnd
);
4969 InvalidateRect(hwnd
, NULL
, TRUE
);
4971 return (LRESULT
)dwTemp
;
4976 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4978 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4979 HIMAGELIST himlTemp
;
4980 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4983 if (infoPtr
->iVersion
>= 5)
4986 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
4988 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
4989 &infoPtr
->cimlHot
, himl
, id
);
4991 /* FIXME: redraw ? */
4993 return (LRESULT
)himlTemp
;
4997 /* Makes previous hot button no longer hot, makes the specified
4998 * button hot and sends appropriate notifications. dwReason is one or
4999 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
5000 * NOTE 1: this function does not validate nHit
5001 * NOTE 2: the name of this function is completely made up and
5002 * not based on any documentation from Microsoft. */
5004 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
5006 if (infoPtr
->nHotItem
!= nHit
)
5008 NMTBHOTITEM nmhotitem
;
5009 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
5010 LRESULT no_highlight
;
5012 /* Remove the effect of an old hot button if the button was
5013 drawn with the hot button effect */
5014 if(infoPtr
->nHotItem
>= 0)
5016 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
5017 oldBtnPtr
->bHot
= FALSE
;
5020 infoPtr
->nHotItem
= nHit
;
5022 /* It's not a separator or in nowhere. It's a hot button. */
5024 btnPtr
= &infoPtr
->buttons
[nHit
];
5026 nmhotitem
.dwFlags
= dwReason
;
5028 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
5030 nmhotitem
.dwFlags
|= HICF_ENTERING
;
5032 nmhotitem
.idNew
= btnPtr
->idCommand
;
5034 nmhotitem
.dwFlags
|= HICF_LEAVING
;
5036 no_highlight
= TOOLBAR_SendNotify(&nmhotitem
.hdr
, infoPtr
, TBN_HOTITEMCHANGE
);
5038 /* now invalidate the old and new buttons so they will be painted,
5039 * but only if they are enabled - disabled buttons cannot become hot */
5040 if (oldBtnPtr
&& (oldBtnPtr
->fsState
& TBSTATE_ENABLED
))
5041 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
5042 if (btnPtr
&& !no_highlight
&& (btnPtr
->fsState
& TBSTATE_ENABLED
))
5044 btnPtr
->bHot
= TRUE
;
5045 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
5051 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
5053 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5054 INT nOldHotItem
= infoPtr
->nHotItem
;
5056 TRACE("hwnd = %p, nHit = %d\n", hwnd
, (INT
)wParam
);
5058 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
5061 /* NOTE: an application can still remove the hot item even if anchor
5062 * highlighting is enabled */
5064 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
5065 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
5067 if (nOldHotItem
< 0)
5070 return (LRESULT
)nOldHotItem
;
5075 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5077 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5078 HIMAGELIST himlTemp
;
5079 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
5082 if (infoPtr
->iVersion
>= 5)
5085 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
5086 &infoPtr
->cimlDef
, himl
, id
);
5088 infoPtr
->nNumBitmaps
= 0;
5089 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
5090 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
5092 if (!ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
5093 &infoPtr
->nBitmapHeight
))
5095 infoPtr
->nBitmapWidth
= 1;
5096 infoPtr
->nBitmapHeight
= 1;
5099 TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n",
5100 hwnd
, infoPtr
->himlDef
, id
, infoPtr
->nNumBitmaps
,
5101 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
5103 InvalidateRect(hwnd
, NULL
, TRUE
);
5105 return (LRESULT
)himlTemp
;
5110 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5112 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5114 infoPtr
->nIndent
= (INT
)wParam
;
5118 /* process only on indent changing */
5119 if(infoPtr
->nIndent
!= (INT
)wParam
)
5121 infoPtr
->nIndent
= (INT
)wParam
;
5122 TOOLBAR_CalcToolbar (hwnd
);
5123 InvalidateRect(hwnd
, NULL
, FALSE
);
5131 TOOLBAR_SetInsertMark (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5133 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5134 TBINSERTMARK
*lptbim
= (TBINSERTMARK
*)lParam
;
5136 TRACE("hwnd = %p, lptbim = { %d, 0x%08lx}\n", hwnd
, lptbim
->iButton
, lptbim
->dwFlags
);
5138 if ((lptbim
->dwFlags
& ~TBIMHT_AFTER
) != 0)
5140 FIXME("Unrecognized flag(s): 0x%08lx\n", (lptbim
->dwFlags
& ~TBIMHT_AFTER
));
5144 if ((lptbim
->iButton
== -1) ||
5145 ((lptbim
->iButton
< infoPtr
->nNumButtons
) &&
5146 (lptbim
->iButton
>= 0)))
5148 infoPtr
->tbim
= *lptbim
;
5149 /* FIXME: don't need to update entire toolbar */
5150 InvalidateRect(hwnd
, NULL
, TRUE
);
5153 ERR("Invalid button index %d\n", lptbim
->iButton
);
5160 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5162 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5164 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
5166 /* FIXME: don't need to update entire toolbar */
5167 InvalidateRect(hwnd
, NULL
, TRUE
);
5174 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5176 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5178 infoPtr
->nMaxTextRows
= (INT
)wParam
;
5180 TOOLBAR_CalcToolbar(hwnd
);
5185 /* MSDN gives slightly wrong info on padding.
5186 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
5187 * 2. It is not used to create a blank area between the edge of the button
5188 * and the text or image if TBSTYLE_LIST is set. It is used to control
5189 * the gap between the image and text.
5190 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
5191 * to control the bottom and right borders [with the border being
5192 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
5193 * is shared evenly on both sides of the button.
5194 * See blueprints in comments above TOOLBAR_MeasureButton for more info.
5197 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5199 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5202 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5203 infoPtr
->szPadding
.cx
= min(LOWORD((DWORD
)lParam
), GetSystemMetrics(SM_CXEDGE
));
5204 infoPtr
->szPadding
.cy
= min(HIWORD((DWORD
)lParam
), GetSystemMetrics(SM_CYEDGE
));
5205 TRACE("cx=%ld, cy=%ld\n",
5206 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
5207 return (LRESULT
) oldPad
;
5212 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5214 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5219 hwndOldNotify
= infoPtr
->hwndNotify
;
5220 infoPtr
->hwndNotify
= (HWND
)wParam
;
5222 return (LRESULT
)hwndOldNotify
;
5227 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5229 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5230 LPRECT lprc
= (LPRECT
)lParam
;
5234 if (LOWORD(wParam
) > 1) {
5235 FIXME("multiple rows not supported!\n");
5238 if(infoPtr
->nRows
!= LOWORD(wParam
))
5240 infoPtr
->nRows
= LOWORD(wParam
);
5242 /* recalculate toolbar */
5243 TOOLBAR_CalcToolbar (hwnd
);
5245 /* repaint toolbar */
5246 InvalidateRect(hwnd
, NULL
, TRUE
);
5249 /* return bounding rectangle */
5251 lprc
->left
= infoPtr
->rcBound
.left
;
5252 lprc
->right
= infoPtr
->rcBound
.right
;
5253 lprc
->top
= infoPtr
->rcBound
.top
;
5254 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
5262 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5264 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5265 TBUTTON_INFO
*btnPtr
;
5268 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
5272 btnPtr
= &infoPtr
->buttons
[nIndex
];
5274 /* if hidden state has changed the invalidate entire window and recalc */
5275 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
5276 btnPtr
->fsState
= LOWORD(lParam
);
5277 TOOLBAR_CalcToolbar (hwnd
);
5278 InvalidateRect(hwnd
, 0, TRUE
);
5282 /* process state changing if current state doesn't match new state */
5283 if(btnPtr
->fsState
!= LOWORD(lParam
))
5285 btnPtr
->fsState
= LOWORD(lParam
);
5286 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5294 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5296 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
5302 inline static LRESULT
5303 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5305 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5307 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
5309 infoPtr
->hwndToolTip
= (HWND
)wParam
;
5315 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5317 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5320 TRACE("%s hwnd=%p\n",
5321 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
5323 bTemp
= infoPtr
->bUnicode
;
5324 infoPtr
->bUnicode
= (BOOL
)wParam
;
5331 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5333 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5335 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
5336 comctl32_color
.clrBtnHighlight
:
5337 infoPtr
->clrBtnHighlight
;
5338 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
5339 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
5345 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
5347 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5349 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
5350 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
5351 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
5353 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
5354 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
5355 InvalidateRect(hwnd
, NULL
, TRUE
);
5361 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
5363 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5364 INT iOldVersion
= infoPtr
->iVersion
;
5366 infoPtr
->iVersion
= iVersion
;
5368 if (infoPtr
->iVersion
>= 5)
5369 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
5376 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5378 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5379 WORD iString
= HIWORD(wParam
);
5380 WORD buffersize
= LOWORD(wParam
);
5381 LPSTR str
= (LPSTR
)lParam
;
5384 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
5386 if (iString
< infoPtr
->nNumStrings
)
5388 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
5390 TRACE("returning %s\n", debugstr_a(str
));
5393 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5400 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5402 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5403 WORD iString
= HIWORD(wParam
);
5404 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
5405 LPWSTR str
= (LPWSTR
)lParam
;
5408 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
5410 if (iString
< infoPtr
->nNumStrings
)
5412 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
5413 ret
= (len
+1)*sizeof(WCHAR
);
5414 memcpy(str
, infoPtr
->strings
[iString
], ret
);
5417 TRACE("returning %s\n", debugstr_w(str
));
5420 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
5425 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
5426 * is the maximum size of the toolbar? */
5427 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5429 SIZE
* pSize
= (SIZE
*)lParam
;
5430 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
5435 /* UNDOCUMENTED MESSAGE: This is an extended version of the
5436 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
5437 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
5440 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5442 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5443 INT nOldHotItem
= infoPtr
->nHotItem
;
5445 TRACE("old item=%d, new item=%d, flags=%08lx\n",
5446 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
5448 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
5451 /* NOTE: an application can still remove the hot item even if anchor
5452 * highlighting is enabled */
5454 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
5458 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
5461 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
5462 * which controls the amount of spacing between the image and the text
5463 * of buttons for TBSTYLE_LIST toolbars. */
5464 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5466 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5468 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
5471 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
5473 infoPtr
->iListGap
= (INT
)wParam
;
5475 InvalidateRect(hwnd
, NULL
, TRUE
);
5480 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
5481 * of image lists associated with the various states. */
5482 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5484 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5486 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5488 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
5492 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5494 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5495 LPSIZE lpsize
= (LPSIZE
)lParam
;
5501 * Testing shows the following:
5502 * wParam = 0 adjust cx value
5503 * = 1 set cy value to max size.
5504 * lParam pointer to SIZE structure
5507 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
5508 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
5512 if (lpsize
->cx
== -1) {
5513 /* **** this is wrong, native measures each button and sets it */
5514 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5516 else if(HIWORD(lpsize
->cx
)) {
5518 HWND hwndParent
= GetParent(hwnd
);
5520 GetWindowRect(hwnd
, &rc
);
5521 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
5522 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
5523 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5524 lpsize
->cx
= max(rc
.right
-rc
.left
,
5525 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
5528 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5532 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5533 /* lpsize->cy = infoPtr->nHeight; */
5536 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
5540 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
5541 lpsize
->cx
, lpsize
->cy
);
5545 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5547 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5549 InvalidateRect(hwnd
, NULL
, TRUE
);
5555 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5557 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5558 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
5561 TRACE("hwnd = %p\n", hwnd
);
5563 /* initialize info structure */
5564 infoPtr
->nButtonHeight
= 22;
5565 infoPtr
->nButtonWidth
= 24;
5566 infoPtr
->nBitmapHeight
= 15;
5567 infoPtr
->nBitmapWidth
= 16;
5569 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5570 infoPtr
->nMaxTextRows
= 1;
5571 infoPtr
->cxMin
= -1;
5572 infoPtr
->cxMax
= -1;
5573 infoPtr
->nNumBitmaps
= 0;
5574 infoPtr
->nNumStrings
= 0;
5576 infoPtr
->bCaptured
= FALSE
;
5577 infoPtr
->nButtonDown
= -1;
5578 infoPtr
->nButtonDrag
= -1;
5579 infoPtr
->nOldHit
= -1;
5580 infoPtr
->nHotItem
= -1;
5581 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5582 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5583 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
: DT_CENTER
| DT_END_ELLIPSIS
;
5584 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5585 infoPtr
->bDragOutSent
= FALSE
;
5586 infoPtr
->iVersion
= 0;
5587 infoPtr
->hwndSelf
= hwnd
;
5588 infoPtr
->bDoRedraw
= TRUE
;
5589 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5590 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5591 infoPtr
->szPadding
.cx
= DEFPAD_CX
;
5592 infoPtr
->szPadding
.cy
= DEFPAD_CY
;
5593 infoPtr
->iListGap
= DEFLISTGAP
;
5594 infoPtr
->dwStyle
= dwStyle
;
5595 infoPtr
->tbim
.iButton
= -1;
5596 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5597 infoPtr
->bUnicode
= infoPtr
->hwndNotify
&&
5598 (NFR_UNICODE
== SendMessageW(hwnd
, WM_NOTIFYFORMAT
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
));
5600 SystemParametersInfoW (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5601 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectW (&logFont
);
5603 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5604 /* Create tooltip control */
5605 infoPtr
->hwndToolTip
=
5606 CreateWindowExW (0, TOOLTIPS_CLASSW
, NULL
, 0,
5607 CW_USEDEFAULT
, CW_USEDEFAULT
,
5608 CW_USEDEFAULT
, CW_USEDEFAULT
,
5611 /* Send NM_TOOLTIPSCREATED notification */
5612 if (infoPtr
->hwndToolTip
)
5614 NMTOOLTIPSCREATED nmttc
;
5616 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5618 TOOLBAR_SendNotify (&nmttc
.hdr
, infoPtr
, NM_TOOLTIPSCREATED
);
5622 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5624 TOOLBAR_CalcToolbar(hwnd
);
5631 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5633 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5635 /* delete tooltip control */
5636 if (infoPtr
->hwndToolTip
)
5637 DestroyWindow (infoPtr
->hwndToolTip
);
5639 /* delete temporary buffer for tooltip text */
5640 Free (infoPtr
->pszTooltipText
);
5642 /* delete button data */
5643 if (infoPtr
->buttons
)
5644 Free (infoPtr
->buttons
);
5646 /* delete strings */
5647 if (infoPtr
->strings
) {
5649 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5650 if (infoPtr
->strings
[i
])
5651 Free (infoPtr
->strings
[i
]);
5653 Free (infoPtr
->strings
);
5656 /* destroy internal image list */
5657 if (infoPtr
->himlInt
)
5658 ImageList_Destroy (infoPtr
->himlInt
);
5660 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5661 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5662 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5664 /* delete default font */
5666 DeleteObject (infoPtr
->hDefaultFont
);
5668 /* free toolbar info data */
5670 SetWindowLongPtrW (hwnd
, 0, 0);
5677 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5679 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5680 NMTBCUSTOMDRAW tbcd
;
5684 /* the app has told us not to redraw the toolbar */
5685 if (!infoPtr
->bDoRedraw
)
5688 if (infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) {
5689 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5690 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5691 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5692 ntfret
= TOOLBAR_SendNotify (&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
5693 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5695 /* FIXME: in general the return flags *can* be or'ed together */
5696 switch (infoPtr
->dwBaseCustDraw
)
5698 case CDRF_DODEFAULT
:
5700 case CDRF_SKIPDEFAULT
:
5703 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5708 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5709 * to my parent for processing.
5711 if (infoPtr
->dwStyle
& TBSTYLE_TRANSPARENT
) {
5713 HDC hdc
= (HDC
)wParam
;
5718 parent
= GetParent(hwnd
);
5719 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5720 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5721 ret
= SendMessageW (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5722 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5725 ret
= DefWindowProcW (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5727 if ((infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5728 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5729 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5730 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5731 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5732 ntfret
= TOOLBAR_SendNotify (&tbcd
.nmcd
.hdr
, infoPtr
, NM_CUSTOMDRAW
);
5733 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5734 switch (infoPtr
->dwBaseCustDraw
)
5736 case CDRF_DODEFAULT
:
5738 case CDRF_SKIPDEFAULT
:
5741 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_POSTERASE)\n",
5750 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5752 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5754 return (LRESULT
)infoPtr
->hFont
;
5759 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5764 pt
.x
= (INT
)LOWORD(lParam
);
5765 pt
.y
= (INT
)HIWORD(lParam
);
5766 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5769 TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5770 else if (GetWindowLongW (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5771 TOOLBAR_Customize (hwnd
);
5778 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5780 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5781 TBUTTON_INFO
*btnPtr
;
5786 BOOL bDragKeyPressed
;
5790 if (infoPtr
->dwStyle
& TBSTYLE_ALTDRAG
)
5791 bDragKeyPressed
= (GetKeyState(VK_MENU
) < 0);
5793 bDragKeyPressed
= (wParam
& MK_SHIFT
);
5795 if (infoPtr
->hwndToolTip
)
5796 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5797 WM_LBUTTONDOWN
, wParam
, lParam
);
5799 pt
.x
= (INT
)LOWORD(lParam
);
5800 pt
.y
= (INT
)HIWORD(lParam
);
5801 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5803 btnPtr
= &infoPtr
->buttons
[nHit
];
5805 if ((nHit
>= 0) && bDragKeyPressed
&& (infoPtr
->dwStyle
& CCS_ADJUSTABLE
))
5807 infoPtr
->nButtonDrag
= nHit
;
5810 /* If drag cursor has not been loaded, load it.
5811 * Note: it doesn't need to be freed */
5813 hCursorDrag
= LoadCursorW(COMCTL32_hModule
, (LPCWSTR
)IDC_MOVEBUTTON
);
5814 SetCursor(hCursorDrag
);
5819 infoPtr
->nOldHit
= nHit
;
5821 CopyRect(&arrowRect
, &btnPtr
->rect
);
5822 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5824 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5825 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5826 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5827 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5828 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5829 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5833 /* draw in pressed state */
5834 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5835 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5837 btnPtr
->bDropDownPressed
= TRUE
;
5838 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5839 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5841 memset(&nmtb
, 0, sizeof(nmtb
));
5842 nmtb
.iItem
= btnPtr
->idCommand
;
5843 nmtb
.rcButton
= btnPtr
->rect
;
5844 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5846 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5848 if (res
!= TBDDRET_TREATPRESSED
)
5852 /* redraw button in unpressed state */
5853 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5854 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5856 btnPtr
->bDropDownPressed
= FALSE
;
5857 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5859 /* find and set hot item
5860 * NOTE: native doesn't do this, but that is a bug */
5862 ScreenToClient(hwnd
, &pt
);
5863 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5864 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5865 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5867 /* remove any left mouse button down or double-click messages
5868 * so that we can get a toggle effect on the button */
5869 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
) ||
5870 PeekMessageW(&msg
, hwnd
, WM_LBUTTONDBLCLK
, WM_LBUTTONDBLCLK
, PM_REMOVE
))
5875 /* otherwise drop through and process as pushed */
5877 infoPtr
->bCaptured
= TRUE
;
5878 infoPtr
->nButtonDown
= nHit
;
5879 infoPtr
->bDragOutSent
= FALSE
;
5881 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5883 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5885 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5886 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5893 memset(&nmtb
, 0, sizeof(nmtb
));
5894 nmtb
.iItem
= btnPtr
->idCommand
;
5895 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_BEGINDRAG
);
5898 nmmouse
.dwHitInfo
= nHit
;
5900 /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */
5902 nmmouse
.dwItemSpec
= -1;
5905 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5906 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5909 ClientToScreen(hwnd
, &pt
);
5912 if (!TOOLBAR_SendNotify(&nmmouse
.hdr
, infoPtr
, NM_LDOWN
))
5913 return DefWindowProcW(hwnd
, WM_LBUTTONDOWN
, wParam
, lParam
);
5919 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5921 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5922 TBUTTON_INFO
*btnPtr
;
5926 BOOL bSendMessage
= TRUE
;
5931 if (infoPtr
->hwndToolTip
)
5932 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5933 WM_LBUTTONUP
, wParam
, lParam
);
5935 pt
.x
= (INT
)LOWORD(lParam
);
5936 pt
.y
= (INT
)HIWORD(lParam
);
5937 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5939 if (!infoPtr
->bAnchor
|| (nHit
>= 0))
5940 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5942 if (infoPtr
->nButtonDrag
>= 0) {
5946 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDrag
];
5949 SetCursor(LoadCursorW(NULL
, (LPCWSTR
)IDC_ARROW
));
5951 GetClientRect(hwnd
, &rcClient
);
5952 if (PtInRect(&rcClient
, pt
))
5959 else if ((nHit
== -1) && PtInRect(&infoPtr
->buttons
[-nHit
].rect
, pt
))
5962 if (nButton
== infoPtr
->nButtonDrag
)
5964 /* if the button is moved sightly left and we have a
5965 * separator there then remove it */
5966 if (pt
.x
< (btnPtr
->rect
.left
+ (btnPtr
->rect
.right
- btnPtr
->rect
.left
)/2))
5968 if ((nButton
> 0) && (infoPtr
->buttons
[nButton
-1].fsStyle
& BTNS_SEP
))
5969 TOOLBAR_DeleteButton(hwnd
, nButton
- 1, 0);
5971 else /* else insert a separator before the dragged button */
5974 memset(&tbb
, 0, sizeof(tbb
));
5975 tbb
.fsStyle
= BTNS_SEP
;
5977 TOOLBAR_InsertButtonW(hwnd
, nButton
, (LPARAM
)&tbb
);
5984 if ((infoPtr
->nNumButtons
> 0) && (pt
.x
< infoPtr
->buttons
[0].rect
.left
))
5985 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, 0);
5987 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, infoPtr
->nNumButtons
);
5990 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, nButton
);
5995 TRACE("button %d dragged out of toolbar\n", infoPtr
->nButtonDrag
);
5996 TOOLBAR_DeleteButton(hwnd
, (WPARAM
)infoPtr
->nButtonDrag
, 0);
5999 /* button under cursor changed so need to re-set hot item */
6000 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
6001 infoPtr
->nButtonDrag
= -1;
6003 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
6005 else if (infoPtr
->nButtonDown
>= 0) {
6006 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6007 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6009 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
6010 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
6011 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
6013 if (nOldIndex
== nHit
)
6014 bSendMessage
= FALSE
;
6015 if ((nOldIndex
!= nHit
) &&
6017 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
6018 btnPtr
->fsState
|= TBSTATE_CHECKED
;
6021 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
6022 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
6024 btnPtr
->fsState
|= TBSTATE_CHECKED
;
6028 if (nOldIndex
!= -1)
6029 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
6032 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
6033 * that resets bCaptured and btn TBSTATE_PRESSED flags,
6034 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
6036 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
6038 infoPtr
->nButtonDown
= -1;
6040 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
6041 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
6042 NM_RELEASEDCAPTURE
);
6044 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
6047 memset(&nmtb
, 0, sizeof(nmtb
));
6048 nmtb
.iItem
= btnPtr
->idCommand
;
6049 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
6052 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
6054 SendMessageW (infoPtr
->hwndNotify
, WM_COMMAND
,
6055 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
6059 /* !!! Undocumented - toolbar at 4.71 level and above sends
6060 * NM_CLICK with the NMMOUSE structure. */
6061 nmmouse
.dwHitInfo
= nHit
;
6063 if (nmmouse
.dwHitInfo
< 0)
6064 nmmouse
.dwItemSpec
= -1;
6067 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
6068 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
6071 ClientToScreen(hwnd
, &pt
);
6074 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_CLICK
))
6075 return DefWindowProcW(hwnd
, WM_LBUTTONUP
, wParam
, lParam
);
6081 TOOLBAR_RButtonUp( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6083 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6088 pt
.x
= LOWORD(lParam
);
6089 pt
.y
= HIWORD(lParam
);
6091 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
6092 nmmouse
.dwHitInfo
= nHit
;
6095 nmmouse
.dwItemSpec
= -1;
6097 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
6098 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
6101 ClientToScreen(hwnd
, &pt
);
6104 if (!TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_RCLICK
))
6105 return DefWindowProcW(hwnd
, WM_RBUTTONUP
, wParam
, lParam
);
6111 TOOLBAR_RButtonDblClk( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6113 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6116 if (!TOOLBAR_SendNotify(&nmhdr
, infoPtr
, NM_RDBLCLK
))
6117 return DefWindowProcW(hwnd
, WM_RBUTTONDBLCLK
, wParam
, lParam
);
6123 TOOLBAR_CaptureChanged(HWND hwnd
)
6125 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6126 TBUTTON_INFO
*btnPtr
;
6128 infoPtr
->bCaptured
= FALSE
;
6130 if (infoPtr
->nButtonDown
>= 0)
6132 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6133 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6135 infoPtr
->nOldHit
= -1;
6137 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
6138 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6144 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6146 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6147 TBUTTON_INFO
*hotBtnPtr
;
6149 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
6151 /* don't remove hot effects when in anchor highlighting mode or when a
6152 * drop-down button is pressed */
6153 if (!infoPtr
->bAnchor
&& (infoPtr
->nOldHit
< 0 || !hotBtnPtr
->bDropDownPressed
))
6154 TOOLBAR_SetHotItemEx(infoPtr
, TOOLBAR_NOWHERE
, HICF_MOUSE
);
6156 if (infoPtr
->nOldHit
< 0)
6159 /* If the last button we were over is depressed then make it not */
6160 /* depressed and redraw it */
6161 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
6163 TBUTTON_INFO
*btnPtr
;
6166 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6168 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6170 rc1
= hotBtnPtr
->rect
;
6171 InflateRect (&rc1
, 1, 1);
6172 InvalidateRect (hwnd
, &rc1
, TRUE
);
6175 if (infoPtr
->bCaptured
&& !infoPtr
->bDragOutSent
)
6178 ZeroMemory(&nmt
, sizeof(nmt
));
6179 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6180 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6181 infoPtr
->bDragOutSent
= TRUE
;
6184 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
6190 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6192 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6194 TRACKMOUSEEVENT trackinfo
;
6196 TBUTTON_INFO
*btnPtr
;
6198 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
) {
6199 /* fill in the TRACKMOUSEEVENT struct */
6200 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
6201 trackinfo
.dwFlags
= TME_QUERY
;
6202 trackinfo
.hwndTrack
= hwnd
;
6203 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
6205 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
6206 _TrackMouseEvent(&trackinfo
);
6208 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
6209 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
6210 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
6212 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
6213 /* and can properly deactivate the hot toolbar button */
6214 _TrackMouseEvent(&trackinfo
);
6218 if (infoPtr
->hwndToolTip
)
6219 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
6220 WM_MOUSEMOVE
, wParam
, lParam
);
6222 pt
.x
= (INT
)LOWORD(lParam
);
6223 pt
.y
= (INT
)HIWORD(lParam
);
6225 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
6227 if ((infoPtr
->dwStyle
& TBSTYLE_FLAT
) && (!infoPtr
->bAnchor
|| (nHit
>= 0)))
6228 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
6230 if (infoPtr
->nOldHit
!= nHit
)
6232 if (infoPtr
->bCaptured
)
6234 if (!infoPtr
->bDragOutSent
)
6237 ZeroMemory(&nmt
, sizeof(nmt
));
6238 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
6239 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
6240 infoPtr
->bDragOutSent
= TRUE
;
6243 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
6244 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
6245 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
6246 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6248 else if (nHit
== infoPtr
->nButtonDown
) {
6249 btnPtr
->fsState
|= TBSTATE_PRESSED
;
6250 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6252 infoPtr
->nOldHit
= nHit
;
6260 inline static LRESULT
6261 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6263 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
6264 return DefWindowProcW (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
6266 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
6270 inline static LRESULT
6271 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6273 if (!(GetWindowLongW(hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
6274 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
6276 return DefWindowProcW (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
6281 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6283 TOOLBAR_INFO
*infoPtr
;
6284 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
6287 /* allocate memory for info structure */
6288 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
6289 SetWindowLongPtrW (hwnd
, 0, (LONG_PTR
)infoPtr
);
6292 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
6295 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
6296 if (!GetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
)) {
6297 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW (GetParent (hwnd
), GWLP_HINSTANCE
);
6298 SetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
, (LONG_PTR
)hInst
);
6301 /* native control does:
6302 * Get a lot of colors and brushes
6304 * SystemParametersInfoW(0x1f, 0x3c, adr1, 0)
6305 * CreateFontIndirectW(adr1)
6306 * CreateBitmap(0x27, 0x24, 1, 1, 0)
6307 * hdc = GetDC(toolbar)
6308 * GetSystemMetrics(0x48)
6309 * fnt2=CreateFontW(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
6310 * 0, 0, 0, 0, "MARLETT")
6311 * oldfnt = SelectObject(hdc, fnt2)
6312 * GetCharWidthW(hdc, 0x36, 0x36, adr2)
6313 * GetTextMetricsW(hdc, adr3)
6314 * SelectObject(hdc, oldfnt)
6315 * DeleteObject(fnt2)
6317 * InvalidateRect(toolbar, 0, 1)
6318 * SetWindowLongW(toolbar, 0, addr)
6319 * SetWindowLongW(toolbar, -16, xxx) **sometimes**
6322 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
6323 * ie 2 0x4600094c 0x4600094c 0x4600894d
6324 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
6325 * rebar 0x50008844 0x40008844 0x50008845
6326 * pager 0x50000844 0x40000844 0x50008845
6327 * IC35mgr 0x5400084e **nochange**
6328 * on entry to _NCCREATE 0x5400084e
6329 * rowlist 0x5400004e **nochange**
6330 * on entry to _NCCREATE 0x5400004e
6334 /* I think the code below is a bug, but it is the way that the native
6335 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
6336 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
6337 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
6338 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
6339 * Somehow, the only cases of this seem to be MFC programs.
6341 * Note also that the addition of _TRANSPARENT occurs *only* here. It
6342 * does not occur in the WM_STYLECHANGING routine.
6343 * (Guy Albertelli 9/2001)
6346 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
6347 styleadd
|= TBSTYLE_TRANSPARENT
;
6348 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
6349 styleadd
|= CCS_TOP
; /* default to top */
6350 SetWindowLongW (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
6353 return DefWindowProcW (hwnd
, WM_NCCREATE
, wParam
, lParam
);
6358 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6360 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
6364 if (dwStyle
& WS_MINIMIZE
)
6365 return 0; /* Nothing to do */
6367 DefWindowProcW (hwnd
, WM_NCPAINT
, wParam
, lParam
);
6369 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
6372 if (!(dwStyle
& CCS_NODIVIDER
))
6374 GetWindowRect (hwnd
, &rcWindow
);
6375 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
6376 if( dwStyle
& WS_BORDER
)
6377 OffsetRect (&rcWindow
, 1, 1);
6378 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
6381 ReleaseDC( hwnd
, hdc
);
6387 /* handles requests from the tooltip control on what text to display */
6388 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
6390 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
6392 TRACE("button index = %d\n", index
);
6394 Free (infoPtr
->pszTooltipText
);
6395 infoPtr
->pszTooltipText
= NULL
;
6400 if (infoPtr
->bUnicode
)
6402 WCHAR wszBuffer
[INFOTIPSIZE
+1];
6403 NMTBGETINFOTIPW tbgit
;
6404 unsigned int len
; /* in chars */
6406 wszBuffer
[0] = '\0';
6407 wszBuffer
[INFOTIPSIZE
] = '\0';
6409 tbgit
.pszText
= wszBuffer
;
6410 tbgit
.cchTextMax
= INFOTIPSIZE
;
6411 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6412 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6414 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
6416 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
6418 len
= strlenW(tbgit
.pszText
);
6419 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6421 /* need to allocate temporary buffer in infoPtr as there
6422 * isn't enough space in buffer passed to us by the
6423 * tooltip control */
6424 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6425 if (infoPtr
->pszTooltipText
)
6427 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6428 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6434 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
6440 CHAR szBuffer
[INFOTIPSIZE
+1];
6441 NMTBGETINFOTIPA tbgit
;
6442 unsigned int len
; /* in chars */
6445 szBuffer
[INFOTIPSIZE
] = '\0';
6447 tbgit
.pszText
= szBuffer
;
6448 tbgit
.cchTextMax
= INFOTIPSIZE
;
6449 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
6450 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
6452 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
6454 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
6456 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
6457 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6459 /* need to allocate temporary buffer in infoPtr as there
6460 * isn't enough space in buffer passed to us by the
6461 * tooltip control */
6462 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6463 if (infoPtr
->pszTooltipText
)
6465 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
6466 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6472 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
6477 /* if button has text, but it is not shown then automatically
6478 * use that text as tooltip */
6479 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
6480 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
6482 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
6483 unsigned int len
= pszText
? strlenW(pszText
) : 0;
6485 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
6487 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6489 /* need to allocate temporary buffer in infoPtr as there
6490 * isn't enough space in buffer passed to us by the
6491 * tooltip control */
6492 infoPtr
->pszTooltipText
= Alloc((len
+1)*sizeof(WCHAR
));
6493 if (infoPtr
->pszTooltipText
)
6495 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
6496 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6502 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
6507 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
6509 /* last resort: send notification on to app */
6510 /* FIXME: find out what is really used here */
6511 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
6515 inline static LRESULT
6516 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6518 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6519 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
6521 switch (lpnmh
->code
)
6525 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
6527 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
6528 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
6529 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
6533 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
6534 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
6542 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
6544 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
6545 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
6546 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
6547 lppgs
->iScroll
, lppgs
->iDir
);
6551 case TTN_GETDISPINFOW
:
6552 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
6554 case TTN_GETDISPINFOA
:
6555 FIXME("TTN_GETDISPINFOA - should not be received; please report\n");
6565 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
6569 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
6571 if (lParam
== NF_QUERY
)
6574 if (lParam
== NF_REQUERY
) {
6575 format
= SendMessageW(infoPtr
->hwndNotify
,
6576 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
6577 if ((format
!= NFR_ANSI
) && (format
!= NFR_UNICODE
)) {
6578 ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n",
6589 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
6591 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6595 /* fill ps.rcPaint with a default rect */
6596 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
6598 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
6600 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
6601 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
6602 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
6604 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
6605 if (!wParam
) EndPaint (hwnd
, &ps
);
6612 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6613 /*****************************************************
6616 * Handles the WM_SETREDRAW message.
6619 * According to testing V4.71 of COMCTL32 returns the
6620 * *previous* status of the redraw flag (either 0 or 1)
6621 * instead of the MSDN documented value of 0 if handled.
6622 * (For laughs see the "consistency" with same function
6625 *****************************************************/
6627 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6628 BOOL oldredraw
= infoPtr
->bDoRedraw
;
6630 TRACE("set to %s\n",
6631 (wParam
) ? "TRUE" : "FALSE");
6632 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
6634 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
6636 return (oldredraw
) ? 1 : 0;
6641 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6643 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6644 DWORD dwStyle
= infoPtr
->dwStyle
;
6653 /* Resize deadlock check */
6654 if (infoPtr
->bAutoSize
) {
6655 infoPtr
->bAutoSize
= FALSE
;
6659 /* FIXME: optimize to only update size if the new size doesn't */
6660 /* match the current size */
6662 flags
= (INT
) wParam
;
6664 /* FIXME for flags =
6665 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
6668 TRACE("sizing toolbar!\n");
6670 if (flags
== SIZE_RESTORED
) {
6671 /* width and height don't apply */
6672 parent
= GetParent (hwnd
);
6673 GetClientRect(parent
, &parent_rect
);
6674 x
= parent_rect
.left
;
6675 y
= parent_rect
.top
;
6677 if (dwStyle
& CCS_NORESIZE
) {
6678 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
6681 * this sets the working width of the toolbar, and
6682 * Calc Toolbar will not adjust it, only the height
6684 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6685 cy
= infoPtr
->nHeight
;
6686 cx
= infoPtr
->nWidth
;
6687 TOOLBAR_CalcToolbar (hwnd
);
6688 infoPtr
->nWidth
= cx
;
6689 infoPtr
->nHeight
= cy
;
6692 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6693 TOOLBAR_CalcToolbar (hwnd
);
6694 cy
= infoPtr
->nHeight
;
6695 cx
= infoPtr
->nWidth
;
6697 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
6698 GetWindowRect(hwnd
, &window_rect
);
6699 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
6700 y
= window_rect
.top
;
6702 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6703 GetWindowRect(hwnd
, &window_rect
);
6704 y
= parent_rect
.bottom
-
6705 ( window_rect
.bottom
- window_rect
.top
);
6709 if (dwStyle
& CCS_NOPARENTALIGN
) {
6710 uPosFlags
|= SWP_NOMOVE
;
6711 cy
= infoPtr
->nHeight
;
6712 cx
= infoPtr
->nWidth
;
6715 if (!(dwStyle
& CCS_NODIVIDER
))
6716 cy
+= GetSystemMetrics(SM_CYEDGE
);
6718 if (dwStyle
& WS_BORDER
)
6721 cy
+= GetSystemMetrics(SM_CYEDGE
);
6722 cx
+= GetSystemMetrics(SM_CXEDGE
);
6725 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6727 RECT delta_width
, delta_height
, client
, dummy
;
6728 DWORD min_x
, max_x
, min_y
, max_y
;
6729 TBUTTON_INFO
*btnPtr
;
6732 GetClientRect(hwnd
, &client
);
6733 if(client
.right
> infoPtr
->client_rect
.right
)
6735 min_x
= infoPtr
->client_rect
.right
;
6736 max_x
= client
.right
;
6740 max_x
= infoPtr
->client_rect
.right
;
6741 min_x
= client
.right
;
6743 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6745 min_y
= infoPtr
->client_rect
.bottom
;
6746 max_y
= client
.bottom
;
6750 max_y
= infoPtr
->client_rect
.bottom
;
6751 min_y
= client
.bottom
;
6754 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6755 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6757 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6758 btnPtr
= infoPtr
->buttons
;
6759 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6760 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6761 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6762 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6765 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) != (SWP_NOSIZE
| SWP_NOMOVE
))
6766 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6768 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6774 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6776 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6778 if (nType
== GWL_STYLE
)
6780 if (lpStyle
->styleNew
& TBSTYLE_LIST
)
6781 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
;
6783 infoPtr
->dwDTFlags
= DT_CENTER
| DT_END_ELLIPSIS
;
6785 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6786 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6787 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6789 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6791 infoPtr
->dwStyle
= lpStyle
->styleNew
;
6793 /* only resize if one of the CCS_* styles was changed */
6794 if ((infoPtr
->dwStyle
^ lpStyle
->styleNew
) & COMMON_STYLES
)
6796 TOOLBAR_AutoSize (hwnd
);
6798 InvalidateRect(hwnd
, NULL
, TRUE
);
6807 TOOLBAR_SysColorChange (HWND hwnd
)
6809 COMCTL32_RefreshSysColors();
6816 static LRESULT WINAPI
6817 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6819 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6821 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6822 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6824 if (!infoPtr
&& (uMsg
!= WM_NCCREATE
))
6825 return DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
6830 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6832 case TB_ADDBUTTONSA
:
6833 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6835 case TB_ADDBUTTONSW
:
6836 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6839 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6842 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6845 return TOOLBAR_AutoSize (hwnd
);
6847 case TB_BUTTONCOUNT
:
6848 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6850 case TB_BUTTONSTRUCTSIZE
:
6851 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6853 case TB_CHANGEBITMAP
:
6854 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6856 case TB_CHECKBUTTON
:
6857 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6859 case TB_COMMANDTOINDEX
:
6860 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6863 return TOOLBAR_Customize (hwnd
);
6865 case TB_DELETEBUTTON
:
6866 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6868 case TB_ENABLEBUTTON
:
6869 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6871 case TB_GETANCHORHIGHLIGHT
:
6872 return TOOLBAR_GetAnchorHighlight (hwnd
);
6875 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6877 case TB_GETBITMAPFLAGS
:
6878 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6881 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6883 case TB_GETBUTTONINFOA
:
6884 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6886 case TB_GETBUTTONINFOW
:
6887 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6889 case TB_GETBUTTONSIZE
:
6890 return TOOLBAR_GetButtonSize (hwnd
);
6892 case TB_GETBUTTONTEXTA
:
6893 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6895 case TB_GETBUTTONTEXTW
:
6896 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6898 case TB_GETDISABLEDIMAGELIST
:
6899 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6901 case TB_GETEXTENDEDSTYLE
:
6902 return TOOLBAR_GetExtendedStyle (hwnd
);
6904 case TB_GETHOTIMAGELIST
:
6905 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6908 return TOOLBAR_GetHotItem (hwnd
);
6910 case TB_GETIMAGELIST
:
6911 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6913 case TB_GETINSERTMARK
:
6914 return TOOLBAR_GetInsertMark (hwnd
, wParam
, lParam
);
6916 case TB_GETINSERTMARKCOLOR
:
6917 return TOOLBAR_GetInsertMarkColor (hwnd
, wParam
, lParam
);
6919 case TB_GETITEMRECT
:
6920 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6923 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6925 /* case TB_GETOBJECT: */ /* 4.71 */
6928 return TOOLBAR_GetPadding (hwnd
);
6931 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6934 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6937 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6940 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6943 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6946 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6948 case TB_GETTEXTROWS
:
6949 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6951 case TB_GETTOOLTIPS
:
6952 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6954 case TB_GETUNICODEFORMAT
:
6955 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6958 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6961 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6963 case TB_INDETERMINATE
:
6964 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6966 case TB_INSERTBUTTONA
:
6967 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6969 case TB_INSERTBUTTONW
:
6970 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6972 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6974 case TB_ISBUTTONCHECKED
:
6975 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6977 case TB_ISBUTTONENABLED
:
6978 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6980 case TB_ISBUTTONHIDDEN
:
6981 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
6983 case TB_ISBUTTONHIGHLIGHTED
:
6984 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
6986 case TB_ISBUTTONINDETERMINATE
:
6987 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
6989 case TB_ISBUTTONPRESSED
:
6990 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
6993 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
6995 case TB_MAPACCELERATORA
:
6996 case TB_MAPACCELERATORW
:
6997 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
7000 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
7003 return TOOLBAR_MoveButton (hwnd
, wParam
, lParam
);
7005 case TB_PRESSBUTTON
:
7006 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
7008 case TB_REPLACEBITMAP
:
7009 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
7011 case TB_SAVERESTOREA
:
7012 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, (LPTBSAVEPARAMSA
)lParam
);
7014 case TB_SAVERESTOREW
:
7015 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, (LPTBSAVEPARAMSW
)lParam
);
7017 case TB_SETANCHORHIGHLIGHT
:
7018 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
7020 case TB_SETBITMAPSIZE
:
7021 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
7023 case TB_SETBUTTONINFOA
:
7024 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
7026 case TB_SETBUTTONINFOW
:
7027 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
7029 case TB_SETBUTTONSIZE
:
7030 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
7032 case TB_SETBUTTONWIDTH
:
7033 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
7036 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
7038 case TB_SETDISABLEDIMAGELIST
:
7039 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
7041 case TB_SETDRAWTEXTFLAGS
:
7042 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
7044 case TB_SETEXTENDEDSTYLE
:
7045 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
7047 case TB_SETHOTIMAGELIST
:
7048 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
7051 return TOOLBAR_SetHotItem (hwnd
, wParam
);
7053 case TB_SETIMAGELIST
:
7054 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
7057 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
7059 case TB_SETINSERTMARK
:
7060 return TOOLBAR_SetInsertMark (hwnd
, wParam
, lParam
);
7062 case TB_SETINSERTMARKCOLOR
:
7063 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
7065 case TB_SETMAXTEXTROWS
:
7066 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
7069 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
7072 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
7075 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
7078 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
7081 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
7083 case TB_SETTOOLTIPS
:
7084 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
7086 case TB_SETUNICODEFORMAT
:
7087 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
7090 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
7093 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
7096 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
7099 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
7102 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
7105 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
7107 /* Common Control Messages */
7109 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
7110 case CCM_GETCOLORSCHEME
:
7111 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7113 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
7114 case CCM_SETCOLORSCHEME
:
7115 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
7117 case CCM_GETVERSION
:
7118 return TOOLBAR_GetVersion (hwnd
);
7120 case CCM_SETVERSION
:
7121 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
7127 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
7130 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
7133 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
7136 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
7138 /* case WM_KEYDOWN: */
7139 /* case WM_KILLFOCUS: */
7141 case WM_LBUTTONDBLCLK
:
7142 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
7144 case WM_LBUTTONDOWN
:
7145 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
7148 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
7151 return TOOLBAR_RButtonUp (hwnd
, wParam
, lParam
);
7153 case WM_RBUTTONDBLCLK
:
7154 return TOOLBAR_RButtonDblClk (hwnd
, wParam
, lParam
);
7157 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
7160 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
7162 case WM_CAPTURECHANGED
:
7163 return TOOLBAR_CaptureChanged(hwnd
);
7166 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
7169 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
7172 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
7175 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
7178 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
7180 case WM_NOTIFYFORMAT
:
7181 return TOOLBAR_NotifyFormat (infoPtr
, wParam
, lParam
);
7184 return TOOLBAR_Paint (hwnd
, wParam
);
7187 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
7190 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
7192 case WM_STYLECHANGED
:
7193 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
7195 case WM_SYSCOLORCHANGE
:
7196 return TOOLBAR_SysColorChange (hwnd
);
7198 /* case WM_WININICHANGE: */
7203 case WM_MEASUREITEM
:
7205 return SendMessageW (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
7207 /* We see this in Outlook Express 5.x and just does DefWindowProc */
7208 case PGM_FORWARDMOUSE
:
7209 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7212 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
7213 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
7214 uMsg
, wParam
, lParam
);
7215 return DefWindowProcW (hwnd
, uMsg
, wParam
, lParam
);
7221 TOOLBAR_Register (void)
7225 ZeroMemory (&wndClass
, sizeof(WNDCLASSW
));
7226 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
7227 wndClass
.lpfnWndProc
= ToolbarWindowProc
;
7228 wndClass
.cbClsExtra
= 0;
7229 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
7230 wndClass
.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
7231 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_BTNFACE
+ 1);
7232 wndClass
.lpszClassName
= TOOLBARCLASSNAMEW
;
7234 RegisterClassW (&wndClass
);
7239 TOOLBAR_Unregister (void)
7241 UnregisterClassW (TOOLBARCLASSNAMEW
, NULL
);
7244 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
7249 /* Check if the entry already exists */
7250 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
7252 /* If this is a new entry we must create it and insert into the array */
7257 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
7260 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
7261 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
7276 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
7280 for (i
= 0; i
< *cies
; i
++)
7290 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
7298 for (i
= 0; i
< cies
; i
++)
7300 if (pies
[i
]->id
== id
)
7312 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
7314 HIMAGELIST himlDef
= 0;
7315 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
7318 himlDef
= pie
->himl
;
7324 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
7326 if (infoPtr
->bUnicode
)
7327 return TOOLBAR_SendNotify(&nmtb
->hdr
, infoPtr
, TBN_GETBUTTONINFOW
);
7334 nmtba
.iItem
= nmtb
->iItem
;
7335 nmtba
.pszText
= Buffer
;
7336 nmtba
.cchText
= 256;
7337 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
7339 if (TOOLBAR_SendNotify(&nmtba
.hdr
, infoPtr
, TBN_GETBUTTONINFOA
))
7341 int ccht
= strlen(nmtba
.pszText
);
7343 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
7344 nmtb
->pszText
, nmtb
->cchText
);
7346 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
7355 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
7356 int iItem
, PCUSTOMBUTTON btnInfo
)
7360 /* MSDN states that iItem is the index of the button, rather than the
7361 * command ID as used by every other NMTOOLBAR notification */
7363 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
7365 return TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_QUERYDELETE
);