4 * Copyright 1998,1999 Eric Kohl
5 * Copyright 2000 Eric Kohl for CodeWeavers
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * Differences between MSDN and actual native control operation:
22 * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text
23 * to the right of the bitmap. Otherwise, this style is
24 * identical to TBSTYLE_FLAT."
25 * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL
26 * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result
27 * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does
28 * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001)
32 * - A little bug in TOOLBAR_DrawMasked()
33 * - Button wrapping (under construction).
35 * - Notifications (under construction).
37 * - Tooltip support (almost complete).
38 * - Unicode suppport (under construction).
39 * - Fix TOOLBAR_SetButtonInfo32A/W.
40 * - TBSTYLE_AUTOSIZE for toolbar and buttons.
41 * - I_IMAGECALLBACK support.
42 * - iString of -1 is undocumented
43 * - Customization dialog:
45 * - Minor buglet in 'available buttons' list:
46 * Buttons are not listed in M$-like order. M$ seems to use a single
47 * internal list to store the button information of both listboxes.
48 * - Drag list support.
49 * - Help and Reset button support.
52 * - Run tests using Waite Group Windows95 API Bible Volume 2.
53 * The second cdrom contains executables addstr.exe, btncount.exe,
54 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
55 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
56 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
57 * setparnt.exe, setrows.exe, toolwnd.exe.
58 * - Microsofts controlspy examples.
59 * - Charles Petzold's 'Programming Windows': gadgets.exe
68 #include "wine/unicode.h"
70 #include "imagelist.h"
72 #include "wine/debug.h"
74 WINE_DEFAULT_DEBUG_CHANNEL(toolbar
);
92 DWORD dwStructSize
; /* size of TBBUTTON struct */
93 INT nHeight
; /* height of the toolbar */
94 INT nWidth
; /* width of the toolbar */
100 INT nRows
; /* number of button rows */
101 INT nMaxTextRows
; /* maximum number of text rows */
102 INT cxMin
; /* minimum button width */
103 INT cxMax
; /* maximum button width */
104 INT nNumButtons
; /* number of buttons */
105 INT nNumBitmaps
; /* number of bitmaps */
106 INT nNumStrings
; /* number of strings */
107 BOOL bUnicode
; /* ASCII (FALSE) or Unicode (TRUE)? */
108 BOOL bCaptured
; /* mouse captured? */
111 INT nHotItem
; /* index of the "hot" item */
112 DWORD dwBaseCustDraw
; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
113 DWORD dwItemCustDraw
; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
114 DWORD dwItemCDFlag
; /* TBCDRF_ flags from last ITEMPREPAINT */
115 SIZE szPadding
; /* padding values around button */
117 HFONT hFont
; /* text font */
118 HIMAGELIST himlInt
; /* image list created internally */
119 HIMAGELIST himlDef
; /* default image list */
120 HIMAGELIST himlHot
; /* hot image list */
121 HIMAGELIST himlDis
; /* disabled image list */
122 HWND hwndToolTip
; /* handle to tool tip control */
123 HWND hwndNotify
; /* handle to the window that gets notifications */
124 HWND hwndSelf
; /* my own handle */
125 BOOL bTransparent
; /* background transparency flag */
126 BOOL bBtnTranspnt
; /* button transparency flag */
127 BOOL bAutoSize
; /* auto size deadlock indicator */
128 BOOL bAnchor
; /* anchor highlight enabled */
129 BOOL bNtfUnicode
; /* TRUE if NOTIFYs use {W} */
130 BOOL bDoRedraw
; /* Redraw status */
131 DWORD dwExStyle
; /* extended toolbar style */
132 DWORD dwDTFlags
; /* DrawText flags */
134 COLORREF clrInsertMark
; /* insert mark color */
135 COLORREF clrBtnHighlight
; /* color for Flat Separator */
136 COLORREF clrBtnShadow
; /* color for Flag Separator */
137 RECT rcBound
; /* bounding rectangle */
140 TBUTTON_INFO
*buttons
; /* pointer to button array */
141 LPWSTR
*strings
; /* pointer to string array */
142 } TOOLBAR_INFO
, *PTOOLBAR_INFO
;
145 /* used by customization dialog */
148 PTOOLBAR_INFO tbInfo
;
150 } CUSTDLG_INFO
, *PCUSTDLG_INFO
;
158 } CUSTOMBUTTON
, *PCUSTOMBUTTON
;
161 #define SEPARATOR_WIDTH 8
163 #define BOTTOM_BORDER 2
164 #define DDARROW_WIDTH 11
166 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
167 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
168 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
170 /* Used to find undocumented extended styles */
171 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
172 TBSTYLE_EX_UNDOC1 | \
173 TBSTYLE_EX_MIXEDBUTTONS | \
174 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
177 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
);
181 TOOLBAR_GetText(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
183 LPWSTR lpText
= NULL
;
185 /* FIXME: iString == -1 is undocumented */
186 if ((HIWORD(btnPtr
->iString
) != 0) && (btnPtr
->iString
!= -1))
187 lpText
= (LPWSTR
)btnPtr
->iString
;
188 else if ((btnPtr
->iString
>= 0) && (btnPtr
->iString
< infoPtr
->nNumStrings
))
189 lpText
= infoPtr
->strings
[btnPtr
->iString
];
195 TOOLBAR_DumpButton(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*bP
, INT btn_num
, BOOL internal
)
197 if (TRACE_ON(toolbar
)){
198 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
199 btn_num
, bP
->idCommand
,
200 bP
->iBitmap
, bP
->fsState
, bP
->fsStyle
, bP
->dwData
, bP
->iString
);
201 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr
,bP
)));
203 TRACE("button %d id %d, hot=%s, row=%d, rect=(%d,%d)-(%d,%d)\n",
204 btn_num
, bP
->idCommand
,
205 (bP
->bHot
) ? "TRUE":"FALSE", bP
->nRow
,
206 bP
->rect
.left
, bP
->rect
.top
,
207 bP
->rect
.right
, bP
->rect
.bottom
);
213 TOOLBAR_DumpToolbar(TOOLBAR_INFO
*iP
, INT line
)
215 if (TRACE_ON(toolbar
)) {
219 dwStyle
= GetWindowLongA (iP
->hwndSelf
, GWL_STYLE
);
220 TRACE("toolbar %08x at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
222 iP
->dwExStyle
, iP
->nNumButtons
, iP
->nNumBitmaps
,
223 iP
->nNumStrings
, dwStyle
);
224 TRACE("toolbar %08x at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
226 iP
->himlInt
, iP
->himlDef
, iP
->himlHot
, iP
->himlDis
,
227 (iP
->bDoRedraw
) ? "TRUE" : "FALSE");
228 for(i
=0; i
<iP
->nNumButtons
; i
++) {
229 TOOLBAR_DumpButton(iP
, &iP
->buttons
[i
], i
, TRUE
);
235 /***********************************************************************
238 * This function validates that the styles set are implemented and
239 * issues FIXME's warning of possible problems. In a perfect world this
240 * function should be null.
243 TOOLBAR_CheckStyle (HWND hwnd
, DWORD dwStyle
)
245 if (dwStyle
& TBSTYLE_ALTDRAG
)
246 FIXME("[%04x] TBSTYLE_ALTDRAG not implemented\n", hwnd
);
247 if (dwStyle
& TBSTYLE_REGISTERDROP
)
248 FIXME("[%04x] TBSTYLE_REGISTERDROP not implemented\n", hwnd
);
253 TOOLBAR_SendNotify (NMHDR
*nmhdr
, TOOLBAR_INFO
*infoPtr
, UINT code
)
255 if(!IsWindow(infoPtr
->hwndSelf
))
256 return 0; /* we have just been destroyed */
258 nmhdr
->idFrom
= GetDlgCtrlID (infoPtr
->hwndSelf
);
259 nmhdr
->hwndFrom
= infoPtr
->hwndSelf
;
262 TRACE("to window %04x, code=%08x, %s\n", infoPtr
->hwndNotify
, code
,
263 (infoPtr
->bNtfUnicode
) ? "via Unicode" : "via ANSI");
265 if (infoPtr
->bNtfUnicode
)
266 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
267 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
269 return SendMessageA (infoPtr
->hwndNotify
, WM_NOTIFY
,
270 (WPARAM
) nmhdr
->idFrom
, (LPARAM
)nmhdr
);
273 /***********************************************************************
274 * TOOLBAR_GetBitmapIndex
276 * This function returns the bitmap index associated with a button.
277 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
278 * is issued to retrieve the index.
281 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
)
283 INT ret
= btnPtr
->iBitmap
;
285 if (ret
== I_IMAGECALLBACK
) {
286 /* issue TBN_GETDISPINFO */
289 nmgd
.idCommand
= btnPtr
->idCommand
;
290 nmgd
.lParam
= btnPtr
->dwData
;
291 nmgd
.dwMask
= TBNF_IMAGE
;
292 TOOLBAR_SendNotify ((NMHDR
*) &nmgd
, infoPtr
,
293 (infoPtr
->bNtfUnicode
) ? TBN_GETDISPINFOW
:
295 if (nmgd
.dwMask
& TBNF_DI_SETITEM
) {
296 btnPtr
->iBitmap
= nmgd
.iImage
;
299 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
300 ret
, nmgd
.dwMask
, infoPtr
->nNumBitmaps
);
307 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO
*infoPtr
, INT index
)
309 if (((index
>=0) && (index
<= infoPtr
->nNumBitmaps
)) ||
310 (index
== I_IMAGECALLBACK
))
317 /***********************************************************************
318 * TOOLBAR_DrawImageList
320 * This function validates the bitmap index (including I_IMAGECALLBACK
321 * functionality). It then draws the image via the ImageList_Draw
322 * function. It returns TRUE if the image was drawn, FALSE otherwise.
325 TOOLBAR_DrawImageList (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
,
326 HDC hdc
, UINT left
, UINT top
, UINT draw_flags
)
330 if (!himl
) return FALSE
;
332 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
333 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
334 ERR("index %d is not valid, max %d\n",
335 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
339 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
340 if ((index
== I_IMAGECALLBACK
) ||
341 (index
== I_IMAGENONE
)) return FALSE
;
342 ERR("TBN_GETDISPINFO returned invalid index %d\n",
346 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
347 index
, himl
, left
, top
, draw_flags
);
349 ImageList_Draw (himl
, index
, hdc
, left
, top
, draw_flags
);
354 /***********************************************************************
355 * TOOLBAR_TestImageExist
357 * This function is similar to TOOLBAR_DrawImageList, except it does not
358 * draw the image. The I_IMAGECALLBACK functionality is implemented.
361 TOOLBAR_TestImageExist (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
, HIMAGELIST himl
)
365 if (!himl
) return FALSE
;
367 if (!TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
368 if (btnPtr
->iBitmap
== I_IMAGENONE
) return FALSE
;
369 ERR("index %d is not valid, max %d\n",
370 btnPtr
->iBitmap
, infoPtr
->nNumBitmaps
);
374 if ((index
= TOOLBAR_GetBitmapIndex(infoPtr
, btnPtr
)) < 0) {
375 if ((index
== I_IMAGECALLBACK
) ||
376 (index
== I_IMAGENONE
)) return FALSE
;
377 ERR("TBN_GETDISPINFO returned invalid index %d\n",
386 TOOLBAR_DrawFlatSeparator (LPRECT lpRect
, HDC hdc
, TOOLBAR_INFO
*infoPtr
)
389 COLORREF oldcolor
, newcolor
;
391 myrect
.left
= (lpRect
->left
+ lpRect
->right
) / 2 - 1;
392 myrect
.right
= myrect
.left
+ 1;
393 myrect
.top
= lpRect
->top
+ 2;
394 myrect
.bottom
= lpRect
->bottom
- 2;
396 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
397 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
398 oldcolor
= SetBkColor (hdc
, newcolor
);
399 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
401 myrect
.left
= myrect
.right
;
402 myrect
.right
= myrect
.left
+ 1;
404 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
405 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
406 SetBkColor (hdc
, newcolor
);
407 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
409 SetBkColor (hdc
, oldcolor
);
413 /***********************************************************************
414 * TOOLBAR_DrawDDFlatSeparator
416 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
417 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
418 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
419 * are horizontal as opposed to the vertical separators for not dropdown
422 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
425 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect
, HDC hdc
, TBUTTON_INFO
*btnPtr
, TOOLBAR_INFO
*infoPtr
)
428 COLORREF oldcolor
, newcolor
;
430 myrect
.left
= lpRect
->left
;
431 myrect
.right
= lpRect
->right
;
432 myrect
.top
= lpRect
->top
+ (lpRect
->bottom
- lpRect
->top
- 2)/2;
433 myrect
.bottom
= myrect
.top
+ 1;
435 InflateRect (&myrect
, -2, 0);
437 TRACE("rect=(%d,%d)-(%d,%d)\n",
438 myrect
.left
, myrect
.top
, myrect
.right
, myrect
.bottom
);
440 newcolor
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
441 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
442 oldcolor
= SetBkColor (hdc
, newcolor
);
443 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
445 myrect
.top
= myrect
.bottom
;
446 myrect
.bottom
= myrect
.top
+ 1;
448 newcolor
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
449 comctl32_color
.clrBtnHighlight
: infoPtr
->clrBtnHighlight
;
450 SetBkColor (hdc
, newcolor
);
451 ExtTextOutA (hdc
, 0, 0, ETO_OPAQUE
, &myrect
, 0, 0, 0);
453 SetBkColor (hdc
, oldcolor
);
458 TOOLBAR_DrawArrow (HDC hdc
, INT left
, INT top
, INT colorRef
)
461 SelectObject ( hdc
, GetSysColorPen (colorRef
));
464 MoveToEx (hdc
, x
, y
, NULL
);
465 LineTo (hdc
, x
+5, y
++); x
++;
466 MoveToEx (hdc
, x
, y
, NULL
);
467 LineTo (hdc
, x
+3, y
++); x
++;
468 MoveToEx (hdc
, x
, y
, NULL
);
469 LineTo (hdc
, x
+1, y
++);
473 * Draw the text string for this button.
474 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
475 * is non-zero, so we can simply check himlDef to see if we have
479 TOOLBAR_DrawString (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
480 HDC hdc
, INT nState
, DWORD dwStyle
,
481 RECT
*rcText
, LPWSTR lpText
, NMTBCUSTOMDRAW
*tbcd
)
488 TRACE("string rect=(%d,%d)-(%d,%d)\n",
489 rcText
->left
, rcText
->top
, rcText
->right
, rcText
->bottom
);
491 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
492 if (!(nState
& TBSTATE_ENABLED
)) {
493 clrOld
= SetTextColor (hdc
, tbcd
->clrBtnHighlight
);
494 OffsetRect (rcText
, 1, 1);
495 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
496 SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
497 OffsetRect (rcText
, -1, -1);
499 else if (nState
& TBSTATE_INDETERMINATE
) {
500 clrOld
= SetTextColor (hdc
, comctl32_color
.clr3dShadow
);
502 else if (btnPtr
->bHot
&& (infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)) {
503 clrOld
= SetTextColor (hdc
, tbcd
->clrTextHighlight
);
506 clrOld
= SetTextColor (hdc
, tbcd
->clrText
);
509 DrawTextW (hdc
, lpText
, -1, rcText
, infoPtr
->dwDTFlags
);
510 SetTextColor (hdc
, clrOld
);
511 SelectObject (hdc
, hOldFont
);
517 TOOLBAR_DrawPattern (HDC hdc
, LPRECT lpRect
)
519 HBRUSH hbr
= SelectObject (hdc
, COMCTL32_hPattern55AABrush
);
520 INT cx
= lpRect
->right
- lpRect
->left
;
521 INT cy
= lpRect
->bottom
- lpRect
->top
;
522 PatBlt (hdc
, lpRect
->left
, lpRect
->top
, cx
, cy
, 0x00FA0089);
523 SelectObject (hdc
, hbr
);
528 TOOLBAR_DrawMasked (TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
529 HDC hdc
, INT x
, INT y
)
531 /* FIXME: this function is a hack since it uses image list
532 internals directly */
534 HIMAGELIST himl
= infoPtr
->himlDef
;
542 /* create new dc's */
543 hdcImageList
= CreateCompatibleDC (0);
544 hdcMask
= CreateCompatibleDC (0);
546 /* create new bitmap */
547 hbmMask
= CreateBitmap (himl
->cx
, himl
->cy
, 1, 1, NULL
);
548 SelectObject (hdcMask
, hbmMask
);
550 /* copy the mask bitmap */
551 SelectObject (hdcImageList
, himl
->hbmMask
);
552 SetBkColor (hdcImageList
, RGB(255, 255, 255));
553 SetTextColor (hdcImageList
, RGB(0, 0, 0));
554 BitBlt (hdcMask
, 0, 0, himl
->cx
, himl
->cy
,
555 hdcImageList
, himl
->cx
* btnPtr
->iBitmap
, 0, SRCCOPY
);
557 /* draw the new mask */
558 SelectObject (hdc
, GetSysColorBrush (COLOR_3DHILIGHT
));
559 BitBlt (hdc
, x
+1, y
+1, himl
->cx
, himl
->cy
,
560 hdcMask
, 0, 0, 0xB8074A);
562 SelectObject (hdc
, GetSysColorBrush (COLOR_3DSHADOW
));
563 BitBlt (hdc
, x
, y
, himl
->cx
, himl
->cy
,
564 hdcMask
, 0, 0, 0xB8074A);
566 DeleteObject (hbmMask
);
568 DeleteDC (hdcImageList
);
573 TOOLBAR_TranslateState(TBUTTON_INFO
*btnPtr
)
577 retstate
|= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? CDIS_CHECKED
: 0;
578 retstate
|= (btnPtr
->fsState
& TBSTATE_PRESSED
) ? CDIS_SELECTED
: 0;
579 retstate
|= (btnPtr
->fsState
& TBSTATE_ENABLED
) ? 0 : CDIS_DISABLED
;
580 retstate
|= (btnPtr
->fsState
& TBSTATE_MARKED
) ? CDIS_MARKED
: 0;
581 retstate
|= (btnPtr
->bHot
) ? CDIS_HOT
: 0;
582 retstate
|= (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) ? CDIS_INDETERMINATE
: 0;
583 /* FIXME: don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
584 /* don't test TBSTATE_HIDDEN */
590 TOOLBAR_DrawButton (HWND hwnd
, TBUTTON_INFO
*btnPtr
, HDC hdc
)
592 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
593 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
594 BOOL hasDropDownArrow
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) &&
595 (btnPtr
->fsStyle
& TBSTYLE_DROPDOWN
);
596 RECT rc
, rcArrow
, rcBitmap
, rcText
, rcFill
;
597 LPWSTR lpText
= NULL
;
602 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
606 CopyRect (&rcFill
, &rc
);
607 CopyRect (&rcArrow
, &rc
);
608 CopyRect(&rcBitmap
, &rc
);
609 CopyRect(&rcText
, &rc
);
611 /* get a pointer to the text */
612 lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
614 if (hasDropDownArrow
)
616 if (dwStyle
& TBSTYLE_FLAT
)
617 rc
.right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
);
619 rc
.right
= max(rc
.left
, rc
.right
- DDARROW_WIDTH
- 2);
620 rcArrow
.left
= rc
.right
;
623 /* Center the bitmap horizontally and vertically */
624 if (dwStyle
& TBSTYLE_LIST
)
627 rcBitmap
.left
+=(infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2;
630 rcBitmap
.top
+=2; /* this looks to be the correct value from vmware comparison - cmm */
632 rcBitmap
.top
+=(infoPtr
->nButtonHeight
- infoPtr
->nBitmapHeight
) / 2;
634 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
635 btnPtr
->iBitmap
, rcBitmap
.left
, rcBitmap
.top
,
636 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
637 TRACE ("iString: %x\n", btnPtr
->iString
);
638 TRACE ("Stringtext: %s\n", debugstr_w(lpText
));
643 InflateRect (&rcText
, -3, -3);
645 if (infoPtr
->himlDef
&&
646 TOOLBAR_IsValidBitmapIndex(infoPtr
,btnPtr
->iBitmap
)) {
647 /* The following test looked like this before
648 * I changed it. IE4 "Links" toolbar would not
649 * draw correctly with the original code. - GA 8/01
650 * ((dwStyle & TBSTYLE_LIST) &&
651 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
652 * (btnPtr->iBitmap != I_IMAGENONE))
654 if (dwStyle
& TBSTYLE_LIST
) {
655 /* LIST style w/ ICON offset is by matching native. */
656 /* Matches IE4 "Links" bar. - GA 8/01 */
657 rcText
.left
+= (infoPtr
->nBitmapWidth
+ 2);
660 rcText
.top
+= infoPtr
->nBitmapHeight
+ 1;
664 if (dwStyle
& TBSTYLE_LIST
) {
665 /* LIST style w/o ICON offset is by matching native. */
666 /* Matches IE4 "menu" bar. - GA 8/01 */
671 if (btnPtr
->fsState
& (TBSTATE_PRESSED
| TBSTATE_CHECKED
))
672 OffsetRect (&rcText
, 1, 1);
675 /* Initialize fields in all cases, because we use these later */
676 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
677 tbcd
.clrText
= comctl32_color
.clrBtnText
;
678 tbcd
.clrTextHighlight
= comctl32_color
.clrHighlightText
;
679 tbcd
.clrBtnFace
= comctl32_color
.clrBtnFace
;
680 tbcd
.clrBtnHighlight
= comctl32_color
.clrBtnHighlight
;
681 tbcd
.clrMark
= comctl32_color
.clrHighlight
;
682 tbcd
.clrHighlightHotTrack
= 0;
683 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
684 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
685 /* MSDN says that this is the text rectangle. */
686 /* But (why always a but) tracing of v5.7 of native shows */
687 /* that this is really a *relative* rectangle based on the */
688 /* the nmcd.rc. Also the left and top are always 0 ignoring*/
689 /* any bitmap that might be present. */
690 tbcd
.rcText
.left
= 0;
692 tbcd
.rcText
.right
= rcText
.right
- rc
.left
;
693 tbcd
.rcText
.bottom
= rcText
.bottom
- rc
.top
;
695 /* FIXME: what should these be set to ????? */
696 tbcd
.hbrMonoDither
= 0;
700 /* Issue Item Prepaint notify */
701 infoPtr
->dwItemCustDraw
= 0;
702 infoPtr
->dwItemCDFlag
= 0;
703 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYITEMDRAW
)
705 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPREPAINT
;
708 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
709 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
710 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
711 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
712 infoPtr
->dwItemCustDraw
= ntfret
& 0xffff;
713 infoPtr
->dwItemCDFlag
= ntfret
& 0xffff0000;
714 if (infoPtr
->dwItemCustDraw
& CDRF_SKIPDEFAULT
)
716 /* save the only part of the rect that the user can change */
717 rcText
.right
= tbcd
.rcText
.right
+ rc
.left
;
718 rcText
.bottom
= tbcd
.rcText
.bottom
+ rc
.top
;
721 if (!infoPtr
->bBtnTranspnt
)
722 FillRect( hdc
, &rcFill
, GetSysColorBrush(COLOR_BTNFACE
));
725 if (btnPtr
->fsStyle
& TBSTYLE_SEP
) {
726 /* with the FLAT style, iBitmap is the width and has already */
727 /* been taken into consideration in calculating the width */
728 /* so now we need to draw the vertical separator */
729 /* empirical tests show that iBitmap can/will be non-zero */
730 /* when drawing the vertical bar... */
731 if ((dwStyle
& TBSTYLE_FLAT
) /* && (btnPtr->iBitmap == 0) */) {
732 if (btnPtr
->fsStyle
& TBSTYLE_DROPDOWN
)
733 TOOLBAR_DrawDDFlatSeparator (&rc
, hdc
, btnPtr
, infoPtr
);
735 TOOLBAR_DrawFlatSeparator (&rc
, hdc
, infoPtr
);
737 else if (btnPtr
->fsStyle
!= TBSTYLE_SEP
) {
738 FIXME("Draw some kind of separator: fsStyle=%x\n",
745 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
)) {
746 if (!(dwStyle
& TBSTYLE_FLAT
) && !(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
748 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
749 BF_SOFT
| BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
750 if (hasDropDownArrow
)
751 DrawEdge (hdc
, &rcArrow
, EDGE_RAISED
,
752 BF_SOFT
| BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
755 if (hasDropDownArrow
)
757 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
+1, COLOR_3DHIGHLIGHT
);
758 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
, COLOR_3DSHADOW
);
761 if (!TOOLBAR_DrawImageList (infoPtr
, btnPtr
, infoPtr
->himlDis
,
762 hdc
, rcBitmap
.left
, rcBitmap
.top
,
764 TOOLBAR_DrawMasked (infoPtr
, btnPtr
, hdc
, rcBitmap
.left
, rcBitmap
.top
);
766 TOOLBAR_DrawString (infoPtr
, btnPtr
, hdc
, btnPtr
->fsState
, dwStyle
, &rcText
, lpText
, &tbcd
);
770 /* pressed TBSTYLE_BUTTON */
771 if (btnPtr
->fsState
& TBSTATE_PRESSED
) {
772 offset
= (infoPtr
->dwItemCDFlag
& TBCDRF_NOOFFSET
) ? 0 : 1;
773 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
775 if (dwStyle
& TBSTYLE_FLAT
)
777 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
, BF_RECT
| BF_ADJUST
);
778 if (hasDropDownArrow
)
779 DrawEdge (hdc
, &rcArrow
, BDR_SUNKENOUTER
, BF_RECT
| BF_ADJUST
);
783 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
784 if (hasDropDownArrow
)
785 DrawEdge (hdc
, &rcArrow
, EDGE_SUNKEN
, BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
789 if (hasDropDownArrow
)
790 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
, COLOR_WINDOWFRAME
);
792 TOOLBAR_DrawImageList (infoPtr
, btnPtr
, infoPtr
->himlDef
,
793 hdc
, rcBitmap
.left
+offset
, rcBitmap
.top
+offset
,
796 TOOLBAR_DrawString (infoPtr
, btnPtr
, hdc
, btnPtr
->fsState
, dwStyle
, &rcText
, lpText
, &tbcd
);
800 /* checked TBSTYLE_CHECK */
801 if ((btnPtr
->fsStyle
& TBSTYLE_CHECK
) &&
802 (btnPtr
->fsState
& TBSTATE_CHECKED
)) {
803 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
805 if (dwStyle
& TBSTYLE_FLAT
)
806 DrawEdge (hdc
, &rc
, BDR_SUNKENOUTER
,
807 BF_RECT
| BF_ADJUST
);
809 DrawEdge (hdc
, &rc
, EDGE_SUNKEN
,
810 BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
813 TOOLBAR_DrawPattern (hdc
, &rc
);
815 TOOLBAR_DrawImageList (infoPtr
, btnPtr
, infoPtr
->himlDef
,
816 hdc
, rcBitmap
.left
+1, rcBitmap
.top
+1,
819 TOOLBAR_DrawString (infoPtr
, btnPtr
, hdc
, btnPtr
->fsState
, dwStyle
, &rcText
, lpText
, &tbcd
);
824 if (btnPtr
->fsState
& TBSTATE_INDETERMINATE
) {
825 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
826 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
827 BF_SOFT
| BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
829 TOOLBAR_DrawPattern (hdc
, &rc
);
830 TOOLBAR_DrawMasked (infoPtr
, btnPtr
, hdc
, rcBitmap
.left
, rcBitmap
.top
);
831 TOOLBAR_DrawString (infoPtr
, btnPtr
, hdc
, btnPtr
->fsState
, dwStyle
, &rcText
, lpText
, &tbcd
);
836 if (dwStyle
& TBSTYLE_FLAT
)
840 if ( infoPtr
->dwItemCDFlag
& TBCDRF_HILITEHOTTRACK
)
844 oldclr
= SetBkColor(hdc
, tbcd
.clrHighlightHotTrack
);
845 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rc
, NULL
, 0, 0);
846 if (hasDropDownArrow
)
847 ExtTextOutA(hdc
, 0, 0, ETO_OPAQUE
, &rcArrow
, NULL
, 0, 0);
848 SetBkColor(hdc
, oldclr
);
852 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
854 DrawEdge (hdc
, &rc
, BDR_RAISEDINNER
, BF_RECT
);
855 if (hasDropDownArrow
)
856 DrawEdge (hdc
, &rcArrow
, BDR_RAISEDINNER
, BF_RECT
);
861 else /* The following code needs to be removed after
862 * "hot item" support has been implemented for the
863 * case where it is being de-selected.
866 FrameRect(hdc
, &rc
, GetSysColorBrush(COLOR_BTNFACE
));
867 if (hasDropDownArrow
)
868 FrameRect(hdc
, &rcArrow
, GetSysColorBrush(COLOR_BTNFACE
));
872 if (hasDropDownArrow
)
873 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
+1, rcArrow
.top
, COLOR_WINDOWFRAME
);
876 /* if hot, attempt to draw with himlHot, if fails, use himlDef */
877 if (!TOOLBAR_DrawImageList (infoPtr
, btnPtr
,
880 rcBitmap
.top
, ILD_NORMAL
))
881 TOOLBAR_DrawImageList (infoPtr
, btnPtr
, infoPtr
->himlDef
,
882 hdc
, rcBitmap
.left
, rcBitmap
.top
,
886 TOOLBAR_DrawImageList (infoPtr
, btnPtr
, infoPtr
->himlDef
,
887 hdc
, rcBitmap
.left
, rcBitmap
.top
,
892 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
893 DrawEdge (hdc
, &rc
, EDGE_RAISED
,
894 BF_SOFT
| BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
896 if (hasDropDownArrow
)
898 if (!(infoPtr
->dwItemCDFlag
& TBCDRF_NOEDGES
))
899 DrawEdge (hdc
, &rcArrow
, EDGE_RAISED
,
900 BF_SOFT
| BF_RECT
| BF_MIDDLE
| BF_ADJUST
);
901 TOOLBAR_DrawArrow(hdc
, rcArrow
.left
, rcArrow
.top
, COLOR_WINDOWFRAME
);
904 TOOLBAR_DrawImageList (infoPtr
, btnPtr
, infoPtr
->himlDef
,
905 hdc
, rcBitmap
.left
, rcBitmap
.top
,
909 TOOLBAR_DrawString (infoPtr
, btnPtr
, hdc
, btnPtr
->fsState
, dwStyle
, &rcText
, lpText
, &tbcd
);
912 if (infoPtr
->dwItemCustDraw
& CDRF_NOTIFYPOSTPAINT
)
914 tbcd
.nmcd
.dwDrawStage
= CDDS_ITEMPOSTPAINT
;
917 tbcd
.nmcd
.dwItemSpec
= btnPtr
->idCommand
;
918 tbcd
.nmcd
.uItemState
= TOOLBAR_TranslateState(btnPtr
);
919 tbcd
.nmcd
.lItemlParam
= btnPtr
->dwData
;
920 tbcd
.rcText
= rcText
;
921 tbcd
.nStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
922 tbcd
.nHLStringBkMode
= (infoPtr
->bBtnTranspnt
) ? TRANSPARENT
: OPAQUE
;
923 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
930 TOOLBAR_Refresh (HWND hwnd
, HDC hdc
, PAINTSTRUCT
* ps
)
932 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
933 TBUTTON_INFO
*btnPtr
;
934 INT i
, oldBKmode
= 0;
939 /* if imagelist belongs to the app, it can be changed
940 by the app after setting it */
941 if (infoPtr
->himlDef
!= infoPtr
->himlInt
)
942 infoPtr
->nNumBitmaps
= ImageList_GetImageCount(infoPtr
->himlDef
);
944 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
946 /* Send initial notify */
947 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
948 tbcd
.nmcd
.dwDrawStage
= CDDS_PREPAINT
;
950 tbcd
.nmcd
.rc
= ps
->rcPaint
;
951 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
952 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
954 if (infoPtr
->bBtnTranspnt
)
955 oldBKmode
= SetBkMode (hdc
, TRANSPARENT
);
957 /* redraw necessary buttons */
958 btnPtr
= infoPtr
->buttons
;
959 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++)
961 if(IntersectRect(&rcTemp
, &(ps
->rcPaint
), &(btnPtr
->rect
)))
962 TOOLBAR_DrawButton (hwnd
, btnPtr
, hdc
);
965 if (infoPtr
->bBtnTranspnt
&& (oldBKmode
!= TRANSPARENT
))
966 SetBkMode (hdc
, oldBKmode
);
968 if (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTPAINT
)
970 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
971 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTPAINT
;
973 tbcd
.nmcd
.rc
= ps
->rcPaint
;
974 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
978 /***********************************************************************
979 * TOOLBAR_MeasureString
981 * This function gets the width and height of a string in pixels. This
982 * is done first by using GetTextExtentPoint to get the basic width
983 * and height. The DrawText is called with DT_CALCRECT to get the exact
984 * width. The reason is because the text may have more than one "&" (or
985 * prefix characters as M$ likes to call them). The prefix character
986 * indicates where the underline goes, except for the string "&&" which
987 * is reduced to a single "&". GetTextExtentPoint does not process these
988 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
991 TOOLBAR_MeasureString(TOOLBAR_INFO
*infoPtr
, TBUTTON_INFO
*btnPtr
,
992 HDC hdc
, LPSIZE lpSize
)
999 if (!(btnPtr
->fsState
& TBSTATE_HIDDEN
) )
1001 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
, btnPtr
);
1003 if(lpText
!= NULL
) {
1004 /* first get size of all the text */
1005 GetTextExtentPoint32W (hdc
, lpText
, strlenW (lpText
), lpSize
);
1007 /* feed above size into the rectangle for DrawText */
1008 myrect
.left
= myrect
.top
= 0;
1009 myrect
.right
= lpSize
->cx
;
1010 myrect
.bottom
= lpSize
->cy
;
1012 /* Use DrawText to get true size as drawn (less pesky "&") */
1013 DrawTextW (hdc
, lpText
, -1, &myrect
, DT_VCENTER
| DT_SINGLELINE
|
1014 DT_CALCRECT
| ((btnPtr
->fsStyle
& TBSTYLE_NOPREFIX
) ?
1017 /* feed back to caller */
1018 lpSize
->cx
= myrect
.right
;
1019 lpSize
->cy
= myrect
.bottom
;
1023 TRACE("string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1026 /***********************************************************************
1027 * TOOLBAR_CalcStrings
1029 * This function walks through each string and measures it and returns
1030 * the largest height and width to caller.
1033 TOOLBAR_CalcStrings (HWND hwnd
, LPSIZE lpSize
)
1035 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1036 TBUTTON_INFO
*btnPtr
;
1046 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1048 btnPtr
= infoPtr
->buttons
;
1049 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1050 if(TOOLBAR_HasText(infoPtr
, btnPtr
))
1052 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1053 if (sz
.cx
> lpSize
->cx
)
1055 if (sz
.cy
> lpSize
->cy
)
1060 SelectObject (hdc
, hOldFont
);
1061 ReleaseDC (hwnd
, hdc
);
1063 TRACE("max string size %ld x %ld!\n", lpSize
->cx
, lpSize
->cy
);
1066 /***********************************************************************
1067 * TOOLBAR_WrapToolbar
1069 * This function walks through the buttons and seperators in the
1070 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1071 * wrapping should occur based on the width of the toolbar window.
1072 * It does *not* calculate button placement itself. That task
1073 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1074 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1075 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1077 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1078 * vertical toolbar lists.
1082 TOOLBAR_WrapToolbar( HWND hwnd
, DWORD dwStyle
)
1084 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1085 TBUTTON_INFO
*btnPtr
;
1088 BOOL bWrap
, bButtonWrap
;
1090 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1091 /* no layout is necessary. Applications may use this style */
1092 /* to perform their own layout on the toolbar. */
1093 if( !(dwStyle
& TBSTYLE_WRAPABLE
) &&
1094 !(infoPtr
->dwExStyle
& TBSTYLE_EX_UNDOC1
) ) return;
1096 btnPtr
= infoPtr
->buttons
;
1097 x
= infoPtr
->nIndent
;
1099 /* this can get the parents width, to know how far we can extend
1100 * this toolbar. We cannot use its height, as there may be multiple
1101 * toolbars in a rebar control
1103 GetClientRect( GetParent(hwnd
), &rc
);
1104 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1105 bButtonWrap
= FALSE
;
1107 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1108 infoPtr
->nButtonWidth
, infoPtr
->nBitmapWidth
, infoPtr
->nWidth
,
1111 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++ )
1114 btnPtr
[i
].fsState
&= ~TBSTATE_WRAP
;
1116 if (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
)
1119 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1120 /* it is the actual width of the separator. This is used for */
1121 /* custom controls in toolbars. */
1123 /* TBSTYLE_DROPDOWN separators are treated as buttons for */
1124 /* width. - GA 8/01 */
1125 if ((btnPtr
[i
].fsStyle
& TBSTYLE_SEP
) &&
1126 !(btnPtr
[i
].fsStyle
& TBSTYLE_DROPDOWN
))
1127 cx
= (btnPtr
[i
].iBitmap
> 0) ?
1128 btnPtr
[i
].iBitmap
: SEPARATOR_WIDTH
;
1130 cx
= infoPtr
->nButtonWidth
;
1132 /* Two or more adjacent separators form a separator group. */
1133 /* The first separator in a group should be wrapped to the */
1134 /* next row if the previous wrapping is on a button. */
1136 (btnPtr
[i
].fsStyle
& TBSTYLE_SEP
) &&
1137 (i
+ 1 < infoPtr
->nNumButtons
) &&
1138 (btnPtr
[i
+ 1].fsStyle
& TBSTYLE_SEP
) )
1140 TRACE("wrap point 1 btn %d style %02x\n", i
, btnPtr
[i
].fsStyle
);
1141 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1142 x
= infoPtr
->nIndent
;
1144 bButtonWrap
= FALSE
;
1148 /* The layout makes sure the bitmap is visible, but not the button. */
1149 /* Test added to also wrap after a button that starts a row but */
1150 /* is bigger than the area. - GA 8/01 */
1151 if (( x
+ cx
- (infoPtr
->nButtonWidth
- infoPtr
->nBitmapWidth
) / 2
1152 > infoPtr
->nWidth
) ||
1153 ((x
== infoPtr
->nIndent
) && (cx
> infoPtr
->nWidth
)))
1155 BOOL bFound
= FALSE
;
1157 /* If the current button is a separator and not hidden, */
1158 /* go to the next until it reaches a non separator. */
1159 /* Wrap the last separator if it is before a button. */
1160 while( ( ((btnPtr
[i
].fsStyle
& TBSTYLE_SEP
) &&
1161 !(btnPtr
[i
].fsStyle
& TBSTYLE_DROPDOWN
)) ||
1162 (btnPtr
[i
].fsState
& TBSTATE_HIDDEN
) ) &&
1163 i
< infoPtr
->nNumButtons
)
1169 if( bFound
&& i
< infoPtr
->nNumButtons
)
1172 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1173 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1174 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1175 x
= infoPtr
->nIndent
;
1176 bButtonWrap
= FALSE
;
1179 else if ( i
>= infoPtr
->nNumButtons
)
1182 /* If the current button is not a separator, find the last */
1183 /* separator and wrap it. */
1184 for ( j
= i
- 1; j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1186 if ((btnPtr
[j
].fsStyle
& TBSTYLE_SEP
) &&
1187 !(btnPtr
[j
].fsState
& TBSTATE_HIDDEN
))
1191 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1192 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1193 x
= infoPtr
->nIndent
;
1194 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1195 bButtonWrap
= FALSE
;
1200 /* If no separator available for wrapping, wrap one of */
1201 /* non-hidden previous button. */
1205 j
>= 0 && !(btnPtr
[j
].fsState
& TBSTATE_WRAP
); j
--)
1207 if (btnPtr
[j
].fsState
& TBSTATE_HIDDEN
)
1212 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1213 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1214 x
= infoPtr
->nIndent
;
1215 btnPtr
[j
].fsState
|= TBSTATE_WRAP
;
1221 /* If all above failed, wrap the current button. */
1224 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1225 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1226 btnPtr
[i
].fsState
|= TBSTATE_WRAP
;
1228 x
= infoPtr
->nIndent
;
1229 if (btnPtr
[i
].fsStyle
& TBSTYLE_SEP
)
1230 bButtonWrap
= FALSE
;
1236 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1237 i
, btnPtr
[i
].fsStyle
, x
, cx
);
1244 /***********************************************************************
1245 * TOOLBAR_CalcToolbar
1247 * This function calculates button and separator placement. It first
1248 * calculates the button sizes, gets the toolbar window width and then
1249 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1250 * on. It assigns a new location to each item and sends this location to
1251 * the tooltip window if appropriate. Finally, it updates the rcBound
1252 * rect and calculates the new required toolbar window height.
1256 TOOLBAR_CalcToolbar (HWND hwnd
)
1258 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
1259 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
1260 TBUTTON_INFO
*btnPtr
;
1261 INT i
, nRows
, nSepRows
;
1265 BOOL usesBitmaps
= FALSE
;
1266 BOOL hasDropDownArrows
= TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
);
1268 TOOLBAR_CalcStrings (hwnd
, &sizeString
);
1270 for (i
= 0; i
< infoPtr
->nNumButtons
&& !usesBitmaps
; i
++)
1272 if (TOOLBAR_IsValidBitmapIndex(infoPtr
,infoPtr
->buttons
[i
].iBitmap
))
1275 if (dwStyle
& TBSTYLE_LIST
)
1277 infoPtr
->nButtonHeight
= max((usesBitmaps
) ? infoPtr
->nBitmapHeight
:
1278 0, sizeString
.cy
) + infoPtr
->szPadding
.cy
;
1279 infoPtr
->nButtonWidth
= ((usesBitmaps
) ? infoPtr
->nBitmapWidth
:
1280 0) + sizeString
.cx
+ 6;
1281 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1282 infoPtr
->nButtonWidth
, infoPtr
->nButtonHeight
, usesBitmaps
,
1283 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
1284 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
1287 if (sizeString
.cy
> 0)
1290 infoPtr
->nButtonHeight
= sizeString
.cy
+
1291 2 + /* this is the space to separate text from bitmap */
1292 infoPtr
->nBitmapHeight
+ 6;
1294 infoPtr
->nButtonHeight
= sizeString
.cy
+ 6;
1296 else if (infoPtr
->nButtonHeight
< infoPtr
->nBitmapHeight
+ 6)
1297 infoPtr
->nButtonHeight
= infoPtr
->nBitmapHeight
+ 6;
1299 if (sizeString
.cx
> infoPtr
->nBitmapWidth
)
1300 infoPtr
->nButtonWidth
= sizeString
.cx
+ 6;
1301 else if (infoPtr
->nButtonWidth
< infoPtr
->nBitmapWidth
+ 6)
1302 infoPtr
->nButtonWidth
= infoPtr
->nBitmapWidth
+ 6;
1305 if ( infoPtr
->cxMin
>= 0 && infoPtr
->nButtonWidth
< infoPtr
->cxMin
)
1306 infoPtr
->nButtonWidth
= infoPtr
->cxMin
;
1307 if ( infoPtr
->cxMax
> 0 && infoPtr
->nButtonWidth
> infoPtr
->cxMax
)
1308 infoPtr
->nButtonWidth
= infoPtr
->cxMax
;
1310 TOOLBAR_WrapToolbar( hwnd
, dwStyle
);
1312 x
= infoPtr
->nIndent
;
1316 * We will set the height below, and we set the width on entry
1317 * so we do not reset them here..
1320 GetClientRect( hwnd
, &rc
);
1321 /* get initial values for toolbar */
1322 infoPtr
->nWidth
= rc
.right
- rc
.left
;
1323 infoPtr
->nHeight
= rc
.bottom
- rc
.top
;
1326 /* from above, minimum is a button, and possible text */
1327 cx
= infoPtr
->nButtonWidth
;
1329 /* cannot use just ButtonHeight, we may have no buttons! */
1330 if (infoPtr
->nNumButtons
> 0)
1331 infoPtr
->nHeight
= infoPtr
->nButtonHeight
;
1333 cy
= infoPtr
->nHeight
;
1335 nRows
= nSepRows
= 0;
1337 infoPtr
->rcBound
.top
= y
;
1338 infoPtr
->rcBound
.left
= x
;
1339 infoPtr
->rcBound
.bottom
= y
+ cy
;
1340 infoPtr
->rcBound
.right
= x
;
1342 btnPtr
= infoPtr
->buttons
;
1344 /* do not base height/width on parent, if the parent is a */
1345 /* rebar control it could have multiple rows of toolbars */
1346 /* GetClientRect( GetParent(hwnd), &rc ); */
1347 /* cx = rc.right - rc.left; */
1348 /* cy = rc.bottom - rc.top; */
1350 TRACE("cy=%d\n", cy
);
1352 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++ )
1355 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1357 SetRectEmpty (&btnPtr
->rect
);
1361 cy
= infoPtr
->nHeight
;
1363 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1364 /* it is the actual width of the separator. This is used for */
1365 /* custom controls in toolbars. */
1366 if (btnPtr
->fsStyle
& TBSTYLE_SEP
) {
1367 if (btnPtr
->fsStyle
& TBSTYLE_DROPDOWN
) {
1368 cy
= (btnPtr
->iBitmap
> 0) ?
1369 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1370 cx
= infoPtr
->nButtonWidth
;
1373 cx
= (btnPtr
->iBitmap
> 0) ?
1374 btnPtr
->iBitmap
: SEPARATOR_WIDTH
;
1378 if (btnPtr
->fsStyle
& TBSTYLE_AUTOSIZE
)
1385 hOldFont
= SelectObject (hdc
, infoPtr
->hFont
);
1387 TOOLBAR_MeasureString(infoPtr
, btnPtr
, hdc
, &sz
);
1389 SelectObject (hdc
, hOldFont
);
1390 ReleaseDC (hwnd
, hdc
);
1392 /* Fudge amount measured against IE4 "menu" and "Links" */
1393 /* toolbars with native control (v4.71). - GA 8/01 */
1394 cx
= sz
.cx
+ 6 + 5 + 5;
1395 if ((dwStyle
& TBSTYLE_LIST
) &&
1396 (TOOLBAR_TestImageExist (infoPtr
, btnPtr
, infoPtr
->himlDef
)))
1397 cx
+= infoPtr
->nBitmapWidth
;
1400 cx
= infoPtr
->nButtonWidth
;
1402 if (hasDropDownArrows
&& (btnPtr
->fsStyle
& TBSTYLE_DROPDOWN
))
1403 cx
+= DDARROW_WIDTH
;
1405 if (btnPtr
->fsState
& TBSTATE_WRAP
)
1408 SetRect (&btnPtr
->rect
, x
, y
, x
+ cx
, y
+ cy
);
1410 if (infoPtr
->rcBound
.left
> x
)
1411 infoPtr
->rcBound
.left
= x
;
1412 if (infoPtr
->rcBound
.right
< x
+ cx
)
1413 infoPtr
->rcBound
.right
= x
+ cx
;
1414 if (infoPtr
->rcBound
.bottom
< y
+ cy
)
1415 infoPtr
->rcBound
.bottom
= y
+ cy
;
1417 /* Set the toolTip only for non-hidden, non-separator button */
1418 if (infoPtr
->hwndToolTip
&& !(btnPtr
->fsStyle
& TBSTYLE_SEP
))
1422 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
1423 ti
.cbSize
= sizeof(TTTOOLINFOA
);
1425 ti
.uId
= btnPtr
->idCommand
;
1426 ti
.rect
= btnPtr
->rect
;
1427 SendMessageA (infoPtr
->hwndToolTip
, TTM_NEWTOOLRECTA
,
1431 /* btnPtr->nRow is zero based. The space between the rows is */
1432 /* also considered as a row. */
1433 btnPtr
->nRow
= nRows
+ nSepRows
;
1435 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1436 i
, btnPtr
->fsStyle
, bWrap
, nRows
, nSepRows
, btnPtr
->nRow
,
1441 if ( !(btnPtr
->fsStyle
& TBSTYLE_SEP
) )
1445 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1446 /* it is the actual width of the separator. This is used for */
1447 /* custom controls in toolbars. */
1448 if ( !(btnPtr
->fsStyle
& TBSTYLE_DROPDOWN
))
1449 y
+= cy
+ ( (btnPtr
->iBitmap
> 0 ) ?
1450 btnPtr
->iBitmap
: SEPARATOR_WIDTH
) * 2 /3;
1454 /* nSepRows is used to calculate the extra height follwoing */
1458 x
= infoPtr
->nIndent
;
1460 /* Increment row number unless this is the last button */
1461 /* and it has Wrap set. */
1462 if (i
!= infoPtr
->nNumButtons
-1)
1469 /* infoPtr->nRows is the number of rows on the toolbar */
1470 infoPtr
->nRows
= nRows
+ nSepRows
+ 1;
1473 /********************************************************************
1474 * The following while interesting, does not match the values *
1475 * created above for the button rectangles, nor the rcBound rect. *
1476 * We will comment it out and remove it later. *
1478 * The problem showed up as heights in the pager control that was *
1480 ********************************************************************/
1482 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1484 infoPtr
->nHeight
= TOP_BORDER
+ (nRows
+ 1) * infoPtr
->nButtonHeight
+
1485 nSepRows
* (SEPARATOR_WIDTH
* 2 / 3) +
1486 nSepRows
* (infoPtr
->nBitmapHeight
+ 1) +
1490 infoPtr
->nHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
1492 TRACE("toolbar height %d, button width %d\n", infoPtr
->nHeight
, infoPtr
->nButtonWidth
);
1497 TOOLBAR_InternalHitTest (HWND hwnd
, LPPOINT lpPt
)
1499 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
1500 TBUTTON_INFO
*btnPtr
;
1503 btnPtr
= infoPtr
->buttons
;
1504 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1505 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
1508 if (btnPtr
->fsStyle
& TBSTYLE_SEP
) {
1509 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1510 TRACE(" ON SEPARATOR %d!\n", i
);
1515 if (PtInRect (&btnPtr
->rect
, *lpPt
)) {
1516 TRACE(" ON BUTTON %d!\n", i
);
1522 TRACE(" NOWHERE!\n");
1528 TOOLBAR_GetButtonIndex (TOOLBAR_INFO
*infoPtr
, INT idCommand
, BOOL CommandIsIndex
)
1530 TBUTTON_INFO
*btnPtr
;
1533 if (CommandIsIndex
) {
1534 TRACE("command is really index command=%d\n", idCommand
);
1535 if (idCommand
>= infoPtr
->nNumButtons
) return -1;
1538 btnPtr
= infoPtr
->buttons
;
1539 for (i
= 0; i
< infoPtr
->nNumButtons
; i
++, btnPtr
++) {
1540 if (btnPtr
->idCommand
== idCommand
) {
1541 TRACE("command=%d index=%d\n", idCommand
, i
);
1545 TRACE("no index found for command=%d\n", idCommand
);
1551 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO
*infoPtr
, INT nIndex
)
1553 TBUTTON_INFO
*btnPtr
;
1556 if ((nIndex
< 0) || (nIndex
> infoPtr
->nNumButtons
))
1559 /* check index button */
1560 btnPtr
= &infoPtr
->buttons
[nIndex
];
1561 if ((btnPtr
->fsStyle
& TBSTYLE_CHECKGROUP
) == TBSTYLE_CHECKGROUP
) {
1562 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1566 /* check previous buttons */
1567 nRunIndex
= nIndex
- 1;
1568 while (nRunIndex
>= 0) {
1569 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1570 if ((btnPtr
->fsStyle
& TBSTYLE_CHECKGROUP
) == TBSTYLE_CHECKGROUP
) {
1571 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1579 /* check next buttons */
1580 nRunIndex
= nIndex
+ 1;
1581 while (nRunIndex
< infoPtr
->nNumButtons
) {
1582 btnPtr
= &infoPtr
->buttons
[nRunIndex
];
1583 if ((btnPtr
->fsStyle
& TBSTYLE_CHECKGROUP
) == TBSTYLE_CHECKGROUP
) {
1584 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
1597 TOOLBAR_RelayEvent (HWND hwndTip
, HWND hwndMsg
, UINT uMsg
,
1598 WPARAM wParam
, LPARAM lParam
)
1604 msg
.wParam
= wParam
;
1605 msg
.lParam
= lParam
;
1606 msg
.time
= GetMessageTime ();
1607 msg
.pt
.x
= LOWORD(GetMessagePos ());
1608 msg
.pt
.y
= HIWORD(GetMessagePos ());
1610 SendMessageA (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
1614 /***********************************************************************
1615 * TOOLBAR_CustomizeDialogProc
1616 * This function implements the toolbar customization dialog.
1619 TOOLBAR_CustomizeDialogProc(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1621 PCUSTDLG_INFO custInfo
= (PCUSTDLG_INFO
)GetWindowLongA (hwnd
, DWL_USER
);
1622 PCUSTOMBUTTON btnInfo
;
1624 TOOLBAR_INFO
*infoPtr
= custInfo
? custInfo
->tbInfo
: NULL
;
1629 custInfo
= (PCUSTDLG_INFO
)lParam
;
1630 SetWindowLongA (hwnd
, DWL_USER
, (DWORD
)custInfo
);
1638 infoPtr
= custInfo
->tbInfo
;
1640 /* send TBN_QUERYINSERT notification */
1641 nmtb
.iItem
= custInfo
->tbInfo
->nNumButtons
;
1643 if (!TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_QUERYINSERT
))
1646 /* add items to 'toolbar buttons' list and check if removable */
1647 for (i
= 0; i
< custInfo
->tbInfo
->nNumButtons
; i
++)
1649 btnInfo
= (PCUSTOMBUTTON
)COMCTL32_Alloc(sizeof(CUSTOMBUTTON
));
1650 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1651 btnInfo
->btn
.fsStyle
= TBSTYLE_SEP
;
1652 btnInfo
->bVirtual
= FALSE
;
1653 LoadStringA (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1655 /* send TBN_QUERYDELETE notification */
1657 btnInfo
->bRemovable
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
,
1661 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1662 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1665 /* insert separator button into 'available buttons' list */
1666 btnInfo
= (PCUSTOMBUTTON
)COMCTL32_Alloc(sizeof(CUSTOMBUTTON
));
1667 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1668 btnInfo
->btn
.fsStyle
= TBSTYLE_SEP
;
1669 btnInfo
->bVirtual
= FALSE
;
1670 btnInfo
->bRemovable
= TRUE
;
1671 LoadStringA (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1672 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1673 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1675 /* insert all buttons into dsa */
1678 /* send TBN_GETBUTTONINFO notification */
1680 nmtb
.pszText
= Buffer
;
1683 if (!TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
, TBN_GETBUTTONINFOA
))
1686 TRACE("style: %x\n", nmtb
.tbButton
.fsStyle
);
1688 /* insert button into the apropriate list */
1689 index
= TOOLBAR_GetButtonIndex (custInfo
->tbInfo
, nmtb
.tbButton
.idCommand
, FALSE
);
1692 btnInfo
= (PCUSTOMBUTTON
)COMCTL32_Alloc(sizeof(CUSTOMBUTTON
));
1693 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
1694 btnInfo
->bVirtual
= FALSE
;
1695 btnInfo
->bRemovable
= TRUE
;
1696 if (!(nmtb
.tbButton
.fsStyle
& TBSTYLE_SEP
))
1697 strcpy (btnInfo
->text
, nmtb
.pszText
);
1699 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1700 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1704 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1705 memcpy (&btnInfo
->btn
, &nmtb
.tbButton
, sizeof(TBBUTTON
));
1706 if (!(nmtb
.tbButton
.fsStyle
& TBSTYLE_SEP
))
1707 strcpy (btnInfo
->text
, nmtb
.pszText
);
1709 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1713 /* select first item in the 'available' list */
1714 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, 0, 0);
1716 /* append 'virtual' separator button to the 'toolbar buttons' list */
1717 btnInfo
= (PCUSTOMBUTTON
)COMCTL32_Alloc(sizeof(CUSTOMBUTTON
));
1718 memset (&btnInfo
->btn
, 0, sizeof(TBBUTTON
));
1719 btnInfo
->btn
.fsStyle
= TBSTYLE_SEP
;
1720 btnInfo
->bVirtual
= TRUE
;
1721 btnInfo
->bRemovable
= FALSE
;
1722 LoadStringA (COMCTL32_hModule
, IDS_SEPARATOR
, btnInfo
->text
, 64);
1723 index
= (int)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_ADDSTRING
, 0, (LPARAM
)btnInfo
);
1724 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1726 /* select last item in the 'toolbar' list */
1727 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
1728 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETTOPINDEX
, index
, 0);
1730 /* set focus and disable buttons */
1731 PostMessageA (hwnd
, WM_USER
, 0, 0);
1736 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1737 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1738 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), FALSE
);
1739 SetFocus (GetDlgItem (hwnd
, IDC_TOOLBARBTN_LBOX
));
1743 EndDialog(hwnd
, FALSE
);
1747 switch (LOWORD(wParam
))
1749 case IDC_TOOLBARBTN_LBOX
:
1750 if (HIWORD(wParam
) == LBN_SELCHANGE
)
1752 PCUSTOMBUTTON btnInfo
;
1757 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1758 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1760 /* send TBN_QUERYINSERT notification */
1762 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1765 /* get list box item */
1766 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1768 if (index
== (count
- 1))
1770 /* last item (virtual separator) */
1771 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1772 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1774 else if (index
== (count
- 2))
1776 /* second last item (last non-virtual item) */
1777 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1778 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1780 else if (index
== 0)
1783 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1784 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1788 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1789 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1792 EnableWindow (GetDlgItem (hwnd
,IDC_REMOVE_BTN
), btnInfo
->bRemovable
);
1796 case IDC_MOVEUP_BTN
:
1798 PCUSTOMBUTTON btnInfo
;
1802 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1803 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1804 TRACE("Move up: index %d\n", index
);
1806 /* send TBN_QUERYINSERT notification */
1809 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1812 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1814 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1815 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
-1, 0);
1816 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
-1, (LPARAM
)btnInfo
);
1817 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
1820 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), FALSE
);
1821 else if (index
>= (count
- 3))
1822 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), TRUE
);
1824 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1825 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
-1, (LPARAM
)&(btnInfo
->btn
));
1830 case IDC_MOVEDN_BTN
: /* move down */
1832 PCUSTOMBUTTON btnInfo
;
1836 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1837 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1838 TRACE("Move up: index %d\n", index
);
1840 /* send TBN_QUERYINSERT notification */
1842 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1845 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1847 /* move button down */
1848 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1849 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
+1, 0);
1850 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
+1, (LPARAM
)btnInfo
);
1851 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
+1 , 0);
1854 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEUP_BTN
), TRUE
);
1855 else if (index
>= (count
- 3))
1856 EnableWindow (GetDlgItem (hwnd
,IDC_MOVEDN_BTN
), FALSE
);
1858 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1859 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
+1, (LPARAM
)&(btnInfo
->btn
));
1864 case IDC_REMOVE_BTN
: /* remove button */
1866 PCUSTOMBUTTON btnInfo
;
1869 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1870 TRACE("Remove: index %d\n", index
);
1872 /* send TBN_QUERYDELETE notification */
1874 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1877 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1878 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1879 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETCURSEL
, index
, 0);
1881 SendMessageA (custInfo
->tbHwnd
, TB_DELETEBUTTON
, index
, 0);
1883 /* insert into 'available button' list */
1884 if (!(btnInfo
->btn
.fsStyle
& TBSTYLE_SEP
))
1886 index
= (int)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_ADDSTRING
, 0, 0);
1887 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1890 COMCTL32_Free (btnInfo
);
1895 case IDOK
: /* Add button */
1900 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1901 index
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1902 TRACE("Add: index %d\n", index
);
1904 /* send TBN_QUERYINSERT notification */
1906 if (TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
1909 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, index
, 0);
1913 /* remove from 'available buttons' list */
1914 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_DELETESTRING
, index
, 0);
1915 if (index
== count
-1)
1916 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
-1 , 0);
1918 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETCURSEL
, index
, 0);
1922 PCUSTOMBUTTON btnNew
;
1924 /* duplicate 'separator' button */
1925 btnNew
= (PCUSTOMBUTTON
)COMCTL32_Alloc (sizeof(CUSTOMBUTTON
));
1926 memcpy (btnNew
, btnInfo
, sizeof(CUSTOMBUTTON
));
1930 /* insert into 'toolbar button' list */
1931 index
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCURSEL
, 0, 0);
1932 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_INSERTSTRING
, index
, 0);
1933 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, index
, (LPARAM
)btnInfo
);
1935 SendMessageA (custInfo
->tbHwnd
, TB_INSERTBUTTONA
, index
, (LPARAM
)&(btnInfo
->btn
));
1941 EndDialog(hwnd
, FALSE
);
1951 /* delete items from 'toolbar buttons' listbox*/
1952 count
= SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1953 for (i
= 0; i
< count
; i
++)
1955 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
1956 COMCTL32_Free(btnInfo
);
1957 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_SETITEMDATA
, 0, 0);
1959 SendDlgItemMessageA (hwnd
, IDC_TOOLBARBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
1962 /* delete items from 'available buttons' listbox*/
1963 count
= SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETCOUNT
, 0, 0);
1964 for (i
= 0; i
< count
; i
++)
1966 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_GETITEMDATA
, i
, 0);
1967 COMCTL32_Free(btnInfo
);
1968 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_SETITEMDATA
, i
, 0);
1970 SendDlgItemMessageA (hwnd
, IDC_AVAILBTN_LBOX
, LB_RESETCONTENT
, 0, 0);
1975 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
1977 LPDRAWITEMSTRUCT lpdis
= (LPDRAWITEMSTRUCT
)lParam
;
1982 COLORREF oldText
= 0;
1986 btnInfo
= (PCUSTOMBUTTON
)SendDlgItemMessageA (hwnd
, wParam
, LB_GETITEMDATA
, (WPARAM
)lpdis
->itemID
, 0);
1987 if (btnInfo
== NULL
)
1989 FIXME("btnInfo invalid!\n");
1993 /* set colors and select objects */
1994 oldBk
= SetBkColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlight
:comctl32_color
.clrWindow
);
1995 if (btnInfo
->bVirtual
)
1996 oldText
= SetTextColor (lpdis
->hDC
, comctl32_color
.clrGrayText
);
1998 oldText
= SetTextColor (lpdis
->hDC
, (lpdis
->itemState
& ODS_FOCUS
)?comctl32_color
.clrHighlightText
:comctl32_color
.clrWindowText
);
1999 hOldPen
= SelectObject (lpdis
->hDC
, GetSysColorPen ((lpdis
->itemState
& ODS_SELECTED
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2000 hOldBrush
= SelectObject (lpdis
->hDC
, GetSysColorBrush ((lpdis
->itemState
& ODS_FOCUS
)?COLOR_HIGHLIGHT
:COLOR_WINDOW
));
2002 /* fill background rectangle */
2003 Rectangle (lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
2004 lpdis
->rcItem
.right
, lpdis
->rcItem
.bottom
);
2006 /* calculate button and text rectangles */
2007 CopyRect (&rcButton
, &lpdis
->rcItem
);
2008 InflateRect (&rcButton
, -1, -1);
2009 CopyRect (&rcText
, &rcButton
);
2010 rcButton
.right
= rcButton
.left
+ custInfo
->tbInfo
->nBitmapWidth
+ 6;
2011 rcText
.left
= rcButton
.right
+ 2;
2013 /* draw focus rectangle */
2014 if (lpdis
->itemState
& ODS_FOCUS
)
2015 DrawFocusRect (lpdis
->hDC
, &lpdis
->rcItem
);
2018 DrawEdge (lpdis
->hDC
, &rcButton
, EDGE_RAISED
, BF_RECT
|BF_MIDDLE
|BF_SOFT
);
2020 /* draw image and text */
2021 if ((btnInfo
->btn
.fsStyle
& TBSTYLE_SEP
) == 0)
2022 ImageList_Draw (custInfo
->tbInfo
->himlDef
, btnInfo
->btn
.iBitmap
, lpdis
->hDC
,
2023 rcButton
.left
+3, rcButton
.top
+3, ILD_NORMAL
);
2024 DrawTextA (lpdis
->hDC
, btnInfo
->text
, -1, &rcText
,
2025 DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
);
2027 /* delete objects and reset colors */
2028 SelectObject (lpdis
->hDC
, hOldBrush
);
2029 SelectObject (lpdis
->hDC
, hOldPen
);
2030 SetBkColor (lpdis
->hDC
, oldBk
);
2031 SetTextColor (lpdis
->hDC
, oldText
);
2037 case WM_MEASUREITEM
:
2038 if (wParam
== IDC_AVAILBTN_LBOX
|| wParam
== IDC_TOOLBARBTN_LBOX
)
2040 MEASUREITEMSTRUCT
*lpmis
= (MEASUREITEMSTRUCT
*)lParam
;
2042 if (custInfo
&& custInfo
->tbInfo
)
2043 lpmis
->itemHeight
= custInfo
->tbInfo
->nBitmapHeight
+ 8;
2045 lpmis
->itemHeight
= 15 + 8; /* default height */
2057 /***********************************************************************
2058 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2062 TOOLBAR_AddBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2064 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2065 LPTBADDBITMAP lpAddBmp
= (LPTBADDBITMAP
)lParam
;
2066 INT nIndex
= 0, nButtons
, nCount
;
2069 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd
, wParam
, lParam
);
2073 if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2075 if ((lpAddBmp
->nID
& ~1) == IDB_STD_SMALL_COLOR
)
2077 else if ((lpAddBmp
->nID
& ~1) == IDB_VIEW_SMALL_COLOR
)
2079 else if ((lpAddBmp
->nID
& ~1) == IDB_HIST_SMALL_COLOR
)
2084 TRACE ("adding %d internal bitmaps!\n", nButtons
);
2086 /* Windows resize all the buttons to the size of a newly added standard image */
2087 if (lpAddBmp
->nID
& 1)
2090 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2091 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2093 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2094 MAKELPARAM((WORD
)24, (WORD
)24));
2095 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2096 MAKELPARAM((WORD
)31, (WORD
)30));
2101 SendMessageA (hwnd
, TB_SETBITMAPSIZE
, 0,
2102 MAKELPARAM((WORD
)16, (WORD
)16));
2103 SendMessageA (hwnd
, TB_SETBUTTONSIZE
, 0,
2104 MAKELPARAM((WORD
)22, (WORD
)22));
2107 TOOLBAR_CalcToolbar (hwnd
);
2111 nButtons
= (INT
)wParam
;
2115 TRACE ("adding %d bitmaps!\n", nButtons
);
2118 if (!(infoPtr
->himlDef
)) {
2119 /* create new default image list */
2120 TRACE ("creating default image list!\n");
2123 ImageList_Create (infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
2124 ILC_COLOR
| ILC_MASK
, nButtons
, 2);
2125 infoPtr
->himlInt
= infoPtr
->himlDef
;
2128 nCount
= ImageList_GetImageCount(infoPtr
->himlDef
);
2130 /* Add bitmaps to the default image list */
2131 if (lpAddBmp
->hInst
== (HINSTANCE
)0)
2134 ImageList_AddMasked (infoPtr
->himlDef
, (HBITMAP
)lpAddBmp
->nID
,
2137 else if (lpAddBmp
->hInst
== HINST_COMMCTRL
)
2139 /* Add system bitmaps */
2140 switch (lpAddBmp
->nID
)
2142 case IDB_STD_SMALL_COLOR
:
2143 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2144 MAKEINTRESOURCEA(IDB_STD_SMALL
));
2145 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
,
2146 hbmLoad
, CLR_DEFAULT
);
2147 DeleteObject (hbmLoad
);
2150 case IDB_STD_LARGE_COLOR
:
2151 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2152 MAKEINTRESOURCEA(IDB_STD_LARGE
));
2153 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
,
2154 hbmLoad
, CLR_DEFAULT
);
2155 DeleteObject (hbmLoad
);
2158 case IDB_VIEW_SMALL_COLOR
:
2159 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2160 MAKEINTRESOURCEA(IDB_VIEW_SMALL
));
2161 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
,
2162 hbmLoad
, CLR_DEFAULT
);
2163 DeleteObject (hbmLoad
);
2166 case IDB_VIEW_LARGE_COLOR
:
2167 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2168 MAKEINTRESOURCEA(IDB_VIEW_LARGE
));
2169 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
,
2170 hbmLoad
, CLR_DEFAULT
);
2171 DeleteObject (hbmLoad
);
2174 case IDB_HIST_SMALL_COLOR
:
2175 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2176 MAKEINTRESOURCEA(IDB_HIST_SMALL
));
2177 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
,
2178 hbmLoad
, CLR_DEFAULT
);
2179 DeleteObject (hbmLoad
);
2182 case IDB_HIST_LARGE_COLOR
:
2183 hbmLoad
= LoadBitmapA (COMCTL32_hModule
,
2184 MAKEINTRESOURCEA(IDB_HIST_LARGE
));
2185 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
,
2186 hbmLoad
, CLR_DEFAULT
);
2187 DeleteObject (hbmLoad
);
2191 nIndex
= ImageList_GetImageCount (infoPtr
->himlDef
);
2192 ERR ("invalid imagelist!\n");
2198 hbmLoad
= LoadBitmapA (lpAddBmp
->hInst
, (LPSTR
)lpAddBmp
->nID
);
2199 nIndex
= ImageList_AddMasked (infoPtr
->himlDef
, hbmLoad
, CLR_DEFAULT
);
2200 DeleteObject (hbmLoad
);
2205 INT imagecount
= ImageList_GetImageCount(infoPtr
->himlDef
);
2207 if (infoPtr
->nNumBitmaps
+ nButtons
!= imagecount
)
2209 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",
2210 infoPtr
->nNumBitmaps
, nCount
, imagecount
- nCount
,
2211 infoPtr
->nNumBitmaps
+nButtons
,imagecount
);
2213 infoPtr
->nNumBitmaps
= imagecount
;
2216 infoPtr
->nNumBitmaps
+= nButtons
;
2219 InvalidateRect(hwnd
, NULL
, FALSE
);
2226 TOOLBAR_AddButtonsA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2228 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2229 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2230 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2232 TRACE("adding %d buttons!\n", wParam
);
2234 nAddButtons
= (UINT
)wParam
;
2235 nOldButtons
= infoPtr
->nNumButtons
;
2236 nNewButtons
= nOldButtons
+ nAddButtons
;
2238 if (infoPtr
->nNumButtons
== 0) {
2240 COMCTL32_Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2243 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2245 COMCTL32_Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2246 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2247 nOldButtons
* sizeof(TBUTTON_INFO
));
2248 COMCTL32_Free (oldButtons
);
2251 infoPtr
->nNumButtons
= nNewButtons
;
2253 /* insert new button data */
2254 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2255 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2256 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2257 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2258 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2259 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2260 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2261 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2262 btnPtr
->bHot
= FALSE
;
2264 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& TBSTYLE_SEP
)) {
2267 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
2268 ti
.cbSize
= sizeof (TTTOOLINFOA
);
2270 ti
.uId
= btnPtr
->idCommand
;
2272 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
2274 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
2279 TOOLBAR_CalcToolbar (hwnd
);
2281 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2283 InvalidateRect(hwnd
, NULL
, FALSE
);
2290 TOOLBAR_AddButtonsW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2292 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2293 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2294 INT nOldButtons
, nNewButtons
, nAddButtons
, nCount
;
2296 TRACE("adding %d buttons!\n", wParam
);
2298 nAddButtons
= (UINT
)wParam
;
2299 nOldButtons
= infoPtr
->nNumButtons
;
2300 nNewButtons
= nOldButtons
+ nAddButtons
;
2302 if (infoPtr
->nNumButtons
== 0) {
2304 COMCTL32_Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2307 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2309 COMCTL32_Alloc (sizeof(TBUTTON_INFO
) * nNewButtons
);
2310 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2311 nOldButtons
* sizeof(TBUTTON_INFO
));
2312 COMCTL32_Free (oldButtons
);
2315 infoPtr
->nNumButtons
= nNewButtons
;
2317 /* insert new button data */
2318 for (nCount
= 0; nCount
< nAddButtons
; nCount
++) {
2319 TBUTTON_INFO
*btnPtr
= &infoPtr
->buttons
[nOldButtons
+nCount
];
2320 btnPtr
->iBitmap
= lpTbb
[nCount
].iBitmap
;
2321 btnPtr
->idCommand
= lpTbb
[nCount
].idCommand
;
2322 btnPtr
->fsState
= lpTbb
[nCount
].fsState
;
2323 btnPtr
->fsStyle
= lpTbb
[nCount
].fsStyle
;
2324 btnPtr
->dwData
= lpTbb
[nCount
].dwData
;
2325 btnPtr
->iString
= lpTbb
[nCount
].iString
;
2326 btnPtr
->bHot
= FALSE
;
2328 if ((infoPtr
->hwndToolTip
) && !(btnPtr
->fsStyle
& TBSTYLE_SEP
)) {
2331 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
2332 ti
.cbSize
= sizeof (TTTOOLINFOW
);
2334 ti
.uId
= btnPtr
->idCommand
;
2336 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
2338 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
2343 TOOLBAR_CalcToolbar (hwnd
);
2345 TOOLBAR_DumpToolbar (infoPtr
, __LINE__
);
2347 InvalidateRect(hwnd
, NULL
, FALSE
);
2354 TOOLBAR_AddStringA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2356 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2359 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2362 TRACE("adding string from resource!\n");
2364 len
= LoadStringA ((HINSTANCE
)wParam
, (UINT
)lParam
,
2367 TRACE("len=%d \"%s\"\n", len
, szString
);
2368 nIndex
= infoPtr
->nNumStrings
;
2369 if (infoPtr
->nNumStrings
== 0) {
2371 COMCTL32_Alloc (sizeof(LPWSTR
));
2374 LPWSTR
*oldStrings
= infoPtr
->strings
;
2376 COMCTL32_Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2377 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2378 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2379 COMCTL32_Free (oldStrings
);
2382 /*COMCTL32_Alloc zeros out the allocated memory*/
2383 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2384 infoPtr
->nNumStrings
++;
2387 LPSTR p
= (LPSTR
)lParam
;
2392 TRACE("adding string(s) from array!\n");
2394 nIndex
= infoPtr
->nNumStrings
;
2397 TRACE("len=%d \"%s\"\n", len
, p
);
2399 if (infoPtr
->nNumStrings
== 0) {
2401 COMCTL32_Alloc (sizeof(LPWSTR
));
2404 LPWSTR
*oldStrings
= infoPtr
->strings
;
2406 COMCTL32_Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2407 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2408 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2409 COMCTL32_Free (oldStrings
);
2412 Str_SetPtrAtoW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2413 infoPtr
->nNumStrings
++;
2424 TOOLBAR_AddStringW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2426 #define MAX_RESOURCE_STRING_LENGTH 512
2427 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2430 if ((wParam
) && (HIWORD(lParam
) == 0)) {
2431 WCHAR szString
[MAX_RESOURCE_STRING_LENGTH
];
2433 TRACE("adding string from resource!\n");
2435 len
= LoadStringW ((HINSTANCE
)wParam
, (UINT
)lParam
,
2436 szString
, MAX_RESOURCE_STRING_LENGTH
);
2438 TRACE("len=%d %s\n", len
, debugstr_w(szString
));
2439 TRACE("First char: 0x%x\n", *szString
);
2440 if (szString
[0] == L
'|')
2442 PWSTR p
= szString
+ 1;
2444 nIndex
= infoPtr
->nNumStrings
;
2445 while (*p
!= L
'|') {
2447 if (infoPtr
->nNumStrings
== 0) {
2449 COMCTL32_Alloc (sizeof(LPWSTR
));
2452 LPWSTR
*oldStrings
= infoPtr
->strings
;
2454 COMCTL32_Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2455 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2456 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2457 COMCTL32_Free (oldStrings
);
2460 len
= COMCTL32_StrChrW (p
, L
'|') - p
;
2461 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2462 infoPtr
->strings
[infoPtr
->nNumStrings
] =
2463 COMCTL32_Alloc (sizeof(WCHAR
)*(len
+1));
2464 lstrcpynW (infoPtr
->strings
[infoPtr
->nNumStrings
], p
, len
+1);
2465 infoPtr
->nNumStrings
++;
2472 nIndex
= infoPtr
->nNumStrings
;
2473 if (infoPtr
->nNumStrings
== 0) {
2475 COMCTL32_Alloc (sizeof(LPWSTR
));
2478 LPWSTR
*oldStrings
= infoPtr
->strings
;
2480 COMCTL32_Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2481 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2482 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2483 COMCTL32_Free (oldStrings
);
2486 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], szString
);
2487 infoPtr
->nNumStrings
++;
2491 LPWSTR p
= (LPWSTR
)lParam
;
2496 TRACE("adding string(s) from array!\n");
2497 nIndex
= infoPtr
->nNumStrings
;
2501 TRACE("len=%d %s\n", len
, debugstr_w(p
));
2502 if (infoPtr
->nNumStrings
== 0) {
2504 COMCTL32_Alloc (sizeof(LPWSTR
));
2507 LPWSTR
*oldStrings
= infoPtr
->strings
;
2509 COMCTL32_Alloc (sizeof(LPWSTR
) * (infoPtr
->nNumStrings
+ 1));
2510 memcpy (&infoPtr
->strings
[0], &oldStrings
[0],
2511 sizeof(LPWSTR
) * infoPtr
->nNumStrings
);
2512 COMCTL32_Free (oldStrings
);
2515 Str_SetPtrW (&infoPtr
->strings
[infoPtr
->nNumStrings
], p
);
2516 infoPtr
->nNumStrings
++;
2527 TOOLBAR_AutoSize (HWND hwnd
)
2529 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2530 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
2536 UINT uPosFlags
= SWP_NOZORDER
;
2538 TRACE("resize forced, style=%lx!\n", dwStyle
);
2540 parent
= GetParent (hwnd
);
2541 GetClientRect(parent
, &parent_rect
);
2543 x
= parent_rect
.left
;
2544 y
= parent_rect
.top
;
2546 /* FIXME: we should be able to early out if nothing */
2547 /* has changed with nWidth != parent_rect width */
2549 if (dwStyle
& CCS_NORESIZE
) {
2550 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
2553 TOOLBAR_CalcToolbar (hwnd
);
2556 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
2557 TOOLBAR_CalcToolbar (hwnd
);
2558 InvalidateRect( hwnd
, NULL
, TRUE
);
2559 cy
= infoPtr
->nHeight
;
2560 cx
= infoPtr
->nWidth
;
2562 if (dwStyle
& CCS_NOMOVEY
) {
2563 GetWindowRect(hwnd
, &window_rect
);
2564 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
2565 y
= window_rect
.top
;
2569 if (dwStyle
& CCS_NOPARENTALIGN
)
2570 uPosFlags
|= SWP_NOMOVE
;
2572 if (!(dwStyle
& CCS_NODIVIDER
))
2573 cy
+= GetSystemMetrics(SM_CYEDGE
);
2575 if (dwStyle
& WS_BORDER
)
2578 cy
+= GetSystemMetrics(SM_CYEDGE
);
2579 cx
+= GetSystemMetrics(SM_CYEDGE
);
2582 infoPtr
->bAutoSize
= TRUE
;
2583 SetWindowPos (hwnd
, HWND_TOP
, parent_rect
.left
- x
, parent_rect
.top
- y
,
2585 /* The following line makes sure that the infoPtr->bAutoSize is turned off after
2586 * the setwindowpos calls */
2587 infoPtr
->bAutoSize
= FALSE
;
2594 TOOLBAR_ButtonCount (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2596 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2598 return infoPtr
->nNumButtons
;
2603 TOOLBAR_ButtonStructSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2605 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2607 if (infoPtr
== NULL
) {
2608 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd
, wParam
, lParam
);
2609 ERR("infoPtr == NULL!\n");
2613 infoPtr
->dwStructSize
= (DWORD
)wParam
;
2620 TOOLBAR_ChangeBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2622 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2623 TBUTTON_INFO
*btnPtr
;
2626 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2630 btnPtr
= &infoPtr
->buttons
[nIndex
];
2631 btnPtr
->iBitmap
= LOWORD(lParam
);
2633 /* we HAVE to erase the background, the new bitmap could be */
2635 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2642 TOOLBAR_CheckButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2644 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2645 TBUTTON_INFO
*btnPtr
;
2648 BOOL bChecked
= FALSE
;
2650 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2654 btnPtr
= &infoPtr
->buttons
[nIndex
];
2656 if (!(btnPtr
->fsStyle
& TBSTYLE_CHECK
))
2659 bChecked
= (btnPtr
->fsState
& TBSTATE_CHECKED
) ? TRUE
: FALSE
;
2661 if (LOWORD(lParam
) == FALSE
)
2662 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
2664 if (btnPtr
->fsStyle
& TBSTYLE_GROUP
) {
2666 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
, nIndex
);
2667 if (nOldIndex
== nIndex
)
2669 if (nOldIndex
!= -1)
2670 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
2672 btnPtr
->fsState
|= TBSTATE_CHECKED
;
2675 if( bChecked
!= LOWORD(lParam
) )
2677 if (nOldIndex
!= -1)
2679 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
,
2680 TOOLBAR_HasText(infoPtr
, &infoPtr
->buttons
[nOldIndex
]));
2682 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
2685 /* FIXME: Send a WM_NOTIFY?? */
2692 TOOLBAR_CommandToIndex (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2694 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2696 return TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2701 TOOLBAR_Customize (HWND hwnd
)
2703 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2704 CUSTDLG_INFO custInfo
;
2710 custInfo
.tbInfo
= infoPtr
;
2711 custInfo
.tbHwnd
= hwnd
;
2713 /* send TBN_BEGINADJUST notification */
2714 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
2717 if (!(hRes
= FindResourceA (COMCTL32_hModule
,
2718 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE
),
2722 if(!(template = (LPVOID
)LoadResource (COMCTL32_hModule
, hRes
)))
2725 ret
= DialogBoxIndirectParamA (GetWindowLongA (hwnd
, GWL_HINSTANCE
),
2726 (LPDLGTEMPLATEA
)template,
2728 (DLGPROC
)TOOLBAR_CustomizeDialogProc
,
2731 /* send TBN_ENDADJUST notification */
2732 TOOLBAR_SendNotify ((NMHDR
*) &nmhdr
, infoPtr
,
2740 TOOLBAR_DeleteButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2742 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2743 INT nIndex
= (INT
)wParam
;
2745 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
2748 if ((infoPtr
->hwndToolTip
) &&
2749 !(infoPtr
->buttons
[nIndex
].fsStyle
& TBSTYLE_SEP
)) {
2752 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
2753 ti
.cbSize
= sizeof (TTTOOLINFOA
);
2755 ti
.uId
= infoPtr
->buttons
[nIndex
].idCommand
;
2757 SendMessageA (infoPtr
->hwndToolTip
, TTM_DELTOOLA
, 0, (LPARAM
)&ti
);
2760 if (infoPtr
->nNumButtons
== 1) {
2761 TRACE(" simple delete!\n");
2762 COMCTL32_Free (infoPtr
->buttons
);
2763 infoPtr
->buttons
= NULL
;
2764 infoPtr
->nNumButtons
= 0;
2767 TBUTTON_INFO
*oldButtons
= infoPtr
->buttons
;
2768 TRACE("complex delete! [nIndex=%d]\n", nIndex
);
2770 infoPtr
->nNumButtons
--;
2771 infoPtr
->buttons
= COMCTL32_Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
2773 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
2774 nIndex
* sizeof(TBUTTON_INFO
));
2777 if (nIndex
< infoPtr
->nNumButtons
) {
2778 memcpy (&infoPtr
->buttons
[nIndex
], &oldButtons
[nIndex
+1],
2779 (infoPtr
->nNumButtons
- nIndex
) * sizeof(TBUTTON_INFO
));
2782 COMCTL32_Free (oldButtons
);
2785 TOOLBAR_CalcToolbar (hwnd
);
2787 InvalidateRect (hwnd
, NULL
, TRUE
);
2794 TOOLBAR_EnableButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2796 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2797 TBUTTON_INFO
*btnPtr
;
2801 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2805 btnPtr
= &infoPtr
->buttons
[nIndex
];
2807 bState
= btnPtr
->fsState
& TBSTATE_ENABLED
;
2809 /* update the toolbar button state */
2810 if(LOWORD(lParam
) == FALSE
) {
2811 btnPtr
->fsState
&= ~(TBSTATE_ENABLED
| TBSTATE_PRESSED
);
2813 btnPtr
->fsState
|= TBSTATE_ENABLED
;
2816 /* redraw the button only if the state of the button changed */
2817 if(bState
!= (btnPtr
->fsState
& TBSTATE_ENABLED
))
2819 InvalidateRect(hwnd
, &btnPtr
->rect
,
2820 TOOLBAR_HasText(infoPtr
, btnPtr
));
2827 static inline LRESULT
2828 TOOLBAR_GetAnchorHighlight (HWND hwnd
)
2830 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2832 return infoPtr
->bAnchor
;
2837 TOOLBAR_GetBitmap (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2839 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2842 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2846 return infoPtr
->buttons
[nIndex
].iBitmap
;
2850 static inline LRESULT
2851 TOOLBAR_GetBitmapFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2853 return (GetDeviceCaps (0, LOGPIXELSX
) >= 120) ? TBBF_LARGE
: 0;
2858 TOOLBAR_GetButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2860 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2861 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
2862 INT nIndex
= (INT
)wParam
;
2863 TBUTTON_INFO
*btnPtr
;
2865 if (infoPtr
== NULL
)
2871 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
2874 btnPtr
= &infoPtr
->buttons
[nIndex
];
2875 lpTbb
->iBitmap
= btnPtr
->iBitmap
;
2876 lpTbb
->idCommand
= btnPtr
->idCommand
;
2877 lpTbb
->fsState
= btnPtr
->fsState
;
2878 lpTbb
->fsStyle
= btnPtr
->fsStyle
;
2879 lpTbb
->dwData
= btnPtr
->dwData
;
2880 lpTbb
->iString
= btnPtr
->iString
;
2887 TOOLBAR_GetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2889 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2890 LPTBBUTTONINFOA lpTbInfo
= (LPTBBUTTONINFOA
)lParam
;
2891 TBUTTON_INFO
*btnPtr
;
2894 if (infoPtr
== NULL
)
2896 if (lpTbInfo
== NULL
)
2898 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOA
))
2901 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
2902 lpTbInfo
->dwMask
& 0x80000000);
2906 if (!(btnPtr
= &infoPtr
->buttons
[nIndex
])) return -1;
2908 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
2909 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
2910 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
2911 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
2912 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
2913 lpTbInfo
->lParam
= btnPtr
->dwData
;
2914 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
2915 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
2916 if (lpTbInfo
->dwMask
& TBIF_STATE
)
2917 lpTbInfo
->fsState
= btnPtr
->fsState
;
2918 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
2919 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
2920 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
2921 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
,btnPtr
);
2922 Str_GetPtrWtoA (lpText
, lpTbInfo
->pszText
,lpTbInfo
->cchText
);
2929 TOOLBAR_GetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2931 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2932 LPTBBUTTONINFOW lpTbInfo
= (LPTBBUTTONINFOW
)lParam
;
2933 TBUTTON_INFO
*btnPtr
;
2936 if (infoPtr
== NULL
)
2938 if (lpTbInfo
== NULL
)
2940 if (lpTbInfo
->cbSize
< sizeof(TBBUTTONINFOW
))
2943 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
2944 lpTbInfo
->dwMask
& 0x80000000);
2948 btnPtr
= &infoPtr
->buttons
[nIndex
];
2950 if (lpTbInfo
->dwMask
& TBIF_COMMAND
)
2951 lpTbInfo
->idCommand
= btnPtr
->idCommand
;
2952 if (lpTbInfo
->dwMask
& TBIF_IMAGE
)
2953 lpTbInfo
->iImage
= btnPtr
->iBitmap
;
2954 if (lpTbInfo
->dwMask
& TBIF_LPARAM
)
2955 lpTbInfo
->lParam
= btnPtr
->dwData
;
2956 if (lpTbInfo
->dwMask
& TBIF_SIZE
)
2957 lpTbInfo
->cx
= (WORD
)(btnPtr
->rect
.right
- btnPtr
->rect
.left
);
2958 if (lpTbInfo
->dwMask
& TBIF_STATE
)
2959 lpTbInfo
->fsState
= btnPtr
->fsState
;
2960 if (lpTbInfo
->dwMask
& TBIF_STYLE
)
2961 lpTbInfo
->fsStyle
= btnPtr
->fsStyle
;
2962 if (lpTbInfo
->dwMask
& TBIF_TEXT
) {
2963 LPWSTR lpText
= TOOLBAR_GetText(infoPtr
,btnPtr
);
2964 Str_GetPtrW (lpText
,lpTbInfo
->pszText
,lpTbInfo
->cchText
);
2972 TOOLBAR_GetButtonSize (HWND hwnd
)
2974 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2976 if (infoPtr
->nNumButtons
> 0)
2977 return MAKELONG((WORD
)infoPtr
->nButtonWidth
,
2978 (WORD
)infoPtr
->nButtonHeight
);
2980 return MAKELONG(8,7);
2985 TOOLBAR_GetButtonTextA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
2987 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
2994 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
2998 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3000 return WideCharToMultiByte( CP_ACP
, 0, lpText
, -1,
3001 (LPSTR
)lParam
, 0x7fffffff, NULL
, NULL
) - 1;
3006 TOOLBAR_GetButtonTextW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3008 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3015 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3019 lpText
= TOOLBAR_GetText(infoPtr
,&infoPtr
->buttons
[nIndex
]);
3021 strcpyW ((LPWSTR
)lParam
, lpText
);
3023 return strlenW (lpText
);
3028 TOOLBAR_GetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3030 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3032 return (LRESULT
)infoPtr
->himlDis
;
3036 inline static LRESULT
3037 TOOLBAR_GetExtendedStyle (HWND hwnd
)
3039 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3041 return infoPtr
->dwExStyle
;
3046 TOOLBAR_GetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3048 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3050 return (LRESULT
)infoPtr
->himlHot
;
3055 TOOLBAR_GetHotItem (HWND hwnd
)
3057 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3059 if (!(GetWindowLongA (hwnd
, GWL_STYLE
) & TBSTYLE_FLAT
))
3062 if (infoPtr
->nHotItem
< 0)
3065 return (LRESULT
)infoPtr
->nHotItem
;
3070 TOOLBAR_GetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3072 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3074 return (LRESULT
)infoPtr
->himlDef
;
3078 /* << TOOLBAR_GetInsertMark >> */
3079 /* << TOOLBAR_GetInsertMarkColor >> */
3083 TOOLBAR_GetItemRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3085 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3086 TBUTTON_INFO
*btnPtr
;
3090 if (infoPtr
== NULL
)
3092 nIndex
= (INT
)wParam
;
3093 btnPtr
= &infoPtr
->buttons
[nIndex
];
3094 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3096 lpRect
= (LPRECT
)lParam
;
3099 if (btnPtr
->fsState
& TBSTATE_HIDDEN
)
3102 lpRect
->left
= btnPtr
->rect
.left
;
3103 lpRect
->right
= btnPtr
->rect
.right
;
3104 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3105 lpRect
->top
= btnPtr
->rect
.top
;
3112 TOOLBAR_GetMaxSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3114 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3115 LPSIZE lpSize
= (LPSIZE
)lParam
;
3120 lpSize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
3121 lpSize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
3123 TRACE("maximum size %d x %d\n",
3124 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
,
3125 infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
);
3131 /* << TOOLBAR_GetObject >> */
3135 TOOLBAR_GetPadding (HWND hwnd
)
3137 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3140 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
3141 return (LRESULT
) oldPad
;
3146 TOOLBAR_GetRect (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3148 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3149 TBUTTON_INFO
*btnPtr
;
3153 if (infoPtr
== NULL
)
3155 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3156 btnPtr
= &infoPtr
->buttons
[nIndex
];
3157 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3159 lpRect
= (LPRECT
)lParam
;
3163 lpRect
->left
= btnPtr
->rect
.left
;
3164 lpRect
->right
= btnPtr
->rect
.right
;
3165 lpRect
->bottom
= btnPtr
->rect
.bottom
;
3166 lpRect
->top
= btnPtr
->rect
.top
;
3173 TOOLBAR_GetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3175 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3177 if (GetWindowLongA (hwnd
, GWL_STYLE
) & TBSTYLE_WRAPABLE
)
3178 return infoPtr
->nRows
;
3185 TOOLBAR_GetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3187 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3190 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3194 return infoPtr
->buttons
[nIndex
].fsState
;
3199 TOOLBAR_GetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3201 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3204 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3208 return infoPtr
->buttons
[nIndex
].fsStyle
;
3213 TOOLBAR_GetTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3215 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3217 if (infoPtr
== NULL
)
3220 return infoPtr
->nMaxTextRows
;
3225 TOOLBAR_GetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3227 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3229 if (infoPtr
== NULL
)
3231 return infoPtr
->hwndToolTip
;
3236 TOOLBAR_GetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3238 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3240 TRACE("%s hwnd=0x%x stub!\n",
3241 infoPtr
->bUnicode
? "TRUE" : "FALSE", hwnd
);
3243 return infoPtr
->bUnicode
;
3247 inline static LRESULT
3248 TOOLBAR_GetVersion (HWND hwnd
)
3250 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3251 return infoPtr
->iVersion
;
3256 TOOLBAR_HideButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3258 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3259 TBUTTON_INFO
*btnPtr
;
3264 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3268 btnPtr
= &infoPtr
->buttons
[nIndex
];
3269 if (LOWORD(lParam
) == FALSE
)
3270 btnPtr
->fsState
&= ~TBSTATE_HIDDEN
;
3272 btnPtr
->fsState
|= TBSTATE_HIDDEN
;
3274 TOOLBAR_CalcToolbar (hwnd
);
3276 InvalidateRect (hwnd
, NULL
, TRUE
);
3282 inline static LRESULT
3283 TOOLBAR_HitTest (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3285 return TOOLBAR_InternalHitTest (hwnd
, (LPPOINT
)lParam
);
3290 TOOLBAR_Indeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3292 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3293 TBUTTON_INFO
*btnPtr
;
3296 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3300 btnPtr
= &infoPtr
->buttons
[nIndex
];
3301 if (LOWORD(lParam
) == FALSE
)
3302 btnPtr
->fsState
&= ~TBSTATE_INDETERMINATE
;
3304 btnPtr
->fsState
|= TBSTATE_INDETERMINATE
;
3306 InvalidateRect(hwnd
, &btnPtr
->rect
, TOOLBAR_HasText(infoPtr
, btnPtr
));
3313 TOOLBAR_InsertButtonA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3315 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3316 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3317 INT nIndex
= (INT
)wParam
;
3318 TBUTTON_INFO
*oldButtons
;
3323 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3326 /* EPP: this seems to be an undocumented call (from my IE4)
3327 * I assume in that case that:
3328 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3329 * - index of insertion is at the end of existing buttons
3330 * I only see this happen with nIndex == -1, but it could have a special
3331 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3333 nIndex
= infoPtr
->nNumButtons
;
3335 } else if (nIndex
< 0)
3338 /* If the string passed is not an index, assume address of string
3339 and do our own AddString */
3340 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3344 TRACE("string %s passed instead of index, adding string\n",
3345 debugstr_a((LPSTR
)lpTbb
->iString
));
3346 len
= strlen((LPSTR
)lpTbb
->iString
) + 2;
3347 ptr
= COMCTL32_Alloc(len
);
3348 strcpy(ptr
, (LPSTR
)lpTbb
->iString
);
3349 ptr
[len
- 1] = 0; /* ended by two '\0' */
3350 lpTbb
->iString
= TOOLBAR_AddStringA(hwnd
, 0, (LPARAM
)ptr
);
3354 TRACE("inserting button index=%d\n", nIndex
);
3355 if (nIndex
> infoPtr
->nNumButtons
) {
3356 nIndex
= infoPtr
->nNumButtons
;
3357 TRACE("adjust index=%d\n", nIndex
);
3360 oldButtons
= infoPtr
->buttons
;
3361 infoPtr
->nNumButtons
++;
3362 infoPtr
->buttons
= COMCTL32_Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3363 /* pre insert copy */
3365 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3366 nIndex
* sizeof(TBUTTON_INFO
));
3369 /* insert new button */
3370 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3371 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3372 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3373 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3374 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3375 /* if passed string and not index, then add string */
3376 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3377 Str_SetPtrAtoW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPCSTR
)lpTbb
->iString
);
3380 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3382 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& TBSTYLE_SEP
)) {
3385 ZeroMemory (&ti
, sizeof(TTTOOLINFOA
));
3386 ti
.cbSize
= sizeof (TTTOOLINFOA
);
3388 ti
.uId
= lpTbb
->idCommand
;
3390 ti
.lpszText
= LPSTR_TEXTCALLBACKA
;
3392 SendMessageA (infoPtr
->hwndToolTip
, TTM_ADDTOOLA
,
3396 /* post insert copy */
3397 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3398 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3399 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3402 COMCTL32_Free (oldButtons
);
3404 TOOLBAR_CalcToolbar (hwnd
);
3406 InvalidateRect (hwnd
, NULL
, TRUE
);
3413 TOOLBAR_InsertButtonW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3415 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3416 LPTBBUTTON lpTbb
= (LPTBBUTTON
)lParam
;
3417 INT nIndex
= (INT
)wParam
;
3418 TBUTTON_INFO
*oldButtons
;
3423 TOOLBAR_DumpButton(infoPtr
, (TBUTTON_INFO
*)lpTbb
, nIndex
, FALSE
);
3426 /* EPP: this seems to be an undocumented call (from my IE4)
3427 * I assume in that case that:
3428 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3429 * - index of insertion is at the end of existing buttons
3430 * I only see this happen with nIndex == -1, but it could have a special
3431 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3433 nIndex
= infoPtr
->nNumButtons
;
3435 } else if (nIndex
< 0)
3438 /* If the string passed is not an index, assume address of string
3439 and do our own AddString */
3440 if ((HIWORD(lpTbb
->iString
) != 0) && (lpTbb
->iString
!= -1)) {
3444 TRACE("string %s passed instead of index, adding string\n",
3445 debugstr_w((LPWSTR
)lpTbb
->iString
));
3446 len
= strlenW((LPWSTR
)lpTbb
->iString
) + 2;
3447 ptr
= COMCTL32_Alloc(len
*sizeof(WCHAR
));
3448 strcpyW(ptr
, (LPWSTR
)lpTbb
->iString
);
3449 ptr
[len
- 1] = 0; /* ended by two '\0' */
3450 lpTbb
->iString
= TOOLBAR_AddStringW(hwnd
, 0, (LPARAM
)ptr
);
3454 TRACE("inserting button index=%d\n", nIndex
);
3455 if (nIndex
> infoPtr
->nNumButtons
) {
3456 nIndex
= infoPtr
->nNumButtons
;
3457 TRACE("adjust index=%d\n", nIndex
);
3460 oldButtons
= infoPtr
->buttons
;
3461 infoPtr
->nNumButtons
++;
3462 infoPtr
->buttons
= COMCTL32_Alloc (sizeof (TBUTTON_INFO
) * infoPtr
->nNumButtons
);
3463 /* pre insert copy */
3465 memcpy (&infoPtr
->buttons
[0], &oldButtons
[0],
3466 nIndex
* sizeof(TBUTTON_INFO
));
3469 /* insert new button */
3470 infoPtr
->buttons
[nIndex
].iBitmap
= lpTbb
->iBitmap
;
3471 infoPtr
->buttons
[nIndex
].idCommand
= lpTbb
->idCommand
;
3472 infoPtr
->buttons
[nIndex
].fsState
= lpTbb
->fsState
;
3473 infoPtr
->buttons
[nIndex
].fsStyle
= lpTbb
->fsStyle
;
3474 infoPtr
->buttons
[nIndex
].dwData
= lpTbb
->dwData
;
3475 /* if passed string and not index, then add string */
3476 if(HIWORD(lpTbb
->iString
) && lpTbb
->iString
!=-1) {
3477 Str_SetPtrW ((LPWSTR
*)&infoPtr
->buttons
[nIndex
].iString
, (LPWSTR
)lpTbb
->iString
);
3480 infoPtr
->buttons
[nIndex
].iString
= lpTbb
->iString
;
3482 if ((infoPtr
->hwndToolTip
) && !(lpTbb
->fsStyle
& TBSTYLE_SEP
)) {
3485 ZeroMemory (&ti
, sizeof(TTTOOLINFOW
));
3486 ti
.cbSize
= sizeof (TTTOOLINFOW
);
3488 ti
.uId
= lpTbb
->idCommand
;
3490 ti
.lpszText
= LPSTR_TEXTCALLBACKW
;
3492 SendMessageW (infoPtr
->hwndToolTip
, TTM_ADDTOOLW
,
3496 /* post insert copy */
3497 if (nIndex
< infoPtr
->nNumButtons
- 1) {
3498 memcpy (&infoPtr
->buttons
[nIndex
+1], &oldButtons
[nIndex
],
3499 (infoPtr
->nNumButtons
- nIndex
- 1) * sizeof(TBUTTON_INFO
));
3502 COMCTL32_Free (oldButtons
);
3504 TOOLBAR_CalcToolbar (hwnd
);
3506 InvalidateRect (hwnd
, NULL
, TRUE
);
3512 /* << TOOLBAR_InsertMarkHitTest >> */
3516 TOOLBAR_IsButtonChecked (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3518 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3521 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3525 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_CHECKED
);
3530 TOOLBAR_IsButtonEnabled (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3532 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3535 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3539 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_ENABLED
);
3544 TOOLBAR_IsButtonHidden (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3546 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3549 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3553 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_HIDDEN
);
3558 TOOLBAR_IsButtonHighlighted (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3560 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3563 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3567 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_MARKED
);
3572 TOOLBAR_IsButtonIndeterminate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3574 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3577 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3581 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_INDETERMINATE
);
3586 TOOLBAR_IsButtonPressed (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3588 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3591 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3595 return (infoPtr
->buttons
[nIndex
].fsState
& TBSTATE_PRESSED
);
3599 /* << TOOLBAR_LoadImages >> */
3600 /* << TOOLBAR_MapAccelerator >> */
3601 /* << TOOLBAR_MarkButton >> */
3602 /* << TOOLBAR_MoveButton >> */
3606 TOOLBAR_PressButton (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3608 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3609 TBUTTON_INFO
*btnPtr
;
3612 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
3616 btnPtr
= &infoPtr
->buttons
[nIndex
];
3617 if (LOWORD(lParam
) == FALSE
)
3618 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
3620 btnPtr
->fsState
|= TBSTATE_PRESSED
;
3622 InvalidateRect(hwnd
, &btnPtr
->rect
, TOOLBAR_HasText(infoPtr
, btnPtr
));
3628 /* << TOOLBAR_ReplaceBitmap >> */
3632 TOOLBAR_SaveRestoreA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3635 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3636 LPTBSAVEPARAMSA lpSave
= (LPTBSAVEPARAMSA
)lParam
;
3638 if (lpSave
== NULL
) return 0;
3641 /* save toolbar information */
3642 FIXME("save to \"%s\" \"%s\"\n",
3643 lpSave
->pszSubKey
, lpSave
->pszValueName
);
3648 /* restore toolbar information */
3650 FIXME("restore from \"%s\" \"%s\"\n",
3651 lpSave
->pszSubKey
, lpSave
->pszValueName
);
3662 TOOLBAR_SaveRestoreW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3665 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3666 LPTBSAVEPARAMSW lpSave
= (LPTBSAVEPARAMSW
)lParam
;
3672 /* save toolbar information */
3673 FIXME("save to \"%s\" \"%s\"\n",
3674 lpSave
->pszSubKey
, lpSave
->pszValueName
);
3679 /* restore toolbar information */
3681 FIXME("restore from \"%s\" \"%s\"\n",
3682 lpSave
->pszSubKey
, lpSave
->pszValueName
);
3693 TOOLBAR_SetAnchorHighlight (HWND hwnd
, WPARAM wParam
)
3695 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3696 BOOL bOldAnchor
= infoPtr
->bAnchor
;
3698 infoPtr
->bAnchor
= (BOOL
)wParam
;
3700 return (LRESULT
)bOldAnchor
;
3705 TOOLBAR_SetBitmapSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3707 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3709 if ((LOWORD(lParam
) <= 0) || (HIWORD(lParam
)<=0))
3712 if (infoPtr
->nNumButtons
> 0)
3713 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
3714 infoPtr
->nNumButtons
,
3715 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
,
3716 LOWORD(lParam
), HIWORD(lParam
));
3718 infoPtr
->nBitmapWidth
= (INT
)LOWORD(lParam
);
3719 infoPtr
->nBitmapHeight
= (INT
)HIWORD(lParam
);
3721 /* uses image list internals directly */
3722 if (infoPtr
->himlDef
) {
3723 infoPtr
->himlDef
->cx
= infoPtr
->nBitmapWidth
;
3724 infoPtr
->himlDef
->cy
= infoPtr
->nBitmapHeight
;
3732 TOOLBAR_SetButtonInfoA (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3734 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3735 LPTBBUTTONINFOA lptbbi
= (LPTBBUTTONINFOA
)lParam
;
3736 TBUTTON_INFO
*btnPtr
;
3741 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOA
))
3744 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3745 lptbbi
->dwMask
& 0x80000000);
3749 btnPtr
= &infoPtr
->buttons
[nIndex
];
3750 if (lptbbi
->dwMask
& TBIF_COMMAND
)
3751 btnPtr
->idCommand
= lptbbi
->idCommand
;
3752 if (lptbbi
->dwMask
& TBIF_IMAGE
)
3753 btnPtr
->iBitmap
= lptbbi
->iImage
;
3754 if (lptbbi
->dwMask
& TBIF_LPARAM
)
3755 btnPtr
->dwData
= lptbbi
->lParam
;
3756 /* if (lptbbi->dwMask & TBIF_SIZE) */
3757 /* btnPtr->cx = lptbbi->cx; */
3758 if (lptbbi
->dwMask
& TBIF_STATE
)
3759 btnPtr
->fsState
= lptbbi
->fsState
;
3760 if (lptbbi
->dwMask
& TBIF_STYLE
)
3761 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
3763 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
3764 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
3765 /* iString is index, zero it to make Str_SetPtr succeed */
3768 Str_SetPtrAtoW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
3775 TOOLBAR_SetButtonInfoW (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3777 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3778 LPTBBUTTONINFOW lptbbi
= (LPTBBUTTONINFOW
)lParam
;
3779 TBUTTON_INFO
*btnPtr
;
3784 if (lptbbi
->cbSize
< sizeof(TBBUTTONINFOW
))
3787 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
,
3788 lptbbi
->dwMask
& 0x80000000);
3792 btnPtr
= &infoPtr
->buttons
[nIndex
];
3793 if (lptbbi
->dwMask
& TBIF_COMMAND
)
3794 btnPtr
->idCommand
= lptbbi
->idCommand
;
3795 if (lptbbi
->dwMask
& TBIF_IMAGE
)
3796 btnPtr
->iBitmap
= lptbbi
->iImage
;
3797 if (lptbbi
->dwMask
& TBIF_LPARAM
)
3798 btnPtr
->dwData
= lptbbi
->lParam
;
3799 /* if (lptbbi->dwMask & TBIF_SIZE) */
3800 /* btnPtr->cx = lptbbi->cx; */
3801 if (lptbbi
->dwMask
& TBIF_STATE
)
3802 btnPtr
->fsState
= lptbbi
->fsState
;
3803 if (lptbbi
->dwMask
& TBIF_STYLE
)
3804 btnPtr
->fsStyle
= lptbbi
->fsStyle
;
3806 if ((lptbbi
->dwMask
& TBIF_TEXT
) && ((INT
)lptbbi
->pszText
!= -1)) {
3807 if ((HIWORD(btnPtr
->iString
) == 0) || (btnPtr
->iString
== -1))
3808 /* iString is index, zero it to make Str_SetPtr succeed */
3810 Str_SetPtrW ((LPWSTR
*)&btnPtr
->iString
, lptbbi
->pszText
);
3817 TOOLBAR_SetButtonSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3819 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3820 INT cx
= LOWORD(lParam
), cy
= HIWORD(lParam
);
3822 if ((cx
< 0) || (cy
< 0))
3824 ERR("invalid parameter 0x%08lx\n", (DWORD
)lParam
);
3828 /* The documentation claims you can only change the button size before
3829 * any button has been added. But this is wrong.
3830 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
3831 * it to the toolbar, and it checks that the return value is nonzero - mjm
3832 * Further testing shows that we must actually perform the change too.
3835 * The documentation also does not mention that if 0 is supplied for
3836 * either size, the system changes it to the default of 24 wide and
3837 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
3839 infoPtr
->nButtonWidth
= (cx
) ? cx
: 24;
3840 infoPtr
->nButtonHeight
= (cy
) ? cy
: 22;
3846 TOOLBAR_SetButtonWidth (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3848 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3850 if (infoPtr
== NULL
) {
3851 TRACE("Toolbar not initialized yet?????\n");
3855 /* if setting to current values, ignore */
3856 if ((infoPtr
->cxMin
== (INT
)LOWORD(lParam
)) &&
3857 (infoPtr
->cxMax
== (INT
)HIWORD(lParam
))) {
3858 TRACE("matches current width, min=%d, max=%d, no recalc\n",
3859 infoPtr
->cxMin
, infoPtr
->cxMax
);
3863 /* save new values */
3864 infoPtr
->cxMin
= (INT
)LOWORD(lParam
);
3865 infoPtr
->cxMax
= (INT
)HIWORD(lParam
);
3867 /* if both values are 0 then we are done */
3869 TRACE("setting both min and max to 0, norecalc\n");
3873 /* otherwise we need to recalc the toolbar and in some cases
3874 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
3875 which doesn't actually draw - GA). */
3876 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
3877 infoPtr
->nNumButtons
, infoPtr
->cxMin
, infoPtr
->cxMax
);
3879 TOOLBAR_CalcToolbar (hwnd
);
3881 InvalidateRect (hwnd
, NULL
, TRUE
);
3888 TOOLBAR_SetCmdId (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3890 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3891 INT nIndex
= (INT
)wParam
;
3893 if ((nIndex
< 0) || (nIndex
>= infoPtr
->nNumButtons
))
3896 infoPtr
->buttons
[nIndex
].idCommand
= (INT
)lParam
;
3898 if (infoPtr
->hwndToolTip
) {
3900 FIXME("change tool tip!\n");
3909 TOOLBAR_SetDisabledImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3911 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3912 HIMAGELIST himlTemp
;
3916 FIXME("no support for multiple image lists\n");
3920 himlTemp
= infoPtr
->himlDis
;
3921 infoPtr
->himlDis
= (HIMAGELIST
)lParam
;
3923 /* FIXME: redraw ? */
3925 return (LRESULT
)himlTemp
;
3930 TOOLBAR_SetDrawTextFlags (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3932 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3935 dwTemp
= infoPtr
->dwDTFlags
;
3936 infoPtr
->dwDTFlags
=
3937 (infoPtr
->dwDTFlags
& (DWORD
)wParam
) | (DWORD
)lParam
;
3939 return (LRESULT
)dwTemp
;
3943 TOOLBAR_SetExtendedStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3945 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
3948 dwTemp
= infoPtr
->dwExStyle
;
3949 infoPtr
->dwExStyle
= (DWORD
)lParam
;
3951 if (infoPtr
->dwExStyle
& (TBSTYLE_EX_MIXEDBUTTONS
|
3952 TBSTYLE_EX_HIDECLIPPEDBUTTONS
)) {
3953 FIXME("Extended style not implemented %s %s\n",
3954 (infoPtr
->dwExStyle
& TBSTYLE_EX_MIXEDBUTTONS
) ?
3955 "TBSTYLE_EX_MIXEDBUTTONS" : "",
3956 (infoPtr
->dwExStyle
& TBSTYLE_EX_HIDECLIPPEDBUTTONS
) ?
3957 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
3960 if (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
)
3961 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
3962 (infoPtr
->dwExStyle
& ~TBSTYLE_EX_ALL
));
3964 return (LRESULT
)dwTemp
;
3969 TOOLBAR_SetHotImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
3971 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
3972 HIMAGELIST himlTemp
;
3975 FIXME("no support for multiple image lists\n");
3979 himlTemp
= infoPtr
->himlHot
;
3980 infoPtr
->himlHot
= (HIMAGELIST
)lParam
;
3982 /* FIXME: redraw ? */
3984 return (LRESULT
)himlTemp
;
3989 TOOLBAR_SetHotItem (HWND hwnd
, WPARAM wParam
)
3991 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
3992 INT nOldHotItem
= infoPtr
->nHotItem
;
3993 TBUTTON_INFO
*btnPtr
;
3995 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
3998 if (GetWindowLongA (hwnd
, GWL_STYLE
) & TBSTYLE_FLAT
)
4001 infoPtr
->nHotItem
= (INT
)wParam
;
4002 if ((INT
)wParam
>=0)
4004 btnPtr
= &infoPtr
->buttons
[(INT
)wParam
];
4005 btnPtr
->bHot
= TRUE
;
4006 InvalidateRect (hwnd
, &btnPtr
->rect
,
4007 TOOLBAR_HasText(infoPtr
, btnPtr
));
4011 btnPtr
= &infoPtr
->buttons
[nOldHotItem
];
4012 btnPtr
->bHot
= FALSE
;
4013 InvalidateRect (hwnd
, &btnPtr
->rect
,
4014 TOOLBAR_HasText(infoPtr
, btnPtr
));
4018 if (nOldHotItem
< 0)
4021 return (LRESULT
)nOldHotItem
;
4026 TOOLBAR_SetImageList (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4028 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4029 HIMAGELIST himlTemp
;
4032 FIXME("no support for multiple image lists\n");
4036 himlTemp
= infoPtr
->himlDef
;
4037 infoPtr
->himlDef
= (HIMAGELIST
)lParam
;
4039 infoPtr
->nNumBitmaps
= ImageList_GetImageCount(infoPtr
->himlDef
);
4041 ImageList_GetIconSize(infoPtr
->himlDef
, &infoPtr
->nBitmapWidth
,
4042 &infoPtr
->nBitmapHeight
);
4043 TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4044 hwnd
, (INT
)infoPtr
->himlDef
, infoPtr
->nNumBitmaps
,
4045 infoPtr
->nBitmapWidth
, infoPtr
->nBitmapHeight
);
4047 /* FIXME: redraw ? */
4048 InvalidateRect(hwnd
, NULL
, TRUE
);
4050 return (LRESULT
)himlTemp
;
4055 TOOLBAR_SetIndent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4057 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4059 infoPtr
->nIndent
= (INT
)wParam
;
4063 /* process only on indent changing */
4064 if(infoPtr
->nIndent
!= (INT
)wParam
)
4066 infoPtr
->nIndent
= (INT
)wParam
;
4067 TOOLBAR_CalcToolbar (hwnd
);
4068 InvalidateRect(hwnd
, NULL
, FALSE
);
4075 /* << TOOLBAR_SetInsertMark >> */
4079 TOOLBAR_SetInsertMarkColor (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4081 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4083 infoPtr
->clrInsertMark
= (COLORREF
)lParam
;
4085 /* FIXME : redraw ??*/
4092 TOOLBAR_SetMaxTextRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4094 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4096 if (infoPtr
== NULL
)
4099 infoPtr
->nMaxTextRows
= (INT
)wParam
;
4106 TOOLBAR_SetPadding (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4108 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4111 oldPad
= MAKELONG(infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4112 infoPtr
->szPadding
.cx
= LOWORD((DWORD
)lParam
);
4113 infoPtr
->szPadding
.cy
= HIWORD((DWORD
)lParam
);
4114 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
4115 infoPtr
->szPadding
.cx
, infoPtr
->szPadding
.cy
);
4116 return (LRESULT
) oldPad
;
4121 TOOLBAR_SetParent (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4123 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4128 if (infoPtr
== NULL
)
4130 hwndOldNotify
= infoPtr
->hwndNotify
;
4131 infoPtr
->hwndNotify
= (HWND
)wParam
;
4133 return hwndOldNotify
;
4138 TOOLBAR_SetRows (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4140 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4141 LPRECT lprc
= (LPRECT
)lParam
;
4145 if (LOWORD(wParam
) > 1) {
4146 FIXME("multiple rows not supported!\n");
4149 if(infoPtr
->nRows
!= LOWORD(wParam
))
4151 infoPtr
->nRows
= LOWORD(wParam
);
4153 /* recalculate toolbar */
4154 TOOLBAR_CalcToolbar (hwnd
);
4156 /* repaint toolbar */
4157 InvalidateRect(hwnd
, NULL
, FALSE
);
4160 /* return bounding rectangle */
4162 lprc
->left
= infoPtr
->rcBound
.left
;
4163 lprc
->right
= infoPtr
->rcBound
.right
;
4164 lprc
->top
= infoPtr
->rcBound
.top
;
4165 lprc
->bottom
= infoPtr
->rcBound
.bottom
;
4173 TOOLBAR_SetState (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4175 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4176 TBUTTON_INFO
*btnPtr
;
4179 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4183 btnPtr
= &infoPtr
->buttons
[nIndex
];
4185 /* if hidden state has changed the invalidate entire window and recalc */
4186 if ((btnPtr
->fsState
& TBSTATE_HIDDEN
) != (LOWORD(lParam
) & TBSTATE_HIDDEN
)) {
4187 btnPtr
->fsState
= LOWORD(lParam
);
4188 TOOLBAR_CalcToolbar (hwnd
);
4189 InvalidateRect(hwnd
, 0, TOOLBAR_HasText(infoPtr
, btnPtr
));
4193 /* process state changing if current state doesn't match new state */
4194 if(btnPtr
->fsState
!= LOWORD(lParam
))
4196 btnPtr
->fsState
= LOWORD(lParam
);
4197 InvalidateRect(hwnd
, &btnPtr
->rect
, TOOLBAR_HasText(infoPtr
,
4206 TOOLBAR_SetStyle (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4208 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4209 TBUTTON_INFO
*btnPtr
;
4212 nIndex
= TOOLBAR_GetButtonIndex (infoPtr
, (INT
)wParam
, FALSE
);
4216 btnPtr
= &infoPtr
->buttons
[nIndex
];
4218 /* process style change if current style doesn't match new style */
4219 if(btnPtr
->fsStyle
!= LOWORD(lParam
))
4221 btnPtr
->fsStyle
= LOWORD(lParam
);
4222 InvalidateRect(hwnd
, &btnPtr
->rect
, TOOLBAR_HasText(infoPtr
,
4225 if (infoPtr
->hwndToolTip
) {
4226 FIXME("change tool tip!\n");
4234 inline static LRESULT
4235 TOOLBAR_SetToolTips (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4237 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4239 if (infoPtr
== NULL
)
4241 infoPtr
->hwndToolTip
= (HWND
)wParam
;
4247 TOOLBAR_SetUnicodeFormat (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4249 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4252 TRACE("%s hwnd=0x%04x stub!\n",
4253 ((BOOL
)wParam
) ? "TRUE" : "FALSE", hwnd
);
4255 bTemp
= infoPtr
->bUnicode
;
4256 infoPtr
->bUnicode
= (BOOL
)wParam
;
4263 TOOLBAR_GetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4265 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4267 lParam
->clrBtnHighlight
= (infoPtr
->clrBtnHighlight
== CLR_DEFAULT
) ?
4268 comctl32_color
.clrBtnHighlight
:
4269 infoPtr
->clrBtnHighlight
;
4270 lParam
->clrBtnShadow
= (infoPtr
->clrBtnShadow
== CLR_DEFAULT
) ?
4271 comctl32_color
.clrBtnShadow
: infoPtr
->clrBtnShadow
;
4277 TOOLBAR_SetColorScheme (HWND hwnd
, LPCOLORSCHEME lParam
)
4279 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4281 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4282 lParam
->clrBtnHighlight
, lParam
->clrBtnShadow
,
4283 infoPtr
->clrBtnHighlight
, infoPtr
->clrBtnShadow
);
4285 infoPtr
->clrBtnHighlight
= lParam
->clrBtnHighlight
;
4286 infoPtr
->clrBtnShadow
= lParam
->clrBtnShadow
;
4287 InvalidateRect(hwnd
, 0, 0);
4293 TOOLBAR_SetVersion (HWND hwnd
, INT iVersion
)
4295 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4296 INT iOldVersion
= infoPtr
->iVersion
;
4298 infoPtr
->iVersion
= iVersion
;
4304 /*********************************************************************/
4306 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */
4307 /* without the restriction of TBSTYLE_FLAT. This implementation is */
4308 /* based on relay traces of the native control and IE 5.5 */
4310 /*********************************************************************/
4312 TOOLBAR_Unkwn45E (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4314 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
4315 INT nOldHotItem
= infoPtr
->nHotItem
;
4316 TBUTTON_INFO
*btnPtr
;
4318 NMTBHOTITEM nmhotitem
;
4320 if ((INT
) wParam
< 0 || (INT
)wParam
> infoPtr
->nNumButtons
)
4323 infoPtr
->nHotItem
= (INT
)wParam
;
4324 if (nOldHotItem
!= infoPtr
->nHotItem
) {
4325 nmhotitem
.dwFlags
= (DWORD
)lParam
;
4326 if ( !(nmhotitem
.dwFlags
& HICF_ENTERING
) )
4327 nmhotitem
.idOld
= (nOldHotItem
>= 0) ?
4328 infoPtr
->buttons
[nOldHotItem
].idCommand
: 0;
4329 if ( !(nmhotitem
.dwFlags
& HICF_LEAVING
) )
4330 nmhotitem
.idNew
= (infoPtr
->nHotItem
>= 0) ?
4331 infoPtr
->buttons
[infoPtr
->nHotItem
].idCommand
: 0;
4332 no_hi
= TOOLBAR_SendNotify((NMHDR
*)&nmhotitem
, infoPtr
, TBN_HOTITEMCHANGE
);
4334 if ((INT
)wParam
>=0) {
4335 btnPtr
= &infoPtr
->buttons
[(INT
)wParam
];
4336 btnPtr
->bHot
= (no_hi
) ? FALSE
: TRUE
;
4337 InvalidateRect (hwnd
, &btnPtr
->rect
,
4338 TOOLBAR_HasText(infoPtr
, btnPtr
));
4340 if (nOldHotItem
>=0) {
4341 btnPtr
= &infoPtr
->buttons
[nOldHotItem
];
4342 btnPtr
->bHot
= FALSE
;
4343 InvalidateRect (hwnd
, &btnPtr
->rect
,
4344 TOOLBAR_HasText(infoPtr
, btnPtr
));
4347 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
4348 nOldHotItem
, infoPtr
->nHotItem
, (DWORD
)lParam
, no_hi
);
4350 if (nOldHotItem
< 0)
4353 return (LRESULT
)nOldHotItem
;
4358 TOOLBAR_Unkwn463 (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4360 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4361 LPSIZE lpsize
= (LPSIZE
)lParam
;
4367 * Testing shows the following:
4368 * wParam = 0 adjust cx value
4369 * = 1 set cy value to max size.
4370 * lParam pointer to SIZE structure
4373 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4374 wParam
, lParam
, lpsize
->cx
, lpsize
->cy
);
4378 if (lpsize
->cx
== -1) {
4379 /* **** this is wrong, native measures each button and sets it */
4380 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
4382 else if(HIWORD(lpsize
->cx
)) {
4384 HWND hwndParent
= GetParent(hwnd
);
4386 InvalidateRect(hwnd
, 0, 1);
4387 GetWindowRect(hwnd
, &rc
);
4388 MapWindowPoints(0, hwndParent
, (LPPOINT
)&rc
, 2);
4389 TRACE("mapped to (%d,%d)-(%d,%d)\n",
4390 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4391 lpsize
->cx
= max(rc
.right
-rc
.left
,
4392 infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
);
4395 lpsize
->cx
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
4399 lpsize
->cy
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
4400 /* lpsize->cy = infoPtr->nHeight; */
4403 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4407 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4408 lpsize
->cx
, lpsize
->cy
);
4414 TOOLBAR_Create (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4416 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4417 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
4420 /* initialize info structure */
4421 infoPtr
->nButtonHeight
= 22;
4422 infoPtr
->nButtonWidth
= 24;
4423 infoPtr
->nBitmapHeight
= 15;
4424 infoPtr
->nBitmapWidth
= 16;
4426 infoPtr
->nHeight
= infoPtr
->nButtonHeight
+ TOP_BORDER
+ BOTTOM_BORDER
;
4428 infoPtr
->nMaxTextRows
= 1;
4429 infoPtr
->cxMin
= -1;
4430 infoPtr
->cxMax
= -1;
4431 infoPtr
->nNumBitmaps
= 0;
4432 infoPtr
->nNumStrings
= 0;
4434 infoPtr
->bCaptured
= FALSE
;
4435 infoPtr
->bUnicode
= IsWindowUnicode (hwnd
);
4436 infoPtr
->nButtonDown
= -1;
4437 infoPtr
->nOldHit
= -1;
4438 infoPtr
->nHotItem
= -2; /* It has to be initially different from nOldHit */
4439 infoPtr
->hwndNotify
= GetParent (hwnd
);
4440 infoPtr
->bTransparent
= (dwStyle
& TBSTYLE_TRANSPARENT
);
4441 infoPtr
->bBtnTranspnt
= (dwStyle
& (TBSTYLE_FLAT
| TBSTYLE_LIST
));
4442 infoPtr
->dwDTFlags
= (dwStyle
& TBSTYLE_LIST
) ? DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
: DT_CENTER
;
4443 infoPtr
->bAnchor
= FALSE
; /* no anchor highlighting */
4444 infoPtr
->iVersion
= 0;
4445 infoPtr
->hwndSelf
= hwnd
;
4446 infoPtr
->bDoRedraw
= TRUE
;
4447 infoPtr
->clrBtnHighlight
= CLR_DEFAULT
;
4448 infoPtr
->clrBtnShadow
= CLR_DEFAULT
;
4449 infoPtr
->szPadding
.cx
= 7;
4450 infoPtr
->szPadding
.cy
= 6;
4451 TOOLBAR_NotifyFormat(infoPtr
, (WPARAM
)hwnd
, (LPARAM
)NF_REQUERY
);
4453 SystemParametersInfoA (SPI_GETICONTITLELOGFONT
, 0, &logFont
, 0);
4454 infoPtr
->hFont
= infoPtr
->hDefaultFont
= CreateFontIndirectA (&logFont
);
4456 if (dwStyle
& TBSTYLE_TOOLTIPS
) {
4457 /* Create tooltip control */
4458 infoPtr
->hwndToolTip
=
4459 CreateWindowExA (0, TOOLTIPS_CLASSA
, NULL
, 0,
4460 CW_USEDEFAULT
, CW_USEDEFAULT
,
4461 CW_USEDEFAULT
, CW_USEDEFAULT
,
4464 /* Send NM_TOOLTIPSCREATED notification */
4465 if (infoPtr
->hwndToolTip
) {
4466 NMTOOLTIPSCREATED nmttc
;
4468 nmttc
.hwndToolTips
= infoPtr
->hwndToolTip
;
4470 TOOLBAR_SendNotify ((NMHDR
*) &nmttc
, infoPtr
,
4471 NM_TOOLTIPSCREATED
);
4475 TOOLBAR_CheckStyle (hwnd
, dwStyle
);
4477 TOOLBAR_CalcToolbar(hwnd
);
4484 TOOLBAR_Destroy (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4486 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4488 /* delete tooltip control */
4489 if (infoPtr
->hwndToolTip
)
4490 DestroyWindow (infoPtr
->hwndToolTip
);
4492 /* delete button data */
4493 if (infoPtr
->buttons
)
4494 COMCTL32_Free (infoPtr
->buttons
);
4496 /* delete strings */
4497 if (infoPtr
->strings
) {
4499 for (i
= 0; i
< infoPtr
->nNumStrings
; i
++)
4500 if (infoPtr
->strings
[i
])
4501 COMCTL32_Free (infoPtr
->strings
[i
]);
4503 COMCTL32_Free (infoPtr
->strings
);
4506 /* destroy internal image list */
4507 if (infoPtr
->himlInt
)
4508 ImageList_Destroy (infoPtr
->himlInt
);
4510 /* delete default font */
4512 DeleteObject (infoPtr
->hDefaultFont
);
4514 /* free toolbar info data */
4515 COMCTL32_Free (infoPtr
);
4516 SetWindowLongA (hwnd
, 0, 0);
4523 TOOLBAR_EraseBackground (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4525 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4526 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
4527 NMTBCUSTOMDRAW tbcd
;
4531 if (dwStyle
& TBSTYLE_CUSTOMERASE
) {
4532 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
4533 tbcd
.nmcd
.dwDrawStage
= CDDS_PREERASE
;
4534 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
4535 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
4536 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
4538 /* FIXME: in general the return flags *can* be or'ed together */
4539 switch (infoPtr
->dwBaseCustDraw
)
4541 case CDRF_DODEFAULT
:
4543 case CDRF_SKIPDEFAULT
:
4546 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4551 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4552 * to my parent for processing.
4554 if (infoPtr
->bTransparent
) {
4556 HDC hdc
= (HDC
)wParam
;
4561 parent
= GetParent(hwnd
);
4562 MapWindowPoints(hwnd
, parent
, &pt
, 1);
4563 OffsetWindowOrgEx (hdc
, pt
.x
, pt
.y
, &ptorig
);
4564 ret
= SendMessageA (parent
, WM_ERASEBKGND
, wParam
, lParam
);
4565 SetWindowOrgEx (hdc
, ptorig
.x
, ptorig
.y
, 0);
4568 ret
= DefWindowProcA (hwnd
, WM_ERASEBKGND
, wParam
, lParam
);
4570 if ((dwStyle
& TBSTYLE_CUSTOMERASE
) &&
4571 (infoPtr
->dwBaseCustDraw
& CDRF_NOTIFYPOSTERASE
)) {
4572 ZeroMemory (&tbcd
, sizeof(NMTBCUSTOMDRAW
));
4573 tbcd
.nmcd
.dwDrawStage
= CDDS_POSTERASE
;
4574 tbcd
.nmcd
.hdc
= (HDC
)wParam
;
4575 ntfret
= TOOLBAR_SendNotify ((NMHDR
*)&tbcd
, infoPtr
, NM_CUSTOMDRAW
);
4576 infoPtr
->dwBaseCustDraw
= ntfret
& 0xffff;
4577 switch (infoPtr
->dwBaseCustDraw
)
4579 case CDRF_DODEFAULT
:
4581 case CDRF_SKIPDEFAULT
:
4584 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4593 TOOLBAR_GetFont (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4595 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4597 return infoPtr
->hFont
;
4602 TOOLBAR_LButtonDblClk (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4604 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4605 TBUTTON_INFO
*btnPtr
;
4609 pt
.x
= (INT
)LOWORD(lParam
);
4610 pt
.y
= (INT
)HIWORD(lParam
);
4611 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
4614 btnPtr
= &infoPtr
->buttons
[nHit
];
4615 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
))
4618 infoPtr
->bCaptured
= TRUE
;
4619 infoPtr
->nButtonDown
= nHit
;
4621 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4623 InvalidateRect(hwnd
, &btnPtr
->rect
, TOOLBAR_HasText(infoPtr
,
4626 else if (GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_ADJUSTABLE
)
4627 TOOLBAR_Customize (hwnd
);
4634 TOOLBAR_LButtonDown (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4636 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4637 TBUTTON_INFO
*btnPtr
;
4642 if (infoPtr
->hwndToolTip
)
4643 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
4644 WM_LBUTTONDOWN
, wParam
, lParam
);
4646 pt
.x
= (INT
)LOWORD(lParam
);
4647 pt
.y
= (INT
)HIWORD(lParam
);
4648 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
4652 btnPtr
= &infoPtr
->buttons
[nHit
];
4653 if (!(btnPtr
->fsState
& TBSTATE_ENABLED
))
4656 infoPtr
->nOldHit
= nHit
;
4658 CopyRect(&arrowRect
, &btnPtr
->rect
);
4659 arrowRect
.left
= max(btnPtr
->rect
.left
, btnPtr
->rect
.right
- DDARROW_WIDTH
);
4661 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4662 if ((btnPtr
->fsStyle
& TBSTYLE_DROPDOWN
) &&
4663 ((TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
) && PtInRect(&arrowRect
, pt
)) ||
4664 (!TOOLBAR_HasDropDownArrows(infoPtr
->dwExStyle
))))
4668 * this time we must force a Redraw, so the btn is
4669 * painted down before CaptureChanged repaints it up
4671 RedrawWindow(hwnd
,&btnPtr
->rect
,0,
4672 RDW_ERASE
|RDW_INVALIDATE
|RDW_UPDATENOW
);
4674 nmtb
.iItem
= btnPtr
->idCommand
;
4675 memset(&nmtb
.tbButton
, 0, sizeof(TBBUTTON
));
4678 memset(&nmtb
.rcButton
, 0, sizeof(RECT
));
4679 res
= TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
4681 if (res
!= TBDDRET_TREATPRESSED
)
4682 /* ??? guess (GA) */
4684 /* otherwise drop through and process as pushed */
4686 /* SetCapture (hwnd); */
4687 infoPtr
->bCaptured
= TRUE
;
4688 infoPtr
->nButtonDown
= nHit
;
4690 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4691 btnPtr
->bHot
= FALSE
;
4693 InvalidateRect(hwnd
, &btnPtr
->rect
,
4694 TOOLBAR_HasText(infoPtr
, btnPtr
));
4698 /* native issues the TBN_BEGINDRAG here */
4699 nmtb
.iItem
= btnPtr
->idCommand
;
4700 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
4701 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
4702 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
4703 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
4704 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
4705 nmtb
.tbButton
.iString
= btnPtr
->iString
;
4706 nmtb
.cchText
= 0; /* !!! not correct */
4707 nmtb
.pszText
= 0; /* !!! not correct */
4708 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
4716 TOOLBAR_LButtonUp (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4718 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4719 TBUTTON_INFO
*btnPtr
;
4723 BOOL bSendMessage
= TRUE
;
4728 if (infoPtr
->hwndToolTip
)
4729 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
4730 WM_LBUTTONUP
, wParam
, lParam
);
4732 pt
.x
= (INT
)LOWORD(lParam
);
4733 pt
.y
= (INT
)HIWORD(lParam
);
4734 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
4736 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
4737 /* if the cursor is still inside of the toolbar */
4738 if((infoPtr
->nHotItem
>= 0) && (nHit
!= -1))
4739 infoPtr
->buttons
[infoPtr
->nHotItem
].bHot
= TRUE
;
4741 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
4742 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4744 if (btnPtr
->fsStyle
& TBSTYLE_CHECK
) {
4745 if (btnPtr
->fsStyle
& TBSTYLE_GROUP
) {
4746 nOldIndex
= TOOLBAR_GetCheckedGroupButtonIndex (infoPtr
,
4748 if (nOldIndex
== nHit
)
4749 bSendMessage
= FALSE
;
4750 if ((nOldIndex
!= nHit
) &&
4752 infoPtr
->buttons
[nOldIndex
].fsState
&= ~TBSTATE_CHECKED
;
4753 btnPtr
->fsState
|= TBSTATE_CHECKED
;
4756 if (btnPtr
->fsState
& TBSTATE_CHECKED
)
4757 btnPtr
->fsState
&= ~TBSTATE_CHECKED
;
4759 btnPtr
->fsState
|= TBSTATE_CHECKED
;
4763 if (nOldIndex
!= -1)
4765 InvalidateRect(hwnd
, &infoPtr
->buttons
[nOldIndex
].rect
,
4766 TOOLBAR_HasText(infoPtr
, &infoPtr
->buttons
[nOldIndex
]));
4770 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
4771 * that resets bCaptured and btn TBSTATE_PRESSED flags,
4772 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
4774 if ((infoPtr
->bCaptured
) && (infoPtr
->nButtonDown
>= 0))
4777 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
4778 TOOLBAR_SendNotify ((NMHDR
*) &hdr
, infoPtr
,
4779 NM_RELEASEDCAPTURE
);
4781 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
4784 nmtb
.iItem
= btnPtr
->idCommand
;
4785 nmtb
.tbButton
.iBitmap
= btnPtr
->iBitmap
;
4786 nmtb
.tbButton
.idCommand
= btnPtr
->idCommand
;
4787 nmtb
.tbButton
.fsState
= btnPtr
->fsState
;
4788 nmtb
.tbButton
.fsStyle
= btnPtr
->fsStyle
;
4789 nmtb
.tbButton
.dwData
= btnPtr
->dwData
;
4790 nmtb
.tbButton
.iString
= btnPtr
->iString
;
4791 nmtb
.cchText
= 0; /* !!! not correct */
4792 nmtb
.pszText
= 0; /* !!! not correct */
4793 TOOLBAR_SendNotify ((NMHDR
*) &nmtb
, infoPtr
,
4796 SendMessageA (infoPtr
->hwndNotify
, WM_COMMAND
,
4797 MAKEWPARAM(infoPtr
->buttons
[nHit
].idCommand
, 0), (LPARAM
)hwnd
);
4799 /* !!! Undocumented - toolbar at 4.71 level and above sends
4800 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
4801 * Only NM_RCLICK is documented.
4803 nmmouse
.dwItemSpec
= btnPtr
->idCommand
;
4804 nmmouse
.dwItemData
= btnPtr
->dwData
;
4805 TOOLBAR_SendNotify ((NMHDR
*) &nmmouse
, infoPtr
,
4811 TOOLBAR_CaptureChanged(HWND hwnd
)
4813 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4814 TBUTTON_INFO
*btnPtr
;
4816 infoPtr
->bCaptured
= FALSE
;
4818 if (infoPtr
->nButtonDown
>= 0)
4820 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
4821 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4823 infoPtr
->nButtonDown
= -1;
4824 infoPtr
->nOldHit
= -1;
4826 InvalidateRect(hwnd
, &btnPtr
->rect
, TOOLBAR_HasText(infoPtr
,
4833 TOOLBAR_MouseLeave (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4835 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4836 TBUTTON_INFO
*hotBtnPtr
, *btnPtr
;
4839 if (infoPtr
->nOldHit
< 0)
4842 hotBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
4844 /* Redraw the button if the last button we were over is the hot button and it
4846 if((infoPtr
->nOldHit
== infoPtr
->nHotItem
) && (hotBtnPtr
->fsState
& TBSTATE_ENABLED
))
4848 hotBtnPtr
->bHot
= FALSE
;
4849 rc1
= hotBtnPtr
->rect
;
4850 InflateRect (&rc1
, 1, 1);
4851 InvalidateRect (hwnd
, &rc1
, TOOLBAR_HasText(infoPtr
,
4855 /* If the last button we were over is depressed then make it not */
4856 /* depressed and redraw it */
4857 if(infoPtr
->nOldHit
== infoPtr
->nButtonDown
)
4859 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
4861 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4863 rc1
= hotBtnPtr
->rect
;
4864 InflateRect (&rc1
, 1, 1);
4865 InvalidateRect (hwnd
, &rc1
, TRUE
);
4868 infoPtr
->nOldHit
= -1; /* reset the old hit index as we've left the toolbar */
4869 infoPtr
->nHotItem
= -2; /* It has to be initially different from nOldHit */
4875 TOOLBAR_MouseMove (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4877 TBUTTON_INFO
*btnPtr
= NULL
, *oldBtnPtr
= NULL
;
4878 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
4881 TRACKMOUSEEVENT trackinfo
;
4882 NMTBHOTITEM nmhotitem
;
4884 /* fill in the TRACKMOUSEEVENT struct */
4885 trackinfo
.cbSize
= sizeof(TRACKMOUSEEVENT
);
4886 trackinfo
.dwFlags
= TME_QUERY
;
4887 trackinfo
.hwndTrack
= hwnd
;
4888 trackinfo
.dwHoverTime
= HOVER_DEFAULT
;
4890 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4891 _TrackMouseEvent(&trackinfo
);
4893 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4894 if(!(trackinfo
.dwFlags
& TME_LEAVE
)) {
4895 trackinfo
.dwFlags
= TME_LEAVE
; /* notify upon leaving */
4897 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4898 /* and can properly deactivate the hot toolbar button */
4899 _TrackMouseEvent(&trackinfo
);
4902 if (infoPtr
->hwndToolTip
)
4903 TOOLBAR_RelayEvent (infoPtr
->hwndToolTip
, hwnd
,
4904 WM_MOUSEMOVE
, wParam
, lParam
);
4906 pt
.x
= (INT
)LOWORD(lParam
);
4907 pt
.y
= (INT
)HIWORD(lParam
);
4909 nHit
= TOOLBAR_InternalHitTest (hwnd
, &pt
);
4911 if (infoPtr
->nOldHit
!= nHit
)
4913 /* Remove the effect of an old hot button if the button was enabled and was
4914 drawn with the hot button effect */
4915 if(infoPtr
->nOldHit
>= 0 && infoPtr
->nOldHit
== infoPtr
->nHotItem
&&
4916 (infoPtr
->buttons
[infoPtr
->nOldHit
].fsState
& TBSTATE_ENABLED
))
4918 oldBtnPtr
= &infoPtr
->buttons
[infoPtr
->nOldHit
];
4919 oldBtnPtr
->bHot
= FALSE
;
4922 /* It's not a separator or in nowhere. It's a hot button. */
4925 btnPtr
= &infoPtr
->buttons
[nHit
];
4927 infoPtr
->nHotItem
= nHit
;
4929 /* only enabled buttons show hot effect */
4930 if(infoPtr
->buttons
[nHit
].fsState
& TBSTATE_ENABLED
)
4932 btnPtr
->bHot
= TRUE
;
4936 nmhotitem
.dwFlags
= HICF_MOUSE
;
4938 nmhotitem
.idOld
= oldBtnPtr
->idCommand
;
4940 nmhotitem
.dwFlags
|= HICF_ENTERING
;
4942 nmhotitem
.idNew
= btnPtr
->idCommand
;
4944 nmhotitem
.dwFlags
|= HICF_LEAVING
;
4945 TOOLBAR_SendNotify((NMHDR
*)&nmhotitem
, infoPtr
, TBN_HOTITEMCHANGE
);
4947 /* now invalidate the old and new buttons so they will be painted */
4949 InvalidateRect (hwnd
, &oldBtnPtr
->rect
,
4950 TOOLBAR_HasText(infoPtr
, oldBtnPtr
));
4951 if (btnPtr
&& (btnPtr
->fsState
& TBSTATE_ENABLED
))
4952 InvalidateRect(hwnd
, &btnPtr
->rect
,
4953 TOOLBAR_HasText(infoPtr
, btnPtr
));
4955 if (infoPtr
->bCaptured
) {
4956 btnPtr
= &infoPtr
->buttons
[infoPtr
->nButtonDown
];
4957 if (infoPtr
->nOldHit
== infoPtr
->nButtonDown
) {
4958 btnPtr
->fsState
&= ~TBSTATE_PRESSED
;
4959 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4961 else if (nHit
== infoPtr
->nButtonDown
) {
4962 btnPtr
->fsState
|= TBSTATE_PRESSED
;
4963 InvalidateRect(hwnd
, &btnPtr
->rect
, TRUE
);
4966 infoPtr
->nOldHit
= nHit
;
4972 inline static LRESULT
4973 TOOLBAR_NCActivate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4975 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
4976 return DefWindowProcA (hwnd
, WM_NCACTIVATE
, wParam
, lParam
);
4978 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
4982 inline static LRESULT
4983 TOOLBAR_NCCalcSize (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4985 if (!(GetWindowLongA (hwnd
, GWL_STYLE
) & CCS_NODIVIDER
))
4986 ((LPRECT
)lParam
)->top
+= GetSystemMetrics(SM_CYEDGE
);
4988 return DefWindowProcA (hwnd
, WM_NCCALCSIZE
, wParam
, lParam
);
4993 TOOLBAR_NCCreate (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
4995 TOOLBAR_INFO
*infoPtr
;
4996 LPCREATESTRUCTA cs
= (LPCREATESTRUCTA
)lParam
;
4999 /* allocate memory for info structure */
5000 infoPtr
= (TOOLBAR_INFO
*)COMCTL32_Alloc (sizeof(TOOLBAR_INFO
));
5001 SetWindowLongA (hwnd
, 0, (DWORD
)infoPtr
);
5004 infoPtr
->dwStructSize
= sizeof(TBBUTTON
);
5006 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5007 if (!GetWindowLongA (hwnd
, GWL_HINSTANCE
)) {
5008 HINSTANCE hInst
= (HINSTANCE
)GetWindowLongA (GetParent (hwnd
), GWL_HINSTANCE
);
5009 SetWindowLongA (hwnd
, GWL_HINSTANCE
, (DWORD
)hInst
);
5012 /* native control does:
5013 * Get a lot of colors and brushes
5015 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5016 * CreateFontIndirectA(adr1)
5017 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5018 * hdc = GetDC(toolbar)
5019 * GetSystemMetrics(0x48)
5020 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5021 * 0, 0, 0, 0, "MARLETT")
5022 * oldfnt = SelectObject(hdc, fnt2)
5023 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5024 * GetTextMetricsA(hdc, adr3)
5025 * SelectObject(hdc, oldfnt)
5026 * DeleteObject(fnt2)
5028 * InvalidateRect(toolbar, 0, 1)
5029 * SetWindowLongA(toolbar, 0, addr)
5030 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5033 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5034 * ie 2 0x4600094c 0x4600094c 0x4600894d
5035 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5036 * rebar 0x50008844 0x40008844 0x50008845
5037 * pager 0x50000844 0x40000844 0x50008845
5038 * IC35mgr 0x5400084e **nochange**
5039 * on entry to _NCCREATE 0x5400084e
5040 * rowlist 0x5400004e **nochange**
5041 * on entry to _NCCREATE 0x5400004e
5045 /* I think the code below is a bug, but it is the way that the native
5046 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5047 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5048 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5049 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5050 * Some how, the only cases of this seem to be MFC programs.
5052 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5053 * does not occur in the WM_STYLECHANGING routine.
5054 * (Guy Albertelli 9/2001)
5057 if ((cs
->style
& TBSTYLE_FLAT
) && !(cs
->style
& TBSTYLE_TRANSPARENT
))
5058 styleadd
|= TBSTYLE_TRANSPARENT
;
5059 if (!(cs
->style
& (CCS_TOP
| CCS_NOMOVEY
))) {
5060 styleadd
|= CCS_TOP
; /* default to top */
5061 SetWindowLongA (hwnd
, GWL_STYLE
, cs
->style
| styleadd
);
5064 return DefWindowProcA (hwnd
, WM_NCCREATE
, wParam
, lParam
);
5069 TOOLBAR_NCPaint (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5071 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
5075 if (dwStyle
& WS_MINIMIZE
)
5076 return 0; /* Nothing to do */
5078 DefWindowProcA (hwnd
, WM_NCPAINT
, wParam
, lParam
);
5080 if (!(hdc
= GetDCEx (hwnd
, 0, DCX_USESTYLE
| DCX_WINDOW
)))
5083 if (!(dwStyle
& CCS_NODIVIDER
))
5085 GetWindowRect (hwnd
, &rcWindow
);
5086 OffsetRect (&rcWindow
, -rcWindow
.left
, -rcWindow
.top
);
5087 if( dwStyle
& WS_BORDER
)
5088 OffsetRect (&rcWindow
, 1, 1);
5089 DrawEdge (hdc
, &rcWindow
, EDGE_ETCHED
, BF_TOP
);
5092 ReleaseDC( hwnd
, hdc
);
5098 inline static LRESULT
5099 TOOLBAR_Notify (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5101 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5102 LPNMHDR lpnmh
= (LPNMHDR
)lParam
;
5104 if (lpnmh
->code
== PGN_CALCSIZE
) {
5105 LPNMPGCALCSIZE lppgc
= (LPNMPGCALCSIZE
)lParam
;
5107 if (lppgc
->dwFlag
== PGF_CALCWIDTH
) {
5108 lppgc
->iWidth
= infoPtr
->rcBound
.right
- infoPtr
->rcBound
.left
;
5109 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5113 lppgc
->iHeight
= infoPtr
->rcBound
.bottom
- infoPtr
->rcBound
.top
;
5114 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5121 TRACE("passing WM_NOTIFY!\n");
5123 if ((infoPtr
->hwndToolTip
) && (lpnmh
->hwndFrom
== infoPtr
->hwndToolTip
)) {
5124 if (infoPtr
->bNtfUnicode
)
5125 return SendMessageW (infoPtr
->hwndNotify
, WM_NOTIFY
,
5128 return SendMessageA (infoPtr
->hwndNotify
, WM_NOTIFY
,
5132 if (lpnmh
->code
== TTN_GETDISPINFOA
) {
5133 LPNMTTDISPINFOA lpdi
= (LPNMTTDISPINFOA
)lParam
;
5135 FIXME("retrieving ASCII string\n");
5138 else if (lpnmh
->code
== TTN_GETDISPINFOW
) {
5139 LPNMTTDISPINFOW lpdi
= (LPNMTTDISPINFOW
)lParam
;
5141 FIXME("retrieving UNICODE string\n");
5152 TOOLBAR_NotifyFormatFake(HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5154 /* remove this routine when Toolbar is improved to pass infoPtr
5155 * around instead of hwnd.
5157 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5158 return TOOLBAR_NotifyFormat(infoPtr
, wParam
, lParam
);
5163 TOOLBAR_NotifyFormat(TOOLBAR_INFO
*infoPtr
, WPARAM wParam
, LPARAM lParam
)
5167 if (lParam
== NF_REQUERY
) {
5168 i
= SendMessageA(GetParent(infoPtr
->hwndSelf
),
5169 WM_NOTIFYFORMAT
, infoPtr
->hwndSelf
, NF_QUERY
);
5170 if ((i
< NFR_ANSI
) || (i
> NFR_UNICODE
)) {
5171 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5175 infoPtr
->bNtfUnicode
= (i
== NFR_UNICODE
) ? 1 : 0;
5178 return (LRESULT
)((infoPtr
->bUnicode
) ? NFR_UNICODE
: NFR_ANSI
);
5183 TOOLBAR_Paint (HWND hwnd
, WPARAM wParam
)
5185 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr(hwnd
);
5189 /* fill ps.rcPaint with a default rect */
5190 memcpy(&(ps
.rcPaint
), &(infoPtr
->rcBound
), sizeof(infoPtr
->rcBound
));
5192 hdc
= wParam
==0 ? BeginPaint(hwnd
, &ps
) : (HDC
)wParam
;
5194 TRACE("psrect=(%d,%d)-(%d,%d)\n",
5195 ps
.rcPaint
.left
, ps
.rcPaint
.top
,
5196 ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
5198 TOOLBAR_Refresh (hwnd
, hdc
, &ps
);
5199 if (!wParam
) EndPaint (hwnd
, &ps
);
5206 TOOLBAR_SetRedraw (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5207 /*****************************************************
5210 * Handles the WM_SETREDRAW message.
5213 * According to testing V4.71 of COMCTL32 returns the
5214 * *previous* status of the redraw flag (either 0 or 1)
5215 * instead of the MSDN documented value of 0 if handled.
5216 * (For laughs see the "consistancy" with same function
5219 *****************************************************/
5221 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5222 BOOL oldredraw
= infoPtr
->bDoRedraw
;
5224 TRACE("set to %s\n",
5225 (wParam
) ? "TRUE" : "FALSE");
5226 infoPtr
->bDoRedraw
= (BOOL
) wParam
;
5228 InvalidateRect (infoPtr
->hwndSelf
, 0, TRUE
);
5230 return (oldredraw
) ? 1 : 0;
5235 TOOLBAR_Size (HWND hwnd
, WPARAM wParam
, LPARAM lParam
)
5237 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5238 DWORD dwStyle
= GetWindowLongA (hwnd
, GWL_STYLE
);
5247 /* Resize deadlock check */
5248 if (infoPtr
->bAutoSize
) {
5249 infoPtr
->bAutoSize
= FALSE
;
5253 /* FIXME: optimize to only update size if the new size doesn't */
5254 /* match the current size */
5256 flags
= (INT
) wParam
;
5258 /* FIXME for flags =
5259 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5262 TRACE("sizing toolbar!\n");
5264 if (flags
== SIZE_RESTORED
) {
5265 /* width and height don't apply */
5266 parent
= GetParent (hwnd
);
5267 GetClientRect(parent
, &parent_rect
);
5268 x
= parent_rect
.left
;
5269 y
= parent_rect
.top
;
5271 if (dwStyle
& CCS_NORESIZE
) {
5272 uPosFlags
|= (SWP_NOSIZE
| SWP_NOMOVE
);
5275 * this sets the working width of the toolbar, and
5276 * Calc Toolbar will not adjust it, only the height
5278 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
5279 cy
= infoPtr
->nHeight
;
5280 cx
= infoPtr
->nWidth
;
5281 TOOLBAR_CalcToolbar (hwnd
);
5282 infoPtr
->nWidth
= cx
;
5283 infoPtr
->nHeight
= cy
;
5286 infoPtr
->nWidth
= parent_rect
.right
- parent_rect
.left
;
5287 TOOLBAR_CalcToolbar (hwnd
);
5288 cy
= infoPtr
->nHeight
;
5289 cx
= infoPtr
->nWidth
;
5291 if (dwStyle
& CCS_NOMOVEY
) {
5292 GetWindowRect(hwnd
, &window_rect
);
5293 ScreenToClient(parent
, (LPPOINT
)&window_rect
.left
);
5294 y
= window_rect
.top
;
5298 if (dwStyle
& CCS_NOPARENTALIGN
) {
5299 uPosFlags
|= SWP_NOMOVE
;
5300 cy
= infoPtr
->nHeight
;
5301 cx
= infoPtr
->nWidth
;
5304 if (!(dwStyle
& CCS_NODIVIDER
))
5305 cy
+= GetSystemMetrics(SM_CYEDGE
);
5307 if (dwStyle
& WS_BORDER
)
5310 cy
+= GetSystemMetrics(SM_CYEDGE
);
5311 cx
+= GetSystemMetrics(SM_CYEDGE
);
5314 SetWindowPos (hwnd
, 0, parent_rect
.left
- x
, parent_rect
.top
- y
,
5315 cx
, cy
, uPosFlags
| SWP_NOZORDER
);
5322 TOOLBAR_StyleChanged (HWND hwnd
, INT nType
, LPSTYLESTRUCT lpStyle
)
5324 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5326 if (nType
== GWL_STYLE
) {
5327 if (lpStyle
->styleNew
& TBSTYLE_LIST
) {
5328 infoPtr
->dwDTFlags
= DT_LEFT
| DT_VCENTER
| DT_SINGLELINE
;
5331 infoPtr
->dwDTFlags
= DT_CENTER
;
5333 infoPtr
->bTransparent
= (lpStyle
->styleNew
& TBSTYLE_TRANSPARENT
);
5334 infoPtr
->bBtnTranspnt
= (lpStyle
->styleNew
&
5335 (TBSTYLE_FLAT
| TBSTYLE_LIST
));
5336 TOOLBAR_CheckStyle (hwnd
, lpStyle
->styleNew
);
5339 TOOLBAR_AutoSize (hwnd
);
5341 InvalidateRect(hwnd
, NULL
, FALSE
);
5348 TOOLBAR_SysColorChange (HWND hwnd
)
5350 COMCTL32_RefreshSysColors();
5357 static LRESULT WINAPI
5358 ToolbarWindowProc (HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
5360 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
5361 hwnd
, uMsg
, /* SPY_GetMsgName(uMsg), */ wParam
, lParam
);
5363 if (!TOOLBAR_GetInfoPtr(hwnd
) && (uMsg
!= WM_NCCREATE
))
5364 return DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
5369 return TOOLBAR_AddBitmap (hwnd
, wParam
, lParam
);
5371 case TB_ADDBUTTONSA
:
5372 return TOOLBAR_AddButtonsA (hwnd
, wParam
, lParam
);
5374 case TB_ADDBUTTONSW
:
5375 return TOOLBAR_AddButtonsW (hwnd
, wParam
, lParam
);
5378 return TOOLBAR_AddStringA (hwnd
, wParam
, lParam
);
5381 return TOOLBAR_AddStringW (hwnd
, wParam
, lParam
);
5384 return TOOLBAR_AutoSize (hwnd
);
5386 case TB_BUTTONCOUNT
:
5387 return TOOLBAR_ButtonCount (hwnd
, wParam
, lParam
);
5389 case TB_BUTTONSTRUCTSIZE
:
5390 return TOOLBAR_ButtonStructSize (hwnd
, wParam
, lParam
);
5392 case TB_CHANGEBITMAP
:
5393 return TOOLBAR_ChangeBitmap (hwnd
, wParam
, lParam
);
5395 case TB_CHECKBUTTON
:
5396 return TOOLBAR_CheckButton (hwnd
, wParam
, lParam
);
5398 case TB_COMMANDTOINDEX
:
5399 return TOOLBAR_CommandToIndex (hwnd
, wParam
, lParam
);
5402 return TOOLBAR_Customize (hwnd
);
5404 case TB_DELETEBUTTON
:
5405 return TOOLBAR_DeleteButton (hwnd
, wParam
, lParam
);
5407 case TB_ENABLEBUTTON
:
5408 return TOOLBAR_EnableButton (hwnd
, wParam
, lParam
);
5410 case TB_GETANCHORHIGHLIGHT
:
5411 return TOOLBAR_GetAnchorHighlight (hwnd
);
5414 return TOOLBAR_GetBitmap (hwnd
, wParam
, lParam
);
5416 case TB_GETBITMAPFLAGS
:
5417 return TOOLBAR_GetBitmapFlags (hwnd
, wParam
, lParam
);
5420 return TOOLBAR_GetButton (hwnd
, wParam
, lParam
);
5422 case TB_GETBUTTONINFOA
:
5423 return TOOLBAR_GetButtonInfoA (hwnd
, wParam
, lParam
);
5425 case TB_GETBUTTONINFOW
:
5426 return TOOLBAR_GetButtonInfoW (hwnd
, wParam
, lParam
);
5428 case TB_GETBUTTONSIZE
:
5429 return TOOLBAR_GetButtonSize (hwnd
);
5431 case TB_GETBUTTONTEXTA
:
5432 return TOOLBAR_GetButtonTextA (hwnd
, wParam
, lParam
);
5434 case TB_GETBUTTONTEXTW
:
5435 return TOOLBAR_GetButtonTextW (hwnd
, wParam
, lParam
);
5437 case TB_GETDISABLEDIMAGELIST
:
5438 return TOOLBAR_GetDisabledImageList (hwnd
, wParam
, lParam
);
5440 case TB_GETEXTENDEDSTYLE
:
5441 return TOOLBAR_GetExtendedStyle (hwnd
);
5443 case TB_GETHOTIMAGELIST
:
5444 return TOOLBAR_GetHotImageList (hwnd
, wParam
, lParam
);
5447 return TOOLBAR_GetHotItem (hwnd
);
5449 case TB_GETIMAGELIST
:
5450 return TOOLBAR_GetImageList (hwnd
, wParam
, lParam
);
5452 /* case TB_GETINSERTMARK: */ /* 4.71 */
5453 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5455 case TB_GETITEMRECT
:
5456 return TOOLBAR_GetItemRect (hwnd
, wParam
, lParam
);
5459 return TOOLBAR_GetMaxSize (hwnd
, wParam
, lParam
);
5461 /* case TB_GETOBJECT: */ /* 4.71 */
5464 return TOOLBAR_GetPadding (hwnd
);
5467 return TOOLBAR_GetRect (hwnd
, wParam
, lParam
);
5470 return TOOLBAR_GetRows (hwnd
, wParam
, lParam
);
5473 return TOOLBAR_GetState (hwnd
, wParam
, lParam
);
5476 return TOOLBAR_GetStyle (hwnd
, wParam
, lParam
);
5478 case TB_GETTEXTROWS
:
5479 return TOOLBAR_GetTextRows (hwnd
, wParam
, lParam
);
5481 case TB_GETTOOLTIPS
:
5482 return TOOLBAR_GetToolTips (hwnd
, wParam
, lParam
);
5484 case TB_GETUNICODEFORMAT
:
5485 return TOOLBAR_GetUnicodeFormat (hwnd
, wParam
, lParam
);
5488 return TOOLBAR_HideButton (hwnd
, wParam
, lParam
);
5491 return TOOLBAR_HitTest (hwnd
, wParam
, lParam
);
5493 case TB_INDETERMINATE
:
5494 return TOOLBAR_Indeterminate (hwnd
, wParam
, lParam
);
5496 case TB_INSERTBUTTONA
:
5497 return TOOLBAR_InsertButtonA (hwnd
, wParam
, lParam
);
5499 case TB_INSERTBUTTONW
:
5500 return TOOLBAR_InsertButtonW (hwnd
, wParam
, lParam
);
5502 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5504 case TB_ISBUTTONCHECKED
:
5505 return TOOLBAR_IsButtonChecked (hwnd
, wParam
, lParam
);
5507 case TB_ISBUTTONENABLED
:
5508 return TOOLBAR_IsButtonEnabled (hwnd
, wParam
, lParam
);
5510 case TB_ISBUTTONHIDDEN
:
5511 return TOOLBAR_IsButtonHidden (hwnd
, wParam
, lParam
);
5513 case TB_ISBUTTONHIGHLIGHTED
:
5514 return TOOLBAR_IsButtonHighlighted (hwnd
, wParam
, lParam
);
5516 case TB_ISBUTTONINDETERMINATE
:
5517 return TOOLBAR_IsButtonIndeterminate (hwnd
, wParam
, lParam
);
5519 case TB_ISBUTTONPRESSED
:
5520 return TOOLBAR_IsButtonPressed (hwnd
, wParam
, lParam
);
5522 case TB_LOADIMAGES
: /* 4.70 */
5523 FIXME("missing standard imagelists\n");
5526 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5527 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5528 /* case TB_MARKBUTTON: */ /* 4.71 */
5529 /* case TB_MOVEBUTTON: */ /* 4.71 */
5531 case TB_PRESSBUTTON
:
5532 return TOOLBAR_PressButton (hwnd
, wParam
, lParam
);
5534 /* case TB_REPLACEBITMAP: */
5536 case TB_SAVERESTOREA
:
5537 return TOOLBAR_SaveRestoreA (hwnd
, wParam
, lParam
);
5539 case TB_SAVERESTOREW
:
5540 return TOOLBAR_SaveRestoreW (hwnd
, wParam
, lParam
);
5542 case TB_SETANCHORHIGHLIGHT
:
5543 return TOOLBAR_SetAnchorHighlight (hwnd
, wParam
);
5545 case TB_SETBITMAPSIZE
:
5546 return TOOLBAR_SetBitmapSize (hwnd
, wParam
, lParam
);
5548 case TB_SETBUTTONINFOA
:
5549 return TOOLBAR_SetButtonInfoA (hwnd
, wParam
, lParam
);
5551 case TB_SETBUTTONINFOW
:
5552 return TOOLBAR_SetButtonInfoW (hwnd
, wParam
, lParam
);
5554 case TB_SETBUTTONSIZE
:
5555 return TOOLBAR_SetButtonSize (hwnd
, wParam
, lParam
);
5557 case TB_SETBUTTONWIDTH
:
5558 return TOOLBAR_SetButtonWidth (hwnd
, wParam
, lParam
);
5561 return TOOLBAR_SetCmdId (hwnd
, wParam
, lParam
);
5563 case TB_SETDISABLEDIMAGELIST
:
5564 return TOOLBAR_SetDisabledImageList (hwnd
, wParam
, lParam
);
5566 case TB_SETDRAWTEXTFLAGS
:
5567 return TOOLBAR_SetDrawTextFlags (hwnd
, wParam
, lParam
);
5569 case TB_SETEXTENDEDSTYLE
:
5570 return TOOLBAR_SetExtendedStyle (hwnd
, wParam
, lParam
);
5572 case TB_SETHOTIMAGELIST
:
5573 return TOOLBAR_SetHotImageList (hwnd
, wParam
, lParam
);
5576 return TOOLBAR_SetHotItem (hwnd
, wParam
);
5578 case TB_SETIMAGELIST
:
5579 return TOOLBAR_SetImageList (hwnd
, wParam
, lParam
);
5582 return TOOLBAR_SetIndent (hwnd
, wParam
, lParam
);
5584 /* case TB_SETINSERTMARK: */ /* 4.71 */
5586 case TB_SETINSERTMARKCOLOR
:
5587 return TOOLBAR_SetInsertMarkColor (hwnd
, wParam
, lParam
);
5589 case TB_SETMAXTEXTROWS
:
5590 return TOOLBAR_SetMaxTextRows (hwnd
, wParam
, lParam
);
5593 return TOOLBAR_SetPadding (hwnd
, wParam
, lParam
);
5596 return TOOLBAR_SetParent (hwnd
, wParam
, lParam
);
5599 return TOOLBAR_SetRows (hwnd
, wParam
, lParam
);
5602 return TOOLBAR_SetState (hwnd
, wParam
, lParam
);
5605 return TOOLBAR_SetStyle (hwnd
, wParam
, lParam
);
5607 case TB_SETTOOLTIPS
:
5608 return TOOLBAR_SetToolTips (hwnd
, wParam
, lParam
);
5610 case TB_SETUNICODEFORMAT
:
5611 return TOOLBAR_SetUnicodeFormat (hwnd
, wParam
, lParam
);
5614 return TOOLBAR_Unkwn45E (hwnd
, wParam
, lParam
);
5617 return TOOLBAR_Unkwn463 (hwnd
, wParam
, lParam
);
5620 /* Common Control Messages */
5622 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
5623 case CCM_GETCOLORSCHEME
:
5624 return TOOLBAR_GetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
5626 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
5627 case CCM_SETCOLORSCHEME
:
5628 return TOOLBAR_SetColorScheme (hwnd
, (LPCOLORSCHEME
)lParam
);
5630 case CCM_GETVERSION
:
5631 return TOOLBAR_GetVersion (hwnd
);
5633 case CCM_SETVERSION
:
5634 return TOOLBAR_SetVersion (hwnd
, (INT
)wParam
);
5640 return TOOLBAR_Create (hwnd
, wParam
, lParam
);
5643 return TOOLBAR_Destroy (hwnd
, wParam
, lParam
);
5646 return TOOLBAR_EraseBackground (hwnd
, wParam
, lParam
);
5649 return TOOLBAR_GetFont (hwnd
, wParam
, lParam
);
5651 /* case WM_KEYDOWN: */
5652 /* case WM_KILLFOCUS: */
5654 case WM_LBUTTONDBLCLK
:
5655 return TOOLBAR_LButtonDblClk (hwnd
, wParam
, lParam
);
5657 case WM_LBUTTONDOWN
:
5658 return TOOLBAR_LButtonDown (hwnd
, wParam
, lParam
);
5661 return TOOLBAR_LButtonUp (hwnd
, wParam
, lParam
);
5664 return TOOLBAR_MouseMove (hwnd
, wParam
, lParam
);
5667 return TOOLBAR_MouseLeave (hwnd
, wParam
, lParam
);
5669 case WM_CAPTURECHANGED
:
5670 return TOOLBAR_CaptureChanged(hwnd
);
5673 return TOOLBAR_NCActivate (hwnd
, wParam
, lParam
);
5676 return TOOLBAR_NCCalcSize (hwnd
, wParam
, lParam
);
5679 return TOOLBAR_NCCreate (hwnd
, wParam
, lParam
);
5682 return TOOLBAR_NCPaint (hwnd
, wParam
, lParam
);
5685 return TOOLBAR_Notify (hwnd
, wParam
, lParam
);
5687 case WM_NOTIFYFORMAT
:
5688 TOOLBAR_NotifyFormatFake (hwnd
, wParam
, lParam
);
5691 return TOOLBAR_Paint (hwnd
, wParam
);
5694 return TOOLBAR_SetRedraw (hwnd
, wParam
, lParam
);
5697 return TOOLBAR_Size (hwnd
, wParam
, lParam
);
5699 case WM_STYLECHANGED
:
5700 return TOOLBAR_StyleChanged (hwnd
, (INT
)wParam
, (LPSTYLESTRUCT
)lParam
);
5702 case WM_SYSCOLORCHANGE
:
5703 return TOOLBAR_SysColorChange (hwnd
);
5705 /* case WM_WININICHANGE: */
5710 case WM_MEASUREITEM
:
5713 TOOLBAR_INFO
*infoPtr
= TOOLBAR_GetInfoPtr (hwnd
);
5715 return SendMessageA (infoPtr
->hwndNotify
, uMsg
, wParam
, lParam
);
5717 return SendMessageA (GetParent (hwnd
), uMsg
, wParam
, lParam
);
5720 /* We see this in Outlook Express 5.x and just does DefWindowProc */
5721 case PGM_FORWARDMOUSE
:
5722 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
5725 if (uMsg
>= WM_USER
)
5726 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
5727 uMsg
, wParam
, lParam
);
5728 return DefWindowProcA (hwnd
, uMsg
, wParam
, lParam
);
5735 TOOLBAR_Register (void)
5739 ZeroMemory (&wndClass
, sizeof(WNDCLASSA
));
5740 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
;
5741 wndClass
.lpfnWndProc
= (WNDPROC
)ToolbarWindowProc
;
5742 wndClass
.cbClsExtra
= 0;
5743 wndClass
.cbWndExtra
= sizeof(TOOLBAR_INFO
*);
5744 wndClass
.hCursor
= LoadCursorA (0, IDC_ARROWA
);
5745 wndClass
.hbrBackground
= (HBRUSH
)(COLOR_3DFACE
+ 1);
5746 wndClass
.lpszClassName
= TOOLBARCLASSNAMEA
;
5748 RegisterClassA (&wndClass
);
5753 TOOLBAR_Unregister (void)
5755 UnregisterClassA (TOOLBARCLASSNAMEA
, (HINSTANCE
)NULL
);