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
58 * - Button wrapping (under construction).
60 * - iListGap custom draw support.
61 * - Customization dialog:
62 * - Minor buglet in 'available buttons' list:
63 * Buttons are not listed in MS-like order. MS seems to use a single
64 * internal list to store the button information of both listboxes.
65 * - Drag list support.
68 * - Run tests using Waite Group Windows95 API Bible Volume 2.
69 * The second cdrom contains executables addstr.exe, btncount.exe,
70 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
71 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
72 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
73 * setparnt.exe, setrows.exe, toolwnd.exe.
74 * - Microsofts controlspy examples.
75 * - Charles Petzold's 'Programming Windows': gadgets.exe
85 #include "wine/unicode.h"
89 #include "wine/debug.h"
91 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
93 static HCURSOR hCursorDrag
= NULL
;
102 BYTE bDropDownPressed
;
107 INT cx
; /* manually set size */
121 } IMLENTRY
, *PIMLENTRY
;
125 DWORD dwStructSize
; /* size of TBBUTTON struct */
126 INT nHeight
; /* height of the toolbar */
127 INT nWidth
; /* width of the toolbar */
134 INT nRows
; /* number of button rows */
135 INT nMaxTextRows
; /* maximum number of text rows */
136 INT cxMin
; /* minimum button width */
137 INT cxMax
; /* maximum button width */
138 INT nNumButtons
; /* number of buttons */
139 INT nNumBitmaps
; /* number of bitmaps */
140 INT nNumStrings
; /* number of strings */
142 BOOL bUnicode
; /* ASCII (FALSE) or Unicode (TRUE)? */
143 BOOL bCaptured
; /* mouse captured? */
144 INT nButtonDown
; /* toolbar button being pressed or -1 if none */
145 INT nButtonDrag
; /* toolbar button being dragged or -1 if none */
147 INT nHotItem
; /* index of the "hot" item */
148 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
149 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
150 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
151 SIZE szPadding
; /* padding values around button */
152 INT iListGap
; /* default gap between text and image for toolbar with list style */
154 HFONT hFont
; /* text font */
155 HIMAGELIST himlInt
; /* image list created internally */
156 PIMLENTRY
*himlDef
; /* default image list array */
157 INT cimlDef
; /* default image list array count */
158 PIMLENTRY
*himlHot
; /* hot image list array */
159 INT cimlHot
; /* hot image list array count */
160 PIMLENTRY
*himlDis
; /* disabled image list array */
161 INT cimlDis
; /* disabled image list array count */
162 HWND hwndToolTip
; /* handle to tool tip control */
163 HWND hwndNotify
; /* handle to the window that gets notifications */
164 HWND hwndSelf
; /* my own handle */
165 BOOL bBtnTranspnt
; /* button transparency flag */
166 BOOL bAutoSize
; /* auto size deadlock indicator */
167 BOOL bAnchor
; /* anchor highlight enabled */
168 BOOL bNtfUnicode
; /* TRUE if NOTIFYs use {W} */
169 BOOL bDoRedraw
; /* Redraw status */
170 BOOL bDragOutSent
; /* has TBN_DRAGOUT notification been sent for this drag? */
171 DWORD dwStyle
; /* regular toolbar style */
172 DWORD dwExStyle
; /* extended toolbar style */
173 DWORD dwDTFlags
; /* DrawText flags */
175 COLORREF clrInsertMark
; /* insert mark color */
176 COLORREF clrBtnHighlight
; /* color for Flat Separator */
177 COLORREF clrBtnShadow
; /* color for Flag Separator */
178 RECT rcBound
; /* bounding rectangle */
180 LPWSTR pszTooltipText
; /* temporary store for a string > 80 characters
181 * for TTN_GETDISPINFOW notification */
182 TBUTTON_INFO
*buttons
; /* pointer to button array */
183 LPWSTR
*strings
; /* pointer to string array */
184 TBITMAP_INFO
*bitmaps
;
185 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
188 /* used by customization dialog */
191 PTOOLBAR_INFO tbInfo
;
193 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
201 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
210 #define SEPARATOR_WIDTH 8
212 #define BOTTOM_BORDER 2
213 #define DDARROW_WIDTH 11
214 #define ARROW_HEIGHT 3
216 /* gap between border of button and text/image */
219 /* how wide to treat the bitmap if it isn't present */
220 #define LIST_IMAGE_ABSENT_WIDTH 2
222 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongPtrW(hwnd,0))
223 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
224 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
226 static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO
*infoPtr
, INT iListGap
)
228 return GetSystemMetrics(SM_CXEDGE
) + iListGap
- infoPtr
->szPadding
.cx
/2;
231 /* Used to find undocumented extended styles */
232 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
233 TBSTYLE_EX_UNDOC1 | \
234 TBSTYLE_EX_MIXEDBUTTONS | \
235 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
237 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
238 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
239 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
240 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
241 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
243 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
);
244 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
, int iItem
, PCUSTOMBUTTON btnInfo
);
245 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
);
246 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
);
247 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
);
248 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
);
249 static LRESULT
TOOLBAR_LButtonDown(HWND hwnd
, WPARAM wParam
, LPARAM lParam
);
252 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
256 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
258 LPWSTR lpText
= NULL
;
260 /* NOTE: iString == -1 is undocumented */
261 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
262 lpText
= (LPWSTR
)btnPtr
->iString
;
263 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
264 lpText
= infoPtr
->strings
[btnPtr
->iString
];
270 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
272 if (TRACE_ON(toolbar
)){
273 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
274 btn_num
, bP
->idCommand
, GETIBITMAP(infoPtr
, bP
->iBitmap
),
275 bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
276 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
278 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
279 btn_num
, bP
->idCommand
,
280 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
281 bP
->rect
.left
, bP
->rect
.top
,
282 bP
->rect
.right
, bP
->rect
.bottom
);
288 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
290 if (TRACE_ON(toolbar
)) {
293 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
295 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
296 iP
->nNumStrings
, iP
->dwStyle
);
297 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
299 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
300 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
301 for(i
=0; i
<iP
->nNumButtons
; i
++) {
302 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
308 /***********************************************************************
311 * This function validates that the styles set are implemented and
312 * issues FIXME's warning of possible problems. In a perfect world this
313 * function should be null.
316 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
318 if (dwStyle
& TBSTYLE_REGISTERDROP
)
319 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd
);
324 TOOLBAR_SendNotify (NMHDR
*nmhdr
, TOOLBAR_INFO
*infoPtr
, UINT code
)
326 if(!IsWindow(infoPtr
->hwndSelf
))
327 return 0; /* we have just been destroyed */
329 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
330 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
333 TRACE("to window %p, code=%08x, %s\n", infoPtr
->hwndNotify
, code
,
334 (infoPtr
->bNtfUnicode
) ? "via Unicode" : "via ANSI");
336 if (infoPtr
->bNtfUnicode
)
337 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
338 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
340 return SendMessageA (infoPtr
->hwndNotify
, WM_NOTIFY
,
341 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
344 /***********************************************************************
345 * TOOLBAR_GetBitmapIndex
347 * This function returns the bitmap index associated with a button.
348 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
349 * is issued to retrieve the index.
352 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
354 INT ret
= btnPtr
->iBitmap
;
356 if (ret
== I_IMAGECALLBACK
) {
357 /* issue TBN_GETDISPINFO */
360 nmgd
.idCommand
= btnPtr
->idCommand
;
361 nmgd
.lParam
= btnPtr
->dwData
;
362 nmgd
.dwMask
= TBNF_IMAGE
;
363 TOOLBAR_SendNotify ((NMHDR
*) &nmgd
, infoPtr
,
364 (infoPtr
->bNtfUnicode
) ? TBN_GETDISPINFOW
:
366 if (nmgd
.dwMask
& TBNF_DI_SETITEM
) {
367 btnPtr
->iBitmap
= nmgd
.iImage
;
370 TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
371 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
374 if (ret
!= I_IMAGENONE
)
375 ret
= GETIBITMAP(infoPtr
, ret
);
382 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
385 INT id
= GETHIMLID(infoPtr
, index
);
386 INT iBitmap
= GETIBITMAP(infoPtr
, index
);
388 if (((himl
= GETDEFIMAGELIST(infoPtr
, id
)) &&
389 iBitmap
>= 0 && iBitmap
< ImageList_GetImageCount(himl
)) ||
390 (index
== I_IMAGECALLBACK
))
397 /***********************************************************************
398 * TOOLBAR_GetImageListForDrawing
400 * This function validates the bitmap index (including I_IMAGECALLBACK
401 * functionality) and returns the corresponding image list.
404 TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, IMAGE_LIST_TYPE imagelist
, INT
* index
)
408 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
409 if (btnPtr
->iBitmap
== I_IMAGENONE
) return NULL
;
410 ERR("index %d,%d is not valid, max %d\n",
411 HIWORD(btnPtr
->iBitmap
), LOWORD(btnPtr
->iBitmap
), infoPtr
->nNumBitmaps
);
415 if ((*index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
416 if ((*index
== I_IMAGECALLBACK
) ||
417 (*index
== I_IMAGENONE
)) return NULL
;
418 ERR("TBN_GETDISPINFO returned invalid index %d\n",
425 case IMAGE_LIST_DEFAULT
:
426 himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
429 himl
= GETHOTIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
431 case IMAGE_LIST_DISABLED
:
432 himl
= GETDISIMAGELIST(infoPtr
, GETHIMLID(infoPtr
, btnPtr
->iBitmap
));
436 FIXME("Shouldn't reach here\n");
440 TRACE("no image list\n");
446 /***********************************************************************
447 * TOOLBAR_TestImageExist
449 * This function is similar to TOOLBAR_GetImageListForDrawing, except it does not
450 * return the image list. The I_IMAGECALLBACK functionality is implemented.
453 TOOLBAR_TestImageExist (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
)
457 if (!himl
) return FALSE
;
459 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
460 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
461 ERR("index %d is not valid, max %d\n",
462 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
466 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
467 if ((index
== I_IMAGECALLBACK
) ||
468 (index
== I_IMAGENONE
)) return FALSE
;
469 ERR("TBN_GETDISPINFO returned invalid index %d\n",
478 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
481 COLORREF oldcolor
, newcolor
;
483 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
484 myrect
.right
= myrect
.left
+ 1;
485 myrect
.top
= lpRect
->top
+ 2;
486 myrect
.bottom
= lpRect
->bottom
- 2;
488 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
489 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
490 oldcolor
= SetBkColor (hdc
, newcolor
);
491 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
493 myrect
.left
= myrect
.right
;
494 myrect
.right
= myrect
.left
+ 1;
496 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
497 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
498 SetBkColor (hdc
, newcolor
);
499 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
501 SetBkColor (hdc
, oldcolor
);
505 /***********************************************************************
506 * TOOLBAR_DrawDDFlatSeparator
508 * This function draws the separator that was flagged as BTNS_DROPDOWN.
509 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
510 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
511 * are horizontal as opposed to the vertical separators for not dropdown
514 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
517 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
520 COLORREF oldcolor
, newcolor
;
522 myrect
.left
= lpRect
->left
;
523 myrect
.right
= lpRect
->right
;
524 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
525 myrect
.bottom
= myrect
.top
+ 1;
527 InflateRect (&myrect
, -2, 0);
529 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
530 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
532 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
533 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
534 oldcolor
= SetBkColor (hdc
, newcolor
);
535 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
537 myrect
.top
= myrect
.bottom
;
538 myrect
.bottom
= myrect
.top
+ 1;
540 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
541 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
542 SetBkColor (hdc
, newcolor
);
543 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
545 SetBkColor (hdc
, oldcolor
);
550 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, COLORREF clr
)
555 if (!(hPen
= CreatePen( PS_SOLID
, 1, clr
))) return;
556 hOldPen
= SelectObject ( hdc
, hPen
);
559 MoveToEx (hdc
, x
, y
, NULL
);
560 LineTo (hdc
, x
+5, y
++); x
++;
561 MoveToEx (hdc
, x
, y
, NULL
);
562 LineTo (hdc
, x
+3, y
++); x
++;
563 MoveToEx (hdc
, x
, y
, NULL
);
564 LineTo (hdc
, x
+1, y
++);
565 SelectObject( hdc
, hOldPen
);
566 DeleteObject( hPen
);
570 * Draw the text string for this button.
571 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
572 * is non-zero, so we can simply check himlDef to see if we have
576 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, RECT
*rcText
, LPWSTR lpText
,
577 NMTBCUSTOMDRAW
*tbcd
)
579 HDC hdc
= tbcd
->nmcd
.hdc
;
582 COLORREF clrOldBk
= 0;
584 UINT state
= tbcd
->nmcd
.uItemState
;
588 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText
),
589 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
591 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
592 if ((state
& CDIS_HOT
) && (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
593 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
595 else if (state
& CDIS_DISABLED
) {
596 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
597 OffsetRect (rcText
, 1, 1);
598 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
599 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
600 OffsetRect (rcText
, -1, -1);
602 else if (state
& CDIS_INDETERMINATE
) {
603 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
605 else if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
)) {
606 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
607 clrOldBk
= SetBkColor (hdc
, tbcd
->clrMark
);
608 oldBkMode
= SetBkMode (hdc
, OPAQUE
); /* FIXME: should this be in the NMTBCUSTOMDRAW structure? */
611 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
614 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
615 SetTextColor (hdc
, clrOld
);
616 if ((state
& CDIS_MARKED
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
))
618 SetBkColor (hdc
, clrOldBk
);
619 SetBkMode (hdc
, oldBkMode
);
621 SelectObject (hdc
, hOldFont
);
627 TOOLBAR_DrawPattern (LPRECT lpRect
, NMTBCUSTOMDRAW
*tbcd
)
629 HDC hdc
= tbcd
->nmcd
.hdc
;
630 HBRUSH hbr
= SelectObject (hdc
, tbcd
->hbrMonoDither
);
633 INT cx
= lpRect
->right
- lpRect
->left
;
634 INT cy
= lpRect
->bottom
- lpRect
->top
;
635 clrTextOld
= SetTextColor(hdc
, tbcd
->clrBtnHighlight
);
636 clrBkOld
= SetBkColor(hdc
, tbcd
->clrBtnFace
);
637 PatBlt (hdc
, lpRect
->left
, lpRect
->top
, cx
, cy
, PATCOPY
);
638 SetBkColor(hdc
, clrBkOld
);
639 SetTextColor(hdc
, clrTextOld
);
640 SelectObject (hdc
, hbr
);
644 static void TOOLBAR_DrawMasked(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
645 HDC hdc
, INT x
, INT y
)
649 TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
654 HBITMAP hbmMask
, hbmImage
;
655 HDC hdcMask
, hdcImage
;
657 ImageList_GetIconSize(himl
, &cx
, &cy
);
659 /* Create src image */
660 hdcImage
= CreateCompatibleDC(hdc
);
661 hbmImage
= CreateBitmap(cx
, cy
, GetDeviceCaps(hdc
,PLANES
),
662 GetDeviceCaps(hdc
,BITSPIXEL
), NULL
);
663 SelectObject(hdcImage
, hbmImage
);
664 ImageList_DrawEx(himl
, index
, hdcImage
, 0, 0, cx
, cy
,
665 RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_NORMAL
);
668 hdcMask
= CreateCompatibleDC(0);
669 hbmMask
= CreateBitmap(cx
, cy
, 1, 1, NULL
);
670 SelectObject(hdcMask
, hbmMask
);
672 /* Remove the background and all white pixels */
673 SetBkColor(hdcImage
, ImageList_GetBkColor(himl
));
674 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, SRCCOPY
);
675 SetBkColor(hdcImage
, RGB(0xff, 0xff, 0xff));
676 BitBlt(hdcMask
, 0, 0, cx
, cy
, hdcImage
, 0, 0, NOTSRCERASE
);
678 /* draw the new mask 'etched' to hdc */
679 SetBkColor(hdc
, RGB(255, 255, 255));
680 SelectObject(hdc
, GetSysColorBrush(COLOR_3DHILIGHT
));
681 /* E20746 op code is (Dst ^ (Src & (Pat ^ Dst))) */
682 BitBlt(hdc
, x
+ 1, y
+ 1, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
683 SelectObject(hdc
, GetSysColorBrush(COLOR_3DSHADOW
));
684 BitBlt(hdc
, x
, y
, cx
, cy
, hdcMask
, 0, 0, 0xE20746);
687 DeleteObject(hbmImage
);
689 DeleteObject (hbmMask
);
696 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
700 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
701 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
702 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
703 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
704 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
705 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
706 /* NOTE: we don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
710 /* draws the image on a toolbar button */
712 TOOLBAR_DrawImage(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, INT left
, INT top
, const NMTBCUSTOMDRAW
*tbcd
)
714 HIMAGELIST himl
= NULL
;
715 BOOL draw_masked
= FALSE
;
718 UINT draw_flags
= ILD_NORMAL
;
720 if (tbcd
->nmcd
.uItemState
& (CDIS_DISABLED
| CDIS_INDETERMINATE
))
722 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DISABLED
, &index
);
726 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && (infoPtr
->dwStyle
& TBSTYLE_FLAT
))
728 /* if hot, attempt to draw with hot image list, if fails,
729 use default image list */
730 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_HOT
, &index
);
732 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
735 himl
= TOOLBAR_GetImageListForDrawing(infoPtr
, btnPtr
, IMAGE_LIST_DEFAULT
, &index
);
737 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) &&
738 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
)))
741 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOMARK
) &&
742 (tbcd
->nmcd
.uItemState
& CDIS_MARKED
))
743 draw_flags
|= ILD_BLEND50
;
745 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, offset=%d\n",
746 index
, himl
, left
, top
, offset
);
749 TOOLBAR_DrawMasked (infoPtr
, btnPtr
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
);
751 ImageList_Draw (himl
, index
, tbcd
->nmcd
.hdc
, left
+ offset
, top
+ offset
, draw_flags
);
754 /* draws a blank frame for a toolbar button */
756 TOOLBAR_DrawFrame(const TOOLBAR_INFO
*infoPtr
, BOOL flat
, const NMTBCUSTOMDRAW
*tbcd
)
758 HDC hdc
= tbcd
->nmcd
.hdc
;
759 RECT rc
= tbcd
->nmcd
.rc
;
760 /* if the state is disabled or indeterminate then the button
761 * cannot have an interactive look like pressed or hot */
762 BOOL non_interactive_state
= (tbcd
->nmcd
.uItemState
& CDIS_DISABLED
) ||
763 (tbcd
->nmcd
.uItemState
& CDIS_INDETERMINATE
);
764 BOOL pressed_look
= !non_interactive_state
&&
765 ((tbcd
->nmcd
.uItemState
& CDIS_SELECTED
) ||
766 (tbcd
->nmcd
.uItemState
& CDIS_CHECKED
));
768 /* app don't want us to draw any edges */
769 if (infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
)
775 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
);
776 else if ((tbcd
->nmcd
.uItemState
& CDIS_HOT
) && !non_interactive_state
)
777 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
782 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
784 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
785 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
790 TOOLBAR_DrawSepDDArrow(const TOOLBAR_INFO
*infoPtr
, const NMTBCUSTOMDRAW
*tbcd
, RECT
*rcArrow
, BOOL bDropDownPressed
)
792 HDC hdc
= tbcd
->nmcd
.hdc
;
794 BOOL pressed
= bDropDownPressed
||
795 (tbcd
->nmcd
.uItemState
& (CDIS_SELECTED
| CDIS_CHECKED
));
797 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
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
);
809 DrawEdge (hdc
, rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
);
811 DrawEdge (hdc
, rcArrow
, EDGE_RAISED
,
812 BF_SOFT
| BF_RECT
| BF_MIDDLE
);
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
, &tbcd
, &rcArrow
, btnPtr
->bDropDownPressed
);
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 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
1815 /* insert separator button into 'available buttons' list */
1816 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1817 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1818 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1819 btnInfo
->bVirtual
= FALSE
;
1820 btnInfo
->bRemovable
= TRUE
;
1821 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1822 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1823 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1825 /* insert all buttons into dsa */
1828 /* send TBN_GETBUTTONINFO notification */
1831 nmtb
.pszText
= Buffer
;
1834 /* Clear previous button's text */
1835 ZeroMemory(nmtb
.pszText
, nmtb
.cchText
* sizeof(WCHAR
));
1837 if (!TOOLBAR_GetButtonInfo(infoPtr
, &nmtb
))
1840 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
1841 nmtb
.tbButton
.fsStyle
, i
,
1842 nmtb
.tbButton
.idCommand
,
1843 nmtb
.tbButton
.iString
,
1844 nmtb
.tbButton
.iString
>= 0 ? debugstr_w(infoPtr
->strings
[nmtb
.tbButton
.iString
])
1847 /* insert button into the apropriate list */
1848 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
1851 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1852 btnInfo
->bVirtual
= FALSE
;
1853 btnInfo
->bRemovable
= TRUE
;
1855 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1856 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
,
1857 LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1861 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
,
1862 IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1865 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
1866 if (!(nmtb
.tbButton
.fsStyle
& BTNS_SEP
))
1868 if (lstrlenW(nmtb
.pszText
))
1869 lstrcpyW(btnInfo
->text
, nmtb
.pszText
);
1870 else if (nmtb
.tbButton
.iString
>= 0 &&
1871 nmtb
.tbButton
.iString
< infoPtr
->nNumStrings
)
1873 lstrcpyW(btnInfo
->text
,
1874 infoPtr
->strings
[nmtb
.tbButton
.iString
]);
1879 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMHEIGHT
, 0, infoPtr
->nBitmapHeight
+ 8);
1881 /* select first item in the 'available' list */
1882 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
1884 /* append 'virtual' separator button to the 'toolbar buttons' list */
1885 btnInfo
= (PCUSTOMBUTTON
)Alloc(sizeof(CUSTOMBUTTON
));
1886 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1887 btnInfo
->btn
.fsStyle
= BTNS_SEP
;
1888 btnInfo
->bVirtual
= TRUE
;
1889 btnInfo
->bRemovable
= FALSE
;
1890 LoadStringW (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1891 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1892 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1894 /* select last item in the 'toolbar' list */
1895 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
1896 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
1898 /* set focus and disable buttons */
1899 PostMessageA (hwnd
, WM_USER
, 0, 0);
1904 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1905 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1906 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
1907 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
1911 EndDialog(hwnd
, FALSE
);
1915 switch (LOWORD(wParam
))
1917 case IDC_TOOLBARBTN_LBOX
:
1918 if (HIWORD(wParam
) == LBN_SELCHANGE
)
1920 PCUSTOMBUTTON btnInfo
;
1925 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1926 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1928 /* send TBN_QUERYINSERT notification */
1930 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1933 /* get list box item */
1934 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1936 if (index
== (count
- 1))
1938 /* last item (virtual separator) */
1939 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1940 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1942 else if (index
== (count
- 2))
1944 /* second last item (last non-virtual item) */
1945 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1946 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1948 else if (index
== 0)
1951 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1952 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1956 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1957 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1960 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
1964 case IDC_MOVEUP_BTN
:
1966 PCUSTOMBUTTON btnInfo
;
1970 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1971 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1972 TRACE("Move up: index %d\n", index
);
1974 /* send TBN_QUERYINSERT notification */
1977 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1982 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1984 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1985 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
-1, 0);
1986 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
-1, (LPARAM
)btnInfo
);
1987 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
1990 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1991 else if (index
>= (count
- 3))
1992 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1994 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1995 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
-1, (LPARAM
)&(btnInfo
->btn
));
1997 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2002 case IDC_MOVEDN_BTN
: /* move down */
2004 PCUSTOMBUTTON btnInfo
;
2008 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2009 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2010 TRACE("Move up: index %d\n", index
);
2012 /* send TBN_QUERYINSERT notification */
2014 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2019 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2021 /* move button down */
2022 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2023 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
+1, 0);
2024 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
+1, (LPARAM
)btnInfo
);
2025 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
+1 , 0);
2028 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
2029 else if (index
>= (count
- 3))
2030 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
2032 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2033 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
+1, (LPARAM
)&(btnInfo
->btn
));
2035 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2040 case IDC_REMOVE_BTN
: /* remove button */
2042 PCUSTOMBUTTON btnInfo
;
2045 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2047 if (LB_ERR
== index
)
2050 TRACE("Remove: index %d\n", index
);
2052 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
,
2053 LB_GETITEMDATA
, index
, 0);
2055 /* send TBN_QUERYDELETE notification */
2056 if (TOOLBAR_IsButtonRemovable(infoPtr
, index
, btnInfo
))
2060 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2061 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2062 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2064 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
2066 /* insert into 'available button' list */
2067 if (!(btnInfo
->btn
.fsStyle
& BTNS_SEP
))
2069 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
2070 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2075 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2080 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_CUSTHELP
);
2083 TOOLBAR_SendNotify(&nmtb
.hdr
, infoPtr
, TBN_RESET
);
2086 case IDOK
: /* Add button */
2091 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2092 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2093 TRACE("Add: index %d\n", index
);
2095 /* send TBN_QUERYINSERT notification */
2097 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
2102 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
2106 /* remove from 'available buttons' list */
2107 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_DELETESTRING
, index
, 0);
2108 if (index
== count
-1)
2109 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
2111 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
, 0);
2115 PCUSTOMBUTTON btnNew
;
2117 /* duplicate 'separator' button */
2118 btnNew
= (PCUSTOMBUTTON
)Alloc (sizeof(CUSTOMBUTTON
));
2119 memcpy (btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
2123 /* insert into 'toolbar button' list */
2124 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
2125 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
, 0);
2126 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
2128 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
, (LPARAM
)&(btnInfo
->btn
));
2130 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
2136 EndDialog(hwnd
, FALSE
);
2146 /* delete items from 'toolbar buttons' listbox*/
2147 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2148 for (i
= 0; i
< count
; i
++)
2150 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2152 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
2154 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2157 /* delete items from 'available buttons' listbox*/
2158 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
2159 for (i
= 0; i
< count
; i
++)
2161 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
2163 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
2165 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
2170 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2172 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
2177 COLORREF oldText
= 0;
2181 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
2182 if (btnInfo
== NULL
)
2184 FIXME("btnInfo invalid!\n");
2188 /* set colors and select objects */
2189 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
2190 if (btnInfo
->bVirtual
)
2191 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
2193 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
2194 hPen
= CreatePen( PS_SOLID
, 1,
2195 GetSysColor( (lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2196 hOldPen
= SelectObject (lpdis
->hDC
, hPen
);
2197 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2199 /* fill background rectangle */
2200 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2201 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2203 /* calculate button and text rectangles */
2204 CopyRect (&rcButton
, &lpdis
->rcItem
);
2205 InflateRect (&rcButton
, -1, -1);
2206 CopyRect (&rcText
, &rcButton
);
2207 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2208 rcText
.left
= rcButton
.right
+ 2;
2210 /* draw focus rectangle */
2211 if (lpdis
->itemState
& ODS_FOCUS
)
2212 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2215 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
2216 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2218 /* draw image and text */
2219 if ((btnInfo
->btn
.fsStyle
& BTNS_SEP
) == 0) {
2220 HIMAGELIST himl
= GETDEFIMAGELIST(infoPtr
, GETHIMLID(infoPtr
,
2221 btnInfo
->btn
.iBitmap
));
2222 ImageList_Draw (himl
, GETIBITMAP(infoPtr
, btnInfo
->btn
.iBitmap
),
2223 lpdis
->hDC
, rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2225 DrawTextW (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2226 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2228 /* delete objects and reset colors */
2229 SelectObject (lpdis
->hDC
, hOldBrush
);
2230 SelectObject (lpdis
->hDC
, hOldPen
);
2231 SetBkColor (lpdis
->hDC
, oldBk
);
2232 SetTextColor (lpdis
->hDC
, oldText
);
2233 DeleteObject( hPen
);
2238 case WM_MEASUREITEM
:
2239 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2241 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2243 lpmis
->itemHeight
= 15 + 8; /* default height */
2255 /***********************************************************************
2256 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2260 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2262 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2263 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2264 INT nIndex
= 0, nButtons
, nCount
;
2268 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2272 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2274 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2276 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2278 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2283 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2285 /* Windows resize all the buttons to the size of a newly added standard image */
2286 if (lpAddBmp
->nID
& 1)
2289 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2290 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2292 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2293 MAKELPARAM((WORD
)24, (WORD
)24));
2294 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2295 MAKELPARAM((WORD
)31, (WORD
)30));
2300 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2301 MAKELPARAM((WORD
)16, (WORD
)16));
2302 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2303 MAKELPARAM((WORD
)22, (WORD
)22));
2306 TOOLBAR_CalcToolbar (hwnd
);
2310 nButtons
= (INT
)wParam
;
2314 TRACE ("adding %d bitmaps!\n", nButtons
);
2317 if (!infoPtr
->cimlDef
) {
2318 /* create new default image list */
2319 TRACE ("creating default image list!\n");
2321 himlDef
= ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2322 ILC_COLORDDB
| ILC_MASK
, nButtons
, 2);
2323 TOOLBAR_InsertImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
, himlDef
, 0);
2324 infoPtr
->himlInt
= himlDef
;
2327 himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
2331 WARN("No default image list available\n");
2335 nCount
= ImageList_GetImageCount(himlDef
);
2337 /* Add bitmaps to the default image list */
2338 if (lpAddBmp
->hInst
== NULL
)
2341 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
;
2342 HDC hdcImage
, hdcBitmap
;
2344 /* copy the bitmap before adding it so that the user's bitmap
2345 * doesn't get modified.
2347 GetObjectA ((HBITMAP
)lpAddBmp
->nID
, sizeof(BITMAP
), (LPVOID
)&bmp
);
2349 hdcImage
= CreateCompatibleDC(0);
2350 hdcBitmap
= CreateCompatibleDC(0);
2352 /* create new bitmap */
2353 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
2354 hOldBitmapBitmap
= SelectObject(hdcBitmap
, (HBITMAP
)lpAddBmp
->nID
);
2355 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
2357 /* Copy the user's image */
2358 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
2359 hdcBitmap
, 0, 0, SRCCOPY
);
2361 SelectObject (hdcImage
, hOldBitmapLoad
);
2362 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
2363 DeleteDC (hdcImage
);
2364 DeleteDC (hdcBitmap
);
2366 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2367 DeleteObject (hbmLoad
);
2369 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2371 /* Add system bitmaps */
2372 switch (lpAddBmp
->nID
)
2374 case IDB_STD_SMALL_COLOR
:
2375 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2376 MAKEINTRESOURCEA(IDB_STD_SMALL
));
2377 nIndex
= ImageList_AddMasked (himlDef
,
2378 hbmLoad
, comctl32_color
.clrBtnFace
);
2379 DeleteObject (hbmLoad
);
2382 case IDB_STD_LARGE_COLOR
:
2383 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2384 MAKEINTRESOURCEA(IDB_STD_LARGE
));
2385 nIndex
= ImageList_AddMasked (himlDef
,
2386 hbmLoad
, comctl32_color
.clrBtnFace
);
2387 DeleteObject (hbmLoad
);
2390 case IDB_VIEW_SMALL_COLOR
:
2391 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2392 MAKEINTRESOURCEA(IDB_VIEW_SMALL
));
2393 nIndex
= ImageList_AddMasked (himlDef
,
2394 hbmLoad
, comctl32_color
.clrBtnFace
);
2395 DeleteObject (hbmLoad
);
2398 case IDB_VIEW_LARGE_COLOR
:
2399 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2400 MAKEINTRESOURCEA(IDB_VIEW_LARGE
));
2401 nIndex
= ImageList_AddMasked (himlDef
,
2402 hbmLoad
, comctl32_color
.clrBtnFace
);
2403 DeleteObject (hbmLoad
);
2406 case IDB_HIST_SMALL_COLOR
:
2407 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2408 MAKEINTRESOURCEA(IDB_HIST_SMALL
));
2409 nIndex
= ImageList_AddMasked (himlDef
,
2410 hbmLoad
, comctl32_color
.clrBtnFace
);
2411 DeleteObject (hbmLoad
);
2414 case IDB_HIST_LARGE_COLOR
:
2415 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2416 MAKEINTRESOURCEA(IDB_HIST_LARGE
));
2417 nIndex
= ImageList_AddMasked (himlDef
,
2418 hbmLoad
, comctl32_color
.clrBtnFace
);
2419 DeleteObject (hbmLoad
);
2423 nIndex
= ImageList_GetImageCount (himlDef
);
2424 ERR ("invalid imagelist!\n");
2430 hbmLoad
= LoadBitmapA (lpAddBmp
->hInst
, (LPSTR
)lpAddBmp
->nID
);
2431 nIndex
= ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
2432 DeleteObject (hbmLoad
);
2435 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2437 if (infoPtr
->nNumBitmapInfos
== 0)
2439 infoPtr
->bitmaps
= Alloc(sizeof(TBITMAP_INFO
));
2443 TBITMAP_INFO
*oldBitmaps
= infoPtr
->bitmaps
;
2444 infoPtr
->bitmaps
= Alloc((infoPtr
->nNumBitmapInfos
+ 1) * sizeof(TBITMAP_INFO
));
2445 memcpy(&infoPtr
->bitmaps
[0], &oldBitmaps
[0], infoPtr
->nNumBitmapInfos
);
2448 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nButtons
= nButtons
;
2449 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].hInst
= lpAddBmp
->hInst
;
2450 infoPtr
->bitmaps
[infoPtr
->nNumBitmapInfos
].nID
= lpAddBmp
->nID
;
2452 infoPtr
->nNumBitmapInfos
++;
2453 TRACE("Number of bitmap infos: %d\n", infoPtr
->nNumBitmapInfos
);
2457 INT imagecount
= ImageList_GetImageCount(himlDef
);
2459 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2461 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",
2462 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2463 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2465 infoPtr
->nNumBitmaps
= imagecount
;
2468 infoPtr
->nNumBitmaps
+= nButtons
;
2471 InvalidateRect(hwnd
, NULL
, TRUE
);
2478 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2480 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2481 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2482 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2484 TRACE("adding %d buttons!\n", wParam
);
2486 nAddButtons
= (UINT
)wParam
;
2487 nOldButtons
= infoPtr
->nNumButtons
;
2488 nNewButtons
= nOldButtons
+ nAddButtons
;
2490 if (infoPtr
->nNumButtons
== 0) {
2492 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2495 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2497 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2498 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2499 nOldButtons
* sizeof(TBUTTON_INFO
));
2503 infoPtr
->nNumButtons
= nNewButtons
;
2505 /* insert new button data */
2506 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2507 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2508 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2509 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2510 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2511 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2512 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2513 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2514 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, (LPSTR
)lpTbb
[nCount
].iString
);
2516 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2517 btnPtr
->bHot
= FALSE
;
2519 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2522 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
2523 ti
.cbSize
= sizeof (TTTOOLINFOA
);
2525 ti
.uId
= btnPtr
->idCommand
;
2527 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
2529 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
2534 TOOLBAR_CalcToolbar (hwnd
);
2536 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2538 InvalidateRect(hwnd
, NULL
, TRUE
);
2545 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2547 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2548 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2549 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2551 TRACE("adding %d buttons!\n", wParam
);
2553 nAddButtons
= (UINT
)wParam
;
2554 nOldButtons
= infoPtr
->nNumButtons
;
2555 nNewButtons
= nOldButtons
+ nAddButtons
;
2557 if (infoPtr
->nNumButtons
== 0) {
2559 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2562 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2564 Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2565 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2566 nOldButtons
* sizeof(TBUTTON_INFO
));
2570 infoPtr
->nNumButtons
= nNewButtons
;
2572 /* insert new button data */
2573 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2574 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2575 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2576 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2577 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2578 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2579 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2580 if(HIWORD(lpTbb
[nCount
].iString
) && lpTbb
[nCount
].iString
!= -1)
2581 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, (LPWSTR
)lpTbb
[nCount
].iString
);
2583 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2584 btnPtr
->bHot
= FALSE
;
2586 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& BTNS_SEP
)) {
2589 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2590 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2592 ti
.uId
= btnPtr
->idCommand
;
2594 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2597 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2602 TOOLBAR_CalcToolbar (hwnd
);
2604 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2606 InvalidateRect(hwnd
, NULL
, TRUE
);
2613 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2615 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2618 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2621 TRACE("adding string from resource!\n");
2623 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
,
2626 TRACE("len=%d \"%s\"\n", len
, szString
);
2627 nIndex
= infoPtr
->nNumStrings
;
2628 if (infoPtr
->nNumStrings
== 0) {
2630 Alloc (sizeof(LPWSTR
));
2633 LPWSTR
*oldStrings
= infoPtr
->strings
;
2635 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2636 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2637 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2641 /*Alloc zeros out the allocated memory*/
2642 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2643 infoPtr
->nNumStrings
++;
2646 LPSTR p
= (LPSTR
)lParam
;
2651 TRACE("adding string(s) from array!\n");
2653 nIndex
= infoPtr
->nNumStrings
;
2656 TRACE("len=%d \"%s\"\n", len
, p
);
2658 if (infoPtr
->nNumStrings
== 0) {
2660 Alloc (sizeof(LPWSTR
));
2663 LPWSTR
*oldStrings
= infoPtr
->strings
;
2665 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2666 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2667 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2671 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2672 infoPtr
->nNumStrings
++;
2683 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2685 #define MAX_RESOURCE_STRING_LENGTH 512
2686 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2689 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2690 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2692 TRACE("adding string from resource!\n");
2694 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2695 szString
, MAX_RESOURCE_STRING_LENGTH
);
2697 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2698 TRACE("First char: 0x%x\n", *szString
);
2699 if (szString
[0] == L
'|')
2701 PWSTR p
= szString
+ 1;
2703 nIndex
= infoPtr
->nNumStrings
;
2704 while (*p
!= L
'|' && *p
!= L
'\0') {
2707 if (infoPtr
->nNumStrings
== 0) {
2708 infoPtr
->strings
= Alloc (sizeof(LPWSTR
));
2712 LPWSTR
*oldStrings
= infoPtr
->strings
;
2713 infoPtr
->strings
= Alloc(sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2714 memcpy(&infoPtr
->strings
[0], &oldStrings
[0],
2715 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2719 np
=strchrW (p
, '|');
2727 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2728 infoPtr
->strings
[infoPtr
->nNumStrings
] =
2729 Alloc (sizeof(WCHAR
)*(len
+1));
2730 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
2731 infoPtr
->nNumStrings
++;
2738 nIndex
= infoPtr
->nNumStrings
;
2739 if (infoPtr
->nNumStrings
== 0) {
2741 Alloc (sizeof(LPWSTR
));
2744 LPWSTR
*oldStrings
= infoPtr
->strings
;
2746 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2747 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2748 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2752 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2753 infoPtr
->nNumStrings
++;
2757 LPWSTR p
= (LPWSTR
)lParam
;
2762 TRACE("adding string(s) from array!\n");
2763 nIndex
= infoPtr
->nNumStrings
;
2767 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2768 if (infoPtr
->nNumStrings
== 0) {
2770 Alloc (sizeof(LPWSTR
));
2773 LPWSTR
*oldStrings
= infoPtr
->strings
;
2775 Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2776 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2777 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2781 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2782 infoPtr
->nNumStrings
++;
2793 TOOLBAR_AutoSize (HWND hwnd
)
2795 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2801 UINT uPosFlags
= SWP_NOZORDER
;
2803 TRACE("resize forced, style=%lx!\n", infoPtr
->dwStyle
);
2805 parent
= GetParent (hwnd
);
2806 GetClientRect(parent
, &parent_rect
);
2808 x
= parent_rect
.left
;
2809 y
= parent_rect
.top
;
2811 /* FIXME: we should be able to early out if nothing */
2812 /* has changed with nWidth != parent_rect width */
2814 if (infoPtr
->dwStyle
& CCS_NORESIZE
) {
2815 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
2818 TOOLBAR_CalcToolbar (hwnd
);
2821 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
2822 TOOLBAR_CalcToolbar (hwnd
);
2823 InvalidateRect( hwnd
, NULL
, TRUE
);
2824 cy
= infoPtr
->nHeight
;
2825 cx
= infoPtr
->nWidth
;
2827 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
2828 GetWindowRect(hwnd
, &window_rect
);
2829 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
2830 y
= window_rect
.top
;
2832 if ((infoPtr
->dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
2833 GetWindowRect(hwnd
, &window_rect
);
2834 y
= parent_rect
.bottom
- ( window_rect
.bottom
- window_rect
.top
);
2838 if (infoPtr
->dwStyle
& CCS_NOPARENTALIGN
)
2839 uPosFlags
|= SWP_NOMOVE
;
2841 if (!(infoPtr
->dwStyle
& CCS_NODIVIDER
))
2842 cy
+= GetSystemMetrics(SM_CYEDGE
);
2844 if (infoPtr
->dwStyle
& WS_BORDER
)
2847 cy
+= GetSystemMetrics(SM_CYEDGE
);
2848 cx
+= GetSystemMetrics(SM_CYEDGE
);
2851 infoPtr
->bAutoSize
= TRUE
;
2852 SetWindowPos (hwnd
, HWND_TOP
, x
, y
, cx
, cy
, uPosFlags
);
2853 /* The following line makes sure that the infoPtr->bAutoSize is turned off
2854 * after the setwindowpos calls */
2855 infoPtr
->bAutoSize
= FALSE
;
2862 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2864 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2866 return infoPtr
->nNumButtons
;
2871 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2873 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2875 if (infoPtr
== NULL
) {
2876 ERR("(%p, 0x%x, 0x%lx)\n", hwnd
, wParam
, lParam
);
2877 ERR("infoPtr == NULL!\n");
2881 infoPtr
->dwStructSize
= (DWORD
)wParam
;
2888 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2890 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2891 TBUTTON_INFO
*btnPtr
;
2894 TRACE("button %d, iBitmap now %d\n", wParam
, LOWORD(lParam
));
2896 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2900 btnPtr
= &infoPtr
->buttons
[nIndex
];
2901 btnPtr
->iBitmap
= LOWORD(lParam
);
2903 /* we HAVE to erase the background, the new bitmap could be */
2905 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2912 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2914 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2915 TBUTTON_INFO
*btnPtr
;
2918 BOOL bChecked
= FALSE
;
2920 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2922 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, nIndex
, lParam
);
2927 btnPtr
= &infoPtr
->buttons
[nIndex
];
2929 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
2931 if (LOWORD(lParam
) == FALSE
)
2932 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
2934 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
2936 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
2937 if (nOldIndex
== nIndex
)
2939 if (nOldIndex
!= -1)
2940 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
2942 btnPtr
->fsState
|= TBSTATE_CHECKED
;
2945 if( bChecked
!= LOWORD(lParam
) )
2947 if (nOldIndex
!= -1)
2948 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
2949 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2952 /* FIXME: Send a WM_NOTIFY?? */
2959 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2961 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2963 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2968 TOOLBAR_Customize (HWND hwnd
)
2970 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2971 CUSTDLG_INFO custInfo
;
2977 custInfo
.tbInfo
= infoPtr
;
2978 custInfo
.tbHwnd
= hwnd
;
2980 /* send TBN_BEGINADJUST notification */
2981 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
2984 if (!(hRes
= FindResourceA (COMCTL32_hModule
,
2985 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE
),
2989 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
2992 ret
= DialogBoxIndirectParamA ((HINSTANCE
)GetWindowLongPtrW(hwnd
, GWLP_HINSTANCE
),
2993 (LPDLGTEMPLATEA
)template,
2995 TOOLBAR_CustomizeDialogProc
,
2998 /* send TBN_ENDADJUST notification */
2999 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
3007 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3009 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3010 INT nIndex
= (INT
)wParam
;
3013 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3016 memset(&nmtb
, 0, sizeof(nmtb
));
3017 nmtb
.iItem
= nIndex
;
3018 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_DELETINGBUTTON
);
3020 if ((infoPtr
->hwndToolTip
) &&
3021 !(infoPtr
->buttons
[nIndex
].fsStyle
& BTNS_SEP
)) {
3024 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3025 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3027 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
3029 SendMessageA (infoPtr
->hwndToolTip
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
3032 if (infoPtr
->nNumButtons
== 1) {
3033 TRACE(" simple delete!\n");
3034 Free (infoPtr
->buttons
);
3035 infoPtr
->buttons
= NULL
;
3036 infoPtr
->nNumButtons
= 0;
3039 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
3040 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
3042 infoPtr
->nNumButtons
--;
3043 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3045 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3046 nIndex
* sizeof(TBUTTON_INFO
));
3049 if (nIndex
< infoPtr
->nNumButtons
) {
3050 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
3051 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
3057 TOOLBAR_CalcToolbar (hwnd
);
3059 InvalidateRect (hwnd
, NULL
, TRUE
);
3066 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3068 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3069 TBUTTON_INFO
*btnPtr
;
3073 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3075 TRACE("hwnd=%p, btn index=%d, lParam=0x%08lx\n", hwnd
, wParam
, lParam
);
3080 btnPtr
= &infoPtr
->buttons
[nIndex
];
3082 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
3084 /* update the toolbar button state */
3085 if(LOWORD(lParam
) == FALSE
) {
3086 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
3088 btnPtr
->fsState
|= TBSTATE_ENABLED
;
3091 /* redraw the button only if the state of the button changed */
3092 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
3093 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3099 static inline LRESULT
3100 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
3102 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3104 return infoPtr
->bAnchor
;
3109 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3111 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3114 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3118 return infoPtr
->buttons
[nIndex
].iBitmap
;
3122 static inline LRESULT
3123 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3125 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
3130 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3132 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3133 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3134 INT nIndex
= (INT
)wParam
;
3135 TBUTTON_INFO
*btnPtr
;
3137 if (infoPtr
== NULL
)
3143 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3146 btnPtr
= &infoPtr
->buttons
[nIndex
];
3147 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
3148 lpTbb
->idCommand
= btnPtr
->idCommand
;
3149 lpTbb
->fsState
= btnPtr
->fsState
;
3150 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
3151 lpTbb
->bReserved
[0] = 0;
3152 lpTbb
->bReserved
[1] = 0;
3153 lpTbb
->dwData
= btnPtr
->dwData
;
3154 lpTbb
->iString
= btnPtr
->iString
;
3161 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3163 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3164 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
3165 TBUTTON_INFO
*btnPtr
;
3168 if (infoPtr
== NULL
)
3170 if (lpTbInfo
== NULL
)
3172 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
3175 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3176 lpTbInfo
->dwMask
& 0x80000000);
3180 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
3182 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3183 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3184 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3185 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3186 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3187 lpTbInfo
->lParam
= btnPtr
->dwData
;
3188 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3189 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3190 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3191 lpTbInfo
->fsState
= btnPtr
->fsState
;
3192 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3193 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3194 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3195 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3196 can't use TOOLBAR_GetText here */
3198 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3199 lpText
= (LPWSTR
)btnPtr
->iString
;
3200 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3202 lpTbInfo
->pszText
[0] = '\0';
3209 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3211 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3212 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
3213 TBUTTON_INFO
*btnPtr
;
3216 if (infoPtr
== NULL
)
3218 if (lpTbInfo
== NULL
)
3220 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
3223 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3224 lpTbInfo
->dwMask
& 0x80000000);
3228 btnPtr
= &infoPtr
->buttons
[nIndex
];
3233 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
3234 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
3235 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
3236 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
3237 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
3238 lpTbInfo
->lParam
= btnPtr
->dwData
;
3239 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
3240 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
3241 if (lpTbInfo
->dwMask
& TBIF_STATE
)
3242 lpTbInfo
->fsState
= btnPtr
->fsState
;
3243 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
3244 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
3245 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
3246 /* TB_GETBUTTONINFO doesn't retrieve text from the string list, so we
3247 can't use TOOLBAR_GetText here */
3249 if (HIWORD(btnPtr
->iString
) && (btnPtr
->iString
!= -1)) {
3250 lpText
= (LPWSTR
)btnPtr
->iString
;
3251 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
3253 lpTbInfo
->pszText
[0] = '\0';
3261 TOOLBAR_GetButtonSize (HWND hwnd
)
3263 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3265 if (infoPtr
->nNumButtons
> 0)
3266 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
3267 (WORD
)infoPtr
->nButtonHeight
);
3269 return MAKELONG(8,7);
3274 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3276 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3283 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3287 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3289 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3290 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3295 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3297 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3304 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3308 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3310 strcpyW ((LPWSTR
)lParam
, lpText
);
3312 return strlenW (lpText
);
3317 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3319 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3320 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3321 return (LRESULT
)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3325 inline static LRESULT
3326 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3328 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3332 return infoPtr
->dwExStyle
;
3337 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3339 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3340 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3341 return (LRESULT
)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd
), wParam
);
3346 TOOLBAR_GetHotItem (HWND hwnd
)
3348 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3350 if (!(infoPtr
->dwStyle
& TBSTYLE_FLAT
))
3353 if (infoPtr
->nHotItem
< 0)
3356 return (LRESULT
)infoPtr
->nHotItem
;
3361 TOOLBAR_GetDefImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3363 TRACE("hwnd=%p, wParam=%d, lParam=0x%lx\n", hwnd
, wParam
, lParam
);
3364 /* UNDOCUMENTED: wParam is actually the ID of the image list to return */
3365 return (LRESULT
) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd
), wParam
);
3369 /* << TOOLBAR_GetInsertMark >> */
3370 /* << TOOLBAR_GetInsertMarkColor >> */
3374 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3376 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3377 TBUTTON_INFO
*btnPtr
;
3381 if (infoPtr
== NULL
)
3383 nIndex
= (INT
)wParam
;
3384 btnPtr
= &infoPtr
->buttons
[nIndex
];
3385 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3387 lpRect
= (LPRECT
)lParam
;
3390 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3393 lpRect
->left
= btnPtr
->rect
.left
;
3394 lpRect
->right
= btnPtr
->rect
.right
;
3395 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3396 lpRect
->top
= btnPtr
->rect
.top
;
3403 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3405 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3406 LPSIZE lpSize
= (LPSIZE
)lParam
;
3411 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3412 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3414 TRACE("maximum size %ld x %ld\n",
3415 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3416 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3422 /* << TOOLBAR_GetObject >> */
3426 TOOLBAR_GetPadding (HWND hwnd
)
3428 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3431 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3432 return (LRESULT
) oldPad
;
3437 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3439 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3440 TBUTTON_INFO
*btnPtr
;
3444 if (infoPtr
== NULL
)
3446 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3447 btnPtr
= &infoPtr
->buttons
[nIndex
];
3448 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3450 lpRect
= (LPRECT
)lParam
;
3454 lpRect
->left
= btnPtr
->rect
.left
;
3455 lpRect
->right
= btnPtr
->rect
.right
;
3456 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3457 lpRect
->top
= btnPtr
->rect
.top
;
3464 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3466 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3468 if (infoPtr
->dwStyle
& TBSTYLE_WRAPABLE
)
3469 return infoPtr
->nRows
;
3476 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3478 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3481 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3485 return infoPtr
->buttons
[nIndex
].fsState
;
3490 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3492 return GetWindowLongW(hwnd
, GWL_STYLE
);
3497 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3499 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3501 if (infoPtr
== NULL
)
3504 return infoPtr
->nMaxTextRows
;
3509 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3511 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3513 if (infoPtr
== NULL
)
3515 return (LRESULT
)infoPtr
->hwndToolTip
;
3520 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3522 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3524 TRACE("%s hwnd=%p stub!\n",
3525 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3527 return infoPtr
->bUnicode
;
3531 inline static LRESULT
3532 TOOLBAR_GetVersion (HWND hwnd
)
3534 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3535 return infoPtr
->iVersion
;
3540 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3542 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3543 TBUTTON_INFO
*btnPtr
;
3548 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3552 btnPtr
= &infoPtr
->buttons
[nIndex
];
3553 if (LOWORD(lParam
) == FALSE
)
3554 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3556 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3558 TOOLBAR_CalcToolbar (hwnd
);
3560 InvalidateRect (hwnd
, NULL
, TRUE
);
3566 inline static LRESULT
3567 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3569 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3574 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3576 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3577 TBUTTON_INFO
*btnPtr
;
3581 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3585 btnPtr
= &infoPtr
->buttons
[nIndex
];
3586 oldState
= btnPtr
->fsState
;
3587 if (LOWORD(lParam
) == FALSE
)
3588 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3590 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3592 if(oldState
!= btnPtr
->fsState
)
3593 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
3600 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3602 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3603 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3604 INT nIndex
= (INT
)wParam
;
3605 TBUTTON_INFO
*oldButtons
;
3610 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3613 /* EPP: this seems to be an undocumented call (from my IE4)
3614 * I assume in that case that:
3615 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3616 * - index of insertion is at the end of existing buttons
3617 * I only see this happen with nIndex == -1, but it could have a special
3618 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3620 nIndex
= infoPtr
->nNumButtons
;
3622 } else if (nIndex
< 0)
3625 /* If the string passed is not an index, assume address of string
3626 and do our own AddString */
3627 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3631 TRACE("string %s passed instead of index, adding string\n",
3632 debugstr_a((LPSTR
)lpTbb
->iString
));
3633 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3635 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3636 ptr
[len
- 1] = 0; /* ended by two '\0' */
3637 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3641 TRACE("inserting button index=%d\n", nIndex
);
3642 if (nIndex
> infoPtr
->nNumButtons
) {
3643 nIndex
= infoPtr
->nNumButtons
;
3644 TRACE("adjust index=%d\n", nIndex
);
3647 oldButtons
= infoPtr
->buttons
;
3648 infoPtr
->nNumButtons
++;
3649 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3650 /* pre insert copy */
3652 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3653 nIndex
* sizeof(TBUTTON_INFO
));
3656 /* insert new button */
3657 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3658 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3659 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3660 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3661 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3662 /* if passed string and not index, then add string */
3663 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3664 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3667 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3669 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3672 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3673 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3675 ti
.uId
= lpTbb
->idCommand
;
3677 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
3679 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
3683 /* post insert copy */
3684 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3685 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3686 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3691 TOOLBAR_CalcToolbar (hwnd
);
3693 InvalidateRect (hwnd
, NULL
, TRUE
);
3700 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3702 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3703 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3704 INT nIndex
= (INT
)wParam
;
3705 TBUTTON_INFO
*oldButtons
;
3710 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3713 /* EPP: this seems to be an undocumented call (from my IE4)
3714 * I assume in that case that:
3715 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3716 * - index of insertion is at the end of existing buttons
3717 * I only see this happen with nIndex == -1, but it could have a special
3718 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3720 nIndex
= infoPtr
->nNumButtons
;
3722 } else if (nIndex
< 0)
3725 /* If the string passed is not an index, assume address of string
3726 and do our own AddString */
3727 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3731 TRACE("string %s passed instead of index, adding string\n",
3732 debugstr_w((LPWSTR
)lpTbb
->iString
));
3733 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
3734 ptr
= Alloc(len
*sizeof(WCHAR
));
3735 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
3736 ptr
[len
- 1] = 0; /* ended by two '\0' */
3737 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
3741 TRACE("inserting button index=%d\n", nIndex
);
3742 if (nIndex
> infoPtr
->nNumButtons
) {
3743 nIndex
= infoPtr
->nNumButtons
;
3744 TRACE("adjust index=%d\n", nIndex
);
3747 oldButtons
= infoPtr
->buttons
;
3748 infoPtr
->nNumButtons
++;
3749 infoPtr
->buttons
= Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3750 /* pre insert copy */
3752 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3753 nIndex
* sizeof(TBUTTON_INFO
));
3756 /* insert new button */
3757 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3758 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3759 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3760 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3761 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3762 /* if passed string and not index, then add string */
3763 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3764 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
3767 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3769 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& BTNS_SEP
)) {
3772 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
3773 ti
.cbSize
= sizeof (TTTOOLINFOW
);
3775 ti
.uId
= lpTbb
->idCommand
;
3777 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3779 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3783 /* post insert copy */
3784 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3785 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3786 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3791 TOOLBAR_CalcToolbar (hwnd
);
3793 InvalidateRect (hwnd
, NULL
, TRUE
);
3799 /* << TOOLBAR_InsertMarkHitTest >> */
3803 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3805 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3808 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3812 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
3817 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3819 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3822 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3826 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
3831 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3833 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3836 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3840 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
3845 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3847 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3850 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3854 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
3859 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3861 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3864 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3868 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
3873 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3875 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3878 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3882 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
3887 TOOLBAR_LoadImages (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3890 tbab
.hInst
= (HINSTANCE
)lParam
;
3891 tbab
.nID
= (UINT_PTR
)wParam
;
3893 TRACE("hwnd = %p, hInst = %p, nID = %u\n", hwnd
, tbab
.hInst
, tbab
.nID
);
3895 return TOOLBAR_AddBitmap(hwnd
, 0, (LPARAM
)&tbab
);
3900 TOOLBAR_MapAccelerator (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3902 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3903 WCHAR wAccel
= (WCHAR
)wParam
;
3904 UINT
* pIDButton
= (UINT
*)lParam
;
3905 WCHAR wszAccel
[] = {'&',wAccel
,0};
3908 TRACE("hwnd = %p, wAccel = %x(%s), pIDButton = %p\n",
3909 hwnd
, wAccel
, debugstr_wn(&wAccel
,1), pIDButton
);
3911 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++)
3913 TBUTTON_INFO
*btnPtr
= infoPtr
->buttons
+i
;
3914 if (!(btnPtr
->fsStyle
& BTNS_NOPREFIX
) &&
3915 !(btnPtr
->fsState
& TBSTATE_HIDDEN
))
3917 int iLen
= strlenW(wszAccel
);
3918 LPCWSTR lpszStr
= TOOLBAR_GetText(infoPtr
, btnPtr
);
3925 if ((lpszStr
[0] == '&') && (lpszStr
[1] == '&'))
3930 if (!strncmpiW(lpszStr
, wszAccel
, iLen
))
3932 *pIDButton
= btnPtr
->idCommand
;
3944 TOOLBAR_MarkButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3946 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3949 TRACE("hwnd = %p, wParam = %d, lParam = 0x%08lx\n", hwnd
, wParam
, lParam
);
3951 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3956 infoPtr
->buttons
[nIndex
].fsState
|= TBSTATE_MARKED
;
3958 infoPtr
->buttons
[nIndex
].fsState
&= ~TBSTATE_MARKED
;
3964 /* fixes up an index of a button affected by a move */
3965 inline static void TOOLBAR_MoveFixupIndex(INT
* pIndex
, INT nIndex
, INT nMoveIndex
, BOOL bMoveUp
)
3969 if (*pIndex
> nIndex
&& *pIndex
<= nMoveIndex
)
3971 else if (*pIndex
== nIndex
)
3972 *pIndex
= nMoveIndex
;
3976 if (*pIndex
>= nMoveIndex
&& *pIndex
< nIndex
)
3978 else if (*pIndex
== nIndex
)
3979 *pIndex
= nMoveIndex
;
3985 TOOLBAR_MoveButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3987 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3990 INT nMoveIndex
= (INT
)lParam
;
3991 TBUTTON_INFO button
;
3993 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
3995 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, TRUE
);
3996 if ((nIndex
== -1) || (nMoveIndex
< 0))
3999 if (nMoveIndex
> infoPtr
->nNumButtons
- 1)
4000 nMoveIndex
= infoPtr
->nNumButtons
- 1;
4002 button
= infoPtr
->buttons
[nIndex
];
4004 /* move button right */
4005 if (nIndex
< nMoveIndex
)
4007 nCount
= nMoveIndex
- nIndex
;
4008 memmove(&infoPtr
->buttons
[nIndex
], &infoPtr
->buttons
[nIndex
+1], nCount
*sizeof(TBUTTON_INFO
));
4009 infoPtr
->buttons
[nMoveIndex
] = button
;
4011 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, TRUE
);
4012 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, TRUE
);
4013 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, TRUE
);
4014 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, TRUE
);
4016 else if (nIndex
> nMoveIndex
) /* move button left */
4018 nCount
= nIndex
- nMoveIndex
;
4019 memmove(&infoPtr
->buttons
[nMoveIndex
+1], &infoPtr
->buttons
[nMoveIndex
], nCount
*sizeof(TBUTTON_INFO
));
4020 infoPtr
->buttons
[nMoveIndex
] = button
;
4022 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDown
, nIndex
, nMoveIndex
, FALSE
);
4023 TOOLBAR_MoveFixupIndex(&infoPtr
->nButtonDrag
, nIndex
, nMoveIndex
, FALSE
);
4024 TOOLBAR_MoveFixupIndex(&infoPtr
->nOldHit
, nIndex
, nMoveIndex
, FALSE
);
4025 TOOLBAR_MoveFixupIndex(&infoPtr
->nHotItem
, nIndex
, nMoveIndex
, FALSE
);
4028 TOOLBAR_CalcToolbar(hwnd
);
4029 InvalidateRect(hwnd
, NULL
, TRUE
);
4036 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4038 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4039 TBUTTON_INFO
*btnPtr
;
4043 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4047 btnPtr
= &infoPtr
->buttons
[nIndex
];
4048 oldState
= btnPtr
->fsState
;
4049 if (LOWORD(lParam
) == FALSE
)
4050 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4052 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4054 if(oldState
!= btnPtr
->fsState
)
4055 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4060 /* FIXME: there might still be some confusion her between number of buttons
4061 * and number of bitmaps */
4063 TOOLBAR_ReplaceBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4065 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4066 LPTBREPLACEBITMAP lpReplace
= (LPTBREPLACEBITMAP
) lParam
;
4068 int i
= 0, nOldButtons
= 0, pos
= 0;
4069 int nOldBitmaps
, nNewBitmaps
;
4070 HIMAGELIST himlDef
= 0;
4072 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
4073 lpReplace
->hInstOld
, lpReplace
->nIDOld
, lpReplace
->hInstNew
, lpReplace
->nIDNew
,
4074 lpReplace
->nButtons
);
4076 if (lpReplace
->hInstOld
== HINST_COMMCTRL
)
4078 FIXME("changing standard bitmaps not implemented\n");
4081 else if (lpReplace
->hInstOld
!= 0)
4083 FIXME("resources not in the current module not implemented\n");
4088 hBitmap
= (HBITMAP
) lpReplace
->nIDNew
;
4091 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4092 for (i
= 0; i
< infoPtr
->nNumBitmapInfos
; i
++) {
4093 TBITMAP_INFO
*tbi
= &infoPtr
->bitmaps
[i
];
4094 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4095 if (tbi
->hInst
== lpReplace
->hInstOld
&& tbi
->nID
== lpReplace
->nIDOld
)
4097 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi
->nButtons
, tbi
->hInst
, tbi
->nID
);
4098 nOldButtons
= tbi
->nButtons
;
4099 tbi
->nButtons
= lpReplace
->nButtons
;
4100 tbi
->hInst
= lpReplace
->hInstNew
;
4101 tbi
->nID
= lpReplace
->nIDNew
;
4102 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i
, tbi
->hInst
, tbi
->nID
);
4105 pos
+= tbi
->nButtons
;
4108 if (nOldButtons
== 0)
4110 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace
->hInstOld
, lpReplace
->nIDOld
);
4114 himlDef
= GETDEFIMAGELIST(infoPtr
, 0); /* fixme: correct? */
4115 nOldBitmaps
= ImageList_GetImageCount(himlDef
);
4117 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
4119 for (i
= pos
+ nOldBitmaps
- 1; i
>= pos
; i
--)
4120 ImageList_Remove(himlDef
, i
);
4124 HBITMAP hOldBitmapBitmap
, hOldBitmapLoad
, hbmLoad
;
4125 HDC hdcImage
, hdcBitmap
;
4127 /* copy the bitmap before adding it so that the user's bitmap
4128 * doesn't get modified.
4130 GetObjectA (hBitmap
, sizeof(BITMAP
), (LPVOID
)&bmp
);
4132 hdcImage
= CreateCompatibleDC(0);
4133 hdcBitmap
= CreateCompatibleDC(0);
4135 /* create new bitmap */
4136 hbmLoad
= CreateBitmap (bmp
.bmWidth
, bmp
.bmHeight
, bmp
.bmPlanes
, bmp
.bmBitsPixel
, NULL
);
4137 hOldBitmapBitmap
= SelectObject(hdcBitmap
, hBitmap
);
4138 hOldBitmapLoad
= SelectObject(hdcImage
, hbmLoad
);
4140 /* Copy the user's image */
4141 BitBlt (hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
,
4142 hdcBitmap
, 0, 0, SRCCOPY
);
4144 SelectObject (hdcImage
, hOldBitmapLoad
);
4145 SelectObject (hdcBitmap
, hOldBitmapBitmap
);
4146 DeleteDC (hdcImage
);
4147 DeleteDC (hdcBitmap
);
4149 ImageList_AddMasked (himlDef
, hbmLoad
, comctl32_color
.clrBtnFace
);
4150 nNewBitmaps
= ImageList_GetImageCount(himlDef
);
4151 DeleteObject (hbmLoad
);
4154 infoPtr
->nNumBitmaps
= infoPtr
->nNumBitmaps
- nOldBitmaps
+ nNewBitmaps
;
4156 TRACE(" pos %d %d old bitmaps replaced by %d new ones.\n",
4157 pos
, nOldBitmaps
, nNewBitmaps
);
4159 InvalidateRect(hwnd
, NULL
, TRUE
);
4165 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4168 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4169 LPTBSAVEPARAMSA lpSave
= (LPTBSAVEPARAMSA
)lParam
;
4171 if (lpSave
== NULL
) return 0;
4174 /* save toolbar information */
4175 FIXME("save to \"%s\" \"%s\"\n",
4176 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4181 /* restore toolbar information */
4183 FIXME("restore from \"%s\" \"%s\"\n",
4184 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4195 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4198 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4199 LPTBSAVEPARAMSW lpSave
= (LPTBSAVEPARAMSW
)lParam
;
4205 /* save toolbar information */
4206 FIXME("save to \"%s\" \"%s\"\n",
4207 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4212 /* restore toolbar information */
4214 FIXME("restore from \"%s\" \"%s\"\n",
4215 lpSave
->pszSubKey
, lpSave
->pszValueName
);
4226 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
4228 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4229 BOOL bOldAnchor
= infoPtr
->bAnchor
;
4231 infoPtr
->bAnchor
= (BOOL
)wParam
;
4233 return (LRESULT
)bOldAnchor
;
4238 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4240 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4241 HIMAGELIST himlDef
= GETDEFIMAGELIST(infoPtr
, 0);
4243 TRACE("hwnd=%p, wParam=%d, lParam=%ld\n", hwnd
, wParam
, lParam
);
4246 FIXME("wParam is %d. Perhaps image list index?\n", wParam
);
4248 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
4251 if (infoPtr
->nNumButtons
> 0)
4252 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
4253 infoPtr
->nNumButtons
,
4254 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
4255 LOWORD(lParam
), HIWORD(lParam
));
4257 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
4258 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
4261 if ((himlDef
== infoPtr
->himlInt
) &&
4262 (ImageList_GetImageCount(infoPtr
->himlInt
) == 0))
4264 ImageList_SetIconSize(infoPtr
->himlInt
, infoPtr
->nBitmapWidth
,
4265 infoPtr
->nBitmapHeight
);
4273 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4275 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4276 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
4277 TBUTTON_INFO
*btnPtr
;
4283 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
4286 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4287 lptbbi
->dwMask
& 0x80000000);
4291 btnPtr
= &infoPtr
->buttons
[nIndex
];
4292 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4293 btnPtr
->idCommand
= lptbbi
->idCommand
;
4294 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4295 btnPtr
->iBitmap
= lptbbi
->iImage
;
4296 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4297 btnPtr
->dwData
= lptbbi
->lParam
;
4298 if (lptbbi
->dwMask
& TBIF_SIZE
)
4299 btnPtr
->cx
= lptbbi
->cx
;
4300 if (lptbbi
->dwMask
& TBIF_STATE
)
4301 btnPtr
->fsState
= lptbbi
->fsState
;
4302 if (lptbbi
->dwMask
& TBIF_STYLE
)
4303 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4305 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4306 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4307 /* iString is index, zero it to make Str_SetPtr succeed */
4310 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4313 /* save the button rect to see if we need to redraw the whole toolbar */
4314 oldBtnRect
= btnPtr
->rect
;
4315 TOOLBAR_CalcToolbar(hwnd
);
4317 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4318 InvalidateRect(hwnd
, NULL
, TRUE
);
4320 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4327 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4329 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4330 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
4331 TBUTTON_INFO
*btnPtr
;
4337 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
4340 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
4341 lptbbi
->dwMask
& 0x80000000);
4345 btnPtr
= &infoPtr
->buttons
[nIndex
];
4346 if (lptbbi
->dwMask
& TBIF_COMMAND
)
4347 btnPtr
->idCommand
= lptbbi
->idCommand
;
4348 if (lptbbi
->dwMask
& TBIF_IMAGE
)
4349 btnPtr
->iBitmap
= lptbbi
->iImage
;
4350 if (lptbbi
->dwMask
& TBIF_LPARAM
)
4351 btnPtr
->dwData
= lptbbi
->lParam
;
4352 if (lptbbi
->dwMask
& TBIF_SIZE
)
4353 btnPtr
->cx
= lptbbi
->cx
;
4354 if (lptbbi
->dwMask
& TBIF_STATE
)
4355 btnPtr
->fsState
= lptbbi
->fsState
;
4356 if (lptbbi
->dwMask
& TBIF_STYLE
)
4357 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
4359 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
4360 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
4361 /* iString is index, zero it to make Str_SetPtr succeed */
4363 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
4366 /* save the button rect to see if we need to redraw the whole toolbar */
4367 oldBtnRect
= btnPtr
->rect
;
4368 TOOLBAR_CalcToolbar(hwnd
);
4370 if (!EqualRect(&oldBtnRect
, &btnPtr
->rect
))
4371 InvalidateRect(hwnd
, NULL
, TRUE
);
4373 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4380 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4382 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4383 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
4385 if ((cx
< 0) || (cy
< 0))
4387 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
4391 /* The documentation claims you can only change the button size before
4392 * any button has been added. But this is wrong.
4393 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4394 * it to the toolbar, and it checks that the return value is nonzero - mjm
4395 * Further testing shows that we must actually perform the change too.
4398 * The documentation also does not mention that if 0 is supplied for
4399 * either size, the system changes it to the default of 24 wide and
4400 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4402 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
4403 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
4409 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4411 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4413 if (infoPtr
== NULL
) {
4414 TRACE("Toolbar not initialized yet?????\n");
4418 /* if setting to current values, ignore */
4419 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
4420 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
4421 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4422 infoPtr
->cxMin
, infoPtr
->cxMax
);
4426 /* save new values */
4427 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
4428 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
4430 /* if both values are 0 then we are done */
4432 TRACE("setting both min and max to 0, norecalc\n");
4436 /* otherwise we need to recalc the toolbar and in some cases
4437 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4438 which doesn't actually draw - GA). */
4439 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4440 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
4442 TOOLBAR_CalcToolbar (hwnd
);
4444 InvalidateRect (hwnd
, NULL
, TRUE
);
4451 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4453 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4454 INT nIndex
= (INT
)wParam
;
4456 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
4459 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
4461 if (infoPtr
->hwndToolTip
) {
4463 FIXME("change tool tip!\n");
4472 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4474 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4475 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4476 HIMAGELIST himlTemp
;
4479 if (infoPtr
->iVersion
>= 5)
4482 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDis
,
4483 &infoPtr
->cimlDis
, himl
, id
);
4485 /* FIXME: redraw ? */
4487 return (LRESULT
)himlTemp
;
4492 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4494 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4497 dwTemp
= infoPtr
->dwDTFlags
;
4498 infoPtr
->dwDTFlags
=
4499 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
4501 return (LRESULT
)dwTemp
;
4504 /* This function differs a bit from what MSDN says it does:
4505 * 1. lParam contains extended style flags to OR with current style
4506 * (MSDN isn't clear on the OR bit)
4507 * 2. wParam appears to contain extended style flags to be reset
4508 * (MSDN says that this parameter is reserved)
4511 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4513 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4516 dwTemp
= infoPtr
->dwExStyle
;
4517 infoPtr
->dwExStyle
&= ~wParam
;
4518 infoPtr
->dwExStyle
|= (DWORD
)lParam
;
4520 TRACE("new style 0x%08lx\n", infoPtr
->dwExStyle
);
4522 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
4523 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4524 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
4526 TOOLBAR_CalcToolbar (hwnd
);
4528 TOOLBAR_AutoSize(hwnd
);
4530 InvalidateRect(hwnd
, NULL
, TRUE
);
4532 return (LRESULT
)dwTemp
;
4537 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4539 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4540 HIMAGELIST himlTemp
;
4541 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4544 if (infoPtr
->iVersion
>= 5)
4547 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd
, himl
, id
);
4549 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlHot
,
4550 &infoPtr
->cimlHot
, himl
, id
);
4552 /* FIXME: redraw ? */
4554 return (LRESULT
)himlTemp
;
4558 /* Makes previous hot button no longer hot, makes the specified
4559 * button hot and sends appropriate notifications. dwReason is one or
4560 * more HICF_ flags. Specify nHit < 0 to make no buttons hot.
4561 * NOTE 1: this function does not validate nHit
4562 * NOTE 2: the name of this function is completely made up and
4563 * not based on any documentation from Microsoft. */
4565 TOOLBAR_SetHotItemEx (TOOLBAR_INFO
*infoPtr
, INT nHit
, DWORD dwReason
)
4567 if (infoPtr
->nHotItem
!= nHit
)
4569 NMTBHOTITEM nmhotitem
;
4570 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
4571 LRESULT no_highlight
;
4573 /* Remove the effect of an old hot button if the button was
4574 drawn with the hot button effect */
4575 if(infoPtr
->nHotItem
>= 0)
4577 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nHotItem
];
4578 oldBtnPtr
->bHot
= FALSE
;
4581 infoPtr
->nHotItem
= nHit
;
4583 /* It's not a separator or in nowhere. It's a hot button. */
4585 btnPtr
= &infoPtr
->buttons
[nHit
];
4587 nmhotitem
.dwFlags
= dwReason
;
4589 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
4591 nmhotitem
.dwFlags
|= HICF_ENTERING
;
4593 nmhotitem
.idNew
= btnPtr
->idCommand
;
4595 nmhotitem
.dwFlags
|= HICF_LEAVING
;
4597 no_highlight
= TOOLBAR_SendNotify((NMHDR
*)&nmhotitem
, infoPtr
, TBN_HOTITEMCHANGE
);
4599 /* now invalidate the old and new buttons so they will be painted */
4601 InvalidateRect(infoPtr
->hwndSelf
, &oldBtnPtr
->rect
, TRUE
);
4602 if (btnPtr
&& !no_highlight
)
4604 btnPtr
->bHot
= TRUE
;
4605 InvalidateRect(infoPtr
->hwndSelf
, &btnPtr
->rect
, TRUE
);
4611 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
4613 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4614 INT nOldHotItem
= infoPtr
->nHotItem
;
4616 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4619 if (infoPtr
->dwStyle
& TBSTYLE_FLAT
)
4620 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, HICF_OTHER
);
4622 if (nOldHotItem
< 0)
4625 return (LRESULT
)nOldHotItem
;
4630 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4632 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4633 HIMAGELIST himlTemp
;
4634 HIMAGELIST himl
= (HIMAGELIST
)lParam
;
4637 if (infoPtr
->iVersion
>= 5)
4640 himlTemp
= TOOLBAR_InsertImageList(&infoPtr
->himlDef
,
4641 &infoPtr
->cimlDef
, himl
, id
);
4643 infoPtr
->nNumBitmaps
= 0;
4644 for (i
= 0; i
< infoPtr
->cimlDef
; i
++)
4645 infoPtr
->nNumBitmaps
+= ImageList_GetImageCount(infoPtr
->himlDef
[i
]->himl
);
4647 ImageList_GetIconSize(himl
, &infoPtr
->nBitmapWidth
,
4648 &infoPtr
->nBitmapHeight
);
4649 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4650 hwnd
, (INT
)infoPtr
->himlDef
, infoPtr
->nNumBitmaps
,
4651 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
4653 InvalidateRect(hwnd
, NULL
, TRUE
);
4655 return (LRESULT
)himlTemp
;
4660 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4662 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4664 infoPtr
->nIndent
= (INT
)wParam
;
4668 /* process only on indent changing */
4669 if(infoPtr
->nIndent
!= (INT
)wParam
)
4671 infoPtr
->nIndent
= (INT
)wParam
;
4672 TOOLBAR_CalcToolbar (hwnd
);
4673 InvalidateRect(hwnd
, NULL
, FALSE
);
4680 /* << TOOLBAR_SetInsertMark >> */
4684 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4686 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4688 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
4690 /* FIXME : redraw ??*/
4697 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4699 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4701 if (infoPtr
== NULL
)
4704 infoPtr
->nMaxTextRows
= (INT
)wParam
;
4706 TOOLBAR_CalcToolbar(hwnd
);
4711 /* MSDN gives slightly wrong info on padding.
4712 * 1. It is not only used on buttons with the BTNS_AUTOSIZE style
4713 * 2. It is not used to create a blank area between the edge of the button
4714 * and the text or image if TBSTYLE_LIST is set. It is used to control
4715 * the gap between the image and text.
4716 * 3. It is not applied to both sides. If TBSTYLE_LIST is set it is used
4717 * to control the bottom and right borders [with the border being
4718 * szPadding.cx - (GetSystemMetrics(SM_CXEDGE)+1)], otherwise the padding
4719 * is shared evenly on both sides of the button.
4722 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4724 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4727 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4728 infoPtr
->szPadding
.cx
= LOWORD((DWORD
)lParam
);
4729 infoPtr
->szPadding
.cy
= HIWORD((DWORD
)lParam
);
4730 TRACE("cx=%ld, cy=%ld\n",
4731 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4732 return (LRESULT
) oldPad
;
4737 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4739 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4744 if (infoPtr
== NULL
)
4746 hwndOldNotify
= infoPtr
->hwndNotify
;
4747 infoPtr
->hwndNotify
= (HWND
)wParam
;
4749 return (LRESULT
)hwndOldNotify
;
4754 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4756 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4757 LPRECT lprc
= (LPRECT
)lParam
;
4761 if (LOWORD(wParam
) > 1) {
4762 FIXME("multiple rows not supported!\n");
4765 if(infoPtr
->nRows
!= LOWORD(wParam
))
4767 infoPtr
->nRows
= LOWORD(wParam
);
4769 /* recalculate toolbar */
4770 TOOLBAR_CalcToolbar (hwnd
);
4772 /* repaint toolbar */
4773 InvalidateRect(hwnd
, NULL
, TRUE
);
4776 /* return bounding rectangle */
4778 lprc
->left
= infoPtr
->rcBound
.left
;
4779 lprc
->right
= infoPtr
->rcBound
.right
;
4780 lprc
->top
= infoPtr
->rcBound
.top
;
4781 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
4789 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4791 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4792 TBUTTON_INFO
*btnPtr
;
4795 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4799 btnPtr
= &infoPtr
->buttons
[nIndex
];
4801 /* if hidden state has changed the invalidate entire window and recalc */
4802 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
4803 btnPtr
->fsState
= LOWORD(lParam
);
4804 TOOLBAR_CalcToolbar (hwnd
);
4805 InvalidateRect(hwnd
, 0, TRUE
);
4809 /* process state changing if current state doesn't match new state */
4810 if(btnPtr
->fsState
!= LOWORD(lParam
))
4812 btnPtr
->fsState
= LOWORD(lParam
);
4813 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4821 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4823 SetWindowLongW(hwnd
, GWL_STYLE
, lParam
);
4829 inline static LRESULT
4830 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4832 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4834 TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd
, (HWND
)wParam
, lParam
);
4836 if (infoPtr
== NULL
)
4838 infoPtr
->hwndToolTip
= (HWND
)wParam
;
4844 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4846 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4849 TRACE("%s hwnd=%p stub!\n",
4850 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
4852 bTemp
= infoPtr
->bUnicode
;
4853 infoPtr
->bUnicode
= (BOOL
)wParam
;
4860 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4862 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4864 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
4865 comctl32_color
.clrBtnHighlight
:
4866 infoPtr
->clrBtnHighlight
;
4867 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
4868 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
4874 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4876 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4878 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4879 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
4880 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
4882 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
4883 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
4884 InvalidateRect(hwnd
, NULL
, TRUE
);
4890 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
4892 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4893 INT iOldVersion
= infoPtr
->iVersion
;
4895 infoPtr
->iVersion
= iVersion
;
4897 if (infoPtr
->iVersion
>= 5)
4898 TOOLBAR_SetUnicodeFormat(hwnd
, (WPARAM
)TRUE
, (LPARAM
)0);
4905 TOOLBAR_GetStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4907 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4908 WORD iString
= HIWORD(wParam
);
4909 WORD buffersize
= LOWORD(wParam
);
4910 LPSTR str
= (LPSTR
)lParam
;
4913 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, buffersize
, str
);
4915 if (iString
< infoPtr
->nNumStrings
)
4917 ret
= WideCharToMultiByte(CP_ACP
, 0, infoPtr
->strings
[iString
], -1, str
, buffersize
, NULL
, NULL
);
4919 TRACE("returning %s\n", debugstr_a(str
));
4922 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
4929 TOOLBAR_GetStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4931 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4932 WORD iString
= HIWORD(wParam
);
4933 WORD len
= LOWORD(wParam
)/sizeof(WCHAR
) - 1;
4934 LPWSTR str
= (LPWSTR
)lParam
;
4937 TRACE("hwnd=%p, iString=%d, buffersize=%d, string=%p\n", hwnd
, iString
, LOWORD(wParam
), str
);
4939 if (iString
< infoPtr
->nNumStrings
)
4941 len
= min(len
, strlenW(infoPtr
->strings
[iString
]));
4942 ret
= (len
+1)*sizeof(WCHAR
);
4943 memcpy(str
, infoPtr
->strings
[iString
], ret
);
4946 TRACE("returning %s\n", debugstr_w(str
));
4949 ERR("String index %d out of range (largest is %d)\n", iString
, infoPtr
->nNumStrings
- 1);
4954 /* UNDOCUMENTED MESSAGE: This appears to set some kind of size. Perhaps it
4955 * is the maximum size of the toolbar? */
4956 static LRESULT
TOOLBAR_Unkwn45D(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4958 SIZE
* pSize
= (SIZE
*)lParam
;
4959 FIXME("hwnd=%p, wParam=0x%08x, size.cx=%ld, size.cy=%ld stub!\n", hwnd
, wParam
, pSize
->cx
, pSize
->cy
);
4964 /* UNDOCUMENTED MESSAGE: This is an extended version of the
4965 * TB_SETHOTITEM message. It allows the caller to specify a reason why the
4966 * hot item changed (rather than just the HICF_OTHER that TB_SETHOTITEM
4969 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4971 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4972 INT nOldHotItem
= infoPtr
->nHotItem
;
4974 TRACE("old item=%d, new item=%d, flags=%08lx\n",
4975 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
);
4977 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4980 TOOLBAR_SetHotItemEx(infoPtr
, wParam
, lParam
);
4984 return (nOldHotItem
< 0) ? -1 : (LRESULT
)nOldHotItem
;
4987 /* UNDOCUMENTED MESSAGE: This sets the toolbar global iListGap parameter
4988 * which controls the amount of spacing between the image and the text
4989 * of buttons for TBSTYLE_LIST toolbars. */
4990 static LRESULT
TOOLBAR_Unkwn460(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4992 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4994 TRACE("hwnd=%p iListGap=%d\n", hwnd
, wParam
);
4997 FIXME("lParam = 0x%08lx. Please report\n", lParam
);
4999 infoPtr
->iListGap
= (INT
)wParam
;
5001 TOOLBAR_CalcToolbar(hwnd
);
5002 InvalidateRect(hwnd
, NULL
, TRUE
);
5007 /* UNDOCUMENTED MESSAGE: This returns the number of maximum number
5008 * of image lists associated with the various states. */
5009 static LRESULT
TOOLBAR_Unkwn462(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5011 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5013 TRACE("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5015 return max(infoPtr
->cimlDef
, max(infoPtr
->cimlHot
, infoPtr
->cimlDis
));
5019 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5021 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5022 LPSIZE lpsize
= (LPSIZE
)lParam
;
5028 * Testing shows the following:
5029 * wParam = 0 adjust cx value
5030 * = 1 set cy value to max size.
5031 * lParam pointer to SIZE structure
5034 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
5035 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
5039 if (lpsize
->cx
== -1) {
5040 /* **** this is wrong, native measures each button and sets it */
5041 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5043 else if(HIWORD(lpsize
->cx
)) {
5045 HWND hwndParent
= GetParent(hwnd
);
5047 GetWindowRect(hwnd
, &rc
);
5048 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
5049 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
5050 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5051 lpsize
->cx
= max(rc
.right
-rc
.left
,
5052 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
5055 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5059 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5060 /* lpsize->cy = infoPtr->nHeight; */
5063 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
5067 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
5068 lpsize
->cx
, lpsize
->cy
);
5072 static LRESULT
TOOLBAR_Unkwn464(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5074 FIXME("hwnd=%p wParam %08x lParam %08lx\n", hwnd
, wParam
, lParam
);
5076 InvalidateRect(hwnd
, NULL
, TRUE
);
5082 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5084 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5085 DWORD dwStyle
= GetWindowLongW (hwnd
, GWL_STYLE
);
5088 TRACE("hwnd = %p\n", hwnd
);
5090 /* initialize info structure */
5091 infoPtr
->nButtonHeight
= 22;
5092 infoPtr
->nButtonWidth
= 24;
5093 infoPtr
->nBitmapHeight
= 15;
5094 infoPtr
->nBitmapWidth
= 16;
5096 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
5097 infoPtr
->nMaxTextRows
= 1;
5098 infoPtr
->cxMin
= -1;
5099 infoPtr
->cxMax
= -1;
5100 infoPtr
->nNumBitmaps
= 0;
5101 infoPtr
->nNumStrings
= 0;
5103 infoPtr
->bCaptured
= FALSE
;
5104 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
5105 infoPtr
->nButtonDown
= -1;
5106 infoPtr
->nButtonDrag
= -1;
5107 infoPtr
->nOldHit
= -1;
5108 infoPtr
->nHotItem
= -1;
5109 infoPtr
->hwndNotify
= ((LPCREATESTRUCTW
)lParam
)->hwndParent
;
5110 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5111 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
: DT_CENTER
| DT_END_ELLIPSIS
;
5112 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
5113 infoPtr
->bDragOutSent
= FALSE
;
5114 infoPtr
->iVersion
= 0;
5115 infoPtr
->hwndSelf
= hwnd
;
5116 infoPtr
->bDoRedraw
= TRUE
;
5117 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
5118 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
5119 /* not sure where the +1 comes from, but this comes to the same value
5120 * as native so this is probably correct */
5121 infoPtr
->szPadding
.cx
= 2*(GetSystemMetrics(SM_CXEDGE
)+OFFSET_X
) + 1;
5122 infoPtr
->szPadding
.cy
= 2*(GetSystemMetrics(SM_CYEDGE
)+OFFSET_Y
);
5123 infoPtr
->iListGap
= infoPtr
->szPadding
.cx
/ 2;
5124 infoPtr
->dwStyle
= dwStyle
;
5125 GetClientRect(hwnd
, &infoPtr
->client_rect
);
5126 TOOLBAR_NotifyFormat(infoPtr
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
);
5128 SystemParametersInfoA (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
5129 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectA (&logFont
);
5131 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
5132 /* Create tooltip control */
5133 infoPtr
->hwndToolTip
=
5134 CreateWindowExA (0, TOOLTIPS_CLASSA
, NULL
, 0,
5135 CW_USEDEFAULT
, CW_USEDEFAULT
,
5136 CW_USEDEFAULT
, CW_USEDEFAULT
,
5139 /* Send NM_TOOLTIPSCREATED notification */
5140 if (infoPtr
->hwndToolTip
) {
5141 NMTOOLTIPSCREATED nmttc
;
5143 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
5145 TOOLBAR_SendNotify ((NMHDR
*) &nmttc
, infoPtr
,
5146 NM_TOOLTIPSCREATED
);
5150 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
5152 TOOLBAR_CalcToolbar(hwnd
);
5159 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5161 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5163 /* delete tooltip control */
5164 if (infoPtr
->hwndToolTip
)
5165 DestroyWindow (infoPtr
->hwndToolTip
);
5167 /* delete temporary buffer for tooltip text */
5168 if (infoPtr
->pszTooltipText
)
5169 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5171 /* delete button data */
5172 if (infoPtr
->buttons
)
5173 Free (infoPtr
->buttons
);
5175 /* delete strings */
5176 if (infoPtr
->strings
) {
5178 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
5179 if (infoPtr
->strings
[i
])
5180 Free (infoPtr
->strings
[i
]);
5182 Free (infoPtr
->strings
);
5185 /* destroy internal image list */
5186 if (infoPtr
->himlInt
)
5187 ImageList_Destroy (infoPtr
->himlInt
);
5189 TOOLBAR_DeleteImageList(&infoPtr
->himlDef
, &infoPtr
->cimlDef
);
5190 TOOLBAR_DeleteImageList(&infoPtr
->himlDis
, &infoPtr
->cimlDis
);
5191 TOOLBAR_DeleteImageList(&infoPtr
->himlHot
, &infoPtr
->cimlHot
);
5193 /* delete default font */
5195 DeleteObject (infoPtr
->hDefaultFont
);
5197 /* free toolbar info data */
5199 SetWindowLongPtrW (hwnd
, 0, 0);
5206 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5208 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5209 NMTBCUSTOMDRAW tbcd
;
5213 if (infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) {
5214 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5215 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
5216 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5217 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5218 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5220 /* FIXME: in general the return flags *can* be or'ed together */
5221 switch (infoPtr
->dwBaseCustDraw
)
5223 case CDRF_DODEFAULT
:
5225 case CDRF_SKIPDEFAULT
:
5228 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5233 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
5234 * to my parent for processing.
5236 if (infoPtr
->dwStyle
& TBSTYLE_TRANSPARENT
) {
5238 HDC hdc
= (HDC
)wParam
;
5243 parent
= GetParent(hwnd
);
5244 MapWindowPoints(hwnd
, parent
, &pt
, 1);
5245 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
5246 ret
= SendMessageA (parent
, WM_ERASEBKGND
, wParam
, lParam
);
5247 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
5250 ret
= DefWindowProcA (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
5252 if ((infoPtr
->dwStyle
& TBSTYLE_CUSTOMERASE
) &&
5253 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
5254 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
5255 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
5256 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
5257 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
5258 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
5259 switch (infoPtr
->dwBaseCustDraw
)
5261 case CDRF_DODEFAULT
:
5263 case CDRF_SKIPDEFAULT
:
5266 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
5275 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5277 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5279 return (LRESULT
)infoPtr
->hFont
;
5284 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5289 pt
.x
= (INT
)LOWORD(lParam
);
5290 pt
.y
= (INT
)HIWORD(lParam
);
5291 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5294 TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5295 else if (GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
5296 TOOLBAR_Customize (hwnd
);
5303 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5305 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5306 TBUTTON_INFO
*btnPtr
;
5310 BOOL bDragKeyPressed
;
5312 if (infoPtr
->dwStyle
& TBSTYLE_ALTDRAG
)
5313 bDragKeyPressed
= (GetKeyState(VK_MENU
) < 0);
5315 bDragKeyPressed
= (wParam
& MK_SHIFT
);
5317 if (infoPtr
->hwndToolTip
)
5318 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5319 WM_LBUTTONDOWN
, wParam
, lParam
);
5321 pt
.x
= (INT
)LOWORD(lParam
);
5322 pt
.y
= (INT
)HIWORD(lParam
);
5323 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5325 btnPtr
= &infoPtr
->buttons
[nHit
];
5327 if ((nHit
>= 0) && bDragKeyPressed
&& (infoPtr
->dwStyle
& CCS_ADJUSTABLE
))
5329 infoPtr
->nButtonDrag
= nHit
;
5332 /* If drag cursor has not been loaded, load it.
5333 * Note: it doesn't need to be freed */
5335 hCursorDrag
= LoadCursorW(COMCTL32_hModule
, (LPCWSTR
)IDC_MOVEBUTTON
);
5336 SetCursor(hCursorDrag
);
5341 infoPtr
->nOldHit
= nHit
;
5343 CopyRect(&arrowRect
, &btnPtr
->rect
);
5344 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
5346 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
5347 if ((btnPtr
->fsState
& TBSTATE_ENABLED
) &&
5348 ((btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
) ||
5349 ((btnPtr
->fsStyle
& BTNS_DROPDOWN
) &&
5350 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
5351 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))))
5355 /* draw in pressed state */
5356 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5357 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5359 btnPtr
->bDropDownPressed
= TRUE
;
5360 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
5361 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
5363 nmtb
.iItem
= btnPtr
->idCommand
;
5364 memset(&nmtb
.tbButton
, 0, sizeof(TBBUTTON
));
5367 CopyRect(&nmtb
.rcButton
, &btnPtr
->rect
);
5368 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5370 TRACE("TBN_DROPDOWN responded with %ld\n", res
);
5372 if (res
!= TBDDRET_TREATPRESSED
)
5376 /* redraw button in unpressed state */
5377 if (btnPtr
->fsStyle
& BTNS_WHOLEDROPDOWN
)
5378 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5380 btnPtr
->bDropDownPressed
= FALSE
;
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 or double-click messages
5391 * so that we can get a toggle effect on the button */
5392 while (PeekMessageW(&msg
, hwnd
, WM_LBUTTONDOWN
, WM_LBUTTONDOWN
, PM_REMOVE
) ||
5393 PeekMessageW(&msg
, hwnd
, WM_LBUTTONDBLCLK
, WM_LBUTTONDBLCLK
, PM_REMOVE
))
5398 /* otherwise drop through and process as pushed */
5400 infoPtr
->bCaptured
= TRUE
;
5401 infoPtr
->nButtonDown
= nHit
;
5402 infoPtr
->bDragOutSent
= FALSE
;
5404 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5406 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5408 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5409 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5416 nmtb
.iItem
= btnPtr
->idCommand
;
5417 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
5418 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
5419 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
5420 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
5421 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
5422 nmtb
.tbButton
.iString
= btnPtr
->iString
;
5423 nmtb
.cchText
= 0; /* !!! not correct */
5424 nmtb
.pszText
= 0; /* !!! not correct */
5425 TOOLBAR_SendNotify((NMHDR
*)&nmtb
, infoPtr
, TBN_BEGINDRAG
);
5432 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5434 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5435 TBUTTON_INFO
*btnPtr
;
5439 BOOL bSendMessage
= TRUE
;
5444 if (infoPtr
->hwndToolTip
)
5445 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5446 WM_LBUTTONUP
, wParam
, lParam
);
5448 pt
.x
= (INT
)LOWORD(lParam
);
5449 pt
.y
= (INT
)HIWORD(lParam
);
5450 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5452 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5454 if (infoPtr
->nButtonDrag
>= 0) {
5458 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDrag
];
5461 SetCursor(LoadCursorW(NULL
, (LPCWSTR
)IDC_ARROW
));
5463 GetClientRect(hwnd
, &rcClient
);
5464 if (PtInRect(&rcClient
, pt
))
5471 else if ((nHit
== -1) && PtInRect(&infoPtr
->buttons
[-nHit
].rect
, pt
))
5474 if (nButton
== infoPtr
->nButtonDrag
)
5476 /* if the button is moved sightly left and we have a
5477 * separator there then remove it */
5478 if (pt
.x
< (btnPtr
->rect
.left
+ (btnPtr
->rect
.right
- btnPtr
->rect
.left
)/2))
5480 if ((nButton
> 0) && (infoPtr
->buttons
[nButton
-1].fsStyle
& BTNS_SEP
))
5481 TOOLBAR_DeleteButton(hwnd
, nButton
- 1, 0);
5483 else /* else insert a separator before the dragged button */
5486 memset(&tbb
, 0, sizeof(tbb
));
5487 tbb
.fsStyle
= BTNS_SEP
;
5489 TOOLBAR_InsertButtonW(hwnd
, nButton
, (LPARAM
)&tbb
);
5496 if ((infoPtr
->nNumButtons
> 0) && (pt
.x
< infoPtr
->buttons
[0].rect
.left
))
5497 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, 0);
5499 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, infoPtr
->nNumButtons
);
5502 TOOLBAR_MoveButton(hwnd
, infoPtr
->nButtonDrag
, nButton
);
5507 TRACE("button %d dragged out of toolbar\n", infoPtr
->nButtonDrag
);
5508 TOOLBAR_DeleteButton(hwnd
, (WPARAM
)infoPtr
->nButtonDrag
, 0);
5511 /* button under cursor changed so need to re-set hot item */
5512 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
| HICF_LMOUSE
);
5513 infoPtr
->nButtonDrag
= -1;
5515 TOOLBAR_SendNotify(&hdr
, infoPtr
, TBN_TOOLBARCHANGE
);
5517 else if (infoPtr
->nButtonDown
>= 0) {
5518 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5519 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5521 if (btnPtr
->fsStyle
& BTNS_CHECK
) {
5522 if (btnPtr
->fsStyle
& BTNS_GROUP
) {
5523 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
5525 if (nOldIndex
== nHit
)
5526 bSendMessage
= FALSE
;
5527 if ((nOldIndex
!= nHit
) &&
5529 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
5530 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5533 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
5534 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
5536 btnPtr
->fsState
|= TBSTATE_CHECKED
;
5540 if (nOldIndex
!= -1)
5541 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
, TRUE
);
5544 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5545 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5546 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5548 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
5550 infoPtr
->nButtonDown
= -1;
5552 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5553 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
5554 NM_RELEASEDCAPTURE
);
5556 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5559 nmtb
.iItem
= btnPtr
->idCommand
;
5560 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
5561 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
5562 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
5563 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
5564 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
5565 nmtb
.tbButton
.iString
= btnPtr
->iString
;
5566 nmtb
.cchText
= 0; /* !!! not correct */
5567 nmtb
.pszText
= 0; /* !!! not correct */
5568 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
5571 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5573 SendMessageA (infoPtr
->hwndNotify
, WM_COMMAND
,
5574 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
5576 /* !!! Undocumented - toolbar at 4.71 level and above sends
5577 * either NM_RCLICK or NM_CLICK with the NMMOUSE structure.
5578 * Only NM_RCLICK is documented.
5580 nmmouse
.dwItemSpec
= btnPtr
->idCommand
;
5581 nmmouse
.dwItemData
= btnPtr
->dwData
;
5582 TOOLBAR_SendNotify ((NMHDR
*) &nmmouse
, infoPtr
, NM_CLICK
);
5589 TOOLBAR_RButtonUp( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5591 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5596 pt
.x
= LOWORD(lParam
);
5597 pt
.y
= HIWORD(lParam
);
5599 nmmouse
.dwHitInfo
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5601 if (nmmouse
.dwHitInfo
< 0) {
5602 nmmouse
.dwItemSpec
= -1;
5604 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5605 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5608 ClientToScreen(hwnd
, &pt
);
5609 memcpy(&nmmouse
.pt
, &pt
, sizeof(POINT
));
5611 TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_RCLICK
);
5617 TOOLBAR_RButtonDblClk( HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5619 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5624 pt
.x
= LOWORD(lParam
);
5625 pt
.y
= HIWORD(lParam
);
5627 nmmouse
.dwHitInfo
= TOOLBAR_InternalHitTest(hwnd
, &pt
);
5629 if (nmmouse
.dwHitInfo
< 0)
5630 nmmouse
.dwItemSpec
= -1;
5632 nmmouse
.dwItemSpec
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].idCommand
;
5633 nmmouse
.dwItemData
= infoPtr
->buttons
[nmmouse
.dwHitInfo
].dwData
;
5636 ClientToScreen(hwnd
, &pt
);
5637 memcpy(&nmmouse
.pt
, &pt
, sizeof(POINT
));
5639 TOOLBAR_SendNotify((LPNMHDR
)&nmmouse
, infoPtr
, NM_RDBLCLK
);
5645 TOOLBAR_CaptureChanged(HWND hwnd
)
5647 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5648 TBUTTON_INFO
*btnPtr
;
5650 infoPtr
->bCaptured
= FALSE
;
5652 if (infoPtr
->nButtonDown
>= 0)
5654 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5655 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5657 infoPtr
->nOldHit
= -1;
5659 if (btnPtr
->fsState
& TBSTATE_ENABLED
)
5660 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5666 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5668 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5669 TBUTTON_INFO
*hotBtnPtr
;
5671 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
5673 /* don't remove hot effects when in drop-down */
5674 if (infoPtr
->nOldHit
< 0 || !hotBtnPtr
->bDropDownPressed
)
5675 TOOLBAR_SetHotItemEx(infoPtr
, -1, HICF_MOUSE
);
5677 if (infoPtr
->nOldHit
< 0)
5680 /* If the last button we were over is depressed then make it not */
5681 /* depressed and redraw it */
5682 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
5684 TBUTTON_INFO
*btnPtr
;
5687 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5689 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5691 rc1
= hotBtnPtr
->rect
;
5692 InflateRect (&rc1
, 1, 1);
5693 InvalidateRect (hwnd
, &rc1
, TRUE
);
5696 if (infoPtr
->bCaptured
&& !infoPtr
->bDragOutSent
)
5699 ZeroMemory(&nmt
, sizeof(nmt
));
5700 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
5701 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
5702 infoPtr
->bDragOutSent
= TRUE
;
5705 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
5711 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5713 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5715 TRACKMOUSEEVENT trackinfo
;
5717 TBUTTON_INFO
*btnPtr
;
5719 /* fill in the TRACKMOUSEEVENT struct */
5720 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
5721 trackinfo
.dwFlags
= TME_QUERY
;
5722 trackinfo
.hwndTrack
= hwnd
;
5723 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
5725 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
5726 _TrackMouseEvent(&trackinfo
);
5728 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
5729 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
5730 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
5732 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
5733 /* and can properly deactivate the hot toolbar button */
5734 _TrackMouseEvent(&trackinfo
);
5737 if (infoPtr
->hwndToolTip
)
5738 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
5739 WM_MOUSEMOVE
, wParam
, lParam
);
5741 pt
.x
= (INT
)LOWORD(lParam
);
5742 pt
.y
= (INT
)HIWORD(lParam
);
5744 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
5746 TOOLBAR_SetHotItemEx(infoPtr
, nHit
, HICF_MOUSE
);
5748 if (infoPtr
->nOldHit
!= nHit
)
5750 if (infoPtr
->bCaptured
)
5752 if (!infoPtr
->bDragOutSent
)
5755 ZeroMemory(&nmt
, sizeof(nmt
));
5756 nmt
.iItem
= infoPtr
->buttons
[infoPtr
->nButtonDown
].idCommand
;
5757 TOOLBAR_SendNotify(&nmt
.hdr
, infoPtr
, TBN_DRAGOUT
);
5758 infoPtr
->bDragOutSent
= TRUE
;
5761 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
5762 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
5763 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
5764 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5766 else if (nHit
== infoPtr
->nButtonDown
) {
5767 btnPtr
->fsState
|= TBSTATE_PRESSED
;
5768 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
5770 infoPtr
->nOldHit
= nHit
;
5778 inline static LRESULT
5779 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5781 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
5782 return DefWindowProcA (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
5784 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
5788 inline static LRESULT
5789 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5791 if (!(GetWindowLongW(hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
5792 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
5794 return DefWindowProcA (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
5799 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5801 TOOLBAR_INFO
*infoPtr
;
5802 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
5805 /* allocate memory for info structure */
5806 infoPtr
= (TOOLBAR_INFO
*)Alloc (sizeof(TOOLBAR_INFO
));
5807 SetWindowLongPtrW (hwnd
, 0, (LONG_PTR
)infoPtr
);
5810 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
5813 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5814 if (!GetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
)) {
5815 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongPtrW (GetParent (hwnd
), GWLP_HINSTANCE
);
5816 SetWindowLongPtrW (hwnd
, GWLP_HINSTANCE
, (LONG_PTR
)hInst
);
5819 /* native control does:
5820 * Get a lot of colors and brushes
5822 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5823 * CreateFontIndirectA(adr1)
5824 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5825 * hdc = GetDC(toolbar)
5826 * GetSystemMetrics(0x48)
5827 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5828 * 0, 0, 0, 0, "MARLETT")
5829 * oldfnt = SelectObject(hdc, fnt2)
5830 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5831 * GetTextMetricsA(hdc, adr3)
5832 * SelectObject(hdc, oldfnt)
5833 * DeleteObject(fnt2)
5835 * InvalidateRect(toolbar, 0, 1)
5836 * SetWindowLongA(toolbar, 0, addr)
5837 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5840 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5841 * ie 2 0x4600094c 0x4600094c 0x4600894d
5842 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5843 * rebar 0x50008844 0x40008844 0x50008845
5844 * pager 0x50000844 0x40000844 0x50008845
5845 * IC35mgr 0x5400084e **nochange**
5846 * on entry to _NCCREATE 0x5400084e
5847 * rowlist 0x5400004e **nochange**
5848 * on entry to _NCCREATE 0x5400004e
5852 /* I think the code below is a bug, but it is the way that the native
5853 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5854 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5855 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5856 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5857 * Some how, the only cases of this seem to be MFC programs.
5859 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5860 * does not occur in the WM_STYLECHANGING routine.
5861 * (Guy Albertelli 9/2001)
5864 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
5865 styleadd
|= TBSTYLE_TRANSPARENT
;
5866 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
5867 styleadd
|= CCS_TOP
; /* default to top */
5868 SetWindowLongW (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
5871 return DefWindowProcA (hwnd
, WM_NCCREATE
, wParam
, lParam
);
5876 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5878 DWORD dwStyle
= GetWindowLongW(hwnd
, GWL_STYLE
);
5882 if (dwStyle
& WS_MINIMIZE
)
5883 return 0; /* Nothing to do */
5885 DefWindowProcA (hwnd
, WM_NCPAINT
, wParam
, lParam
);
5887 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
5890 if (!(dwStyle
& CCS_NODIVIDER
))
5892 GetWindowRect (hwnd
, &rcWindow
);
5893 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
5894 if( dwStyle
& WS_BORDER
)
5895 OffsetRect (&rcWindow
, 1, 1);
5896 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
5899 ReleaseDC( hwnd
, hdc
);
5905 /* handles requests from the tooltip control on what text to display */
5906 static LRESULT
TOOLBAR_TTGetDispInfo (TOOLBAR_INFO
*infoPtr
, NMTTDISPINFOW
*lpnmtdi
)
5908 int index
= TOOLBAR_GetButtonIndex(infoPtr
, lpnmtdi
->hdr
.idFrom
, FALSE
);
5910 TRACE("button index = %d\n", index
);
5912 if (infoPtr
->pszTooltipText
)
5914 HeapFree(GetProcessHeap(), 0, infoPtr
->pszTooltipText
);
5915 infoPtr
->pszTooltipText
= NULL
;
5921 if (infoPtr
->bNtfUnicode
)
5923 WCHAR wszBuffer
[INFOTIPSIZE
+1];
5924 NMTBGETINFOTIPW tbgit
;
5925 int len
; /* in chars */
5927 wszBuffer
[0] = '\0';
5928 wszBuffer
[INFOTIPSIZE
] = '\0';
5930 tbgit
.pszText
= wszBuffer
;
5931 tbgit
.cchTextMax
= INFOTIPSIZE
;
5932 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
5933 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
5935 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPW
);
5937 TRACE("TBN_GETINFOTIPW - got string %s\n", debugstr_w(tbgit
.pszText
));
5939 len
= strlenW(tbgit
.pszText
);
5940 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5942 /* need to allocate temporary buffer in infoPtr as there
5943 * isn't enough space in buffer passed to us by the
5944 * tooltip control */
5945 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5946 if (infoPtr
->pszTooltipText
)
5948 memcpy(infoPtr
->pszTooltipText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
5949 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5955 memcpy(lpnmtdi
->lpszText
, tbgit
.pszText
, (len
+1)*sizeof(WCHAR
));
5961 CHAR szBuffer
[INFOTIPSIZE
+1];
5962 NMTBGETINFOTIPA tbgit
;
5963 int len
; /* in chars */
5966 szBuffer
[INFOTIPSIZE
] = '\0';
5968 tbgit
.pszText
= szBuffer
;
5969 tbgit
.cchTextMax
= INFOTIPSIZE
;
5970 tbgit
.iItem
= lpnmtdi
->hdr
.idFrom
;
5971 tbgit
.lParam
= infoPtr
->buttons
[index
].dwData
;
5973 TOOLBAR_SendNotify(&tbgit
.hdr
, infoPtr
, TBN_GETINFOTIPA
);
5975 TRACE("TBN_GETINFOTIPA - got string %s\n", debugstr_a(tbgit
.pszText
));
5977 len
= -1 + MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, -1, NULL
, 0);
5978 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
5980 /* need to allocate temporary buffer in infoPtr as there
5981 * isn't enough space in buffer passed to us by the
5982 * tooltip control */
5983 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
5984 if (infoPtr
->pszTooltipText
)
5986 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, infoPtr
->pszTooltipText
, (len
+1)*sizeof(WCHAR
));
5987 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
5993 MultiByteToWideChar(CP_ACP
, 0, tbgit
.pszText
, len
+1, lpnmtdi
->lpszText
, (len
+1)*sizeof(WCHAR
));
5998 /* if button has text, but it is not shown then automatically
5999 * use that text as tooltip */
6000 if ((infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) &&
6001 !(infoPtr
->buttons
[index
].fsStyle
& BTNS_SHOWTEXT
))
6003 LPWSTR pszText
= TOOLBAR_GetText(infoPtr
, &infoPtr
->buttons
[index
]);
6004 int len
= pszText
? strlenW(pszText
) : 0;
6006 TRACE("using button hidden text %s\n", debugstr_w(pszText
));
6008 if (len
> sizeof(lpnmtdi
->szText
)/sizeof(lpnmtdi
->szText
[0])-1)
6010 /* need to allocate temporary buffer in infoPtr as there
6011 * isn't enough space in buffer passed to us by the
6012 * tooltip control */
6013 infoPtr
->pszTooltipText
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
6014 if (infoPtr
->pszTooltipText
)
6016 memcpy(infoPtr
->pszTooltipText
, pszText
, (len
+1)*sizeof(WCHAR
));
6017 lpnmtdi
->lpszText
= infoPtr
->pszTooltipText
;
6023 memcpy(lpnmtdi
->lpszText
, pszText
, (len
+1)*sizeof(WCHAR
));
6028 TRACE("Sending tooltip notification to %p\n", infoPtr
->hwndNotify
);
6030 /* last resort: send notification on to app */
6031 /* FIXME: find out what is really used here */
6032 return SendMessageW(infoPtr
->hwndNotify
, WM_NOTIFY
, 0, (LPARAM
)lpnmtdi
);
6036 inline static LRESULT
6037 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6039 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6040 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
6042 switch (lpnmh
->code
)
6046 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
6048 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
6049 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
6050 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
6054 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
6055 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
6063 LPNMPGSCROLL lppgs
= (LPNMPGSCROLL
)lParam
;
6065 lppgs
->iScroll
= (lppgs
->iDir
& (PGF_SCROLLLEFT
| PGF_SCROLLRIGHT
)) ?
6066 infoPtr
->nButtonWidth
: infoPtr
->nButtonHeight
;
6067 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
6068 lppgs
->iScroll
, lppgs
->iDir
);
6072 case TTN_GETDISPINFOW
:
6073 return TOOLBAR_TTGetDispInfo(infoPtr
, (LPNMTTDISPINFOW
)lParam
);
6075 case TTN_GETDISPINFOA
:
6076 FIXME("TTN_GETDISPINFOA - stub\n");
6086 TOOLBAR_NotifyFormatFake(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6088 /* remove this routine when Toolbar is improved to pass infoPtr
6089 * around instead of hwnd.
6091 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6092 return TOOLBAR_NotifyFormat(infoPtr
, wParam
, lParam
);
6097 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
6101 TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam
, lParam
);
6103 if ((lParam
== NF_QUERY
) && ((HWND
)wParam
== infoPtr
->hwndToolTip
))
6106 if (lParam
== NF_REQUERY
) {
6107 i
= SendMessageA(infoPtr
->hwndNotify
,
6108 WM_NOTIFYFORMAT
, (WPARAM
)infoPtr
->hwndSelf
, NF_QUERY
);
6109 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
6110 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
6114 infoPtr
->bNtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
6117 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
6122 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
6124 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
6128 /* fill ps.rcPaint with a default rect */
6129 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
6131 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
6133 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
6134 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
6135 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
6137 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
6138 if (!wParam
) EndPaint (hwnd
, &ps
);
6145 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6146 /*****************************************************
6149 * Handles the WM_SETREDRAW message.
6152 * According to testing V4.71 of COMCTL32 returns the
6153 * *previous* status of the redraw flag (either 0 or 1)
6154 * instead of the MSDN documented value of 0 if handled.
6155 * (For laughs see the "consistency" with same function
6158 *****************************************************/
6160 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6161 BOOL oldredraw
= infoPtr
->bDoRedraw
;
6163 TRACE("set to %s\n",
6164 (wParam
) ? "TRUE" : "FALSE");
6165 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
6167 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
6169 return (oldredraw
) ? 1 : 0;
6174 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
6176 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6177 DWORD dwStyle
= infoPtr
->dwStyle
;
6186 /* Resize deadlock check */
6187 if (infoPtr
->bAutoSize
) {
6188 infoPtr
->bAutoSize
= FALSE
;
6192 /* FIXME: optimize to only update size if the new size doesn't */
6193 /* match the current size */
6195 flags
= (INT
) wParam
;
6197 /* FIXME for flags =
6198 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
6201 TRACE("sizing toolbar!\n");
6203 if (flags
== SIZE_RESTORED
) {
6204 /* width and height don't apply */
6205 parent
= GetParent (hwnd
);
6206 GetClientRect(parent
, &parent_rect
);
6207 x
= parent_rect
.left
;
6208 y
= parent_rect
.top
;
6210 if (dwStyle
& CCS_NORESIZE
) {
6211 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
6214 * this sets the working width of the toolbar, and
6215 * Calc Toolbar will not adjust it, only the height
6217 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6218 cy
= infoPtr
->nHeight
;
6219 cx
= infoPtr
->nWidth
;
6220 TOOLBAR_CalcToolbar (hwnd
);
6221 infoPtr
->nWidth
= cx
;
6222 infoPtr
->nHeight
= cy
;
6225 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
6226 TOOLBAR_CalcToolbar (hwnd
);
6227 cy
= infoPtr
->nHeight
;
6228 cx
= infoPtr
->nWidth
;
6230 if ((dwStyle
& CCS_BOTTOM
) == CCS_NOMOVEY
) {
6231 GetWindowRect(hwnd
, &window_rect
);
6232 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
6233 y
= window_rect
.top
;
6235 if ((dwStyle
& CCS_BOTTOM
) == CCS_BOTTOM
) {
6236 GetWindowRect(hwnd
, &window_rect
);
6237 y
= parent_rect
.bottom
-
6238 ( window_rect
.bottom
- window_rect
.top
);
6242 if (dwStyle
& CCS_NOPARENTALIGN
) {
6243 uPosFlags
|= SWP_NOMOVE
;
6244 cy
= infoPtr
->nHeight
;
6245 cx
= infoPtr
->nWidth
;
6248 if (!(dwStyle
& CCS_NODIVIDER
))
6249 cy
+= GetSystemMetrics(SM_CYEDGE
);
6251 if (dwStyle
& WS_BORDER
)
6254 cy
+= GetSystemMetrics(SM_CYEDGE
);
6255 cx
+= GetSystemMetrics(SM_CYEDGE
);
6258 if(infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
)
6260 RECT delta_width
, delta_height
, client
, dummy
;
6261 DWORD min_x
, max_x
, min_y
, max_y
;
6262 TBUTTON_INFO
*btnPtr
;
6265 GetClientRect(hwnd
, &client
);
6266 if(client
.right
> infoPtr
->client_rect
.right
)
6268 min_x
= infoPtr
->client_rect
.right
;
6269 max_x
= client
.right
;
6273 max_x
= infoPtr
->client_rect
.right
;
6274 min_x
= client
.right
;
6276 if(client
.bottom
> infoPtr
->client_rect
.bottom
)
6278 min_y
= infoPtr
->client_rect
.bottom
;
6279 max_y
= client
.bottom
;
6283 max_y
= infoPtr
->client_rect
.bottom
;
6284 min_y
= client
.bottom
;
6287 SetRect(&delta_width
, min_x
, 0, max_x
, min_y
);
6288 SetRect(&delta_height
, 0, min_y
, max_x
, max_y
);
6290 TRACE("delta_width %s delta_height %s\n", wine_dbgstr_rect(&delta_width
), wine_dbgstr_rect(&delta_height
));
6291 btnPtr
= infoPtr
->buttons
;
6292 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
6293 if(IntersectRect(&dummy
, &delta_width
, &btnPtr
->rect
) ||
6294 IntersectRect(&dummy
, &delta_height
, &btnPtr
->rect
))
6295 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
6298 if((uPosFlags
& (SWP_NOSIZE
| SWP_NOMOVE
)) != (SWP_NOSIZE
| SWP_NOMOVE
))
6299 SetWindowPos (hwnd
, 0, x
, y
, cx
, cy
, uPosFlags
| SWP_NOZORDER
);
6301 GetClientRect(hwnd
, &infoPtr
->client_rect
);
6307 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
6309 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6311 if (nType
== GWL_STYLE
) {
6312 if (lpStyle
->styleNew
& TBSTYLE_LIST
) {
6313 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
| DT_END_ELLIPSIS
;
6316 infoPtr
->dwDTFlags
= DT_CENTER
| DT_END_ELLIPSIS
;
6318 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
6319 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
6320 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
6322 TRACE("new style 0x%08lx\n", lpStyle
->styleNew
);
6324 infoPtr
->dwStyle
= lpStyle
->styleNew
;
6327 TOOLBAR_CalcToolbar(hwnd
);
6329 TOOLBAR_AutoSize (hwnd
);
6331 InvalidateRect(hwnd
, NULL
, TRUE
);
6338 TOOLBAR_SysColorChange (HWND hwnd
)
6340 COMCTL32_RefreshSysColors();
6347 static LRESULT WINAPI
6348 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
6350 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
6352 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
6353 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
6355 if (!TOOLBAR_GetInfoPtr(hwnd
) && (uMsg
!= WM_NCCREATE
))
6356 return DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
6361 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
6363 case TB_ADDBUTTONSA
:
6364 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
6366 case TB_ADDBUTTONSW
:
6367 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
6370 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
6373 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
6376 return TOOLBAR_AutoSize (hwnd
);
6378 case TB_BUTTONCOUNT
:
6379 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
6381 case TB_BUTTONSTRUCTSIZE
:
6382 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
6384 case TB_CHANGEBITMAP
:
6385 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
6387 case TB_CHECKBUTTON
:
6388 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
6390 case TB_COMMANDTOINDEX
:
6391 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
6394 return TOOLBAR_Customize (hwnd
);
6396 case TB_DELETEBUTTON
:
6397 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
6399 case TB_ENABLEBUTTON
:
6400 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
6402 case TB_GETANCHORHIGHLIGHT
:
6403 return TOOLBAR_GetAnchorHighlight (hwnd
);
6406 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
6408 case TB_GETBITMAPFLAGS
:
6409 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
6412 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
6414 case TB_GETBUTTONINFOA
:
6415 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
6417 case TB_GETBUTTONINFOW
:
6418 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
6420 case TB_GETBUTTONSIZE
:
6421 return TOOLBAR_GetButtonSize (hwnd
);
6423 case TB_GETBUTTONTEXTA
:
6424 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
6426 case TB_GETBUTTONTEXTW
:
6427 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
6429 case TB_GETDISABLEDIMAGELIST
:
6430 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
6432 case TB_GETEXTENDEDSTYLE
:
6433 return TOOLBAR_GetExtendedStyle (hwnd
);
6435 case TB_GETHOTIMAGELIST
:
6436 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
6439 return TOOLBAR_GetHotItem (hwnd
);
6441 case TB_GETIMAGELIST
:
6442 return TOOLBAR_GetDefImageList (hwnd
, wParam
, lParam
);
6444 /* case TB_GETINSERTMARK: */ /* 4.71 */
6445 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
6447 case TB_GETITEMRECT
:
6448 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
6451 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
6453 /* case TB_GETOBJECT: */ /* 4.71 */
6456 return TOOLBAR_GetPadding (hwnd
);
6459 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
6462 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
6465 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
6468 return TOOLBAR_GetStringA (hwnd
, wParam
, lParam
);
6471 return TOOLBAR_GetStringW (hwnd
, wParam
, lParam
);
6474 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
6476 case TB_GETTEXTROWS
:
6477 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
6479 case TB_GETTOOLTIPS
:
6480 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
6482 case TB_GETUNICODEFORMAT
:
6483 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
6486 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
6489 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
6491 case TB_INDETERMINATE
:
6492 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
6494 case TB_INSERTBUTTONA
:
6495 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
6497 case TB_INSERTBUTTONW
:
6498 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
6500 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
6502 case TB_ISBUTTONCHECKED
:
6503 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
6505 case TB_ISBUTTONENABLED
:
6506 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
6508 case TB_ISBUTTONHIDDEN
:
6509 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
6511 case TB_ISBUTTONHIGHLIGHTED
:
6512 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
6514 case TB_ISBUTTONINDETERMINATE
:
6515 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
6517 case TB_ISBUTTONPRESSED
:
6518 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
6521 return TOOLBAR_LoadImages (hwnd
, wParam
, lParam
);
6523 case TB_MAPACCELERATORA
:
6524 case TB_MAPACCELERATORW
:
6525 return TOOLBAR_MapAccelerator (hwnd
, wParam
, lParam
);
6528 return TOOLBAR_MarkButton (hwnd
, wParam
, lParam
);
6531 return TOOLBAR_MoveButton (hwnd
, wParam
, lParam
);
6533 case TB_PRESSBUTTON
:
6534 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
6536 case TB_REPLACEBITMAP
:
6537 return TOOLBAR_ReplaceBitmap (hwnd
, wParam
, lParam
);
6539 case TB_SAVERESTOREA
:
6540 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, lParam
);
6542 case TB_SAVERESTOREW
:
6543 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, lParam
);
6545 case TB_SETANCHORHIGHLIGHT
:
6546 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
6548 case TB_SETBITMAPSIZE
:
6549 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
6551 case TB_SETBUTTONINFOA
:
6552 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
6554 case TB_SETBUTTONINFOW
:
6555 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
6557 case TB_SETBUTTONSIZE
:
6558 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
6560 case TB_SETBUTTONWIDTH
:
6561 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
6564 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
6566 case TB_SETDISABLEDIMAGELIST
:
6567 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
6569 case TB_SETDRAWTEXTFLAGS
:
6570 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
6572 case TB_SETEXTENDEDSTYLE
:
6573 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
6575 case TB_SETHOTIMAGELIST
:
6576 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
6579 return TOOLBAR_SetHotItem (hwnd
, wParam
);
6581 case TB_SETIMAGELIST
:
6582 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
6585 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
6587 /* case TB_SETINSERTMARK: */ /* 4.71 */
6589 case TB_SETINSERTMARKCOLOR
:
6590 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
6592 case TB_SETMAXTEXTROWS
:
6593 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
6596 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
6599 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
6602 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
6605 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
6608 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
6610 case TB_SETTOOLTIPS
:
6611 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
6613 case TB_SETUNICODEFORMAT
:
6614 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
6617 return TOOLBAR_Unkwn45D(hwnd
, wParam
, lParam
);
6620 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
6623 return TOOLBAR_Unkwn460(hwnd
, wParam
, lParam
);
6626 return TOOLBAR_Unkwn462(hwnd
, wParam
, lParam
);
6629 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
6632 return TOOLBAR_Unkwn464(hwnd
, wParam
, lParam
);
6634 /* Common Control Messages */
6636 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
6637 case CCM_GETCOLORSCHEME
:
6638 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
6640 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
6641 case CCM_SETCOLORSCHEME
:
6642 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
6644 case CCM_GETVERSION
:
6645 return TOOLBAR_GetVersion (hwnd
);
6647 case CCM_SETVERSION
:
6648 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
6654 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
6657 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
6660 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
6663 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
6665 /* case WM_KEYDOWN: */
6666 /* case WM_KILLFOCUS: */
6668 case WM_LBUTTONDBLCLK
:
6669 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
6671 case WM_LBUTTONDOWN
:
6672 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
6675 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
6678 return TOOLBAR_RButtonUp (hwnd
, wParam
, lParam
);
6680 case WM_RBUTTONDBLCLK
:
6681 return TOOLBAR_RButtonDblClk (hwnd
, wParam
, lParam
);
6684 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
6687 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
6689 case WM_CAPTURECHANGED
:
6690 return TOOLBAR_CaptureChanged(hwnd
);
6693 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
6696 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
6699 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
6702 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
6705 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
6707 case WM_NOTIFYFORMAT
:
6708 return TOOLBAR_NotifyFormatFake (hwnd
, wParam
, lParam
);
6711 return TOOLBAR_Paint (hwnd
, wParam
);
6714 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
6717 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
6719 case WM_STYLECHANGED
:
6720 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
6722 case WM_SYSCOLORCHANGE
:
6723 return TOOLBAR_SysColorChange (hwnd
);
6725 /* case WM_WININICHANGE: */
6730 case WM_MEASUREITEM
:
6732 return SendMessageA (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
6734 /* We see this in Outlook Express 5.x and just does DefWindowProc */
6735 case PGM_FORWARDMOUSE
:
6736 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
6739 if ((uMsg
>= WM_USER
) && (uMsg
< WM_APP
))
6740 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
6741 uMsg
, wParam
, lParam
);
6742 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
6749 TOOLBAR_Register (void)
6753 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
6754 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
6755 wndClass
.lpfnWndProc
= (WNDPROC
)ToolbarWindowProc
;
6756 wndClass
.cbClsExtra
= 0;
6757 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
6758 wndClass
.hCursor
= LoadCursorA (0, (LPSTR
)IDC_ARROW
);
6759 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
6760 wndClass
.lpszClassName
= TOOLBARCLASSNAMEA
;
6762 RegisterClassA (&wndClass
);
6767 TOOLBAR_Unregister (void)
6769 UnregisterClassA (TOOLBARCLASSNAMEA
, NULL
);
6772 static HIMAGELIST
TOOLBAR_InsertImageList(PIMLENTRY
**pies
, INT
*cies
, HIMAGELIST himl
, INT id
)
6777 /* Check if the entry already exists */
6778 c
= TOOLBAR_GetImageListEntry(*pies
, *cies
, id
);
6780 /* If this is a new entry we must create it and insert into the array */
6785 c
= (PIMLENTRY
) Alloc(sizeof(IMLENTRY
));
6788 pnies
= Alloc((*cies
+ 1) * sizeof(PIMLENTRY
));
6789 memcpy(pnies
, *pies
, ((*cies
) * sizeof(PIMLENTRY
)));
6804 static VOID
TOOLBAR_DeleteImageList(PIMLENTRY
**pies
, INT
*cies
)
6808 for (i
= 0; i
< *cies
; i
++)
6818 static PIMLENTRY
TOOLBAR_GetImageListEntry(PIMLENTRY
*pies
, INT cies
, INT id
)
6826 for (i
= 0; i
< cies
; i
++)
6828 if (pies
[i
]->id
== id
)
6840 static HIMAGELIST
TOOLBAR_GetImageList(PIMLENTRY
*pies
, INT cies
, INT id
)
6842 HIMAGELIST himlDef
= 0;
6843 PIMLENTRY pie
= TOOLBAR_GetImageListEntry(pies
, cies
, id
);
6846 himlDef
= pie
->himl
;
6852 static BOOL
TOOLBAR_GetButtonInfo(TOOLBAR_INFO
*infoPtr
, NMTOOLBARW
*nmtb
)
6854 if (infoPtr
->bUnicode
)
6855 return TOOLBAR_SendNotify ((NMHDR
*) nmtb
, infoPtr
, TBN_GETBUTTONINFOW
);
6862 nmtba
.iItem
= nmtb
->iItem
;
6863 nmtba
.pszText
= Buffer
;
6864 nmtba
.cchText
= 256;
6865 ZeroMemory(nmtba
.pszText
, nmtba
.cchText
);
6867 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtba
, infoPtr
, TBN_GETBUTTONINFOA
))
6869 int ccht
= strlen(nmtba
.pszText
);
6871 MultiByteToWideChar(CP_ACP
, 0, (LPCSTR
)nmtba
.pszText
, -1,
6872 nmtb
->pszText
, nmtb
->cchText
);
6874 memcpy(&nmtb
->tbButton
, &nmtba
.tbButton
, sizeof(TBBUTTON
));
6883 static BOOL
TOOLBAR_IsButtonRemovable(TOOLBAR_INFO
*infoPtr
,
6884 int iItem
, PCUSTOMBUTTON btnInfo
)
6889 memcpy(&nmtb
.tbButton
, &btnInfo
->btn
, sizeof(TBBUTTON
));
6891 return TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYDELETE
);