4 * Copyright 1998,1999 Eric Kohl
5 * Copyright 2000 Eric Kohl for CodeWeavers
6 * Copyright 2004 Robert Shearman
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Differences between MSDN and actual native control operation:
25 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
26 * to the right of the bitmap. Otherwise, this style is
27 * identical to TBSTYLE_FLAT."
28 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
29 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
30 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
31 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
33 * This code was audited for completeness against the documented features
34 * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman.
36 * Unless otherwise noted, we believe this code to be complete, as per
37 * the specification mentioned above.
38 * If you discover missing features or bugs please note them below.
42 * - TBSTYLE_REGISTERDROP
43 * - TBSTYLE_EX_DOUBLEBUFFER
46 * - TB_GETINSERTMARKCOLOR
49 * - TB_INSERTMARKHITTEST
61 * - Button wrapping (under construction).
63 * - iListGap custom draw support.
64 * - Customization dialog:
65 * - Minor buglet in 'available buttons' list:
66 * Buttons are not listed in MS-like order. MS seems to use a single
67 * internal list to store the button information of both listboxes.
68 * - Drag list support.
71 * - Run tests using Waite Group Windows95 API Bible Volume 2.
72 * The second cdrom contains executables addstr.exe, btncount.exe,
73 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
74 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
75 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
76 * setparnt.exe, setrows.exe, toolwnd.exe.
77 * - Microsofts controlspy examples.
78 * - Charles Petzold's 'Programming Windows': gadgets.exe
88 #include "wine/unicode.h"
92 #include "wine/debug.h"
94 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
96 static HCURSOR hCursorDrag
= NULL
;
109 INT cx
; /* manually set size */
123 } IMLENTRY
, *PIMLENTRY
;
127 DWORD dwStructSize
; /* size of TBBUTTON struct */
128 INT nHeight
; /* height of the toolbar */
129 INT nWidth
; /* width of the toolbar */
136 INT nRows
; /* number of button rows */
137 INT nMaxTextRows
; /* maximum number of text rows */
138 INT cxMin
; /* minimum button width */
139 INT cxMax
; /* maximum button width */
140 INT nNumButtons
; /* number of buttons */
141 INT nNumBitmaps
; /* number of bitmaps */
142 INT nNumStrings
; /* number of strings */
144 BOOL bUnicode
; /* ASCII (FALSE) or Unicode (TRUE)? */
145 BOOL bCaptured
; /* mouse captured? */
146 INT nButtonDown
; /* toolbar button being pressed or -1 if none */
147 INT nButtonDrag
; /* toolbar button being dragged or -1 if none */
149 INT nHotItem
; /* index of the "hot" item */
150 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
151 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
152 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
153 SIZE szPadding
; /* padding values around button */
154 INT iListGap
; /* default gap between text and image for toolbar with list style */
156 HFONT hFont
; /* text font */
157 HIMAGELIST himlInt
; /* image list created internally */
158 PIMLENTRY
*himlDef
; /* default image list array */
159 INT cimlDef
; /* default image list array count */
160 PIMLENTRY
*himlHot
; /* hot image list array */
161 INT cimlHot
; /* hot image list array count */
162 PIMLENTRY
*himlDis
; /* disabled image list array */
163 INT cimlDis
; /* disabled image list array count */
164 HWND hwndToolTip
; /* handle to tool tip control */
165 HWND hwndNotify
; /* handle to the window that gets notifications */
166 HWND hwndSelf
; /* my own handle */
167 BOOL bTransparent
; /* background transparency flag */
168 BOOL bBtnTranspnt
; /* button transparency flag */
169 BOOL bAutoSize
; /* auto size deadlock indicator */
170 BOOL bAnchor
; /* anchor highlight enabled */
171 BOOL bNtfUnicode
; /* TRUE if NOTIFYs use {W} */
172 BOOL bDoRedraw
; /* Redraw status */
173 DWORD dwStyle
; /* regular toolbar style */
174 DWORD dwExStyle
; /* extended toolbar style */
175 DWORD dwDTFlags
; /* DrawText flags */
177 COLORREF clrInsertMark
; /* insert mark color */
178 COLORREF clrBtnHighlight
; /* color for Flat Separator */
179 COLORREF clrBtnShadow
; /* color for Flag Separator */
180 RECT rcBound
; /* bounding rectangle */
182 LPWSTR pszTooltipText
; /* temporary store for a string > 80 characters
183 * for TTN_GETDISPINFOW notification */
184 TBUTTON_INFO
*buttons
; /* pointer to button array */
185 LPWSTR
*strings
; /* pointer to string array */
186 TBITMAP_INFO
*bitmaps
;
187 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
190 /* used by customization dialog */
193 PTOOLBAR_INFO tbInfo
;
195 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
203 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
212 #define SEPARATOR_WIDTH 8
214 #define BOTTOM_BORDER 2
215 #define DDARROW_WIDTH 11
216 #define ARROW_HEIGHT 3
218 /* gap between border of button and text/image */
221 /* how wide to treat the bitmap if it isn't present */
222 #define LIST_IMAGE_ABSENT_WIDTH 2
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 static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO
*infoPtr
, INT iListGap
)
230 return GetSystemMetrics(SM_CXEDGE
) + iListGap
- infoPtr
->szPadding
.cx
/2;
233 /* Used to find undocumented extended styles */
234 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
235 TBSTYLE_EX_UNDOC1 | \
236 TBSTYLE_EX_MIXEDBUTTONS | \
237 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
239 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
240 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
241 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
242 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
243 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
245 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
246 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
247 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
248 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
249 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
250 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
251 static LRESULT
TOOLBAR_LButtonDown(HWND hwnd
, WPARAM wParam
, LPARAM lParam
);
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
->bNtfUnicode
) ? "via Unicode" : "via ANSI");
338 if (infoPtr
->bNtfUnicode
)
339 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
340 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
342 return SendMessageA (infoPtr
->hwndNotify
, WM_NOTIFY
,
343 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
346 /***********************************************************************
347 * TOOLBAR_GetBitmapIndex
349 * This function returns the bitmap index associated with a button.
350 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
351 * is issued to retrieve the index.
354 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
356 INT ret
= btnPtr
->iBitmap
;
358 if (ret
== I_IMAGECALLBACK
) {
359 /* issue TBN_GETDISPINFO */
362 nmgd
.idCommand
= btnPtr
->idCommand
;
363 nmgd
.lParam
= btnPtr
->dwData
;
364 nmgd
.dwMask
= TBNF_IMAGE
;
365 TOOLBAR_SendNotify ((NMHDR
*) &nmgd
, infoPtr
,
366 (infoPtr
->bNtfUnicode
) ? TBN_GETDISPINFOW
:
368 if (nmgd
.dwMask
& TBNF_DI_SETITEM
) {
369 btnPtr
->iBitmap
= nmgd
.iImage
;
372 TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
373 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
376 if (ret
!= I_IMAGENONE
)
377 ret
= GETIBITMAP(infoPtr
, ret
);
384 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
387 INT id
= GETHIMLID(infoPtr
, index
);
388 INT iBitmap
= GETIBITMAP(infoPtr
, index
);
390 if (((himl
= GETDEFIMAGELIST(infoPtr
, id
)) &&
391 iBitmap
>= 0 && iBitmap
< ImageList_GetImageCount(himl
)) ||
392 (index
== I_IMAGECALLBACK
))
399 /***********************************************************************
400 * TOOLBAR_GetImageListForDrawing
402 * This function validates the bitmap index (including I_IMAGECALLBACK
403 * functionality) and returns the corresponding image list.
406 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
410 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
411 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
412 ERR("index %d,%d is not valid, max %d\n",
413 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
417 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
418 if ((*index
== I_IMAGECALLBACK
) ||
419 (*index
== I_IMAGENONE
)) return NULL
;
420 ERR("TBN_GETDISPINFO returned invalid index %d\n",
427 case IMAGE_LIST_DEFAULT
:
428 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
431 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
433 case IMAGE_LIST_DISABLED
:
434 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
438 FIXME("Shouldn't reach here\n");
442 TRACE("no image list\n");
448 /***********************************************************************
449 * TOOLBAR_TestImageExist
451 * This function is similar to TOOLBAR_GetImageListForDrawing, except it does not
452 * return the image list. The I_IMAGECALLBACK functionality is implemented.
455 TOOLBAR_TestImageExist (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
)
459 if (!himl
) return FALSE
;
461 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
462 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
463 ERR("index %d is not valid, max %d\n",
464 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
468 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
469 if ((index
== I_IMAGECALLBACK
) ||
470 (index
== I_IMAGENONE
)) return FALSE
;
471 ERR("TBN_GETDISPINFO returned invalid index %d\n",
480 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
483 COLORREF oldcolor
, newcolor
;
485 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
486 myrect
.right
= myrect
.left
+ 1;
487 myrect
.top
= lpRect
->top
+ 2;
488 myrect
.bottom
= lpRect
->bottom
- 2;
490 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
491 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
492 oldcolor
= SetBkColor (hdc
, newcolor
);
493 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
495 myrect
.left
= myrect
.right
;
496 myrect
.right
= myrect
.left
+ 1;
498 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
499 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
500 SetBkColor (hdc
, newcolor
);
501 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
503 SetBkColor (hdc
, oldcolor
);
507 /***********************************************************************
508 * TOOLBAR_DrawDDFlatSeparator
510 * This function draws the separator that was flagged as BTNS_DROPDOWN.
511 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
512 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
513 * are horizontal as opposed to the vertical separators for not dropdown
516 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
519 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
522 COLORREF oldcolor
, newcolor
;
524 myrect
.left
= lpRect
->left
;
525 myrect
.right
= lpRect
->right
;
526 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
527 myrect
.bottom
= myrect
.top
+ 1;
529 InflateRect (&myrect
, -2, 0);
531 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
532 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
534 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
535 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
536 oldcolor
= SetBkColor (hdc
, newcolor
);
537 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
539 myrect
.top
= myrect
.bottom
;
540 myrect
.bottom
= myrect
.top
+ 1;
542 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
543 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
544 SetBkColor (hdc
, newcolor
);
545 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
547 SetBkColor (hdc
, oldcolor
);
552 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
557 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
558 hOldPen
= SelectObject ( hdc
, hPen
);
561 MoveToEx (hdc
, x
, y
, NULL
);
562 LineTo (hdc
, x
+5, y
++); x
++;
563 MoveToEx (hdc
, x
, y
, NULL
);
564 LineTo (hdc
, x
+3, y
++); x
++;
565 MoveToEx (hdc
, x
, y
, NULL
);
566 LineTo (hdc
, x
+1, y
++);
567 SelectObject( hdc
, hOldPen
);
568 DeleteObject( hPen
);
572 * Draw the text string for this button.
573 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
574 * is non-zero, so we can simply check himlDef to see if we have
578 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
579 NMTBCUSTOMDRAW
*tbcd
)
581 HDC hdc
= tbcd
->nmcd
.hdc
;
584 COLORREF clrOldBk
= 0;
586 UINT state
= tbcd
->nmcd
.uItemState
;
590 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
591 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
593 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
594 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
595 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
597 else if (state
& CDIS_DISABLED
) {
598 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
599 OffsetRect (rcText
, 1, 1);
600 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
601 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
602 OffsetRect (rcText
, -1, -1);
604 else if (state
& CDIS_INDETERMINATE
) {
605 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
607 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
608 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
609 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
610 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
613 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
616 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
617 SetTextColor (hdc
, clrOld
);
618 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
620 SetBkColor (hdc
, clrOldBk
);
621 SetBkMode (hdc
, oldBkMode
);
623 SelectObject (hdc
, hOldFont
);
629 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
631 HDC hdc
= tbcd
->nmcd
.hdc
;
632 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
635 INT cx
= lpRect
->right
- lpRect
->left
;
636 INT cy
= lpRect
->bottom
- lpRect
->top
;
637 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
638 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
639 PatBlt (hdc
, lpRect
->left
, lpRect
->top
, cx
, cy
, PATCOPY
);
640 SetBkColor(hdc
, clrBkOld
);
641 SetTextColor(hdc
, clrTextOld
);
642 SelectObject (hdc
, hbr
);
646 static void TOOLBAR_DrawMasked(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
647 HDC hdc
, INT x
, INT y
)
651 TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
656 HBITMAP hbmMask
, hbmImage
;
657 HDC hdcMask
, hdcImage
;
659 ImageList_GetIconSize(himl
, &cx
, &cy
);
661 /* Create src image */
662 hdcImage
= CreateCompatibleDC(hdc
);
663 hbmImage
= CreateBitmap(cx
, cy
, GetDeviceCaps(hdc
,PLANES
),
664 GetDeviceCaps(hdc
,BITSPIXEL
), NULL
);
665 SelectObject(hdcImage
, hbmImage
);
666 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
667 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_NORMAL
);
670 hdcMask
= CreateCompatibleDC(0);
671 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
672 SelectObject(hdcMask
, hbmMask
);
674 /* Remove the background and all white pixels */
675 SetBkColor(hdcImage
, ImageList_GetBkColor(himl
));
676 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, SRCCOPY
);
677 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
678 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
680 /* draw the new mask 'etched' to hdc */
681 SetBkColor(hdc
, RGB(255, 255, 255));
682 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
683 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
684 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
685 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
686 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
689 DeleteObject(hbmImage
);
691 DeleteObject (hbmMask
);
698 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
702 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
703 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
704 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
705 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
706 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
707 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
708 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
712 /* draws the image on a toolbar button */
714 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
716 HIMAGELIST himl
= NULL
;
717 BOOL draw_masked
= FALSE
;
720 UINT draw_flags
= ILD_NORMAL
;
722 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
724 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
728 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (infoPtr
->dwStyle
& TBSTYLE_FLAT
))
730 /* if hot, attempt to draw with hot image list, if fails,
731 use default image list */
732 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
734 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
737 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
739 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
740 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
743 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
744 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
745 draw_flags
|= ILD_BLEND50
;
747 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
748 index
, himl
, left
, top
, offset
);
751 TOOLBAR_DrawMasked (infoPtr
, btnPtr
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
);
753 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
756 /* draws a blank frame for a toolbar button */
758 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
)
760 HDC hdc
= tbcd
->nmcd
.hdc
;
761 RECT rc
= tbcd
->nmcd
.rc
;
762 /* if the state is disabled or indeterminate then the button
763 * cannot have an interactive look like pressed or hot */
764 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
765 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
766 BOOL pressed_look
= !non_interactive_state
&&
767 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
768 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
770 /* app don't want us to draw any edges */
771 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
777 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
778 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
779 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
784 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
786 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
787 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
792 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
)
794 HDC hdc
= tbcd
->nmcd
.hdc
;
799 if ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) || (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
))
800 DrawEdge (hdc
, rcArrow
, BDR_SUNKENOUTER
, BF_RECT
);
801 else if ( (tbcd
->nmcd
.uItemState
& CDIS_HOT
) &&
802 !(tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) &&
803 !(tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
))
804 DrawEdge (hdc
, rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
808 if ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) || (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
))
809 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
811 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
812 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
815 if (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
816 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
818 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
820 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+1, rcArrow
->top
+1 + (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
821 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
, rcArrow
->top
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
824 TOOLBAR_DrawArrow(hdc
, rcArrow
->left
+ offset
, rcArrow
->top
+ offset
+ (rcArrow
->bottom
- rcArrow
->top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
827 /* draws a complete toolbar button */
829 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
831 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
832 DWORD dwStyle
= infoPtr
->dwStyle
;
833 BOOL hasDropDownArrow
= (TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
834 (btnPtr
->fsStyle
& BTNS_DROPDOWN
)) ||
835 (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
836 BOOL drawSepDropDownArrow
= hasDropDownArrow
&&
837 (~btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
);
838 RECT rc
, rcArrow
, rcBitmap
, rcText
;
839 LPWSTR lpText
= NULL
;
845 CopyRect (&rcArrow
, &rc
);
846 CopyRect(&rcBitmap
, &rc
);
848 /* get a pointer to the text */
849 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
851 if (hasDropDownArrow
)
855 if (dwStyle
& TBSTYLE_FLAT
)
856 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
858 right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
860 if (drawSepDropDownArrow
)
863 rcArrow
.left
= right
;
866 /* copy text rect after adjusting for drop-down arrow
867 * so that text is centred in the rectangle not containing
869 CopyRect(&rcText
, &rc
);
871 /* Center the bitmap horizontally and vertically */
872 if (dwStyle
& TBSTYLE_LIST
)
873 rcBitmap
.left
+= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
875 rcBitmap
.left
+=(infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
878 rcBitmap
.top
+= GetSystemMetrics(SM_CYEDGE
) + OFFSET_Y
;
880 rcBitmap
.top
+=(infoPtr
->nButtonHeight
- infoPtr
->nBitmapHeight
) / 2;
882 TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
883 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
884 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
885 TRACE ("iString: %x\n", btnPtr
->iString
);
886 TRACE ("Stringtext: %s\n", debugstr_w(lpText
));
890 rcText
.left
+= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
891 rcText
.right
-= GetSystemMetrics(SM_CXEDGE
) + OFFSET_X
;
892 if (GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,btnPtr
->iBitmap
)) &&
893 TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
))
895 if (dwStyle
& TBSTYLE_LIST
)
896 rcText
.left
+= infoPtr
->nBitmapWidth
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
898 rcText
.top
+= GetSystemMetrics(SM_CYEDGE
) + OFFSET_Y
+ infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
/2;
901 if (dwStyle
& TBSTYLE_LIST
)
902 rcText
.left
+= LIST_IMAGE_ABSENT_WIDTH
+ TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
);
904 if (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
))
905 OffsetRect (&rcText
, 1, 1);
908 /* Initialize fields in all cases, because we use these later
909 * NOTE: applications can and do alter these to customize their
911 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
912 tbcd
.clrText
= comctl32_color
.clrBtnText
;
913 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
914 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
915 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
916 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
917 tbcd
.clrHighlightHotTrack
= 0;
918 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
919 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
920 /* MSDN says that this is the text rectangle.
921 * But (why always a but) tracing of v5.7 of native shows
922 * that this is really a *relative* rectangle based on the
923 * the nmcd.rc. Also the left and top are always 0 ignoring
924 * any bitmap that might be present. */
925 tbcd
.rcText
.left
= 0;
927 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
928 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
929 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
932 tbcd
.hbrMonoDither
= COMCTL32_hPattern55AABrush
;
934 /* FIXME: what are these used for? */
938 /* Issue Item Prepaint notify */
939 infoPtr
->dwItemCustDraw
= 0;
940 infoPtr
->dwItemCDFlag
= 0;
941 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
943 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
944 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
945 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
946 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
947 /* reset these fields so the user can't alter the behaviour like native */
951 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
952 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
953 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
955 /* save the only part of the rect that the user can change */
956 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
957 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
961 if (btnPtr
->fsStyle
& BTNS_SEP
) {
962 /* with the FLAT style, iBitmap is the width and has already */
963 /* been taken into consideration in calculating the width */
964 /* so now we need to draw the vertical separator */
965 /* empirical tests show that iBitmap can/will be non-zero */
966 /* when drawing the vertical bar... */
967 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
968 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
)
969 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
971 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
973 else if (btnPtr
->fsStyle
!= BTNS_SEP
) {
974 FIXME("Draw some kind of separator: fsStyle=%x\n",
980 if (!(tbcd
.nmcd
.uItemState
& CDIS_HOT
) &&
981 ((tbcd
.nmcd
.uItemState
& CDIS_CHECKED
) || (tbcd
.nmcd
.uItemState
& CDIS_INDETERMINATE
)))
982 TOOLBAR_DrawPattern (&rc
, &tbcd
);
984 if ((dwStyle
& TBSTYLE_FLAT
) && (tbcd
.nmcd
.uItemState
& CDIS_HOT
))
986 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
990 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
991 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
992 if (hasDropDownArrow
)
993 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
994 SetBkColor(hdc
, oldclr
);
998 TOOLBAR_DrawFrame(infoPtr
, dwStyle
& TBSTYLE_FLAT
, &tbcd
);
1000 if (drawSepDropDownArrow
)
1001 TOOLBAR_DrawSepDDArrow(infoPtr
, dwStyle
& TBSTYLE_FLAT
, &tbcd
, &rcArrow
);
1003 if (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) || (btnPtr
->fsStyle
& BTNS_SHOWTEXT
))
1004 TOOLBAR_DrawString (infoPtr
, &rcText
, lpText
, &tbcd
);
1006 TOOLBAR_DrawImage(infoPtr
, btnPtr
, rcBitmap
.left
, rcBitmap
.top
, &tbcd
);
1008 if (hasDropDownArrow
&& !drawSepDropDownArrow
)
1010 if (tbcd
.nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
1012 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1 + (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnHighlight
);
1013 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clr3dShadow
);
1015 else if (tbcd
.nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
))
1017 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
1018 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+ offset
, rcArrow
.top
+ offset
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1021 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
+ (rcArrow
.bottom
- rcArrow
.top
- ARROW_HEIGHT
) / 2, comctl32_color
.clrBtnText
);
1025 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1027 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
1028 tbcd
.nmcd
.hdc
= hdc
;
1030 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
1031 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
1032 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
1033 tbcd
.rcText
= rcText
;
1034 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1035 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
1036 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1043 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
1045 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1046 TBUTTON_INFO
*btnPtr
;
1047 INT i
, oldBKmode
= 0;
1048 RECT rcTemp
, rcClient
;
1049 NMTBCUSTOMDRAW tbcd
;
1052 /* the app has told us not to redraw the toolbar */
1053 if (!infoPtr
->bDoRedraw
)
1056 /* if imagelist belongs to the app, it can be changed
1057 by the app after setting it */
1058 if (GETDEFIMAGELIST(infoPtr
, 0) != infoPtr
->himlInt
)
1060 infoPtr
->nNumBitmaps
= 0;
1061 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
1062 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
1065 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1067 /* Send initial notify */
1068 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1069 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
1070 tbcd
.nmcd
.hdc
= hdc
;
1071 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1072 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1073 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
1075 if (infoPtr
->bBtnTranspnt
)
1076 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
1078 GetClientRect(hwnd
, &rcClient
);
1080 /* redraw necessary buttons */
1081 btnPtr
= infoPtr
->buttons
;
1082 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
1085 if (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
1087 IntersectRect(&rcTemp
, &rcClient
, &btnPtr
->rect
);
1088 bDraw
= EqualRect(&rcTemp
, &btnPtr
->rect
);
1092 bDraw
&= IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
));
1093 bDraw
= (btnPtr
->fsState
& TBSTATE_HIDDEN
) ? FALSE
: bDraw
;
1095 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
1098 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
1099 SetBkMode (hdc
, oldBKmode
);
1101 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
1103 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
1104 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
1105 tbcd
.nmcd
.hdc
= hdc
;
1106 tbcd
.nmcd
.rc
= ps
->rcPaint
;
1107 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
1111 /***********************************************************************
1112 * TOOLBAR_MeasureString
1114 * This function gets the width and height of a string in pixels. This
1115 * is done first by using GetTextExtentPoint to get the basic width
1116 * and height. The DrawText is called with DT_CALCRECT to get the exact
1117 * width. The reason is because the text may have more than one "&" (or
1118 * prefix characters as M$ likes to call them). The prefix character
1119 * indicates where the underline goes, except for the string "&&" which
1120 * is reduced to a single "&". GetTextExtentPoint does not process these
1121 * only DrawText does. Note that the BTNS_NOPREFIX is handled here.
1124 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
1125 HDC hdc
, LPSIZE lpSize
)
1132 if (infoPtr
->nMaxTextRows
> 0 &&
1133 !(btnPtr
->fsState
& TBSTATE_HIDDEN
) &&
1134 (!(infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1135 (btnPtr
->fsStyle
& BTNS_SHOWTEXT
)) )
1137 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1139 if(lpText
!= NULL
) {
1140 /* first get size of all the text */
1141 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1143 /* feed above size into the rectangle for DrawText */
1144 myrect
.left
= myrect
.top
= 0;
1145 myrect
.right
= lpSize
->cx
;
1146 myrect
.bottom
= lpSize
->cy
;
1148 /* Use DrawText to get true size as drawn (less pesky "&") */
1149 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1150 DT_CALCRECT
| ((btnPtr
->fsStyle
& BTNS_NOPREFIX
) ?
1153 /* feed back to caller */
1154 lpSize
->cx
= myrect
.right
;
1155 lpSize
->cy
= myrect
.bottom
;
1159 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1162 /***********************************************************************
1163 * TOOLBAR_CalcStrings
1165 * This function walks through each string and measures it and returns
1166 * the largest height and width to caller.
1169 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1171 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1172 TBUTTON_INFO
*btnPtr
;
1181 if(infoPtr
->nMaxTextRows
== 0)
1185 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1187 btnPtr
= infoPtr
->buttons
;
1188 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1189 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1191 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1192 if (sz
.cx
> lpSize
->cx
)
1194 if (sz
.cy
> lpSize
->cy
)
1199 SelectObject (hdc
, hOldFont
);
1200 ReleaseDC (hwnd
, hdc
);
1202 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1205 /***********************************************************************
1206 * TOOLBAR_WrapToolbar
1208 * This function walks through the buttons and separators in the
1209 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1210 * wrapping should occur based on the width of the toolbar window.
1211 * It does *not* calculate button placement itself. That task
1212 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1213 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1214 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1216 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1217 * vertical toolbar lists.
1221 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1223 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1224 TBUTTON_INFO
*btnPtr
;
1227 BOOL bWrap
, bButtonWrap
;
1229 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1230 /* no layout is necessary. Applications may use this style */
1231 /* to perform their own layout on the toolbar. */
1232 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1233 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1235 btnPtr
= infoPtr
->buttons
;
1236 x
= infoPtr
->nIndent
;
1238 /* this can get the parents width, to know how far we can extend
1239 * this toolbar. We cannot use its height, as there may be multiple
1240 * toolbars in a rebar control
1242 GetClientRect( GetParent(hwnd
), &rc
);
1243 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1244 bButtonWrap
= FALSE
;
1246 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1247 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1250 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1253 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1255 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1258 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1259 /* it is the actual width of the separator. This is used for */
1260 /* custom controls in toolbars. */
1262 /* BTNS_DROPDOWN separators are treated as buttons for */
1263 /* width. - GA 8/01 */
1264 if ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1265 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
))
1266 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1267 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1269 cx
= infoPtr
->nButtonWidth
;
1271 /* Two or more adjacent separators form a separator group. */
1272 /* The first separator in a group should be wrapped to the */
1273 /* next row if the previous wrapping is on a button. */
1275 (btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1276 (i
+ 1 < infoPtr
->nNumButtons
) &&
1277 (btnPtr
[i
+ 1].fsStyle
& BTNS_SEP
) )
1279 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1280 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1281 x
= infoPtr
->nIndent
;
1283 bButtonWrap
= FALSE
;
1287 /* The layout makes sure the bitmap is visible, but not the button. */
1288 /* Test added to also wrap after a button that starts a row but */
1289 /* is bigger than the area. - GA 8/01 */
1290 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1291 > infoPtr
->nWidth
) ||
1292 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1294 BOOL bFound
= FALSE
;
1296 /* If the current button is a separator and not hidden, */
1297 /* go to the next until it reaches a non separator. */
1298 /* Wrap the last separator if it is before a button. */
1299 while( ( ((btnPtr
[i
].fsStyle
& BTNS_SEP
) &&
1300 !(btnPtr
[i
].fsStyle
& BTNS_DROPDOWN
)) ||
1301 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1302 i
< infoPtr
->nNumButtons
)
1308 if( bFound
&& i
< infoPtr
->nNumButtons
)
1311 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1312 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1313 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1314 x
= infoPtr
->nIndent
;
1315 bButtonWrap
= FALSE
;
1318 else if ( i
>= infoPtr
->nNumButtons
)
1321 /* If the current button is not a separator, find the last */
1322 /* separator and wrap it. */
1323 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1325 if ((btnPtr
[j
].fsStyle
& BTNS_SEP
) &&
1326 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1330 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1331 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1332 x
= infoPtr
->nIndent
;
1333 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1334 bButtonWrap
= FALSE
;
1339 /* If no separator available for wrapping, wrap one of */
1340 /* non-hidden previous button. */
1344 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1346 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1351 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1352 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1353 x
= infoPtr
->nIndent
;
1354 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1360 /* If all above failed, wrap the current button. */
1363 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1364 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1365 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1367 x
= infoPtr
->nIndent
;
1368 if (btnPtr
[i
].fsStyle
& BTNS_SEP
)
1369 bButtonWrap
= FALSE
;
1375 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1376 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1383 /***********************************************************************
1384 * TOOLBAR_CalcToolbar
1386 * This function calculates button and separator placement. It first
1387 * calculates the button sizes, gets the toolbar window width and then
1388 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1389 * on. It assigns a new location to each item and sends this location to
1390 * the tooltip window if appropriate. Finally, it updates the rcBound
1391 * rect and calculates the new required toolbar window height.
1395 TOOLBAR_CalcToolbar (HWND hwnd
)
1397 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1398 DWORD dwStyle
= infoPtr
->dwStyle
;
1399 TBUTTON_INFO
*btnPtr
;
1400 INT i
, nRows
, nSepRows
;
1404 BOOL usesBitmaps
= FALSE
;
1405 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1407 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1409 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1411 for (i
= 0; i
< infoPtr
->nNumButtons
&& !usesBitmaps
; i
++)
1413 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,infoPtr
->buttons
[i
].iBitmap
))
1416 if (dwStyle
& TBSTYLE_LIST
)
1418 infoPtr
->nButtonHeight
= max((usesBitmaps
) ? infoPtr
->nBitmapHeight
:
1419 0, sizeString
.cy
) + infoPtr
->szPadding
.cy
;
1420 infoPtr
->nButtonWidth
= ((usesBitmaps
) ? infoPtr
->nBitmapWidth
:
1421 LIST_IMAGE_ABSENT_WIDTH
) + sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1422 if (sizeString
.cx
> 0)
1423 infoPtr
->nButtonWidth
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1424 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1425 infoPtr
->nButtonWidth
, infoPtr
->nButtonHeight
, usesBitmaps
,
1426 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
1429 if (sizeString
.cy
> 0)
1432 infoPtr
->nButtonHeight
= sizeString
.cy
+
1433 infoPtr
->szPadding
.cy
/2 + /* this is the space to separate text from bitmap */
1434 infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1436 infoPtr
->nButtonHeight
= sizeString
.cy
+ infoPtr
->szPadding
.cy
;
1439 infoPtr
->nButtonHeight
= infoPtr
->nBitmapHeight
+ infoPtr
->szPadding
.cy
;
1441 if (sizeString
.cx
> infoPtr
->nBitmapWidth
)
1442 infoPtr
->nButtonWidth
= sizeString
.cx
+ infoPtr
->szPadding
.cx
;
1444 infoPtr
->nButtonWidth
= infoPtr
->nBitmapWidth
+ infoPtr
->szPadding
.cx
;
1447 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1448 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1449 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1450 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1452 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1454 x
= infoPtr
->nIndent
;
1457 /* from above, minimum is a button, and possible text */
1458 cx
= infoPtr
->nButtonWidth
;
1460 /* cannot use just ButtonHeight, we may have no buttons! */
1461 if (infoPtr
->nNumButtons
> 0)
1462 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1464 cy
= infoPtr
->nHeight
;
1466 nRows
= nSepRows
= 0;
1468 infoPtr
->rcBound
.top
= y
;
1469 infoPtr
->rcBound
.left
= x
;
1470 infoPtr
->rcBound
.bottom
= y
+ cy
;
1471 infoPtr
->rcBound
.right
= x
;
1473 btnPtr
= infoPtr
->buttons
;
1475 TRACE("cy=%d\n", cy
);
1477 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1480 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1482 SetRectEmpty (&btnPtr
->rect
);
1486 cy
= infoPtr
->nHeight
;
1488 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1489 /* it is the actual width of the separator. This is used for */
1490 /* custom controls in toolbars. */
1491 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1492 if (btnPtr
->fsStyle
& BTNS_DROPDOWN
) {
1493 cy
= (btnPtr
->iBitmap
> 0) ?
1494 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1495 cx
= infoPtr
->nButtonWidth
;
1498 cx
= (btnPtr
->iBitmap
> 0) ?
1499 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1505 else if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ||
1506 (btnPtr
->fsStyle
& BTNS_AUTOSIZE
))
1513 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1515 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1517 SelectObject (hdc
, hOldFont
);
1518 ReleaseDC (hwnd
, hdc
);
1520 /* add space on for button frame, etc */
1521 cx
= sz
.cx
+ infoPtr
->szPadding
.cx
;
1523 /* add list padding */
1524 if ((dwStyle
& TBSTYLE_LIST
) && sz
.cx
> 0)
1525 cx
+= TOOLBAR_GetListTextOffset(infoPtr
, infoPtr
->iListGap
) + infoPtr
->szPadding
.cx
/2;
1527 if (TOOLBAR_TestImageExist (infoPtr
, btnPtr
, GETDEFIMAGELIST(infoPtr
,0)))
1529 if (dwStyle
& TBSTYLE_LIST
)
1530 cx
+= infoPtr
->nBitmapWidth
;
1531 else if (cx
< (infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
))
1532 cx
= infoPtr
->nBitmapWidth
+infoPtr
->szPadding
.cx
;
1534 else if (dwStyle
& TBSTYLE_LIST
)
1535 cx
+= LIST_IMAGE_ABSENT_WIDTH
;
1538 cx
= infoPtr
->nButtonWidth
;
1540 /* if size has been set manually then don't add on extra space
1541 * for the drop down arrow */
1542 if (!btnPtr
->cx
&& hasDropDownArrows
&&
1543 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) || (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)))
1544 cx
+= DDARROW_WIDTH
;
1546 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1549 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1551 if (infoPtr
->rcBound
.left
> x
)
1552 infoPtr
->rcBound
.left
= x
;
1553 if (infoPtr
->rcBound
.right
< x
+ cx
)
1554 infoPtr
->rcBound
.right
= x
+ cx
;
1555 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1556 infoPtr
->rcBound
.bottom
= y
+ cy
;
1558 /* Set the toolTip only for non-hidden, non-separator button */
1559 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& BTNS_SEP
))
1563 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
1564 ti
.cbSize
= sizeof(TTTOOLINFOA
);
1566 ti
.uId
= btnPtr
->idCommand
;
1567 ti
.rect
= btnPtr
->rect
;
1568 SendMessageA (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTA
,
1572 /* btnPtr->nRow is zero based. The space between the rows is */
1573 /* also considered as a row. */
1574 btnPtr
->nRow
= nRows
+ nSepRows
;
1576 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1577 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1582 if ( !(btnPtr
->fsStyle
& BTNS_SEP
) )
1586 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1587 /* it is the actual width of the separator. This is used for */
1588 /* custom controls in toolbars. */
1589 if ( !(btnPtr
->fsStyle
& BTNS_DROPDOWN
))
1590 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1591 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1595 /* nSepRows is used to calculate the extra height follwoing */
1599 x
= infoPtr
->nIndent
;
1601 /* Increment row number unless this is the last button */
1602 /* and it has Wrap set. */
1603 if (i
!= infoPtr
->nNumButtons
-1)
1610 /* infoPtr->nRows is the number of rows on the toolbar */
1611 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1614 /********************************************************************
1615 * The following while interesting, does not match the values *
1616 * created above for the button rectangles, nor the rcBound rect. *
1617 * We will comment it out and remove it later. *
1619 * The problem showed up as heights in the pager control that was *
1621 ********************************************************************/
1623 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1625 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1626 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1627 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1631 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1633 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1638 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1640 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1641 TBUTTON_INFO
*btnPtr
;
1644 btnPtr
= infoPtr
->buttons
;
1645 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1646 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1649 if (btnPtr
->fsStyle
& BTNS_SEP
) {
1650 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1651 TRACE(" ON SEPARATOR %d!\n", i
);
1656 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1657 TRACE(" ON BUTTON %d!\n", i
);
1663 TRACE(" NOWHERE!\n");
1669 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1671 TBUTTON_INFO
*btnPtr
;
1674 if (CommandIsIndex
) {
1675 TRACE("command is really index command=%d\n", idCommand
);
1676 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1679 btnPtr
= infoPtr
->buttons
;
1680 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1681 if (btnPtr
->idCommand
== idCommand
) {
1682 TRACE("command=%d index=%d\n", idCommand
, i
);
1686 TRACE("no index found for command=%d\n", idCommand
);
1692 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1694 TBUTTON_INFO
*btnPtr
;
1697 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1700 /* check index button */
1701 btnPtr
= &infoPtr
->buttons
[nIndex
];
1702 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1703 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1707 /* check previous buttons */
1708 nRunIndex
= nIndex
- 1;
1709 while (nRunIndex
>= 0) {
1710 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1711 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1712 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1720 /* check next buttons */
1721 nRunIndex
= nIndex
+ 1;
1722 while (nRunIndex
< infoPtr
->nNumButtons
) {
1723 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1724 if ((btnPtr
->fsStyle
& BTNS_CHECKGROUP
) == BTNS_CHECKGROUP
) {
1725 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1738 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1739 WPARAM wParam
, LPARAM lParam
)
1745 msg
.wParam
= wParam
;
1746 msg
.lParam
= lParam
;
1747 msg
.time
= GetMessageTime ();
1748 msg
.pt
.x
= LOWORD(GetMessagePos ());
1749 msg
.pt
.y
= HIWORD(GetMessagePos ());
1751 SendMessageA (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1755 /***********************************************************************
1756 * TOOLBAR_CustomizeDialogProc
1757 * This function implements the toolbar customization dialog.
1759 static INT_PTR CALLBACK
1760 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1762 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongPtrW (hwnd
, DWLP_USER
);
1763 PCUSTOMBUTTON btnInfo
;
1765 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
1770 custInfo
= (PCUSTDLG_INFO
)lParam
;
1771 SetWindowLongPtrW (hwnd
, DWLP_USER
, (LONG_PTR
)custInfo
);
1779 infoPtr
= custInfo
->tbInfo
;
1781 /* send TBN_QUERYINSERT notification */
1782 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
1784 if (!TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYINSERT
))
1787 /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */
1788 nmtb
.iItem
= (int)hwnd
;
1789 /* Send TBN_INITCUSTOMIZE notification */
1790 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_INITCUSTOMIZE
) ==
1793 TRACE("TBNRF_HIDEHELP requested\n");
1794 ShowWindow(GetDlgItem(hwnd
, IDC_HELP_BTN
), SW_HIDE
);
1797 /* add items to 'toolbar buttons' list and check if removable */
1798 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
1800 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1801 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1802 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1803 btnInfo
->bVirtual
= FALSE
;
1804 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1806 /* send TBN_QUERYDELETE notification */
1807 btnInfo
->bRemovable
= TOOLBAR_IsButtonRemovable(infoPtr
, i
, btnInfo
);
1809 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1810 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1813 /* insert separator button into 'available buttons' list */
1814 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1815 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1816 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1817 btnInfo
->bVirtual
= FALSE
;
1818 btnInfo
->bRemovable
= TRUE
;
1819 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1820 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1821 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1823 /* insert all buttons into dsa */
1826 /* send TBN_GETBUTTONINFO notification */
1829 nmtb
.pszText
= Buffer
;
1832 /* Clear previous button's text */
1833 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
1835 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
1838 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
1839 nmtb
.tbButton
.fsStyle
, i
,
1840 nmtb
.tbButton
.idCommand
,
1841 nmtb
.tbButton
.iString
,
1842 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
1845 /* insert button into the apropriate list */
1846 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
1849 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1850 btnInfo
->bVirtual
= FALSE
;
1851 btnInfo
->bRemovable
= TRUE
;
1853 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1854 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
,
1855 LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1859 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
,
1860 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1863 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
1864 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
1866 if (lstrlenW(nmtb
.pszText
))
1867 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
1868 else if (nmtb
.tbButton
.iString
>= 0 &&
1869 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
1871 lstrcpyW(btnInfo
->text
,
1872 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
1877 /* select first item in the 'available' list */
1878 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
1880 /* append 'virtual' separator button to the 'toolbar buttons' list */
1881 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1882 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1883 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1884 btnInfo
->bVirtual
= TRUE
;
1885 btnInfo
->bRemovable
= FALSE
;
1886 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1887 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1888 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1890 /* select last item in the 'toolbar' list */
1891 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
1892 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
1894 /* set focus and disable buttons */
1895 PostMessageA (hwnd
, WM_USER
, 0, 0);
1900 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1901 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1902 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
1903 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
1907 EndDialog(hwnd
, FALSE
);
1911 switch (LOWORD(wParam
))
1913 case IDC_TOOLBARBTN_LBOX
:
1914 if (HIWORD(wParam
) == LBN_SELCHANGE
)
1916 PCUSTOMBUTTON btnInfo
;
1921 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1922 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1924 /* send TBN_QUERYINSERT notification */
1926 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1929 /* get list box item */
1930 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1932 if (index
== (count
- 1))
1934 /* last item (virtual separator) */
1935 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1936 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1938 else if (index
== (count
- 2))
1940 /* second last item (last non-virtual item) */
1941 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1942 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1944 else if (index
== 0)
1947 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1948 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1952 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1953 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1956 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
1960 case IDC_MOVEUP_BTN
:
1962 PCUSTOMBUTTON btnInfo
;
1966 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1967 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1968 TRACE("Move up: index %d\n", index
);
1970 /* send TBN_QUERYINSERT notification */
1973 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1978 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1980 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1981 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
-1, 0);
1982 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
-1, (LPARAM
)btnInfo
);
1983 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
1986 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1987 else if (index
>= (count
- 3))
1988 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1990 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1991 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
-1, (LPARAM
)&(btnInfo
->btn
));
1993 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
1998 case IDC_MOVEDN_BTN
: /* move down */
2000 PCUSTOMBUTTON btnInfo
;
2004 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2005 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2006 TRACE("Move up: index %d\n", index
);
2008 /* send TBN_QUERYINSERT notification */
2010 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2015 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2017 /* move button down */
2018 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2019 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
+1, 0);
2020 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
+1, (LPARAM
)btnInfo
);
2021 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
+1 , 0);
2024 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2025 else if (index
>= (count
- 3))
2026 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2028 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2029 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
+1, (LPARAM
)&(btnInfo
->btn
));
2031 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2036 case IDC_REMOVE_BTN
: /* remove button */
2038 PCUSTOMBUTTON btnInfo
;
2041 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2043 if (LB_ERR
== index
)
2046 TRACE("Remove: index %d\n", index
);
2048 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
,
2049 LB_GETITEMDATA
, index
, 0);
2051 /* send TBN_QUERYDELETE notification */
2052 if (TOOLBAR_IsButtonRemovable(infoPtr
, index
, btnInfo
))
2056 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2057 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2058 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2060 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2062 /* insert into 'available button' list */
2063 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
2065 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2066 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2071 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2076 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2079 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2082 case IDOK
: /* Add button */
2087 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2088 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2089 TRACE("Add: index %d\n", index
);
2091 /* send TBN_QUERYINSERT notification */
2093 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2098 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2102 /* remove from 'available buttons' list */
2103 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2104 if (index
== count
-1)
2105 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
2107 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2111 PCUSTOMBUTTON btnNew
;
2113 /* duplicate 'separator' button */
2114 btnNew
= (PCUSTOMBUTTON
)Alloc (sizeof(CUSTOMBUTTON
));
2115 memcpy (btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
2119 /* insert into 'toolbar button' list */
2120 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2121 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
, 0);
2122 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2124 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
, (LPARAM
)&(btnInfo
->btn
));
2126 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2132 EndDialog(hwnd
, FALSE
);
2142 /* delete items from 'toolbar buttons' listbox*/
2143 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2144 for (i
= 0; i
< count
; i
++)
2146 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2148 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2150 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2153 /* delete items from 'available buttons' listbox*/
2154 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2155 for (i
= 0; i
< count
; i
++)
2157 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2159 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2161 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2166 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2168 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2173 COLORREF oldText
= 0;
2177 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2178 if (btnInfo
== NULL
)
2180 FIXME("btnInfo invalid!\n");
2184 /* set colors and select objects */
2185 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2186 if (btnInfo
->bVirtual
)
2187 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2189 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2190 hPen
= CreatePen( PS_SOLID
, 1,
2191 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2192 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2193 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2195 /* fill background rectangle */
2196 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2197 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2199 /* calculate button and text rectangles */
2200 CopyRect (&rcButton
, &lpdis
->rcItem
);
2201 InflateRect (&rcButton
, -1, -1);
2202 CopyRect (&rcText
, &rcButton
);
2203 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2204 rcText
.left
= rcButton
.right
+ 2;
2206 /* draw focus rectangle */
2207 if (lpdis
->itemState
& ODS_FOCUS
)
2208 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2211 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
2212 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2214 /* draw image and text */
2215 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2216 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2217 btnInfo
->btn
.iBitmap
));
2218 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2219 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2221 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2222 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2224 /* delete objects and reset colors */
2225 SelectObject (lpdis
->hDC
, hOldBrush
);
2226 SelectObject (lpdis
->hDC
, hOldPen
);
2227 SetBkColor (lpdis
->hDC
, oldBk
);
2228 SetTextColor (lpdis
->hDC
, oldText
);
2229 DeleteObject( hPen
);
2234 case WM_MEASUREITEM
:
2235 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2237 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2239 if (custInfo
&& custInfo
->tbInfo
)
2240 lpmis
->itemHeight
= custInfo
->tbInfo
->nBitmapHeight
+ 8;
2242 lpmis
->itemHeight
= 15 + 8; /* default height */
2254 /***********************************************************************
2255 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2259 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2261 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2262 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2263 INT nIndex
= 0, nButtons
, nCount
;
2267 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2271 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2273 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2275 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2277 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2282 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2284 /* Windows resize all the buttons to the size of a newly added standard image */
2285 if (lpAddBmp
->nID
& 1)
2288 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2289 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2291 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2292 MAKELPARAM((WORD
)24, (WORD
)24));
2293 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2294 MAKELPARAM((WORD
)31, (WORD
)30));
2299 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2300 MAKELPARAM((WORD
)16, (WORD
)16));
2301 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2302 MAKELPARAM((WORD
)22, (WORD
)22));
2305 TOOLBAR_CalcToolbar (hwnd
);
2309 nButtons
= (INT
)wParam
;
2313 TRACE ("adding %d bitmaps!\n", nButtons
);
2316 if (!infoPtr
->cimlDef
) {
2317 /* create new default image list */
2318 TRACE ("creating default image list!\n");
2320 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2321 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2322 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2323 infoPtr
->himlInt
= himlDef
;
2326 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2330 WARN("No default image list available\n");
2334 nCount
= ImageList_GetImageCount(himlDef
);
2336 /* Add bitmaps to the default image list */
2337 if (lpAddBmp
->hInst
== NULL
)
2340 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2341 HDC hdcImage
, hdcBitmap
;
2343 /* copy the bitmap before adding it so that the user's bitmap
2344 * doesn't get modified.
2346 GetObjectA ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2348 hdcImage
= CreateCompatibleDC(0);
2349 hdcBitmap
= CreateCompatibleDC(0);
2351 /* create new bitmap */
2352 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2353 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2354 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2356 /* Copy the user's image */
2357 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2358 hdcBitmap
, 0, 0, SRCCOPY
);
2360 SelectObject (hdcImage
, hOldBitmapLoad
);
2361 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2362 DeleteDC (hdcImage
);
2363 DeleteDC (hdcBitmap
);
2365 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2366 DeleteObject (hbmLoad
);
2368 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2370 /* Add system bitmaps */
2371 switch (lpAddBmp
->nID
)
2373 case IDB_STD_SMALL_COLOR
:
2374 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2375 MAKEINTRESOURCEA(IDB_STD_SMALL
));
2376 nIndex
= ImageList_AddMasked (himlDef
,
2377 hbmLoad
, comctl32_color
.clrBtnFace
);
2378 DeleteObject (hbmLoad
);
2381 case IDB_STD_LARGE_COLOR
:
2382 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2383 MAKEINTRESOURCEA(IDB_STD_LARGE
));
2384 nIndex
= ImageList_AddMasked (himlDef
,
2385 hbmLoad
, comctl32_color
.clrBtnFace
);
2386 DeleteObject (hbmLoad
);
2389 case IDB_VIEW_SMALL_COLOR
:
2390 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2391 MAKEINTRESOURCEA(IDB_VIEW_SMALL
));
2392 nIndex
= ImageList_AddMasked (himlDef
,
2393 hbmLoad
, comctl32_color
.clrBtnFace
);
2394 DeleteObject (hbmLoad
);
2397 case IDB_VIEW_LARGE_COLOR
:
2398 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2399 MAKEINTRESOURCEA(IDB_VIEW_LARGE
));
2400 nIndex
= ImageList_AddMasked (himlDef
,
2401 hbmLoad
, comctl32_color
.clrBtnFace
);
2402 DeleteObject (hbmLoad
);
2405 case IDB_HIST_SMALL_COLOR
:
2406 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2407 MAKEINTRESOURCEA(IDB_HIST_SMALL
));
2408 nIndex
= ImageList_AddMasked (himlDef
,
2409 hbmLoad
, comctl32_color
.clrBtnFace
);
2410 DeleteObject (hbmLoad
);
2413 case IDB_HIST_LARGE_COLOR
:
2414 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2415 MAKEINTRESOURCEA(IDB_HIST_LARGE
));
2416 nIndex
= ImageList_AddMasked (himlDef
,
2417 hbmLoad
, comctl32_color
.clrBtnFace
);
2418 DeleteObject (hbmLoad
);
2422 nIndex
= ImageList_GetImageCount (himlDef
);
2423 ERR ("invalid imagelist!\n");
2429 hbmLoad
= LoadBitmapA (lpAddBmp
->hInst
, (LPSTR
)lpAddBmp
->nID
);
2430 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2431 DeleteObject (hbmLoad
);
2434 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2436 if (infoPtr
->nNumBitmapInfos
== 0)
2438 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2442 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2443 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2444 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
);
2447 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2448 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2449 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2451 infoPtr
->nNumBitmapInfos
++;
2452 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2456 INT imagecount
= ImageList_GetImageCount(himlDef
);
2458 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2460 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",
2461 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2462 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2464 infoPtr
->nNumBitmaps
= imagecount
;
2467 infoPtr
->nNumBitmaps
+= nButtons
;
2470 InvalidateRect(hwnd
, NULL
, TRUE
);
2477 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2479 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2480 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2481 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2483 TRACE("adding %d buttons!\n", wParam
);
2485 nAddButtons
= (UINT
)wParam
;
2486 nOldButtons
= infoPtr
->nNumButtons
;
2487 nNewButtons
= nOldButtons
+ nAddButtons
;
2489 if (infoPtr
->nNumButtons
== 0) {
2491 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2494 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2496 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2497 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2498 nOldButtons
* sizeof(TBUTTON_INFO
));
2502 infoPtr
->nNumButtons
= nNewButtons
;
2504 /* insert new button data */
2505 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2506 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2507 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2508 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2509 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2510 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2511 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2512 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2513 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2515 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2516 btnPtr
->bHot
= FALSE
;
2518 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2521 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
2522 ti
.cbSize
= sizeof (TTTOOLINFOA
);
2524 ti
.uId
= btnPtr
->idCommand
;
2526 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
2528 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
2533 TOOLBAR_CalcToolbar (hwnd
);
2535 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2537 InvalidateRect(hwnd
, NULL
, TRUE
);
2544 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2546 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2547 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2548 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2550 TRACE("adding %d buttons!\n", wParam
);
2552 nAddButtons
= (UINT
)wParam
;
2553 nOldButtons
= infoPtr
->nNumButtons
;
2554 nNewButtons
= nOldButtons
+ nAddButtons
;
2556 if (infoPtr
->nNumButtons
== 0) {
2558 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2561 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2563 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2564 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2565 nOldButtons
* sizeof(TBUTTON_INFO
));
2569 infoPtr
->nNumButtons
= nNewButtons
;
2571 /* insert new button data */
2572 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2573 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2574 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2575 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2576 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2577 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2578 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2579 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2580 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2582 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2583 btnPtr
->bHot
= FALSE
;
2585 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2588 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2589 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2591 ti
.uId
= btnPtr
->idCommand
;
2593 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2596 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2601 TOOLBAR_CalcToolbar (hwnd
);
2603 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2605 InvalidateRect(hwnd
, NULL
, TRUE
);
2612 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2614 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2617 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2620 TRACE("adding string from resource!\n");
2622 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
,
2625 TRACE("len=%d \"%s\"\n", len
, szString
);
2626 nIndex
= infoPtr
->nNumStrings
;
2627 if (infoPtr
->nNumStrings
== 0) {
2629 Alloc (sizeof(LPWSTR
));
2632 LPWSTR
*oldStrings
= infoPtr
->strings
;
2634 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2635 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2636 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2640 /*Alloc zeros out the allocated memory*/
2641 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2642 infoPtr
->nNumStrings
++;
2645 LPSTR p
= (LPSTR
)lParam
;
2650 TRACE("adding string(s) from array!\n");
2652 nIndex
= infoPtr
->nNumStrings
;
2655 TRACE("len=%d \"%s\"\n", len
, p
);
2657 if (infoPtr
->nNumStrings
== 0) {
2659 Alloc (sizeof(LPWSTR
));
2662 LPWSTR
*oldStrings
= infoPtr
->strings
;
2664 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2665 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2666 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2670 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2671 infoPtr
->nNumStrings
++;
2682 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2684 #define MAX_RESOURCE_STRING_LENGTH 512
2685 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2688 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2689 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2691 TRACE("adding string from resource!\n");
2693 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2694 szString
, MAX_RESOURCE_STRING_LENGTH
);
2696 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2697 TRACE("First char: 0x%x\n", *szString
);
2698 if (szString
[0] == L
'|')
2700 PWSTR p
= szString
+ 1;
2702 nIndex
= infoPtr
->nNumStrings
;
2703 while (*p
!= L
'|' && *p
!= L
'\0') {
2706 if (infoPtr
->nNumStrings
== 0) {
2707 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
2711 LPWSTR
*oldStrings
= infoPtr
->strings
;
2712 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2713 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
2714 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2718 np
=strchrW (p
, '|');
2726 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2727 infoPtr
->strings
[infoPtr
->nNumStrings
] =
2728 Alloc (sizeof(WCHAR
)*(len
+1));
2729 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
2730 infoPtr
->nNumStrings
++;
2737 nIndex
= infoPtr
->nNumStrings
;
2738 if (infoPtr
->nNumStrings
== 0) {
2740 Alloc (sizeof(LPWSTR
));
2743 LPWSTR
*oldStrings
= infoPtr
->strings
;
2745 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2746 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2747 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2751 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2752 infoPtr
->nNumStrings
++;
2756 LPWSTR p
= (LPWSTR
)lParam
;
2761 TRACE("adding string(s) from array!\n");
2762 nIndex
= infoPtr
->nNumStrings
;
2766 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2767 if (infoPtr
->nNumStrings
== 0) {
2769 Alloc (sizeof(LPWSTR
));
2772 LPWSTR
*oldStrings
= infoPtr
->strings
;
2774 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2775 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2776 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2780 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2781 infoPtr
->nNumStrings
++;
2792 TOOLBAR_AutoSize (HWND hwnd
)
2794 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2800 UINT uPosFlags
= SWP_NOZORDER
;
2802 TRACE("resize forced, style=%lx!\n", infoPtr
->dwStyle
);
2804 parent
= GetParent (hwnd
);
2805 GetClientRect(parent
, &parent_rect
);
2807 x
= parent_rect
.left
;
2808 y
= parent_rect
.top
;
2810 /* FIXME: we should be able to early out if nothing */
2811 /* has changed with nWidth != parent_rect width */
2813 if (infoPtr
->dwStyle
& CCS_NORESIZE
) {
2814 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
2817 TOOLBAR_CalcToolbar (hwnd
);
2820 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
2821 TOOLBAR_CalcToolbar (hwnd
);
2822 InvalidateRect( hwnd
, NULL
, TRUE
);
2823 cy
= infoPtr
->nHeight
;
2824 cx
= infoPtr
->nWidth
;
2826 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
2827 GetWindowRect(hwnd
, &window_rect
);
2828 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
2829 y
= window_rect
.top
;
2831 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
2832 GetWindowRect(hwnd
, &window_rect
);
2833 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
2837 if (infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)
2838 uPosFlags
|= SWP_NOMOVE
;
2840 if (!(infoPtr
->dwStyle
& CCS_NODIVIDER
))
2841 cy
+= GetSystemMetrics(SM_CYEDGE
);
2843 if (infoPtr
->dwStyle
& WS_BORDER
)
2846 cy
+= GetSystemMetrics(SM_CYEDGE
);
2847 cx
+= GetSystemMetrics(SM_CYEDGE
);
2850 infoPtr
->bAutoSize
= TRUE
;
2851 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
2852 /* The following line makes sure that the infoPtr->bAutoSize is turned off
2853 * after the setwindowpos calls */
2854 infoPtr
->bAutoSize
= FALSE
;
2861 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2863 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2865 return infoPtr
->nNumButtons
;
2870 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2872 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2874 if (infoPtr
== NULL
) {
2875 ERR("(%p, 0x%x, 0x%lx)\n", hwnd
, wParam
, lParam
);
2876 ERR("infoPtr == NULL!\n");
2880 infoPtr
->dwStructSize
= (DWORD
)wParam
;
2887 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2889 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2890 TBUTTON_INFO
*btnPtr
;
2893 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
2895 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2899 btnPtr
= &infoPtr
->buttons
[nIndex
];
2900 btnPtr
->iBitmap
= LOWORD(lParam
);
2902 /* we HAVE to erase the background, the new bitmap could be */
2904 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2911 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2913 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2914 TBUTTON_INFO
*btnPtr
;
2917 BOOL bChecked
= FALSE
;
2919 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2921 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
2926 btnPtr
= &infoPtr
->buttons
[nIndex
];
2928 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
2930 if (LOWORD(lParam
) == FALSE
)
2931 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
2933 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
2935 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
2936 if (nOldIndex
== nIndex
)
2938 if (nOldIndex
!= -1)
2939 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
2941 btnPtr
->fsState
|= TBSTATE_CHECKED
;
2944 if( bChecked
!= LOWORD(lParam
) )
2946 if (nOldIndex
!= -1)
2947 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
2948 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2951 /* FIXME: Send a WM_NOTIFY?? */
2958 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2960 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2962 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2967 TOOLBAR_Customize (HWND hwnd
)
2969 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2970 CUSTDLG_INFO custInfo
;
2976 custInfo
.tbInfo
= infoPtr
;
2977 custInfo
.tbHwnd
= hwnd
;
2979 /* send TBN_BEGINADJUST notification */
2980 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
2983 if (!(hRes
= FindResourceA (COMCTL32_hModule
,
2984 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE
),
2988 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
2991 ret
= DialogBoxIndirectParamA ((HINSTANCE
)GetWindowLongPtrW(hwnd
, GWLP_HINSTANCE
),
2992 (LPDLGTEMPLATEA
)template,
2994 TOOLBAR_CustomizeDialogProc
,
2997 /* send TBN_ENDADJUST notification */
2998 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
3006 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3008 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3009 INT nIndex
= (INT
)wParam
;
3012 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3015 memset(&nmtb
, 0, sizeof(nmtb
));
3016 nmtb
.iItem
= nIndex
;
3017 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_DELETINGBUTTON
);
3019 if ((infoPtr
->hwndToolTip
) &&
3020 !(infoPtr
->buttons
[nIndex
].fsStyle
& BTNS_SEP
)) {
3023 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3024 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3026 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3028 SendMessageA (infoPtr
->hwndToolTip
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
3031 if (infoPtr
->nNumButtons
== 1) {
3032 TRACE(" simple delete!\n");
3033 Free (infoPtr
->buttons
);
3034 infoPtr
->buttons
= NULL
;
3035 infoPtr
->nNumButtons
= 0;
3038 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3039 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3041 infoPtr
->nNumButtons
--;
3042 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3044 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3045 nIndex
* sizeof(TBUTTON_INFO
));
3048 if (nIndex
< infoPtr
->nNumButtons
) {
3049 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3050 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3056 TOOLBAR_CalcToolbar (hwnd
);
3058 InvalidateRect (hwnd
, NULL
, TRUE
);
3065 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3067 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3068 TBUTTON_INFO
*btnPtr
;
3072 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3074 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3079 btnPtr
= &infoPtr
->buttons
[nIndex
];
3081 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3083 /* update the toolbar button state */
3084 if(LOWORD(lParam
) == FALSE
) {
3085 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3087 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3090 /* redraw the button only if the state of the button changed */
3091 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3092 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3098 static inline LRESULT
3099 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3101 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3103 return infoPtr
->bAnchor
;
3108 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3110 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3113 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3117 return infoPtr
->buttons
[nIndex
].iBitmap
;
3121 static inline LRESULT
3122 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3124 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3129 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3131 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3132 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3133 INT nIndex
= (INT
)wParam
;
3134 TBUTTON_INFO
*btnPtr
;
3136 if (infoPtr
== NULL
)
3142 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3145 btnPtr
= &infoPtr
->buttons
[nIndex
];
3146 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3147 lpTbb
->idCommand
= btnPtr
->idCommand
;
3148 lpTbb
->fsState
= btnPtr
->fsState
;
3149 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3150 lpTbb
->bReserved
[0] = 0;
3151 lpTbb
->bReserved
[1] = 0;
3152 lpTbb
->dwData
= btnPtr
->dwData
;
3153 lpTbb
->iString
= btnPtr
->iString
;
3160 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3162 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3163 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3164 TBUTTON_INFO
*btnPtr
;
3167 if (infoPtr
== NULL
)
3169 if (lpTbInfo
== NULL
)
3171 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3174 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3175 lpTbInfo
->dwMask
& 0x80000000);
3179 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3181 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3182 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3183 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3184 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3185 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3186 lpTbInfo
->lParam
= btnPtr
->dwData
;
3187 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3188 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3189 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3190 lpTbInfo
->fsState
= btnPtr
->fsState
;
3191 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3192 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3193 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3194 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3195 can't use TOOLBAR_GetText here */
3197 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3198 lpText
= (LPWSTR
)btnPtr
->iString
;
3199 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3201 lpTbInfo
->pszText
[0] = '\0';
3208 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3210 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3211 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3212 TBUTTON_INFO
*btnPtr
;
3215 if (infoPtr
== NULL
)
3217 if (lpTbInfo
== NULL
)
3219 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3222 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3223 lpTbInfo
->dwMask
& 0x80000000);
3227 btnPtr
= &infoPtr
->buttons
[nIndex
];
3232 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3233 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3234 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3235 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3236 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3237 lpTbInfo
->lParam
= btnPtr
->dwData
;
3238 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3239 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3240 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3241 lpTbInfo
->fsState
= btnPtr
->fsState
;
3242 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3243 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3244 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3245 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3246 can't use TOOLBAR_GetText here */
3248 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3249 lpText
= (LPWSTR
)btnPtr
->iString
;
3250 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3252 lpTbInfo
->pszText
[0] = '\0';
3260 TOOLBAR_GetButtonSize (HWND hwnd
)
3262 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3264 if (infoPtr
->nNumButtons
> 0)
3265 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3266 (WORD
)infoPtr
->nButtonHeight
);
3268 return MAKELONG(8,7);
3273 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3275 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3282 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3286 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3288 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3289 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3294 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3296 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3303 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3307 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3309 strcpyW ((LPWSTR
)lParam
, lpText
);
3311 return strlenW (lpText
);
3316 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3318 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3319 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3320 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3324 inline static LRESULT
3325 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3327 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3331 return infoPtr
->dwExStyle
;
3336 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3338 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3339 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3340 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3345 TOOLBAR_GetHotItem (HWND hwnd
)
3347 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3349 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
3352 if (infoPtr
->nHotItem
< 0)
3355 return (LRESULT
)infoPtr
->nHotItem
;
3360 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3362 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3363 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3364 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3368 /* << TOOLBAR_GetInsertMark >> */
3369 /* << TOOLBAR_GetInsertMarkColor >> */
3373 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3375 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3376 TBUTTON_INFO
*btnPtr
;
3380 if (infoPtr
== NULL
)
3382 nIndex
= (INT
)wParam
;
3383 btnPtr
= &infoPtr
->buttons
[nIndex
];
3384 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3386 lpRect
= (LPRECT
)lParam
;
3389 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3392 lpRect
->left
= btnPtr
->rect
.left
;
3393 lpRect
->right
= btnPtr
->rect
.right
;
3394 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3395 lpRect
->top
= btnPtr
->rect
.top
;
3402 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3404 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3405 LPSIZE lpSize
= (LPSIZE
)lParam
;
3410 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3411 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3413 TRACE("maximum size %ld x %ld\n",
3414 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3415 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3421 /* << TOOLBAR_GetObject >> */
3425 TOOLBAR_GetPadding (HWND hwnd
)
3427 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3430 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3431 return (LRESULT
) oldPad
;
3436 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3438 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3439 TBUTTON_INFO
*btnPtr
;
3443 if (infoPtr
== NULL
)
3445 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3446 btnPtr
= &infoPtr
->buttons
[nIndex
];
3447 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3449 lpRect
= (LPRECT
)lParam
;
3453 lpRect
->left
= btnPtr
->rect
.left
;
3454 lpRect
->right
= btnPtr
->rect
.right
;
3455 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3456 lpRect
->top
= btnPtr
->rect
.top
;
3463 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3465 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3467 if (infoPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
3468 return infoPtr
->nRows
;
3475 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3477 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3480 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3484 return infoPtr
->buttons
[nIndex
].fsState
;
3489 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3491 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3494 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3498 return infoPtr
->buttons
[nIndex
].fsStyle
;
3503 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3505 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3507 if (infoPtr
== NULL
)
3510 return infoPtr
->nMaxTextRows
;
3515 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3517 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3519 if (infoPtr
== NULL
)
3521 return (LRESULT
)infoPtr
->hwndToolTip
;
3526 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3528 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3530 TRACE("%s hwnd=%p stub!\n",
3531 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3533 return infoPtr
->bUnicode
;
3537 inline static LRESULT
3538 TOOLBAR_GetVersion (HWND hwnd
)
3540 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3541 return infoPtr
->iVersion
;
3546 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3548 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3549 TBUTTON_INFO
*btnPtr
;
3554 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3558 btnPtr
= &infoPtr
->buttons
[nIndex
];
3559 if (LOWORD(lParam
) == FALSE
)
3560 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3562 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3564 TOOLBAR_CalcToolbar (hwnd
);
3566 InvalidateRect (hwnd
, NULL
, TRUE
);
3572 inline static LRESULT
3573 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3575 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3580 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3582 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3583 TBUTTON_INFO
*btnPtr
;
3587 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3591 btnPtr
= &infoPtr
->buttons
[nIndex
];
3592 oldState
= btnPtr
->fsState
;
3593 if (LOWORD(lParam
) == FALSE
)
3594 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3596 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3598 if(oldState
!= btnPtr
->fsState
)
3599 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3606 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3608 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3609 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3610 INT nIndex
= (INT
)wParam
;
3611 TBUTTON_INFO
*oldButtons
;
3616 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3619 /* EPP: this seems to be an undocumented call (from my IE4)
3620 * I assume in that case that:
3621 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3622 * - index of insertion is at the end of existing buttons
3623 * I only see this happen with nIndex == -1, but it could have a special
3624 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3626 nIndex
= infoPtr
->nNumButtons
;
3628 } else if (nIndex
< 0)
3631 /* If the string passed is not an index, assume address of string
3632 and do our own AddString */
3633 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3637 TRACE("string %s passed instead of index, adding string\n",
3638 debugstr_a((LPSTR
)lpTbb
->iString
));
3639 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3641 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3642 ptr
[len
- 1] = 0; /* ended by two '\0' */
3643 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3647 TRACE("inserting button index=%d\n", nIndex
);
3648 if (nIndex
> infoPtr
->nNumButtons
) {
3649 nIndex
= infoPtr
->nNumButtons
;
3650 TRACE("adjust index=%d\n", nIndex
);
3653 oldButtons
= infoPtr
->buttons
;
3654 infoPtr
->nNumButtons
++;
3655 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3656 /* pre insert copy */
3658 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3659 nIndex
* sizeof(TBUTTON_INFO
));
3662 /* insert new button */
3663 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3664 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3665 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3666 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3667 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3668 /* if passed string and not index, then add string */
3669 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3670 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3673 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3675 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3678 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3679 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3681 ti
.uId
= lpTbb
->idCommand
;
3683 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
3685 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
3689 /* post insert copy */
3690 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3691 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3692 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3697 TOOLBAR_CalcToolbar (hwnd
);
3699 InvalidateRect (hwnd
, NULL
, TRUE
);
3706 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3708 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3709 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3710 INT nIndex
= (INT
)wParam
;
3711 TBUTTON_INFO
*oldButtons
;
3716 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3719 /* EPP: this seems to be an undocumented call (from my IE4)
3720 * I assume in that case that:
3721 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3722 * - index of insertion is at the end of existing buttons
3723 * I only see this happen with nIndex == -1, but it could have a special
3724 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3726 nIndex
= infoPtr
->nNumButtons
;
3728 } else if (nIndex
< 0)
3731 /* If the string passed is not an index, assume address of string
3732 and do our own AddString */
3733 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3737 TRACE("string %s passed instead of index, adding string\n",
3738 debugstr_w((LPWSTR
)lpTbb
->iString
));
3739 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
3740 ptr
= Alloc(len
*sizeof(WCHAR
));
3741 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
3742 ptr
[len
- 1] = 0; /* ended by two '\0' */
3743 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
3747 TRACE("inserting button index=%d\n", nIndex
);
3748 if (nIndex
> infoPtr
->nNumButtons
) {
3749 nIndex
= infoPtr
->nNumButtons
;
3750 TRACE("adjust index=%d\n", nIndex
);
3753 oldButtons
= infoPtr
->buttons
;
3754 infoPtr
->nNumButtons
++;
3755 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3756 /* pre insert copy */
3758 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3759 nIndex
* sizeof(TBUTTON_INFO
));
3762 /* insert new button */
3763 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3764 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3765 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3766 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3767 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3768 /* if passed string and not index, then add string */
3769 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3770 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
3773 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3775 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3778 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
3779 ti
.cbSize
= sizeof (TTTOOLINFOW
);
3781 ti
.uId
= lpTbb
->idCommand
;
3783 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3785 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3789 /* post insert copy */
3790 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3791 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3792 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3797 TOOLBAR_CalcToolbar (hwnd
);
3799 InvalidateRect (hwnd
, NULL
, TRUE
);
3805 /* << TOOLBAR_InsertMarkHitTest >> */
3809 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3811 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3814 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3818 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
3823 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3825 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3828 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3832 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
3837 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3839 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3842 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3846 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
3851 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3853 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3856 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3860 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
3865 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3867 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3870 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3874 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
3879 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3881 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3884 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3888 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
3893 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3896 tbab
.hInst
= (HINSTANCE
)lParam
;
3897 tbab
.nID
= (UINT_PTR
)wParam
;
3899 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
3901 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
3906 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3908 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3909 WCHAR wAccel
= (WCHAR
)wParam
;
3910 UINT
* pIDButton
= (UINT
*)lParam
;
3911 WCHAR wszAccel
[] = {'&',wAccel
,0};
3914 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
3915 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
3917 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
3919 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
3920 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
3921 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
3923 int iLen
= strlenW(wszAccel
);
3924 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
3931 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
3936 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
3938 *pIDButton
= btnPtr
->idCommand
;
3950 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3952 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3955 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
3957 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3962 infoPtr
->buttons
[nIndex
].fsState
|= TBSTATE_MARKED
;
3964 infoPtr
->buttons
[nIndex
].fsState
&= ~TBSTATE_MARKED
;
3970 /* fixes up an index of a button affected by a move */
3971 inline static void TOOLBAR_MoveFixupIndex(INT
* pIndex
, INT nIndex
, INT nMoveIndex
, BOOL bMoveUp
)
3975 if (*pIndex
> nIndex
&& *pIndex
<= nMoveIndex
)
3977 else if (*pIndex
== nIndex
)
3978 *pIndex
= nMoveIndex
;
3982 if (*pIndex
>= nMoveIndex
&& *pIndex
< nIndex
)
3984 else if (*pIndex
== nIndex
)
3985 *pIndex
= nMoveIndex
;
3991 TOOLBAR_MoveButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3993 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3996 INT nMoveIndex
= (INT
)lParam
;
3997 TBUTTON_INFO button
;
3999 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4001 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, TRUE
);
4002 if ((nIndex
== -1) || (nMoveIndex
< 0))
4005 if (nMoveIndex
> infoPtr
->nNumButtons
- 1)
4006 nMoveIndex
= infoPtr
->nNumButtons
- 1;
4008 button
= infoPtr
->buttons
[nIndex
];
4010 /* move button right */
4011 if (nIndex
< nMoveIndex
)
4013 nCount
= nMoveIndex
- nIndex
;
4014 memmove(&infoPtr
->buttons
[nIndex
], &infoPtr
->buttons
[nIndex
+1], nCount
*sizeof(TBUTTON_INFO
));
4015 infoPtr
->buttons
[nMoveIndex
] = button
;
4017 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, TRUE
);
4018 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, TRUE
);
4019 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, TRUE
);
4020 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, TRUE
);
4022 else if (nIndex
> nMoveIndex
) /* move button left */
4024 nCount
= nIndex
- nMoveIndex
;
4025 memmove(&infoPtr
->buttons
[nMoveIndex
+1], &infoPtr
->buttons
[nMoveIndex
], nCount
*sizeof(TBUTTON_INFO
));
4026 infoPtr
->buttons
[nMoveIndex
] = button
;
4028 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, FALSE
);
4029 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, FALSE
);
4030 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, FALSE
);
4031 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, FALSE
);
4034 TOOLBAR_CalcToolbar(hwnd
);
4035 InvalidateRect(hwnd
, NULL
, TRUE
);
4042 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4044 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4045 TBUTTON_INFO
*btnPtr
;
4049 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4053 btnPtr
= &infoPtr
->buttons
[nIndex
];
4054 oldState
= btnPtr
->fsState
;
4055 if (LOWORD(lParam
) == FALSE
)
4056 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4058 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4060 if(oldState
!= btnPtr
->fsState
)
4061 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4066 /* FIXME: there might still be some confusion her between number of buttons
4067 * and number of bitmaps */
4069 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4071 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4072 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
4074 int i
= 0, nOldButtons
= 0, pos
= 0;
4075 int nOldBitmaps
, nNewBitmaps
;
4076 HIMAGELIST himlDef
= 0;
4078 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
4079 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
4080 lpReplace
->nButtons
);
4082 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4084 FIXME("changing standard bitmaps not implemented\n");
4087 else if (lpReplace
->hInstOld
!= 0)
4089 FIXME("resources not in the current module not implemented\n");
4094 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4097 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4098 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4099 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4100 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4101 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4103 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4104 nOldButtons
= tbi
->nButtons
;
4105 tbi
->nButtons
= lpReplace
->nButtons
;
4106 tbi
->hInst
= lpReplace
->hInstNew
;
4107 tbi
->nID
= lpReplace
->nIDNew
;
4108 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4111 pos
+= tbi
->nButtons
;
4114 if (nOldButtons
== 0)
4116 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4120 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4121 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4123 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4125 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4126 ImageList_Remove(himlDef
, i
);
4130 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4131 HDC hdcImage
, hdcBitmap
;
4133 /* copy the bitmap before adding it so that the user's bitmap
4134 * doesn't get modified.
4136 GetObjectA (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4138 hdcImage
= CreateCompatibleDC(0);
4139 hdcBitmap
= CreateCompatibleDC(0);
4141 /* create new bitmap */
4142 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4143 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4144 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4146 /* Copy the user's image */
4147 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4148 hdcBitmap
, 0, 0, SRCCOPY
);
4150 SelectObject (hdcImage
, hOldBitmapLoad
);
4151 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4152 DeleteDC (hdcImage
);
4153 DeleteDC (hdcBitmap
);
4155 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4156 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4157 DeleteObject (hbmLoad
);
4160 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4162 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4163 pos
, nOldBitmaps
, nNewBitmaps
);
4165 InvalidateRect(hwnd
, NULL
, TRUE
);
4171 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4174 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4175 LPTBSAVEPARAMSA lpSave
= (LPTBSAVEPARAMSA
)lParam
;
4177 if (lpSave
== NULL
) return 0;
4180 /* save toolbar information */
4181 FIXME("save to \"%s\" \"%s\"\n",
4182 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4187 /* restore toolbar information */
4189 FIXME("restore from \"%s\" \"%s\"\n",
4190 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4201 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4204 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4205 LPTBSAVEPARAMSW lpSave
= (LPTBSAVEPARAMSW
)lParam
;
4211 /* save toolbar information */
4212 FIXME("save to \"%s\" \"%s\"\n",
4213 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4218 /* restore toolbar information */
4220 FIXME("restore from \"%s\" \"%s\"\n",
4221 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4232 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4234 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4235 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4237 infoPtr
->bAnchor
= (BOOL
)wParam
;
4239 return (LRESULT
)bOldAnchor
;
4244 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4246 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4247 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4249 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4252 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4254 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4257 if (infoPtr
->nNumButtons
> 0)
4258 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4259 infoPtr
->nNumButtons
,
4260 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4261 LOWORD(lParam
), HIWORD(lParam
));
4263 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4264 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4267 if ((himlDef
== infoPtr
->himlInt
) &&
4268 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4270 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4271 infoPtr
->nBitmapHeight
);
4279 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4281 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4282 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4283 TBUTTON_INFO
*btnPtr
;
4289 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4292 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4293 lptbbi
->dwMask
& 0x80000000);
4297 btnPtr
= &infoPtr
->buttons
[nIndex
];
4298 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4299 btnPtr
->idCommand
= lptbbi
->idCommand
;
4300 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4301 btnPtr
->iBitmap
= lptbbi
->iImage
;
4302 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4303 btnPtr
->dwData
= lptbbi
->lParam
;
4304 if (lptbbi
->dwMask
& TBIF_SIZE
)
4305 btnPtr
->cx
= lptbbi
->cx
;
4306 if (lptbbi
->dwMask
& TBIF_STATE
)
4307 btnPtr
->fsState
= lptbbi
->fsState
;
4308 if (lptbbi
->dwMask
& TBIF_STYLE
)
4309 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4311 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4312 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4313 /* iString is index, zero it to make Str_SetPtr succeed */
4316 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4319 /* save the button rect to see if we need to redraw the whole toolbar */
4320 oldBtnRect
= btnPtr
->rect
;
4321 TOOLBAR_CalcToolbar(hwnd
);
4323 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4324 InvalidateRect(hwnd
, NULL
, TRUE
);
4326 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4333 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4335 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4336 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4337 TBUTTON_INFO
*btnPtr
;
4343 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4346 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4347 lptbbi
->dwMask
& 0x80000000);
4351 btnPtr
= &infoPtr
->buttons
[nIndex
];
4352 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4353 btnPtr
->idCommand
= lptbbi
->idCommand
;
4354 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4355 btnPtr
->iBitmap
= lptbbi
->iImage
;
4356 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4357 btnPtr
->dwData
= lptbbi
->lParam
;
4358 if (lptbbi
->dwMask
& TBIF_SIZE
)
4359 btnPtr
->cx
= lptbbi
->cx
;
4360 if (lptbbi
->dwMask
& TBIF_STATE
)
4361 btnPtr
->fsState
= lptbbi
->fsState
;
4362 if (lptbbi
->dwMask
& TBIF_STYLE
)
4363 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4365 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4366 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4367 /* iString is index, zero it to make Str_SetPtr succeed */
4369 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4372 /* save the button rect to see if we need to redraw the whole toolbar */
4373 oldBtnRect
= btnPtr
->rect
;
4374 TOOLBAR_CalcToolbar(hwnd
);
4376 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4377 InvalidateRect(hwnd
, NULL
, TRUE
);
4379 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4386 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4388 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4389 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4391 if ((cx
< 0) || (cy
< 0))
4393 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4397 /* The documentation claims you can only change the button size before
4398 * any button has been added. But this is wrong.
4399 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4400 * it to the toolbar, and it checks that the return value is nonzero - mjm
4401 * Further testing shows that we must actually perform the change too.
4404 * The documentation also does not mention that if 0 is supplied for
4405 * either size, the system changes it to the default of 24 wide and
4406 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4408 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4409 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4415 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4417 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4419 if (infoPtr
== NULL
) {
4420 TRACE("Toolbar not initialized yet?????\n");
4424 /* if setting to current values, ignore */
4425 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4426 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4427 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4428 infoPtr
->cxMin
, infoPtr
->cxMax
);
4432 /* save new values */
4433 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4434 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4436 /* if both values are 0 then we are done */
4438 TRACE("setting both min and max to 0, norecalc\n");
4442 /* otherwise we need to recalc the toolbar and in some cases
4443 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4444 which doesn't actually draw - GA). */
4445 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4446 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4448 TOOLBAR_CalcToolbar (hwnd
);
4450 InvalidateRect (hwnd
, NULL
, TRUE
);
4457 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4459 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4460 INT nIndex
= (INT
)wParam
;
4462 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4465 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4467 if (infoPtr
->hwndToolTip
) {
4469 FIXME("change tool tip!\n");
4478 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4480 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4481 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4482 HIMAGELIST himlTemp
;
4485 if (infoPtr
->iVersion
>= 5)
4488 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4489 &infoPtr
->cimlDis
, himl
, id
);
4491 /* FIXME: redraw ? */
4493 return (LRESULT
)himlTemp
;
4498 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4500 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4503 dwTemp
= infoPtr
->dwDTFlags
;
4504 infoPtr
->dwDTFlags
=
4505 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4507 return (LRESULT
)dwTemp
;
4510 /* This function differs a bit from what MSDN says it does:
4511 * 1. lParam contains extended style flags to OR with current style
4512 * (MSDN isn't clear on the OR bit)
4513 * 2. wParam appears to contain extended style flags to be reset
4514 * (MSDN says that this parameter is reserved)
4517 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4519 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4522 dwTemp
= infoPtr
->dwExStyle
;
4523 infoPtr
->dwExStyle
&= ~wParam
;
4524 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4526 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4528 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4529 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4530 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4532 TOOLBAR_CalcToolbar (hwnd
);
4534 TOOLBAR_AutoSize(hwnd
);
4536 InvalidateRect(hwnd
, NULL
, TRUE
);
4538 return (LRESULT
)dwTemp
;
4543 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4545 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4546 HIMAGELIST himlTemp
;
4547 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4550 if (infoPtr
->iVersion
>= 5)
4553 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
4555 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
4556 &infoPtr
->cimlHot
, himl
, id
);
4558 /* FIXME: redraw ? */
4560 return (LRESULT
)himlTemp
;
4564 /* Makes previous hot button no longer hot, makes the specified
4565 * button hot and sends appropriate notifications. dwReason is one or
4566 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
4567 * NOTE 1: this function does not validate nHit
4568 * NOTE 2: the name of this function is completely made up and
4569 * not based on any documentation from Microsoft. */
4571 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
4573 if (infoPtr
->nHotItem
!= nHit
)
4575 NMTBHOTITEM nmhotitem
;
4576 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
4577 LRESULT no_highlight
;
4579 /* Remove the effect of an old hot button if the button was
4580 drawn with the hot button effect */
4581 if(infoPtr
->nHotItem
>= 0)
4583 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
4584 oldBtnPtr
->bHot
= FALSE
;
4587 infoPtr
->nHotItem
= nHit
;
4589 /* It's not a separator or in nowhere. It's a hot button. */
4591 btnPtr
= &infoPtr
->buttons
[nHit
];
4593 nmhotitem
.dwFlags
= dwReason
;
4595 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
4597 nmhotitem
.dwFlags
|= HICF_ENTERING
;
4599 nmhotitem
.idNew
= btnPtr
->idCommand
;
4601 nmhotitem
.dwFlags
|= HICF_LEAVING
;
4603 no_highlight
= TOOLBAR_SendNotify((NMHDR
*)&nmhotitem
, infoPtr
, TBN_HOTITEMCHANGE
);
4605 /* now invalidate the old and new buttons so they will be painted */
4607 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
4608 if (btnPtr
&& !no_highlight
)
4610 btnPtr
->bHot
= TRUE
;
4611 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
4617 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
4619 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4620 INT nOldHotItem
= infoPtr
->nHotItem
;
4622 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4625 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
4626 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
4628 if (nOldHotItem
< 0)
4631 return (LRESULT
)nOldHotItem
;
4636 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4638 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4639 HIMAGELIST himlTemp
;
4640 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4643 if (infoPtr
->iVersion
>= 5)
4646 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
4647 &infoPtr
->cimlDef
, himl
, id
);
4649 infoPtr
->nNumBitmaps
= 0;
4650 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
4651 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
4653 ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
4654 &infoPtr
->nBitmapHeight
);
4655 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4656 hwnd
, (INT
)infoPtr
->himlDef
, infoPtr
->nNumBitmaps
,
4657 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
4659 InvalidateRect(hwnd
, NULL
, TRUE
);
4661 return (LRESULT
)himlTemp
;
4666 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4668 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4670 infoPtr
->nIndent
= (INT
)wParam
;
4674 /* process only on indent changing */
4675 if(infoPtr
->nIndent
!= (INT
)wParam
)
4677 infoPtr
->nIndent
= (INT
)wParam
;
4678 TOOLBAR_CalcToolbar (hwnd
);
4679 InvalidateRect(hwnd
, NULL
, FALSE
);
4686 /* << TOOLBAR_SetInsertMark >> */
4690 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4692 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4694 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
4696 /* FIXME : redraw ??*/
4703 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4705 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4707 if (infoPtr
== NULL
)
4710 infoPtr
->nMaxTextRows
= (INT
)wParam
;
4712 TOOLBAR_CalcToolbar(hwnd
);
4717 /* MSDN gives slightly wrong info on padding.
4718 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
4719 * 2. It is not used to create a blank area between the edge of the button
4720 * and the text or image if TBSTYLE_LIST is set. It is used to control
4721 * the gap between the image and text.
4722 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
4723 * to control the bottom and right borders [with the border being
4724 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
4725 * is shared evenly on both sides of the button.
4728 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4730 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4733 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4734 infoPtr
->szPadding
.cx
= LOWORD((DWORD
)lParam
);
4735 infoPtr
->szPadding
.cy
= HIWORD((DWORD
)lParam
);
4736 TRACE("cx=%ld, cy=%ld\n",
4737 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4738 return (LRESULT
) oldPad
;
4743 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4745 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4750 if (infoPtr
== NULL
)
4752 hwndOldNotify
= infoPtr
->hwndNotify
;
4753 infoPtr
->hwndNotify
= (HWND
)wParam
;
4755 return (LRESULT
)hwndOldNotify
;
4760 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4762 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4763 LPRECT lprc
= (LPRECT
)lParam
;
4767 if (LOWORD(wParam
) > 1) {
4768 FIXME("multiple rows not supported!\n");
4771 if(infoPtr
->nRows
!= LOWORD(wParam
))
4773 infoPtr
->nRows
= LOWORD(wParam
);
4775 /* recalculate toolbar */
4776 TOOLBAR_CalcToolbar (hwnd
);
4778 /* repaint toolbar */
4779 InvalidateRect(hwnd
, NULL
, TRUE
);
4782 /* return bounding rectangle */
4784 lprc
->left
= infoPtr
->rcBound
.left
;
4785 lprc
->right
= infoPtr
->rcBound
.right
;
4786 lprc
->top
= infoPtr
->rcBound
.top
;
4787 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
4795 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4797 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4798 TBUTTON_INFO
*btnPtr
;
4801 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4805 btnPtr
= &infoPtr
->buttons
[nIndex
];
4807 /* if hidden state has changed the invalidate entire window and recalc */
4808 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
4809 btnPtr
->fsState
= LOWORD(lParam
);
4810 TOOLBAR_CalcToolbar (hwnd
);
4811 InvalidateRect(hwnd
, 0, TRUE
);
4815 /* process state changing if current state doesn't match new state */
4816 if(btnPtr
->fsState
!= LOWORD(lParam
))
4818 btnPtr
->fsState
= LOWORD(lParam
);
4819 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4827 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4829 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
4835 inline static LRESULT
4836 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4838 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4840 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
4842 if (infoPtr
== NULL
)
4844 infoPtr
->hwndToolTip
= (HWND
)wParam
;
4850 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4852 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4855 TRACE("%s hwnd=%p stub!\n",
4856 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
4858 bTemp
= infoPtr
->bUnicode
;
4859 infoPtr
->bUnicode
= (BOOL
)wParam
;
4866 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4868 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4870 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
4871 comctl32_color
.clrBtnHighlight
:
4872 infoPtr
->clrBtnHighlight
;
4873 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
4874 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
4880 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4882 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4884 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4885 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
4886 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
4888 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
4889 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
4890 InvalidateRect(hwnd
, NULL
, TRUE
);
4896 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
4898 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4899 INT iOldVersion
= infoPtr
->iVersion
;
4901 infoPtr
->iVersion
= iVersion
;
4903 if (infoPtr
->iVersion
>= 5)
4904 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
4911 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4913 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4914 WORD iString
= HIWORD(wParam
);
4915 WORD buffersize
= LOWORD(wParam
);
4916 LPSTR str
= (LPSTR
)lParam
;
4919 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
4921 if (iString
< infoPtr
->nNumStrings
)
4923 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
4925 TRACE("returning %s\n", debugstr_a(str
));
4928 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
4935 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4937 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4938 WORD iString
= HIWORD(wParam
);
4939 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
4940 LPWSTR str
= (LPWSTR
)lParam
;
4943 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
4945 if (iString
< infoPtr
->nNumStrings
)
4947 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
4948 ret
= (len
+1)*sizeof(WCHAR
);
4949 memcpy(str
, infoPtr
->strings
[iString
], ret
);
4952 TRACE("returning %s\n", debugstr_w(str
));
4955 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
4960 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
4961 * is the maximum size of the toolbar? */
4962 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4964 SIZE
* pSize
= (SIZE
*)lParam
;
4965 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
4970 /* UNDOCUMENTED MESSAGE: This is an extended version of the
4971 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
4972 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
4975 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4977 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4978 INT nOldHotItem
= infoPtr
->nHotItem
;
4980 TRACE("old item=%d, new item=%d, flags=%08lx\n",
4981 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
4983 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4986 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
4990 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
4993 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
4994 * which controls the amount of spacing between the image and the text
4995 * of buttons for TBSTYLE_LIST toolbars. */
4996 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4998 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5000 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
5003 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
5005 infoPtr
->iListGap
= (INT
)wParam
;
5007 TOOLBAR_CalcToolbar(hwnd
);
5008 InvalidateRect(hwnd
, NULL
, TRUE
);
5013 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
5014 * of image lists associated with the various states. */
5015 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5017 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5019 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5021 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
5025 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5027 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5028 LPSIZE lpsize
= (LPSIZE
)lParam
;
5034 * Testing shows the following:
5035 * wParam = 0 adjust cx value
5036 * = 1 set cy value to max size.
5037 * lParam pointer to SIZE structure
5040 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
5041 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
5045 if (lpsize
->cx
== -1) {
5046 /* **** this is wrong, native measures each button and sets it */
5047 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5049 else if(HIWORD(lpsize
->cx
)) {
5051 HWND hwndParent
= GetParent(hwnd
);
5053 GetWindowRect(hwnd
, &rc
);
5054 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
5055 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
5056 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5057 lpsize
->cx
= max(rc
.right
-rc
.left
,
5058 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
5061 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5065 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5066 /* lpsize->cy = infoPtr->nHeight; */
5069 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
5073 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
5074 lpsize
->cx
, lpsize
->cy
);
5078 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5080 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5082 InvalidateRect(hwnd
, NULL
, TRUE
);
5088 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5090 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5091 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
5094 TRACE("hwnd = %p\n", hwnd
);
5096 /* initialize info structure */
5097 infoPtr
->nButtonHeight
= 22;
5098 infoPtr
->nButtonWidth
= 24;
5099 infoPtr
->nBitmapHeight
= 15;
5100 infoPtr
->nBitmapWidth
= 16;
5102 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5103 infoPtr
->nMaxTextRows
= 1;
5104 infoPtr
->cxMin
= -1;
5105 infoPtr
->cxMax
= -1;
5106 infoPtr
->nNumBitmaps
= 0;
5107 infoPtr
->nNumStrings
= 0;
5109 infoPtr
->bCaptured
= FALSE
;
5110 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
5111 infoPtr
->nButtonDown
= -1;
5112 infoPtr
->nButtonDrag
= -1;
5113 infoPtr
->nOldHit
= -1;
5114 infoPtr
->nHotItem
= -1;
5115 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5116 infoPtr
->bTransparent
= (dwStyle
& TBSTYLE_TRANSPARENT
);
5117 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5118 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
: DT_CENTER
;
5119 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5120 infoPtr
->iVersion
= 0;
5121 infoPtr
->hwndSelf
= hwnd
;
5122 infoPtr
->bDoRedraw
= TRUE
;
5123 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5124 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5125 /* not sure where the +1 comes from, but this comes to the same value
5126 * as native so this is probably correct */
5127 infoPtr
->szPadding
.cx
= 2*(GetSystemMetrics(SM_CXEDGE
)+OFFSET_X
) + 1;
5128 infoPtr
->szPadding
.cy
= 2*(GetSystemMetrics(SM_CYEDGE
)+OFFSET_Y
);
5129 infoPtr
->iListGap
= infoPtr
->szPadding
.cx
/ 2;
5130 infoPtr
->dwStyle
= dwStyle
;
5131 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5132 TOOLBAR_NotifyFormat(infoPtr
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
);
5134 SystemParametersInfoA (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5135 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectA (&logFont
);
5137 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5138 /* Create tooltip control */
5139 infoPtr
->hwndToolTip
=
5140 CreateWindowExA (0, TOOLTIPS_CLASSA
, NULL
, 0,
5141 CW_USEDEFAULT
, CW_USEDEFAULT
,
5142 CW_USEDEFAULT
, CW_USEDEFAULT
,
5145 /* Send NM_TOOLTIPSCREATED notification */
5146 if (infoPtr
->hwndToolTip
) {
5147 NMTOOLTIPSCREATED nmttc
;
5149 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5151 TOOLBAR_SendNotify ((NMHDR
*) &nmttc
, infoPtr
,
5152 NM_TOOLTIPSCREATED
);
5156 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5158 TOOLBAR_CalcToolbar(hwnd
);
5165 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5167 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5169 /* delete tooltip control */
5170 if (infoPtr
->hwndToolTip
)
5171 DestroyWindow (infoPtr
->hwndToolTip
);
5173 /* delete temporary buffer for tooltip text */
5174 if (infoPtr
->pszTooltipText
)
5175 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5177 /* delete button data */
5178 if (infoPtr
->buttons
)
5179 Free (infoPtr
->buttons
);
5181 /* delete strings */
5182 if (infoPtr
->strings
) {
5184 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5185 if (infoPtr
->strings
[i
])
5186 Free (infoPtr
->strings
[i
]);
5188 Free (infoPtr
->strings
);
5191 /* destroy internal image list */
5192 if (infoPtr
->himlInt
)
5193 ImageList_Destroy (infoPtr
->himlInt
);
5195 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5196 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5197 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5199 /* delete default font */
5201 DeleteObject (infoPtr
->hDefaultFont
);
5203 /* free toolbar info data */
5205 SetWindowLongPtrW (hwnd
, 0, 0);
5212 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5214 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5215 NMTBCUSTOMDRAW tbcd
;
5219 if (infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) {
5220 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5221 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5222 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5223 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5224 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5226 /* FIXME: in general the return flags *can* be or'ed together */
5227 switch (infoPtr
->dwBaseCustDraw
)
5229 case CDRF_DODEFAULT
:
5231 case CDRF_SKIPDEFAULT
:
5234 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5239 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5240 * to my parent for processing.
5242 if (infoPtr
->bTransparent
) {
5244 HDC hdc
= (HDC
)wParam
;
5249 parent
= GetParent(hwnd
);
5250 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5251 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5252 ret
= SendMessageA (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5253 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5256 ret
= DefWindowProcA (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5258 if ((infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5259 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5260 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5261 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5262 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5263 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5264 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5265 switch (infoPtr
->dwBaseCustDraw
)
5267 case CDRF_DODEFAULT
:
5269 case CDRF_SKIPDEFAULT
:
5272 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5281 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5283 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5285 return (LRESULT
)infoPtr
->hFont
;
5290 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5295 pt
.x
= (INT
)LOWORD(lParam
);
5296 pt
.y
= (INT
)HIWORD(lParam
);
5297 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5300 TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5301 else if (GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5302 TOOLBAR_Customize (hwnd
);
5309 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5311 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5312 TBUTTON_INFO
*btnPtr
;
5316 BOOL bDragKeyPressed
;
5318 if (infoPtr
->dwStyle
& TBSTYLE_ALTDRAG
)
5319 bDragKeyPressed
= (GetKeyState(VK_MENU
) < 0);
5321 bDragKeyPressed
= (wParam
& MK_SHIFT
);
5323 if (infoPtr
->hwndToolTip
)
5324 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5325 WM_LBUTTONDOWN
, wParam
, lParam
);
5327 pt
.x
= (INT
)LOWORD(lParam
);
5328 pt
.y
= (INT
)HIWORD(lParam
);
5329 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5331 btnPtr
= &infoPtr
->buttons
[nHit
];
5333 if ((nHit
>= 0) && bDragKeyPressed
&& (infoPtr
->dwStyle
& CCS_ADJUSTABLE
))
5335 infoPtr
->nButtonDrag
= nHit
;
5338 /* If drag cursor has not been loaded, load it.
5339 * Note: it doesn't need to be freed */
5341 hCursorDrag
= LoadCursorW(COMCTL32_hModule
, (LPCWSTR
)IDC_MOVEBUTTON
);
5342 SetCursor(hCursorDrag
);
5347 infoPtr
->nOldHit
= nHit
;
5349 CopyRect(&arrowRect
, &btnPtr
->rect
);
5350 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5352 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5353 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5354 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5355 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5356 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5357 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5361 /* draw in pressed state */
5362 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5363 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5364 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5366 nmtb
.iItem
= btnPtr
->idCommand
;
5367 memset(&nmtb
.tbButton
, 0, sizeof(TBBUTTON
));
5370 CopyRect(&nmtb
.rcButton
, &btnPtr
->rect
);
5371 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5373 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5375 if (res
!= TBDDRET_TREATPRESSED
)
5379 /* redraw button in unpressed state */
5380 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5381 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5383 /* find and set hot item
5384 * NOTE: native doesn't do this, but that is a bug */
5386 ScreenToClient(hwnd
, &pt
);
5387 nHit
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5388 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5390 /* remove any left mouse button down messages so that we can
5391 * get a toggle effect on the button */
5392 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
))
5397 /* otherwise drop through and process as pushed */
5399 infoPtr
->bCaptured
= TRUE
;
5400 infoPtr
->nButtonDown
= nHit
;
5402 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5404 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5406 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5407 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5414 nmtb
.iItem
= btnPtr
->idCommand
;
5415 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
5416 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
5417 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
5418 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
5419 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
5420 nmtb
.tbButton
.iString
= btnPtr
->iString
;
5421 nmtb
.cchText
= 0; /* !!! not correct */
5422 nmtb
.pszText
= 0; /* !!! not correct */
5423 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_BEGINDRAG
);
5430 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5432 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5433 TBUTTON_INFO
*btnPtr
;
5437 BOOL bSendMessage
= TRUE
;
5442 if (infoPtr
->hwndToolTip
)
5443 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5444 WM_LBUTTONUP
, wParam
, lParam
);
5446 pt
.x
= (INT
)LOWORD(lParam
);
5447 pt
.y
= (INT
)HIWORD(lParam
);
5448 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5450 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5452 if (infoPtr
->nButtonDrag
>= 0) {
5456 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDrag
];
5459 SetCursor(LoadCursorW(NULL
, (LPCWSTR
)IDC_ARROW
));
5461 GetClientRect(hwnd
, &rcClient
);
5462 if (PtInRect(&rcClient
, pt
))
5469 else if ((nHit
== -1) && PtInRect(&infoPtr
->buttons
[-nHit
].rect
, pt
))
5472 if (nButton
== infoPtr
->nButtonDrag
)
5474 /* if the button is moved sightly left and we have a
5475 * separator there then remove it */
5476 if (pt
.x
< (btnPtr
->rect
.left
+ (btnPtr
->rect
.right
- btnPtr
->rect
.left
)/2))
5478 if ((nButton
> 0) && (infoPtr
->buttons
[nButton
-1].fsStyle
& BTNS_SEP
))
5479 TOOLBAR_DeleteButton(hwnd
, nButton
- 1, 0);
5481 else /* else insert a separator before the dragged button */
5484 memset(&tbb
, 0, sizeof(tbb
));
5485 tbb
.fsStyle
= BTNS_SEP
;
5487 TOOLBAR_InsertButtonW(hwnd
, nButton
, (LPARAM
)&tbb
);
5494 if ((infoPtr
->nNumButtons
> 0) && (pt
.x
< infoPtr
->buttons
[0].rect
.left
))
5495 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, 0);
5497 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, infoPtr
->nNumButtons
);
5500 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, nButton
);
5505 TRACE("button %d dragged out of toolbar\n", infoPtr
->nButtonDrag
);
5506 TOOLBAR_DeleteButton(hwnd
, (WPARAM
)infoPtr
->nButtonDrag
, 0);
5509 /* button under cursor changed so need to re-set hot item */
5510 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5511 infoPtr
->nButtonDrag
= -1;
5513 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
5515 else if (infoPtr
->nButtonDown
>= 0) {
5516 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5517 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5519 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
5520 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
5521 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
5523 if (nOldIndex
== nHit
)
5524 bSendMessage
= FALSE
;
5525 if ((nOldIndex
!= nHit
) &&
5527 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
5528 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5531 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
5532 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
5534 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5538 if (nOldIndex
!= -1)
5539 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
5542 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5543 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5544 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5546 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
5548 infoPtr
->nButtonDown
= -1;
5550 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5551 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
5552 NM_RELEASEDCAPTURE
);
5554 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5557 nmtb
.iItem
= btnPtr
->idCommand
;
5558 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
5559 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
5560 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
5561 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
5562 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
5563 nmtb
.tbButton
.iString
= btnPtr
->iString
;
5564 nmtb
.cchText
= 0; /* !!! not correct */
5565 nmtb
.pszText
= 0; /* !!! not correct */
5566 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5569 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5571 SendMessageA (infoPtr
->hwndNotify
, WM_COMMAND
,
5572 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
5574 /* !!! Undocumented - toolbar at 4.71 level and above sends
5575 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
5576 * Only NM_RCLICK is documented.
5578 nmmouse
.dwItemSpec
= btnPtr
->idCommand
;
5579 nmmouse
.dwItemData
= btnPtr
->dwData
;
5580 TOOLBAR_SendNotify ((NMHDR
*) &nmmouse
, infoPtr
, NM_CLICK
);
5587 TOOLBAR_CaptureChanged(HWND hwnd
)
5589 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5590 TBUTTON_INFO
*btnPtr
;
5592 infoPtr
->bCaptured
= FALSE
;
5594 if (infoPtr
->nButtonDown
>= 0)
5596 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5597 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5599 infoPtr
->nOldHit
= -1;
5601 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5602 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5608 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5610 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5611 TBUTTON_INFO
*hotBtnPtr
, *btnPtr
;
5614 TOOLBAR_SetHotItemEx(infoPtr
, -1, HICF_MOUSE
);
5616 if (infoPtr
->nOldHit
< 0)
5619 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
5621 /* If the last button we were over is depressed then make it not */
5622 /* depressed and redraw it */
5623 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
5625 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5627 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5629 rc1
= hotBtnPtr
->rect
;
5630 InflateRect (&rc1
, 1, 1);
5631 InvalidateRect (hwnd
, &rc1
, TRUE
);
5634 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
5640 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5642 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5644 TRACKMOUSEEVENT trackinfo
;
5646 TBUTTON_INFO
*btnPtr
;
5648 /* fill in the TRACKMOUSEEVENT struct */
5649 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
5650 trackinfo
.dwFlags
= TME_QUERY
;
5651 trackinfo
.hwndTrack
= hwnd
;
5652 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
5654 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
5655 _TrackMouseEvent(&trackinfo
);
5657 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
5658 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
5659 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
5661 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
5662 /* and can properly deactivate the hot toolbar button */
5663 _TrackMouseEvent(&trackinfo
);
5666 if (infoPtr
->hwndToolTip
)
5667 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5668 WM_MOUSEMOVE
, wParam
, lParam
);
5670 pt
.x
= (INT
)LOWORD(lParam
);
5671 pt
.y
= (INT
)HIWORD(lParam
);
5673 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5675 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
5677 if (infoPtr
->nOldHit
!= nHit
)
5679 if (infoPtr
->bCaptured
)
5681 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5682 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
5683 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5684 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5686 else if (nHit
== infoPtr
->nButtonDown
) {
5687 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5688 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5690 infoPtr
->nOldHit
= nHit
;
5698 inline static LRESULT
5699 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5701 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
5702 return DefWindowProcA (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
5704 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
5708 inline static LRESULT
5709 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5711 if (!(GetWindowLongW(hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
5712 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
5714 return DefWindowProcA (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
5719 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5721 TOOLBAR_INFO
*infoPtr
;
5722 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
5725 /* allocate memory for info structure */
5726 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
5727 SetWindowLongPtrW (hwnd
, 0, (LONG_PTR
)infoPtr
);
5730 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
5733 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5734 if (!GetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
)) {
5735 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW (GetParent (hwnd
), GWLP_HINSTANCE
);
5736 SetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
, (LONG_PTR
)hInst
);
5739 /* native control does:
5740 * Get a lot of colors and brushes
5742 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5743 * CreateFontIndirectA(adr1)
5744 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5745 * hdc = GetDC(toolbar)
5746 * GetSystemMetrics(0x48)
5747 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5748 * 0, 0, 0, 0, "MARLETT")
5749 * oldfnt = SelectObject(hdc, fnt2)
5750 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5751 * GetTextMetricsA(hdc, adr3)
5752 * SelectObject(hdc, oldfnt)
5753 * DeleteObject(fnt2)
5755 * InvalidateRect(toolbar, 0, 1)
5756 * SetWindowLongA(toolbar, 0, addr)
5757 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5760 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5761 * ie 2 0x4600094c 0x4600094c 0x4600894d
5762 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5763 * rebar 0x50008844 0x40008844 0x50008845
5764 * pager 0x50000844 0x40000844 0x50008845
5765 * IC35mgr 0x5400084e **nochange**
5766 * on entry to _NCCREATE 0x5400084e
5767 * rowlist 0x5400004e **nochange**
5768 * on entry to _NCCREATE 0x5400004e
5772 /* I think the code below is a bug, but it is the way that the native
5773 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5774 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5775 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5776 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5777 * Some how, the only cases of this seem to be MFC programs.
5779 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5780 * does not occur in the WM_STYLECHANGING routine.
5781 * (Guy Albertelli 9/2001)
5784 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
5785 styleadd
|= TBSTYLE_TRANSPARENT
;
5786 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
5787 styleadd
|= CCS_TOP
; /* default to top */
5788 SetWindowLongW (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
5791 return DefWindowProcA (hwnd
, WM_NCCREATE
, wParam
, lParam
);
5796 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5798 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
5802 if (dwStyle
& WS_MINIMIZE
)
5803 return 0; /* Nothing to do */
5805 DefWindowProcA (hwnd
, WM_NCPAINT
, wParam
, lParam
);
5807 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
5810 if (!(dwStyle
& CCS_NODIVIDER
))
5812 GetWindowRect (hwnd
, &rcWindow
);
5813 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
5814 if( dwStyle
& WS_BORDER
)
5815 OffsetRect (&rcWindow
, 1, 1);
5816 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
5819 ReleaseDC( hwnd
, hdc
);
5825 /* handles requests from the tooltip control on what text to display */
5826 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
5828 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
5830 TRACE("button index = %d\n", index
);
5832 if (infoPtr
->pszTooltipText
)
5834 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5835 infoPtr
->pszTooltipText
= NULL
;
5841 if (infoPtr
->bNtfUnicode
)
5843 WCHAR wszBuffer
[INFOTIPSIZE
+1];
5844 NMTBGETINFOTIPW tbgit
;
5845 int len
; /* in chars */
5847 wszBuffer
[0] = '\0';
5848 wszBuffer
[INFOTIPSIZE
] = '\0';
5850 tbgit
.pszText
= wszBuffer
;
5851 tbgit
.cchTextMax
= INFOTIPSIZE
;
5852 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
5853 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
5855 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
5857 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
5859 len
= strlenW(tbgit
.pszText
);
5860 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5862 /* need to allocate temporary buffer in infoPtr as there
5863 * isn't enough space in buffer passed to us by the
5864 * tooltip control */
5865 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5866 if (infoPtr
->pszTooltipText
)
5868 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
5869 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5875 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
5881 CHAR szBuffer
[INFOTIPSIZE
+1];
5882 NMTBGETINFOTIPA tbgit
;
5883 int len
; /* in chars */
5886 szBuffer
[INFOTIPSIZE
] = '\0';
5888 tbgit
.pszText
= szBuffer
;
5889 tbgit
.cchTextMax
= INFOTIPSIZE
;
5890 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
5891 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
5893 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
5895 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
5897 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
5898 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5900 /* need to allocate temporary buffer in infoPtr as there
5901 * isn't enough space in buffer passed to us by the
5902 * tooltip control */
5903 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5904 if (infoPtr
->pszTooltipText
)
5906 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
5907 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5913 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
5918 /* if button has text, but it is not shown then automatically
5919 * use that text as tooltip */
5920 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
5921 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
5923 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
5924 int len
= pszText
? strlenW(pszText
) : 0;
5926 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
5928 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5930 /* need to allocate temporary buffer in infoPtr as there
5931 * isn't enough space in buffer passed to us by the
5932 * tooltip control */
5933 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5934 if (infoPtr
->pszTooltipText
)
5936 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
5937 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5943 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
5948 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
5950 /* last resort: send notification on to app */
5951 /* FIXME: find out what is really used here */
5952 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
5956 inline static LRESULT
5957 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5959 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5960 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
5962 switch (lpnmh
->code
)
5966 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
5968 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
5969 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5970 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5974 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5975 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5983 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
5985 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
5986 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
5987 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
5988 lppgs
->iScroll
, lppgs
->iDir
);
5992 case TTN_GETDISPINFOW
:
5993 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
5995 case TTN_GETDISPINFOA
:
5996 FIXME("TTN_GETDISPINFOA - stub\n");
6006 TOOLBAR_NotifyFormatFake(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6008 /* remove this routine when Toolbar is improved to pass infoPtr
6009 * around instead of hwnd.
6011 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6012 return TOOLBAR_NotifyFormat(infoPtr
, wParam
, lParam
);
6017 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
6021 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
6023 if ((lParam
== NF_QUERY
) && ((HWND
)wParam
== infoPtr
->hwndToolTip
))
6026 if (lParam
== NF_REQUERY
) {
6027 i
= SendMessageA(infoPtr
->hwndNotify
,
6028 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
6029 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
6030 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
6034 infoPtr
->bNtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
6037 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
6042 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
6044 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6048 /* fill ps.rcPaint with a default rect */
6049 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
6051 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
6053 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
6054 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
6055 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
6057 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
6058 if (!wParam
) EndPaint (hwnd
, &ps
);
6065 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6066 /*****************************************************
6069 * Handles the WM_SETREDRAW message.
6072 * According to testing V4.71 of COMCTL32 returns the
6073 * *previous* status of the redraw flag (either 0 or 1)
6074 * instead of the MSDN documented value of 0 if handled.
6075 * (For laughs see the "consistency" with same function
6078 *****************************************************/
6080 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6081 BOOL oldredraw
= infoPtr
->bDoRedraw
;
6083 TRACE("set to %s\n",
6084 (wParam
) ? "TRUE" : "FALSE");
6085 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
6087 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
6089 return (oldredraw
) ? 1 : 0;
6094 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6096 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6097 DWORD dwStyle
= infoPtr
->dwStyle
;
6106 /* Resize deadlock check */
6107 if (infoPtr
->bAutoSize
) {
6108 infoPtr
->bAutoSize
= FALSE
;
6112 /* FIXME: optimize to only update size if the new size doesn't */
6113 /* match the current size */
6115 flags
= (INT
) wParam
;
6117 /* FIXME for flags =
6118 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
6121 TRACE("sizing toolbar!\n");
6123 if (flags
== SIZE_RESTORED
) {
6124 /* width and height don't apply */
6125 parent
= GetParent (hwnd
);
6126 GetClientRect(parent
, &parent_rect
);
6127 x
= parent_rect
.left
;
6128 y
= parent_rect
.top
;
6130 if (dwStyle
& CCS_NORESIZE
) {
6131 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
6134 * this sets the working width of the toolbar, and
6135 * Calc Toolbar will not adjust it, only the height
6137 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6138 cy
= infoPtr
->nHeight
;
6139 cx
= infoPtr
->nWidth
;
6140 TOOLBAR_CalcToolbar (hwnd
);
6141 infoPtr
->nWidth
= cx
;
6142 infoPtr
->nHeight
= cy
;
6145 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6146 TOOLBAR_CalcToolbar (hwnd
);
6147 cy
= infoPtr
->nHeight
;
6148 cx
= infoPtr
->nWidth
;
6150 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
6151 GetWindowRect(hwnd
, &window_rect
);
6152 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
6153 y
= window_rect
.top
;
6155 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6156 GetWindowRect(hwnd
, &window_rect
);
6157 y
= parent_rect
.bottom
-
6158 ( window_rect
.bottom
- window_rect
.top
);
6162 if (dwStyle
& CCS_NOPARENTALIGN
) {
6163 uPosFlags
|= SWP_NOMOVE
;
6164 cy
= infoPtr
->nHeight
;
6165 cx
= infoPtr
->nWidth
;
6168 if (!(dwStyle
& CCS_NODIVIDER
))
6169 cy
+= GetSystemMetrics(SM_CYEDGE
);
6171 if (dwStyle
& WS_BORDER
)
6174 cy
+= GetSystemMetrics(SM_CYEDGE
);
6175 cx
+= GetSystemMetrics(SM_CYEDGE
);
6178 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6180 RECT delta_width
, delta_height
, client
, dummy
;
6181 DWORD min_x
, max_x
, min_y
, max_y
;
6182 TBUTTON_INFO
*btnPtr
;
6185 GetClientRect(hwnd
, &client
);
6186 if(client
.right
> infoPtr
->client_rect
.right
)
6188 min_x
= infoPtr
->client_rect
.right
;
6189 max_x
= client
.right
;
6193 max_x
= infoPtr
->client_rect
.right
;
6194 min_x
= client
.right
;
6196 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6198 min_y
= infoPtr
->client_rect
.bottom
;
6199 max_y
= client
.bottom
;
6203 max_y
= infoPtr
->client_rect
.bottom
;
6204 min_y
= client
.bottom
;
6207 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6208 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6210 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6211 btnPtr
= infoPtr
->buttons
;
6212 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6213 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6214 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6215 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6218 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) != (SWP_NOSIZE
| SWP_NOMOVE
))
6219 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6221 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6227 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6229 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6231 if (nType
== GWL_STYLE
) {
6232 if (lpStyle
->styleNew
& TBSTYLE_LIST
) {
6233 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
;
6236 infoPtr
->dwDTFlags
= DT_CENTER
;
6238 infoPtr
->bTransparent
= (lpStyle
->styleNew
& TBSTYLE_TRANSPARENT
);
6239 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6240 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6241 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6243 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6245 infoPtr
->dwStyle
= lpStyle
->styleNew
;
6248 TOOLBAR_CalcToolbar(hwnd
);
6250 TOOLBAR_AutoSize (hwnd
);
6252 InvalidateRect(hwnd
, NULL
, TRUE
);
6259 TOOLBAR_SysColorChange (HWND hwnd
)
6261 COMCTL32_RefreshSysColors();
6268 static LRESULT WINAPI
6269 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6271 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6273 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6274 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6276 if (!TOOLBAR_GetInfoPtr(hwnd
) && (uMsg
!= WM_NCCREATE
))
6277 return DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
6282 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6284 case TB_ADDBUTTONSA
:
6285 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6287 case TB_ADDBUTTONSW
:
6288 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6291 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6294 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6297 return TOOLBAR_AutoSize (hwnd
);
6299 case TB_BUTTONCOUNT
:
6300 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6302 case TB_BUTTONSTRUCTSIZE
:
6303 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6305 case TB_CHANGEBITMAP
:
6306 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6308 case TB_CHECKBUTTON
:
6309 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6311 case TB_COMMANDTOINDEX
:
6312 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6315 return TOOLBAR_Customize (hwnd
);
6317 case TB_DELETEBUTTON
:
6318 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6320 case TB_ENABLEBUTTON
:
6321 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6323 case TB_GETANCHORHIGHLIGHT
:
6324 return TOOLBAR_GetAnchorHighlight (hwnd
);
6327 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6329 case TB_GETBITMAPFLAGS
:
6330 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6333 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6335 case TB_GETBUTTONINFOA
:
6336 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6338 case TB_GETBUTTONINFOW
:
6339 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6341 case TB_GETBUTTONSIZE
:
6342 return TOOLBAR_GetButtonSize (hwnd
);
6344 case TB_GETBUTTONTEXTA
:
6345 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6347 case TB_GETBUTTONTEXTW
:
6348 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6350 case TB_GETDISABLEDIMAGELIST
:
6351 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6353 case TB_GETEXTENDEDSTYLE
:
6354 return TOOLBAR_GetExtendedStyle (hwnd
);
6356 case TB_GETHOTIMAGELIST
:
6357 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6360 return TOOLBAR_GetHotItem (hwnd
);
6362 case TB_GETIMAGELIST
:
6363 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6365 /* case TB_GETINSERTMARK: */ /* 4.71 */
6366 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
6368 case TB_GETITEMRECT
:
6369 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6372 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6374 /* case TB_GETOBJECT: */ /* 4.71 */
6377 return TOOLBAR_GetPadding (hwnd
);
6380 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6383 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6386 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6389 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6392 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6395 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6397 case TB_GETTEXTROWS
:
6398 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6400 case TB_GETTOOLTIPS
:
6401 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6403 case TB_GETUNICODEFORMAT
:
6404 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6407 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6410 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6412 case TB_INDETERMINATE
:
6413 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6415 case TB_INSERTBUTTONA
:
6416 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6418 case TB_INSERTBUTTONW
:
6419 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6421 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6423 case TB_ISBUTTONCHECKED
:
6424 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6426 case TB_ISBUTTONENABLED
:
6427 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6429 case TB_ISBUTTONHIDDEN
:
6430 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
6432 case TB_ISBUTTONHIGHLIGHTED
:
6433 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
6435 case TB_ISBUTTONINDETERMINATE
:
6436 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
6438 case TB_ISBUTTONPRESSED
:
6439 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
6442 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
6444 case TB_MAPACCELERATORA
:
6445 case TB_MAPACCELERATORW
:
6446 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
6449 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
6452 return TOOLBAR_MoveButton (hwnd
, wParam
, lParam
);
6454 case TB_PRESSBUTTON
:
6455 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
6457 case TB_REPLACEBITMAP
:
6458 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
6460 case TB_SAVERESTOREA
:
6461 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, lParam
);
6463 case TB_SAVERESTOREW
:
6464 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, lParam
);
6466 case TB_SETANCHORHIGHLIGHT
:
6467 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
6469 case TB_SETBITMAPSIZE
:
6470 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
6472 case TB_SETBUTTONINFOA
:
6473 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
6475 case TB_SETBUTTONINFOW
:
6476 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
6478 case TB_SETBUTTONSIZE
:
6479 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
6481 case TB_SETBUTTONWIDTH
:
6482 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
6485 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
6487 case TB_SETDISABLEDIMAGELIST
:
6488 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
6490 case TB_SETDRAWTEXTFLAGS
:
6491 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
6493 case TB_SETEXTENDEDSTYLE
:
6494 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
6496 case TB_SETHOTIMAGELIST
:
6497 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
6500 return TOOLBAR_SetHotItem (hwnd
, wParam
);
6502 case TB_SETIMAGELIST
:
6503 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
6506 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
6508 /* case TB_SETINSERTMARK: */ /* 4.71 */
6510 case TB_SETINSERTMARKCOLOR
:
6511 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
6513 case TB_SETMAXTEXTROWS
:
6514 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
6517 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
6520 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
6523 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
6526 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
6529 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
6531 case TB_SETTOOLTIPS
:
6532 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
6534 case TB_SETUNICODEFORMAT
:
6535 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
6538 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
6541 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
6544 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
6547 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
6550 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
6553 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
6555 /* Common Control Messages */
6557 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
6558 case CCM_GETCOLORSCHEME
:
6559 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
6561 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
6562 case CCM_SETCOLORSCHEME
:
6563 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
6565 case CCM_GETVERSION
:
6566 return TOOLBAR_GetVersion (hwnd
);
6568 case CCM_SETVERSION
:
6569 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
6575 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
6578 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
6581 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
6584 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
6586 /* case WM_KEYDOWN: */
6587 /* case WM_KILLFOCUS: */
6589 case WM_LBUTTONDBLCLK
:
6590 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
6592 case WM_LBUTTONDOWN
:
6593 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
6596 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
6599 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
6602 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
6604 case WM_CAPTURECHANGED
:
6605 return TOOLBAR_CaptureChanged(hwnd
);
6608 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
6611 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
6614 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
6617 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
6620 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
6622 case WM_NOTIFYFORMAT
:
6623 return TOOLBAR_NotifyFormatFake (hwnd
, wParam
, lParam
);
6626 return TOOLBAR_Paint (hwnd
, wParam
);
6629 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
6632 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
6634 case WM_STYLECHANGED
:
6635 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
6637 case WM_SYSCOLORCHANGE
:
6638 return TOOLBAR_SysColorChange (hwnd
);
6640 /* case WM_WININICHANGE: */
6645 case WM_MEASUREITEM
:
6647 return SendMessageA (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
6649 /* We see this in Outlook Express 5.x and just does DefWindowProc */
6650 case PGM_FORWARDMOUSE
:
6651 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
6654 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
6655 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
6656 uMsg
, wParam
, lParam
);
6657 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
6664 TOOLBAR_Register (void)
6668 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
6669 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
6670 wndClass
.lpfnWndProc
= (WNDPROC
)ToolbarWindowProc
;
6671 wndClass
.cbClsExtra
= 0;
6672 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
6673 wndClass
.hCursor
= LoadCursorA (0, (LPSTR
)IDC_ARROW
);
6674 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
6675 wndClass
.lpszClassName
= TOOLBARCLASSNAMEA
;
6677 RegisterClassA (&wndClass
);
6682 TOOLBAR_Unregister (void)
6684 UnregisterClassA (TOOLBARCLASSNAMEA
, NULL
);
6687 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
6692 /* Check if the entry already exists */
6693 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
6695 /* If this is a new entry we must create it and insert into the array */
6700 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
6703 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
6704 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
6719 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
6723 for (i
= 0; i
< *cies
; i
++)
6733 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
6741 for (i
= 0; i
< cies
; i
++)
6743 if (pies
[i
]->id
== id
)
6755 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
6757 HIMAGELIST himlDef
= 0;
6758 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
6761 himlDef
= pie
->himl
;
6767 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
6769 if (infoPtr
->bUnicode
)
6770 return TOOLBAR_SendNotify ((NMHDR
*) nmtb
, infoPtr
, TBN_GETBUTTONINFOW
);
6777 nmtba
.iItem
= nmtb
->iItem
;
6778 nmtba
.pszText
= Buffer
;
6779 nmtba
.cchText
= 256;
6780 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
6782 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtba
, infoPtr
, TBN_GETBUTTONINFOA
))
6784 int ccht
= strlen(nmtba
.pszText
);
6786 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
6787 nmtb
->pszText
, nmtb
->cchText
);
6789 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
6798 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
6799 int iItem
, PCUSTOMBUTTON btnInfo
)
6804 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
6806 return TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYDELETE
);