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 ERR("index %d is not valid, max %d\n",
334 btnPtr->iBitmap, infoPtr->nNumBitmaps);
338 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
339 if (index == -1) return FALSE;
340 ERR("TBN_GETDISPINFO returned invalid index %d\n",
344 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
345 index, himl, left, top, draw_flags);
347 ImageList_Draw (himl, index, hdc, left, top, draw_flags);
352 /***********************************************************************
353 * TOOLBAR_TestImageExist
355 * This function is similar to TOOLBAR_DrawImageList, except it does not
356 * draw the image. The I_IMAGECALLBACK functionality is implemented.
359 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
363 if (!himl) return FALSE;
365 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
366 ERR("index %d is not valid, max %d\n",
367 btnPtr->iBitmap, infoPtr->nNumBitmaps);
371 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
372 if (index == -1) return FALSE;
373 ERR("TBN_GETDISPINFO returned invalid index %d\n",
382 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr)
385 COLORREF oldcolor, newcolor;
387 myrect.left = (lpRect->left + lpRect->right) / 2 - 1;
388 myrect.right = myrect.left + 1;
389 myrect.top = lpRect->top + 2;
390 myrect.bottom = lpRect->bottom - 2;
392 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
393 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
394 oldcolor = SetBkColor (hdc, newcolor);
395 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
397 myrect.left = myrect.right;
398 myrect.right = myrect.left + 1;
400 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
401 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
402 SetBkColor (hdc, newcolor);
403 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
405 SetBkColor (hdc, oldcolor);
409 /***********************************************************************
410 * TOOLBAR_DrawDDFlatSeparator
412 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
413 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
414 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
415 * are horizontal as opposed to the vertical separators for not dropdown
418 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
421 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLBAR_INFO *infoPtr)
424 COLORREF oldcolor, newcolor;
426 myrect.left = lpRect->left;
427 myrect.right = lpRect->right;
428 myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
429 myrect.bottom = myrect.top + 1;
431 InflateRect (&myrect, -2, 0);
433 TRACE("rect=(%d,%d)-(%d,%d)\n",
434 myrect.left, myrect.top, myrect.right, myrect.bottom);
436 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
437 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
438 oldcolor = SetBkColor (hdc, newcolor);
439 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
441 myrect.top = myrect.bottom;
442 myrect.bottom = myrect.top + 1;
444 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
445 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
446 SetBkColor (hdc, newcolor);
447 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
449 SetBkColor (hdc, oldcolor);
454 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
457 SelectObject ( hdc, GetSysColorPen (colorRef));
460 MoveToEx (hdc, x, y, NULL);
461 LineTo (hdc, x+5, y++); x++;
462 MoveToEx (hdc, x, y, NULL);
463 LineTo (hdc, x+3, y++); x++;
464 MoveToEx (hdc, x, y, NULL);
465 LineTo (hdc, x+1, y++);
469 * Draw the text string for this button.
470 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
471 * is non-zero, so we can simply check himlDef to see if we have
475 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
476 HDC hdc, INT nState, DWORD dwStyle,
477 RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd)
484 TRACE("string rect=(%d,%d)-(%d,%d)\n",
485 rcText->left, rcText->top, rcText->right, rcText->bottom);
487 hOldFont = SelectObject (hdc, infoPtr->hFont);
488 if (!(nState & TBSTATE_ENABLED)) {
489 clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight);
490 OffsetRect (rcText, 1, 1);
491 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
492 SetTextColor (hdc, comctl32_color.clr3dShadow);
493 OffsetRect (rcText, -1, -1);
495 else if (nState & TBSTATE_INDETERMINATE) {
496 clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
498 else if (btnPtr->bHot && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
499 clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
502 clrOld = SetTextColor (hdc, tbcd->clrText);
505 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
506 SetTextColor (hdc, clrOld);
507 SelectObject (hdc, hOldFont);
513 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
515 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
516 INT cx = lpRect->right - lpRect->left;
517 INT cy = lpRect->bottom - lpRect->top;
518 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
519 SelectObject (hdc, hbr);
524 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
525 HDC hdc, INT x, INT y)
527 /* FIXME: this function is a hack since it uses image list
528 internals directly */
530 HIMAGELIST himl = infoPtr->himlDef;
538 /* create new dc's */
539 hdcImageList = CreateCompatibleDC (0);
540 hdcMask = CreateCompatibleDC (0);
542 /* create new bitmap */
543 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
544 SelectObject (hdcMask, hbmMask);
546 /* copy the mask bitmap */
547 SelectObject (hdcImageList, himl->hbmMask);
548 SetBkColor (hdcImageList, RGB(255, 255, 255));
549 SetTextColor (hdcImageList, RGB(0, 0, 0));
550 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
551 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
553 /* draw the new mask */
554 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
555 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
556 hdcMask, 0, 0, 0xB8074A);
558 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
559 BitBlt (hdc, x, y, himl->cx, himl->cy,
560 hdcMask, 0, 0, 0xB8074A);
562 DeleteObject (hbmMask);
564 DeleteDC (hdcImageList);
569 TOOLBAR_TranslateState(TBUTTON_INFO *btnPtr)
573 retstate |= (btnPtr->fsState & TBSTATE_CHECKED) ? CDIS_CHECKED : 0;
574 retstate |= (btnPtr->fsState & TBSTATE_PRESSED) ? CDIS_SELECTED : 0;
575 retstate |= (btnPtr->fsState & TBSTATE_ENABLED) ? 0 : CDIS_DISABLED;
576 retstate |= (btnPtr->fsState & TBSTATE_MARKED ) ? CDIS_MARKED : 0;
577 retstate |= (btnPtr->bHot ) ? CDIS_HOT : 0;
578 retstate |= (btnPtr->fsState & TBSTATE_INDETERMINATE) ? CDIS_INDETERMINATE : 0;
579 /* FIXME: don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
580 /* don't test TBSTATE_HIDDEN */
586 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
588 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
589 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
590 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
591 (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
592 RECT rc, rcArrow, rcBitmap, rcText, rcFill;
593 LPWSTR lpText = NULL;
598 if (btnPtr->fsState & TBSTATE_HIDDEN)
602 CopyRect (&rcFill, &rc);
603 CopyRect (&rcArrow, &rc);
604 CopyRect(&rcBitmap, &rc);
605 CopyRect(&rcText, &rc);
607 /* get a pointer to the text */
608 lpText = TOOLBAR_GetText(infoPtr, btnPtr);
610 if (hasDropDownArrow)
612 if (dwStyle & TBSTYLE_FLAT)
613 rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
615 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
616 rcArrow.left = rc.right;
619 /* Center the bitmap horizontally and vertically */
620 if (dwStyle & TBSTYLE_LIST)
623 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
626 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
628 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
630 TRACE("iBitmap: %d, start=(%d,%d) w=%d, h=%d\n",
631 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
632 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
633 TRACE ("iString: %x\n", btnPtr->iString);
634 TRACE ("Stringtext: %s\n", debugstr_w(lpText));
639 InflateRect (&rcText, -3, -3);
641 if (infoPtr->himlDef &&
642 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
643 /* The following test looked like this before
644 * I changed it. IE4 "Links" toolbar would not
645 * draw correctly with the original code. - GA 8/01
646 * ((dwStyle & TBSTYLE_LIST) &&
647 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
648 * (btnPtr->iBitmap != I_IMAGENONE))
650 if (dwStyle & TBSTYLE_LIST) {
651 /* LIST style w/ ICON offset is by matching native. */
652 /* Matches IE4 "Links" bar. - GA 8/01 */
653 rcText.left += (infoPtr->nBitmapWidth + 2);
656 rcText.top += infoPtr->nBitmapHeight + 1;
660 if (dwStyle & TBSTYLE_LIST) {
661 /* LIST style w/o ICON offset is by matching native. */
662 /* Matches IE4 "menu" bar. - GA 8/01 */
667 if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
668 OffsetRect (&rcText, 1, 1);
671 /* Initialize fields in all cases, because we use these later */
672 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
673 tbcd.clrText = comctl32_color.clrBtnText;
674 tbcd.clrTextHighlight = comctl32_color.clrHighlightText;
675 tbcd.clrBtnFace = comctl32_color.clrBtnFace;
676 tbcd.clrBtnHighlight = comctl32_color.clrBtnHighlight;
677 tbcd.clrMark = comctl32_color.clrHighlight;
678 tbcd.clrHighlightHotTrack = 0;
679 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
680 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
681 /* MSDN says that this is the text rectangle. */
682 /* But (why always a but) tracing of v5.7 of native shows */
683 /* that this is really a *relative* rectangle based on the */
684 /* the nmcd.rc. Also the left and top are always 0 ignoring*/
685 /* any bitmap that might be present. */
686 tbcd.rcText.left = 0;
688 tbcd.rcText.right = rcText.right - rc.left;
689 tbcd.rcText.bottom = rcText.bottom - rc.top;
691 /* FIXME: what should these be set to ????? */
692 tbcd.hbrMonoDither = 0;
696 /* Issue Item Prepaint notify */
697 infoPtr->dwItemCustDraw = 0;
698 infoPtr->dwItemCDFlag = 0;
699 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYITEMDRAW)
701 tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
704 tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
705 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
706 tbcd.nmcd.lItemlParam = btnPtr->dwData;
707 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
708 infoPtr->dwItemCustDraw = ntfret & 0xffff;
709 infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
710 if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT)
712 /* save the only part of the rect that the user can change */
713 rcText.right = tbcd.rcText.right + rc.left;
714 rcText.bottom = tbcd.rcText.bottom + rc.top;
717 if (!infoPtr->bBtnTranspnt)
718 FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE));
721 if (btnPtr->fsStyle & TBSTYLE_SEP) {
722 /* with the FLAT style, iBitmap is the width and has already */
723 /* been taken into consideration in calculating the width */
724 /* so now we need to draw the vertical separator */
725 /* empirical tests show that iBitmap can/will be non-zero */
726 /* when drawing the vertical bar... */
727 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
728 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
729 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
731 TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
733 else if (btnPtr->fsStyle != TBSTYLE_SEP) {
734 FIXME("Draw some kind of separator: fsStyle=%x\n",
741 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
742 if (!(dwStyle & TBSTYLE_FLAT) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
744 DrawEdge (hdc, &rc, EDGE_RAISED,
745 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
746 if (hasDropDownArrow)
747 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
748 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
751 if (hasDropDownArrow)
753 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
754 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
757 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDis,
758 hdc, rcBitmap.left, rcBitmap.top,
760 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
762 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
766 /* pressed TBSTYLE_BUTTON */
767 if (btnPtr->fsState & TBSTATE_PRESSED) {
768 offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
769 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
771 if (dwStyle & TBSTYLE_FLAT)
773 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
774 if (hasDropDownArrow)
775 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
779 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
780 if (hasDropDownArrow)
781 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
785 if (hasDropDownArrow)
786 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
788 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
789 hdc, rcBitmap.left+offset, rcBitmap.top+offset,
792 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
796 /* checked TBSTYLE_CHECK */
797 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
798 (btnPtr->fsState & TBSTATE_CHECKED)) {
799 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
801 if (dwStyle & TBSTYLE_FLAT)
802 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
803 BF_RECT | BF_ADJUST);
805 DrawEdge (hdc, &rc, EDGE_SUNKEN,
806 BF_RECT | BF_MIDDLE | BF_ADJUST);
809 TOOLBAR_DrawPattern (hdc, &rc);
811 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
812 hdc, rcBitmap.left+1, rcBitmap.top+1,
815 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
820 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
821 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
822 DrawEdge (hdc, &rc, EDGE_RAISED,
823 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
825 TOOLBAR_DrawPattern (hdc, &rc);
826 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
827 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
832 if (dwStyle & TBSTYLE_FLAT)
836 if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )
840 oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack);
841 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
842 if (hasDropDownArrow)
843 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
844 SetBkColor(hdc, oldclr);
848 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
850 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
851 if (hasDropDownArrow)
852 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
857 else /* The following code needs to be removed after
858 * "hot item" support has been implemented for the
859 * case where it is being de-selected.
862 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
863 if (hasDropDownArrow)
864 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
868 if (hasDropDownArrow)
869 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
872 /* if hot, attempt to draw with himlHot, if fails, use himlDef */
873 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
876 rcBitmap.top, ILD_NORMAL))
877 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
878 hdc, rcBitmap.left, rcBitmap.top,
882 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
883 hdc, rcBitmap.left, rcBitmap.top,
888 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
889 DrawEdge (hdc, &rc, EDGE_RAISED,
890 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
892 if (hasDropDownArrow)
894 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
895 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
896 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
897 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
900 TOOLBAR_DrawImageList (infoPtr, btnPtr, infoPtr->himlDef,
901 hdc, rcBitmap.left, rcBitmap.top,
905 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
908 if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT)
910 tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
913 tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
914 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
915 tbcd.nmcd.lItemlParam = btnPtr->dwData;
916 tbcd.rcText = rcText;
917 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
918 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
919 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
926 TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
928 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
929 TBUTTON_INFO *btnPtr;
930 INT i, oldBKmode = 0;
935 /* if imagelist belongs to the app, it can be changed
936 by the app after setting it */
937 if (infoPtr->himlDef != infoPtr->himlInt)
938 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
940 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
942 /* Send initial notify */
943 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
944 tbcd.nmcd.dwDrawStage = CDDS_PREPAINT;
946 tbcd.nmcd.rc = ps->rcPaint;
947 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
948 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
950 if (infoPtr->bBtnTranspnt)
951 oldBKmode = SetBkMode (hdc, TRANSPARENT);
953 /* redraw necessary buttons */
954 btnPtr = infoPtr->buttons;
955 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
957 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
958 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
961 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
962 SetBkMode (hdc, oldBKmode);
964 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTPAINT)
966 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
967 tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT;
969 tbcd.nmcd.rc = ps->rcPaint;
970 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
974 /***********************************************************************
975 * TOOLBAR_MeasureString
977 * This function gets the width and height of a string in pixels. This
978 * is done first by using GetTextExtentPoint to get the basic width
979 * and height. The DrawText is called with DT_CALCRECT to get the exact
980 * width. The reason is because the text may have more than one "&" (or
981 * prefix characters as M$ likes to call them). The prefix character
982 * indicates where the underline goes, except for the string "&&" which
983 * is reduced to a single "&". GetTextExtentPoint does not process these
984 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
987 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
988 HDC hdc, LPSIZE lpSize)
995 if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
997 LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
1000 /* first get size of all the text */
1001 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
1003 /* feed above size into the rectangle for DrawText */
1004 myrect.left = myrect.top = 0;
1005 myrect.right = lpSize->cx;
1006 myrect.bottom = lpSize->cy;
1008 /* Use DrawText to get true size as drawn (less pesky "&") */
1009 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
1010 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
1013 /* feed back to caller */
1014 lpSize->cx = myrect.right;
1015 lpSize->cy = myrect.bottom;
1019 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
1022 /***********************************************************************
1023 * TOOLBAR_CalcStrings
1025 * This function walks through each string and measures it and returns
1026 * the largest height and width to caller.
1029 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
1031 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1032 TBUTTON_INFO *btnPtr;
1042 hOldFont = SelectObject (hdc, infoPtr->hFont);
1044 btnPtr = infoPtr->buttons;
1045 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1046 if(TOOLBAR_HasText(infoPtr, btnPtr))
1048 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1049 if (sz.cx > lpSize->cx)
1051 if (sz.cy > lpSize->cy)
1056 SelectObject (hdc, hOldFont);
1057 ReleaseDC (hwnd, hdc);
1059 TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
1062 /***********************************************************************
1063 * TOOLBAR_WrapToolbar
1065 * This function walks through the buttons and seperators in the
1066 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1067 * wrapping should occur based on the width of the toolbar window.
1068 * It does *not* calculate button placement itself. That task
1069 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1070 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1071 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1073 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1074 * vertical toolbar lists.
1078 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
1080 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1081 TBUTTON_INFO *btnPtr;
1084 BOOL bWrap, bButtonWrap;
1086 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1087 /* no layout is necessary. Applications may use this style */
1088 /* to perform their own layout on the toolbar. */
1089 if( !(dwStyle & TBSTYLE_WRAPABLE) &&
1090 !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) ) return;
1092 btnPtr = infoPtr->buttons;
1093 x = infoPtr->nIndent;
1095 /* this can get the parents width, to know how far we can extend
1096 * this toolbar. We cannot use its height, as there may be multiple
1097 * toolbars in a rebar control
1099 GetClientRect( GetParent(hwnd), &rc );
1100 infoPtr->nWidth = rc.right - rc.left;
1101 bButtonWrap = FALSE;
1103 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1104 infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
1107 for (i = 0; i < infoPtr->nNumButtons; i++ )
1110 btnPtr[i].fsState &= ~TBSTATE_WRAP;
1112 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
1115 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1116 /* it is the actual width of the separator. This is used for */
1117 /* custom controls in toolbars. */
1119 /* TBSTYLE_DROPDOWN separators are treated as buttons for */
1120 /* width. - GA 8/01 */
1121 if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1122 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
1123 cx = (btnPtr[i].iBitmap > 0) ?
1124 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
1126 cx = infoPtr->nButtonWidth;
1128 /* Two or more adjacent separators form a separator group. */
1129 /* The first separator in a group should be wrapped to the */
1130 /* next row if the previous wrapping is on a button. */
1132 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1133 (i + 1 < infoPtr->nNumButtons ) &&
1134 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
1136 TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
1137 btnPtr[i].fsState |= TBSTATE_WRAP;
1138 x = infoPtr->nIndent;
1140 bButtonWrap = FALSE;
1144 /* The layout makes sure the bitmap is visible, but not the button. */
1145 /* Test added to also wrap after a button that starts a row but */
1146 /* is bigger than the area. - GA 8/01 */
1147 if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
1148 > infoPtr->nWidth ) ||
1149 ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
1151 BOOL bFound = FALSE;
1153 /* If the current button is a separator and not hidden, */
1154 /* go to the next until it reaches a non separator. */
1155 /* Wrap the last separator if it is before a button. */
1156 while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1157 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
1158 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
1159 i < infoPtr->nNumButtons )
1165 if( bFound && i < infoPtr->nNumButtons )
1168 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1169 i, btnPtr[i].fsStyle, x, cx);
1170 btnPtr[i].fsState |= TBSTATE_WRAP;
1171 x = infoPtr->nIndent;
1172 bButtonWrap = FALSE;
1175 else if ( i >= infoPtr->nNumButtons)
1178 /* If the current button is not a separator, find the last */
1179 /* separator and wrap it. */
1180 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1182 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
1183 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
1187 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1188 i, btnPtr[i].fsStyle, x, cx);
1189 x = infoPtr->nIndent;
1190 btnPtr[j].fsState |= TBSTATE_WRAP;
1191 bButtonWrap = FALSE;
1196 /* If no separator available for wrapping, wrap one of */
1197 /* non-hidden previous button. */
1201 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1203 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
1208 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1209 i, btnPtr[i].fsStyle, x, cx);
1210 x = infoPtr->nIndent;
1211 btnPtr[j].fsState |= TBSTATE_WRAP;
1217 /* If all above failed, wrap the current button. */
1220 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1221 i, btnPtr[i].fsStyle, x, cx);
1222 btnPtr[i].fsState |= TBSTATE_WRAP;
1224 x = infoPtr->nIndent;
1225 if (btnPtr[i].fsStyle & TBSTYLE_SEP )
1226 bButtonWrap = FALSE;
1232 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1233 i, btnPtr[i].fsStyle, x, cx);
1240 /***********************************************************************
1241 * TOOLBAR_CalcToolbar
1243 * This function calculates button and separator placement. It first
1244 * calculates the button sizes, gets the toolbar window width and then
1245 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1246 * on. It assigns a new location to each item and sends this location to
1247 * the tooltip window if appropriate. Finally, it updates the rcBound
1248 * rect and calculates the new required toolbar window height.
1252 TOOLBAR_CalcToolbar (HWND hwnd)
1254 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
1255 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1256 TBUTTON_INFO *btnPtr;
1257 INT i, nRows, nSepRows;
1261 BOOL usesBitmaps = FALSE;
1262 BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
1264 TOOLBAR_CalcStrings (hwnd, &sizeString);
1266 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
1268 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
1271 if (dwStyle & TBSTYLE_LIST)
1273 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
1274 0, sizeString.cy) + infoPtr->szPadding.cy;
1275 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
1276 0) + sizeString.cx + 6;
1277 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1278 infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
1279 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
1280 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
1283 if (sizeString.cy > 0)
1286 infoPtr->nButtonHeight = sizeString.cy +
1287 2 + /* this is the space to separate text from bitmap */
1288 infoPtr->nBitmapHeight + 6;
1290 infoPtr->nButtonHeight = sizeString.cy + 6;
1292 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
1293 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
1295 if (sizeString.cx > infoPtr->nBitmapWidth)
1296 infoPtr->nButtonWidth = sizeString.cx + 6;
1297 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
1298 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
1301 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
1302 infoPtr->nButtonWidth = infoPtr->cxMin;
1303 if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
1304 infoPtr->nButtonWidth = infoPtr->cxMax;
1306 TOOLBAR_WrapToolbar( hwnd, dwStyle );
1308 x = infoPtr->nIndent;
1312 * We will set the height below, and we set the width on entry
1313 * so we do not reset them here..
1316 GetClientRect( hwnd, &rc );
1317 /* get initial values for toolbar */
1318 infoPtr->nWidth = rc.right - rc.left;
1319 infoPtr->nHeight = rc.bottom - rc.top;
1322 /* from above, minimum is a button, and possible text */
1323 cx = infoPtr->nButtonWidth;
1325 /* cannot use just ButtonHeight, we may have no buttons! */
1326 if (infoPtr->nNumButtons > 0)
1327 infoPtr->nHeight = infoPtr->nButtonHeight;
1329 cy = infoPtr->nHeight;
1331 nRows = nSepRows = 0;
1333 infoPtr->rcBound.top = y;
1334 infoPtr->rcBound.left = x;
1335 infoPtr->rcBound.bottom = y + cy;
1336 infoPtr->rcBound.right = x;
1338 btnPtr = infoPtr->buttons;
1340 /* do not base height/width on parent, if the parent is a */
1341 /* rebar control it could have multiple rows of toolbars */
1342 /* GetClientRect( GetParent(hwnd), &rc ); */
1343 /* cx = rc.right - rc.left; */
1344 /* cy = rc.bottom - rc.top; */
1346 TRACE("cy=%d\n", cy);
1348 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
1351 if (btnPtr->fsState & TBSTATE_HIDDEN)
1353 SetRectEmpty (&btnPtr->rect);
1357 cy = infoPtr->nHeight;
1359 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1360 /* it is the actual width of the separator. This is used for */
1361 /* custom controls in toolbars. */
1362 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1363 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
1364 cy = (btnPtr->iBitmap > 0) ?
1365 btnPtr->iBitmap : SEPARATOR_WIDTH;
1366 cx = infoPtr->nButtonWidth;
1369 cx = (btnPtr->iBitmap > 0) ?
1370 btnPtr->iBitmap : SEPARATOR_WIDTH;
1374 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
1381 hOldFont = SelectObject (hdc, infoPtr->hFont);
1383 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1385 SelectObject (hdc, hOldFont);
1386 ReleaseDC (hwnd, hdc);
1388 /* Fudge amount measured against IE4 "menu" and "Links" */
1389 /* toolbars with native control (v4.71). - GA 8/01 */
1390 cx = sz.cx + 6 + 5 + 5;
1391 if ((dwStyle & TBSTYLE_LIST) &&
1392 (TOOLBAR_TestImageExist (infoPtr, btnPtr, infoPtr->himlDef)))
1393 cx += infoPtr->nBitmapWidth;
1396 cx = infoPtr->nButtonWidth;
1398 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1399 cx += DDARROW_WIDTH;
1401 if (btnPtr->fsState & TBSTATE_WRAP )
1404 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
1406 if (infoPtr->rcBound.left > x)
1407 infoPtr->rcBound.left = x;
1408 if (infoPtr->rcBound.right < x + cx)
1409 infoPtr->rcBound.right = x + cx;
1410 if (infoPtr->rcBound.bottom < y + cy)
1411 infoPtr->rcBound.bottom = y + cy;
1413 /* Set the toolTip only for non-hidden, non-separator button */
1414 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
1418 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1419 ti.cbSize = sizeof(TTTOOLINFOA);
1421 ti.uId = btnPtr->idCommand;
1422 ti.rect = btnPtr->rect;
1423 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
1427 /* btnPtr->nRow is zero based. The space between the rows is */
1428 /* also considered as a row. */
1429 btnPtr->nRow = nRows + nSepRows;
1431 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1432 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow,
1437 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
1441 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1442 /* it is the actual width of the separator. This is used for */
1443 /* custom controls in toolbars. */
1444 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1445 y += cy + ( (btnPtr->iBitmap > 0 ) ?
1446 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
1450 /* nSepRows is used to calculate the extra height follwoing */
1454 x = infoPtr->nIndent;
1456 /* Increment row number unless this is the last button */
1457 /* and it has Wrap set. */
1458 if (i != infoPtr->nNumButtons-1)
1465 /* infoPtr->nRows is the number of rows on the toolbar */
1466 infoPtr->nRows = nRows + nSepRows + 1;
1469 /********************************************************************
1470 * The following while interesting, does not match the values *
1471 * created above for the button rectangles, nor the rcBound rect. *
1472 * We will comment it out and remove it later. *
1474 * The problem showed up as heights in the pager control that was *
1476 ********************************************************************/
1478 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1480 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
1481 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
1482 nSepRows * (infoPtr->nBitmapHeight + 1) +
1486 infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1488 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
1493 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
1495 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1496 TBUTTON_INFO *btnPtr;
1499 btnPtr = infoPtr->buttons;
1500 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1501 if (btnPtr->fsState & TBSTATE_HIDDEN)
1504 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1505 if (PtInRect (&btnPtr->rect, *lpPt)) {
1506 TRACE(" ON SEPARATOR %d!\n", i);
1511 if (PtInRect (&btnPtr->rect, *lpPt)) {
1512 TRACE(" ON BUTTON %d!\n", i);
1518 TRACE(" NOWHERE!\n");
1524 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
1526 TBUTTON_INFO *btnPtr;
1529 if (CommandIsIndex) {
1530 TRACE("command is really index command=%d\n", idCommand);
1531 if (idCommand >= infoPtr->nNumButtons) return -1;
1534 btnPtr = infoPtr->buttons;
1535 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1536 if (btnPtr->idCommand == idCommand) {
1537 TRACE("command=%d index=%d\n", idCommand, i);
1541 TRACE("no index found for command=%d\n", idCommand);
1547 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
1549 TBUTTON_INFO *btnPtr;
1552 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
1555 /* check index button */
1556 btnPtr = &infoPtr->buttons[nIndex];
1557 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1558 if (btnPtr->fsState & TBSTATE_CHECKED)
1562 /* check previous buttons */
1563 nRunIndex = nIndex - 1;
1564 while (nRunIndex >= 0) {
1565 btnPtr = &infoPtr->buttons[nRunIndex];
1566 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1567 if (btnPtr->fsState & TBSTATE_CHECKED)
1575 /* check next buttons */
1576 nRunIndex = nIndex + 1;
1577 while (nRunIndex < infoPtr->nNumButtons) {
1578 btnPtr = &infoPtr->buttons[nRunIndex];
1579 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1580 if (btnPtr->fsState & TBSTATE_CHECKED)
1593 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
1594 WPARAM wParam, LPARAM lParam)
1600 msg.wParam = wParam;
1601 msg.lParam = lParam;
1602 msg.time = GetMessageTime ();
1603 msg.pt.x = LOWORD(GetMessagePos ());
1604 msg.pt.y = HIWORD(GetMessagePos ());
1606 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
1610 /***********************************************************************
1611 * TOOLBAR_CustomizeDialogProc
1612 * This function implements the toolbar customization dialog.
1615 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1617 PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
1618 PCUSTOMBUTTON btnInfo;
1620 TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
1625 custInfo = (PCUSTDLG_INFO)lParam;
1626 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
1634 infoPtr = custInfo->tbInfo;
1636 /* send TBN_QUERYINSERT notification */
1637 nmtb.iItem = custInfo->tbInfo->nNumButtons;
1639 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
1642 /* add items to 'toolbar buttons' list and check if removable */
1643 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
1645 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1646 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1647 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1648 btnInfo->bVirtual = FALSE;
1649 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1651 /* send TBN_QUERYDELETE notification */
1653 btnInfo->bRemovable = TOOLBAR_SendNotify ((NMHDR *) &nmtb,
1657 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
1658 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1661 /* insert separator button into 'available buttons' list */
1662 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1663 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1664 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1665 btnInfo->bVirtual = FALSE;
1666 btnInfo->bRemovable = TRUE;
1667 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1668 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1669 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1671 /* insert all buttons into dsa */
1674 /* send TBN_GETBUTTONINFO notification */
1676 nmtb.pszText = Buffer;
1679 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_GETBUTTONINFOA))
1682 TRACE("style: %x\n", nmtb.tbButton.fsStyle);
1684 /* insert button into the apropriate list */
1685 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
1688 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1689 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1690 btnInfo->bVirtual = FALSE;
1691 btnInfo->bRemovable = TRUE;
1692 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1693 strcpy (btnInfo->text, nmtb.pszText);
1695 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1696 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1700 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1701 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1702 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1703 strcpy (btnInfo->text, nmtb.pszText);
1705 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1709 /* select first item in the 'available' list */
1710 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
1712 /* append 'virtual' separator button to the 'toolbar buttons' list */
1713 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1714 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1715 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1716 btnInfo->bVirtual = TRUE;
1717 btnInfo->bRemovable = FALSE;
1718 LoadStringA (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1719 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1720 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1722 /* select last item in the 'toolbar' list */
1723 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
1724 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
1726 /* set focus and disable buttons */
1727 PostMessageA (hwnd, WM_USER, 0, 0);
1732 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1733 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1734 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
1735 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
1739 EndDialog(hwnd, FALSE);
1743 switch (LOWORD(wParam))
1745 case IDC_TOOLBARBTN_LBOX:
1746 if (HIWORD(wParam) == LBN_SELCHANGE)
1748 PCUSTOMBUTTON btnInfo;
1753 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1754 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1756 /* send TBN_QUERYINSERT notification */
1758 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1761 /* get list box item */
1762 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1764 if (index == (count - 1))
1766 /* last item (virtual separator) */
1767 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1768 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1770 else if (index == (count - 2))
1772 /* second last item (last non-virtual item) */
1773 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1774 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1776 else if (index == 0)
1779 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1780 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1784 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1785 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1788 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
1792 case IDC_MOVEUP_BTN:
1794 PCUSTOMBUTTON btnInfo;
1798 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1799 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1800 TRACE("Move up: index %d\n", index);
1802 /* send TBN_QUERYINSERT notification */
1805 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1808 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1810 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1811 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
1812 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
1813 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1816 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1817 else if (index >= (count - 3))
1818 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1820 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1821 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
1826 case IDC_MOVEDN_BTN: /* move down */
1828 PCUSTOMBUTTON btnInfo;
1832 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1833 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1834 TRACE("Move up: index %d\n", index);
1836 /* send TBN_QUERYINSERT notification */
1838 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1841 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1843 /* move button down */
1844 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1845 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
1846 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
1847 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
1850 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1851 else if (index >= (count - 3))
1852 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1854 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1855 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
1860 case IDC_REMOVE_BTN: /* remove button */
1862 PCUSTOMBUTTON btnInfo;
1865 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1866 TRACE("Remove: index %d\n", index);
1868 /* send TBN_QUERYDELETE notification */
1870 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1873 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1874 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1875 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
1877 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1879 /* insert into 'available button' list */
1880 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
1882 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1883 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1886 COMCTL32_Free (btnInfo);
1891 case IDOK: /* Add button */
1896 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1897 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
1898 TRACE("Add: index %d\n", index);
1900 /* send TBN_QUERYINSERT notification */
1902 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1905 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
1909 /* remove from 'available buttons' list */
1910 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
1911 if (index == count-1)
1912 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1914 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
1918 PCUSTOMBUTTON btnNew;
1920 /* duplicate 'separator' button */
1921 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
1922 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
1926 /* insert into 'toolbar button' list */
1927 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1928 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
1929 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1931 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
1937 EndDialog(hwnd, FALSE);
1947 /* delete items from 'toolbar buttons' listbox*/
1948 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1949 for (i = 0; i < count; i++)
1951 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
1952 COMCTL32_Free(btnInfo);
1953 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
1955 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
1958 /* delete items from 'available buttons' listbox*/
1959 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1960 for (i = 0; i < count; i++)
1962 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
1963 COMCTL32_Free(btnInfo);
1964 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
1966 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
1971 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
1973 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
1978 COLORREF oldText = 0;
1982 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
1983 if (btnInfo == NULL)
1985 FIXME("btnInfo invalid!\n");
1989 /* set colors and select objects */
1990 oldBk = SetBkColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlight:comctl32_color.clrWindow);
1991 if (btnInfo->bVirtual)
1992 oldText = SetTextColor (lpdis->hDC, comctl32_color.clrGrayText);
1994 oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText);
1995 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1996 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
1998 /* fill background rectangle */
1999 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
2000 lpdis->rcItem.right, lpdis->rcItem.bottom);
2002 /* calculate button and text rectangles */
2003 CopyRect (&rcButton, &lpdis->rcItem);
2004 InflateRect (&rcButton, -1, -1);
2005 CopyRect (&rcText, &rcButton);
2006 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
2007 rcText.left = rcButton.right + 2;
2009 /* draw focus rectangle */
2010 if (lpdis->itemState & ODS_FOCUS)
2011 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
2014 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
2016 /* draw image and text */
2017 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0)
2018 ImageList_Draw (custInfo->tbInfo->himlDef, btnInfo->btn.iBitmap, lpdis->hDC,
2019 rcButton.left+3, rcButton.top+3, ILD_NORMAL);
2020 DrawTextA (lpdis->hDC, btnInfo->text, -1, &rcText,
2021 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
2023 /* delete objects and reset colors */
2024 SelectObject (lpdis->hDC, hOldBrush);
2025 SelectObject (lpdis->hDC, hOldPen);
2026 SetBkColor (lpdis->hDC, oldBk);
2027 SetTextColor (lpdis->hDC, oldText);
2033 case WM_MEASUREITEM:
2034 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
2036 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
2038 if (custInfo && custInfo->tbInfo)
2039 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
2041 lpmis->itemHeight = 15 + 8; /* default height */
2053 /***********************************************************************
2054 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2058 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2060 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2061 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
2062 INT nIndex = 0, nButtons, nCount;
2065 TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
2069 if (lpAddBmp->hInst == HINST_COMMCTRL)
2071 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
2073 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
2075 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
2080 TRACE ("adding %d internal bitmaps!\n", nButtons);
2082 /* Windows resize all the buttons to the size of a newly added standard image */
2083 if (lpAddBmp->nID & 1)
2086 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2087 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2089 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
2090 MAKELPARAM((WORD)24, (WORD)24));
2091 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
2092 MAKELPARAM((WORD)31, (WORD)30));
2097 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
2098 MAKELPARAM((WORD)16, (WORD)16));
2099 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
2100 MAKELPARAM((WORD)22, (WORD)22));
2103 TOOLBAR_CalcToolbar (hwnd);
2107 nButtons = (INT)wParam;
2111 TRACE ("adding %d bitmaps!\n", nButtons);
2114 if (!(infoPtr->himlDef)) {
2115 /* create new default image list */
2116 TRACE ("creating default image list!\n");
2119 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
2120 ILC_COLOR | ILC_MASK, nButtons, 2);
2121 infoPtr->himlInt = infoPtr->himlDef;
2124 nCount = ImageList_GetImageCount(infoPtr->himlDef);
2126 /* Add bitmaps to the default image list */
2127 if (lpAddBmp->hInst == (HINSTANCE)0)
2130 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
2133 else if (lpAddBmp->hInst == HINST_COMMCTRL)
2135 /* Add system bitmaps */
2136 switch (lpAddBmp->nID)
2138 case IDB_STD_SMALL_COLOR:
2139 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2140 MAKEINTRESOURCEA(IDB_STD_SMALL));
2141 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2142 hbmLoad, CLR_DEFAULT);
2143 DeleteObject (hbmLoad);
2146 case IDB_STD_LARGE_COLOR:
2147 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2148 MAKEINTRESOURCEA(IDB_STD_LARGE));
2149 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2150 hbmLoad, CLR_DEFAULT);
2151 DeleteObject (hbmLoad);
2154 case IDB_VIEW_SMALL_COLOR:
2155 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2156 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
2157 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2158 hbmLoad, CLR_DEFAULT);
2159 DeleteObject (hbmLoad);
2162 case IDB_VIEW_LARGE_COLOR:
2163 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2164 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
2165 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2166 hbmLoad, CLR_DEFAULT);
2167 DeleteObject (hbmLoad);
2170 case IDB_HIST_SMALL_COLOR:
2171 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2172 MAKEINTRESOURCEA(IDB_HIST_SMALL));
2173 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2174 hbmLoad, CLR_DEFAULT);
2175 DeleteObject (hbmLoad);
2178 case IDB_HIST_LARGE_COLOR:
2179 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2180 MAKEINTRESOURCEA(IDB_HIST_LARGE));
2181 nIndex = ImageList_AddMasked (infoPtr->himlDef,
2182 hbmLoad, CLR_DEFAULT);
2183 DeleteObject (hbmLoad);
2187 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
2188 ERR ("invalid imagelist!\n");
2194 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
2195 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
2196 DeleteObject (hbmLoad);
2201 INT imagecount = ImageList_GetImageCount(infoPtr->himlDef);
2203 if (infoPtr->nNumBitmaps + nButtons != imagecount)
2205 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",
2206 infoPtr->nNumBitmaps, nCount, imagecount - nCount,
2207 infoPtr->nNumBitmaps+nButtons,imagecount);
2209 infoPtr->nNumBitmaps = imagecount;
2212 infoPtr->nNumBitmaps += nButtons;
2215 InvalidateRect(hwnd, NULL, FALSE);
2222 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2224 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2225 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2226 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2228 TRACE("adding %d buttons!\n", wParam);
2230 nAddButtons = (UINT)wParam;
2231 nOldButtons = infoPtr->nNumButtons;
2232 nNewButtons = nOldButtons + nAddButtons;
2234 if (infoPtr->nNumButtons == 0) {
2236 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2239 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2241 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2242 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2243 nOldButtons * sizeof(TBUTTON_INFO));
2244 COMCTL32_Free (oldButtons);
2247 infoPtr->nNumButtons = nNewButtons;
2249 /* insert new button data */
2250 for (nCount = 0; nCount < nAddButtons; nCount++) {
2251 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2252 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2253 btnPtr->idCommand = lpTbb[nCount].idCommand;
2254 btnPtr->fsState = lpTbb[nCount].fsState;
2255 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2256 btnPtr->dwData = lpTbb[nCount].dwData;
2257 btnPtr->iString = lpTbb[nCount].iString;
2258 btnPtr->bHot = FALSE;
2260 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2263 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2264 ti.cbSize = sizeof (TTTOOLINFOA);
2266 ti.uId = btnPtr->idCommand;
2268 ti.lpszText = LPSTR_TEXTCALLBACKA;
2270 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2275 TOOLBAR_CalcToolbar (hwnd);
2277 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2279 InvalidateRect(hwnd, NULL, FALSE);
2286 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2288 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2289 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2290 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2292 TRACE("adding %d buttons!\n", wParam);
2294 nAddButtons = (UINT)wParam;
2295 nOldButtons = infoPtr->nNumButtons;
2296 nNewButtons = nOldButtons + nAddButtons;
2298 if (infoPtr->nNumButtons == 0) {
2300 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2303 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2305 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2306 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2307 nOldButtons * sizeof(TBUTTON_INFO));
2308 COMCTL32_Free (oldButtons);
2311 infoPtr->nNumButtons = nNewButtons;
2313 /* insert new button data */
2314 for (nCount = 0; nCount < nAddButtons; nCount++) {
2315 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2316 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2317 btnPtr->idCommand = lpTbb[nCount].idCommand;
2318 btnPtr->fsState = lpTbb[nCount].fsState;
2319 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2320 btnPtr->dwData = lpTbb[nCount].dwData;
2321 btnPtr->iString = lpTbb[nCount].iString;
2322 btnPtr->bHot = FALSE;
2324 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2327 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2328 ti.cbSize = sizeof (TTTOOLINFOW);
2330 ti.uId = btnPtr->idCommand;
2332 ti.lpszText = LPSTR_TEXTCALLBACKW;
2334 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2339 TOOLBAR_CalcToolbar (hwnd);
2341 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2343 InvalidateRect(hwnd, NULL, FALSE);
2350 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2352 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2355 if ((wParam) && (HIWORD(lParam) == 0)) {
2358 TRACE("adding string from resource!\n");
2360 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
2363 TRACE("len=%d \"%s\"\n", len, szString);
2364 nIndex = infoPtr->nNumStrings;
2365 if (infoPtr->nNumStrings == 0) {
2367 COMCTL32_Alloc (sizeof(LPWSTR));
2370 LPWSTR *oldStrings = infoPtr->strings;
2372 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2373 memcpy (&infoPtr->strings[0], &oldStrings[0],
2374 sizeof(LPWSTR) * infoPtr->nNumStrings);
2375 COMCTL32_Free (oldStrings);
2378 /*COMCTL32_Alloc zeros out the allocated memory*/
2379 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
2380 infoPtr->nNumStrings++;
2383 LPSTR p = (LPSTR)lParam;
2388 TRACE("adding string(s) from array!\n");
2390 nIndex = infoPtr->nNumStrings;
2393 TRACE("len=%d \"%s\"\n", len, p);
2395 if (infoPtr->nNumStrings == 0) {
2397 COMCTL32_Alloc (sizeof(LPWSTR));
2400 LPWSTR *oldStrings = infoPtr->strings;
2402 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2403 memcpy (&infoPtr->strings[0], &oldStrings[0],
2404 sizeof(LPWSTR) * infoPtr->nNumStrings);
2405 COMCTL32_Free (oldStrings);
2408 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
2409 infoPtr->nNumStrings++;
2420 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2422 #define MAX_RESOURCE_STRING_LENGTH 512
2423 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2426 if ((wParam) && (HIWORD(lParam) == 0)) {
2427 WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
2429 TRACE("adding string from resource!\n");
2431 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
2432 szString, MAX_RESOURCE_STRING_LENGTH);
2434 TRACE("len=%d %s\n", len, debugstr_w(szString));
2435 TRACE("First char: 0x%x\n", *szString);
2436 if (szString[0] == L'|')
2438 PWSTR p = szString + 1;
2440 nIndex = infoPtr->nNumStrings;
2441 while (*p != L'|') {
2443 if (infoPtr->nNumStrings == 0) {
2445 COMCTL32_Alloc (sizeof(LPWSTR));
2448 LPWSTR *oldStrings = infoPtr->strings;
2450 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2451 memcpy (&infoPtr->strings[0], &oldStrings[0],
2452 sizeof(LPWSTR) * infoPtr->nNumStrings);
2453 COMCTL32_Free (oldStrings);
2456 len = COMCTL32_StrChrW (p, L'|') - p;
2457 TRACE("len=%d %s\n", len, debugstr_w(p));
2458 infoPtr->strings[infoPtr->nNumStrings] =
2459 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
2460 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
2461 infoPtr->nNumStrings++;
2468 nIndex = infoPtr->nNumStrings;
2469 if (infoPtr->nNumStrings == 0) {
2471 COMCTL32_Alloc (sizeof(LPWSTR));
2474 LPWSTR *oldStrings = infoPtr->strings;
2476 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2477 memcpy (&infoPtr->strings[0], &oldStrings[0],
2478 sizeof(LPWSTR) * infoPtr->nNumStrings);
2479 COMCTL32_Free (oldStrings);
2482 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
2483 infoPtr->nNumStrings++;
2487 LPWSTR p = (LPWSTR)lParam;
2492 TRACE("adding string(s) from array!\n");
2493 nIndex = infoPtr->nNumStrings;
2497 TRACE("len=%d %s\n", len, debugstr_w(p));
2498 if (infoPtr->nNumStrings == 0) {
2500 COMCTL32_Alloc (sizeof(LPWSTR));
2503 LPWSTR *oldStrings = infoPtr->strings;
2505 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2506 memcpy (&infoPtr->strings[0], &oldStrings[0],
2507 sizeof(LPWSTR) * infoPtr->nNumStrings);
2508 COMCTL32_Free (oldStrings);
2511 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
2512 infoPtr->nNumStrings++;
2523 TOOLBAR_AutoSize (HWND hwnd)
2525 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2526 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2532 UINT uPosFlags = SWP_NOZORDER;
2534 TRACE("resize forced, style=%lx!\n", dwStyle);
2536 parent = GetParent (hwnd);
2537 GetClientRect(parent, &parent_rect);
2539 x = parent_rect.left;
2540 y = parent_rect.top;
2542 /* FIXME: we should be able to early out if nothing */
2543 /* has changed with nWidth != parent_rect width */
2545 if (dwStyle & CCS_NORESIZE) {
2546 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2549 TOOLBAR_CalcToolbar (hwnd);
2552 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2553 TOOLBAR_CalcToolbar (hwnd);
2554 InvalidateRect( hwnd, NULL, TRUE );
2555 cy = infoPtr->nHeight;
2556 cx = infoPtr->nWidth;
2558 if (dwStyle & CCS_NOMOVEY) {
2559 GetWindowRect(hwnd, &window_rect);
2560 ScreenToClient(parent, (LPPOINT)&window_rect.left);
2561 y = window_rect.top;
2565 if (dwStyle & CCS_NOPARENTALIGN)
2566 uPosFlags |= SWP_NOMOVE;
2568 if (!(dwStyle & CCS_NODIVIDER))
2569 cy += GetSystemMetrics(SM_CYEDGE);
2571 if (dwStyle & WS_BORDER)
2574 cy += GetSystemMetrics(SM_CYEDGE);
2575 cx += GetSystemMetrics(SM_CYEDGE);
2578 infoPtr->bAutoSize = TRUE;
2579 SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
2581 /* The following line makes sure that the infoPtr->bAutoSize is turned off after
2582 * the setwindowpos calls */
2583 infoPtr->bAutoSize = FALSE;
2590 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
2592 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2594 return infoPtr->nNumButtons;
2599 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2601 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2603 if (infoPtr == NULL) {
2604 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
2605 ERR("infoPtr == NULL!\n");
2609 infoPtr->dwStructSize = (DWORD)wParam;
2616 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2618 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2619 TBUTTON_INFO *btnPtr;
2622 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2626 btnPtr = &infoPtr->buttons[nIndex];
2627 btnPtr->iBitmap = LOWORD(lParam);
2629 /* we HAVE to erase the background, the new bitmap could be */
2631 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2638 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2640 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2641 TBUTTON_INFO *btnPtr;
2644 BOOL bChecked = FALSE;
2646 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2650 btnPtr = &infoPtr->buttons[nIndex];
2652 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
2655 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
2657 if (LOWORD(lParam) == FALSE)
2658 btnPtr->fsState &= ~TBSTATE_CHECKED;
2660 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2662 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
2663 if (nOldIndex == nIndex)
2665 if (nOldIndex != -1)
2666 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2668 btnPtr->fsState |= TBSTATE_CHECKED;
2671 if( bChecked != LOWORD(lParam) )
2673 if (nOldIndex != -1)
2675 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
2676 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
2678 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2681 /* FIXME: Send a WM_NOTIFY?? */
2688 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
2690 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2692 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2697 TOOLBAR_Customize (HWND hwnd)
2699 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2700 CUSTDLG_INFO custInfo;
2706 custInfo.tbInfo = infoPtr;
2707 custInfo.tbHwnd = hwnd;
2709 /* send TBN_BEGINADJUST notification */
2710 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2713 if (!(hRes = FindResourceA (COMCTL32_hModule,
2714 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
2718 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
2721 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
2722 (LPDLGTEMPLATEA)template,
2724 (DLGPROC)TOOLBAR_CustomizeDialogProc,
2727 /* send TBN_ENDADJUST notification */
2728 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2736 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2738 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2739 INT nIndex = (INT)wParam;
2741 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2744 if ((infoPtr->hwndToolTip) &&
2745 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
2748 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2749 ti.cbSize = sizeof (TTTOOLINFOA);
2751 ti.uId = infoPtr->buttons[nIndex].idCommand;
2753 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
2756 if (infoPtr->nNumButtons == 1) {
2757 TRACE(" simple delete!\n");
2758 COMCTL32_Free (infoPtr->buttons);
2759 infoPtr->buttons = NULL;
2760 infoPtr->nNumButtons = 0;
2763 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2764 TRACE("complex delete! [nIndex=%d]\n", nIndex);
2766 infoPtr->nNumButtons--;
2767 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2769 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2770 nIndex * sizeof(TBUTTON_INFO));
2773 if (nIndex < infoPtr->nNumButtons) {
2774 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
2775 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
2778 COMCTL32_Free (oldButtons);
2781 TOOLBAR_CalcToolbar (hwnd);
2783 InvalidateRect (hwnd, NULL, TRUE);
2790 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2792 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2793 TBUTTON_INFO *btnPtr;
2797 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2801 btnPtr = &infoPtr->buttons[nIndex];
2803 bState = btnPtr->fsState & TBSTATE_ENABLED;
2805 /* update the toolbar button state */
2806 if(LOWORD(lParam) == FALSE) {
2807 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
2809 btnPtr->fsState |= TBSTATE_ENABLED;
2812 /* redraw the button only if the state of the button changed */
2813 if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
2815 InvalidateRect(hwnd, &btnPtr->rect,
2816 TOOLBAR_HasText(infoPtr, btnPtr));
2823 static inline LRESULT
2824 TOOLBAR_GetAnchorHighlight (HWND hwnd)
2826 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2828 return infoPtr->bAnchor;
2833 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2835 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2838 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2842 return infoPtr->buttons[nIndex].iBitmap;
2846 static inline LRESULT
2847 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2849 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
2854 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2856 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2857 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2858 INT nIndex = (INT)wParam;
2859 TBUTTON_INFO *btnPtr;
2861 if (infoPtr == NULL)
2867 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2870 btnPtr = &infoPtr->buttons[nIndex];
2871 lpTbb->iBitmap = btnPtr->iBitmap;
2872 lpTbb->idCommand = btnPtr->idCommand;
2873 lpTbb->fsState = btnPtr->fsState;
2874 lpTbb->fsStyle = btnPtr->fsStyle;
2875 lpTbb->dwData = btnPtr->dwData;
2876 lpTbb->iString = btnPtr->iString;
2883 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2885 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2886 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
2887 TBUTTON_INFO *btnPtr;
2890 if (infoPtr == NULL)
2892 if (lpTbInfo == NULL)
2894 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
2897 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
2898 lpTbInfo->dwMask & 0x80000000);
2902 if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
2904 if (lpTbInfo->dwMask & TBIF_COMMAND)
2905 lpTbInfo->idCommand = btnPtr->idCommand;
2906 if (lpTbInfo->dwMask & TBIF_IMAGE)
2907 lpTbInfo->iImage = btnPtr->iBitmap;
2908 if (lpTbInfo->dwMask & TBIF_LPARAM)
2909 lpTbInfo->lParam = btnPtr->dwData;
2910 if (lpTbInfo->dwMask & TBIF_SIZE)
2911 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
2912 if (lpTbInfo->dwMask & TBIF_STATE)
2913 lpTbInfo->fsState = btnPtr->fsState;
2914 if (lpTbInfo->dwMask & TBIF_STYLE)
2915 lpTbInfo->fsStyle = btnPtr->fsStyle;
2916 if (lpTbInfo->dwMask & TBIF_TEXT) {
2917 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
2918 Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
2925 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2927 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2928 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
2929 TBUTTON_INFO *btnPtr;
2932 if (infoPtr == NULL)
2934 if (lpTbInfo == NULL)
2936 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
2939 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
2940 lpTbInfo->dwMask & 0x80000000);
2944 btnPtr = &infoPtr->buttons[nIndex];
2946 if (lpTbInfo->dwMask & TBIF_COMMAND)
2947 lpTbInfo->idCommand = btnPtr->idCommand;
2948 if (lpTbInfo->dwMask & TBIF_IMAGE)
2949 lpTbInfo->iImage = btnPtr->iBitmap;
2950 if (lpTbInfo->dwMask & TBIF_LPARAM)
2951 lpTbInfo->lParam = btnPtr->dwData;
2952 if (lpTbInfo->dwMask & TBIF_SIZE)
2953 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
2954 if (lpTbInfo->dwMask & TBIF_STATE)
2955 lpTbInfo->fsState = btnPtr->fsState;
2956 if (lpTbInfo->dwMask & TBIF_STYLE)
2957 lpTbInfo->fsStyle = btnPtr->fsStyle;
2958 if (lpTbInfo->dwMask & TBIF_TEXT) {
2959 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
2960 Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
2968 TOOLBAR_GetButtonSize (HWND hwnd)
2970 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2972 if (infoPtr->nNumButtons > 0)
2973 return MAKELONG((WORD)infoPtr->nButtonWidth,
2974 (WORD)infoPtr->nButtonHeight);
2976 return MAKELONG(8,7);
2981 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2983 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2990 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2994 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
2996 return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
2997 (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
3002 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3004 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3011 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3015 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
3017 strcpyW ((LPWSTR)lParam, lpText);
3019 return strlenW (lpText);
3024 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3026 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3028 return (LRESULT)infoPtr->himlDis;
3032 inline static LRESULT
3033 TOOLBAR_GetExtendedStyle (HWND hwnd)
3035 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3037 return infoPtr->dwExStyle;
3042 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3044 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3046 return (LRESULT)infoPtr->himlHot;
3051 TOOLBAR_GetHotItem (HWND hwnd)
3053 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3055 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
3058 if (infoPtr->nHotItem < 0)
3061 return (LRESULT)infoPtr->nHotItem;
3066 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3068 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3070 return (LRESULT)infoPtr->himlDef;
3074 /* << TOOLBAR_GetInsertMark >> */
3075 /* << TOOLBAR_GetInsertMarkColor >> */
3079 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3081 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3082 TBUTTON_INFO *btnPtr;
3086 if (infoPtr == NULL)
3088 nIndex = (INT)wParam;
3089 btnPtr = &infoPtr->buttons[nIndex];
3090 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3092 lpRect = (LPRECT)lParam;
3095 if (btnPtr->fsState & TBSTATE_HIDDEN)
3098 lpRect->left = btnPtr->rect.left;
3099 lpRect->right = btnPtr->rect.right;
3100 lpRect->bottom = btnPtr->rect.bottom;
3101 lpRect->top = btnPtr->rect.top;
3108 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3110 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3111 LPSIZE lpSize = (LPSIZE)lParam;
3116 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
3117 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
3119 TRACE("maximum size %d x %d\n",
3120 infoPtr->rcBound.right - infoPtr->rcBound.left,
3121 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
3127 /* << TOOLBAR_GetObject >> */
3131 TOOLBAR_GetPadding (HWND hwnd)
3133 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3136 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
3137 return (LRESULT) oldPad;
3142 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3144 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3145 TBUTTON_INFO *btnPtr;
3149 if (infoPtr == NULL)
3151 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3152 btnPtr = &infoPtr->buttons[nIndex];
3153 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3155 lpRect = (LPRECT)lParam;
3159 lpRect->left = btnPtr->rect.left;
3160 lpRect->right = btnPtr->rect.right;
3161 lpRect->bottom = btnPtr->rect.bottom;
3162 lpRect->top = btnPtr->rect.top;
3169 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3171 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3173 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
3174 return infoPtr->nRows;
3181 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
3183 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3186 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3190 return infoPtr->buttons[nIndex].fsState;
3195 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3197 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3200 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3204 return infoPtr->buttons[nIndex].fsStyle;
3209 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3211 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3213 if (infoPtr == NULL)
3216 return infoPtr->nMaxTextRows;
3221 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
3223 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3225 if (infoPtr == NULL)
3227 return infoPtr->hwndToolTip;
3232 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
3234 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3236 TRACE("%s hwnd=0x%x stub!\n",
3237 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
3239 return infoPtr->bUnicode;
3243 inline static LRESULT
3244 TOOLBAR_GetVersion (HWND hwnd)
3246 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3247 return infoPtr->iVersion;
3252 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3254 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3255 TBUTTON_INFO *btnPtr;
3260 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3264 btnPtr = &infoPtr->buttons[nIndex];
3265 if (LOWORD(lParam) == FALSE)
3266 btnPtr->fsState &= ~TBSTATE_HIDDEN;
3268 btnPtr->fsState |= TBSTATE_HIDDEN;
3270 TOOLBAR_CalcToolbar (hwnd);
3272 InvalidateRect (hwnd, NULL, TRUE);
3278 inline static LRESULT
3279 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
3281 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
3286 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3288 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3289 TBUTTON_INFO *btnPtr;
3292 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3296 btnPtr = &infoPtr->buttons[nIndex];
3297 if (LOWORD(lParam) == FALSE)
3298 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
3300 btnPtr->fsState |= TBSTATE_INDETERMINATE;
3302 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3309 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3311 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3312 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3313 INT nIndex = (INT)wParam;
3314 TBUTTON_INFO *oldButtons;
3319 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3322 /* EPP: this seems to be an undocumented call (from my IE4)
3323 * I assume in that case that:
3324 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3325 * - index of insertion is at the end of existing buttons
3326 * I only see this happen with nIndex == -1, but it could have a special
3327 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3329 nIndex = infoPtr->nNumButtons;
3331 } else if (nIndex < 0)
3334 /* If the string passed is not an index, assume address of string
3335 and do our own AddString */
3336 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3340 TRACE("string %s passed instead of index, adding string\n",
3341 debugstr_a((LPSTR)lpTbb->iString));
3342 len = strlen((LPSTR)lpTbb->iString) + 2;
3343 ptr = COMCTL32_Alloc(len);
3344 strcpy(ptr, (LPSTR)lpTbb->iString);
3345 ptr[len - 1] = 0; /* ended by two '\0' */
3346 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
3350 TRACE("inserting button index=%d\n", nIndex);
3351 if (nIndex > infoPtr->nNumButtons) {
3352 nIndex = infoPtr->nNumButtons;
3353 TRACE("adjust index=%d\n", nIndex);
3356 oldButtons = infoPtr->buttons;
3357 infoPtr->nNumButtons++;
3358 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3359 /* pre insert copy */
3361 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3362 nIndex * sizeof(TBUTTON_INFO));
3365 /* insert new button */
3366 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3367 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3368 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3369 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3370 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3371 /* if passed string and not index, then add string */
3372 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3373 Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
3376 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3378 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3381 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
3382 ti.cbSize = sizeof (TTTOOLINFOA);
3384 ti.uId = lpTbb->idCommand;
3386 ti.lpszText = LPSTR_TEXTCALLBACKA;
3388 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
3392 /* post insert copy */
3393 if (nIndex < infoPtr->nNumButtons - 1) {
3394 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3395 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3398 COMCTL32_Free (oldButtons);
3400 TOOLBAR_CalcToolbar (hwnd);
3402 InvalidateRect (hwnd, NULL, TRUE);
3409 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3411 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3412 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3413 INT nIndex = (INT)wParam;
3414 TBUTTON_INFO *oldButtons;
3419 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3422 /* EPP: this seems to be an undocumented call (from my IE4)
3423 * I assume in that case that:
3424 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3425 * - index of insertion is at the end of existing buttons
3426 * I only see this happen with nIndex == -1, but it could have a special
3427 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3429 nIndex = infoPtr->nNumButtons;
3431 } else if (nIndex < 0)
3434 /* If the string passed is not an index, assume address of string
3435 and do our own AddString */
3436 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3440 TRACE("string %s passed instead of index, adding string\n",
3441 debugstr_w((LPWSTR)lpTbb->iString));
3442 len = strlenW((LPWSTR)lpTbb->iString) + 2;
3443 ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
3444 strcpyW(ptr, (LPWSTR)lpTbb->iString);
3445 ptr[len - 1] = 0; /* ended by two '\0' */
3446 lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
3450 TRACE("inserting button index=%d\n", nIndex);
3451 if (nIndex > infoPtr->nNumButtons) {
3452 nIndex = infoPtr->nNumButtons;
3453 TRACE("adjust index=%d\n", nIndex);
3456 oldButtons = infoPtr->buttons;
3457 infoPtr->nNumButtons++;
3458 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3459 /* pre insert copy */
3461 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3462 nIndex * sizeof(TBUTTON_INFO));
3465 /* insert new button */
3466 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3467 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3468 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3469 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3470 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3471 /* if passed string and not index, then add string */
3472 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3473 Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
3476 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3478 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3481 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
3482 ti.cbSize = sizeof (TTTOOLINFOW);
3484 ti.uId = lpTbb->idCommand;
3486 ti.lpszText = LPSTR_TEXTCALLBACKW;
3488 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
3492 /* post insert copy */
3493 if (nIndex < infoPtr->nNumButtons - 1) {
3494 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3495 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3498 COMCTL32_Free (oldButtons);
3500 TOOLBAR_CalcToolbar (hwnd);
3502 InvalidateRect (hwnd, NULL, TRUE);
3508 /* << TOOLBAR_InsertMarkHitTest >> */
3512 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
3514 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3517 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3521 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
3526 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
3528 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3531 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3535 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
3540 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
3542 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3545 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3549 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
3554 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
3556 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3559 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3563 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
3568 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3570 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3573 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3577 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
3582 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
3584 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3587 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3591 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
3595 /* << TOOLBAR_LoadImages >> */
3596 /* << TOOLBAR_MapAccelerator >> */
3597 /* << TOOLBAR_MarkButton >> */
3598 /* << TOOLBAR_MoveButton >> */
3602 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3604 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3605 TBUTTON_INFO *btnPtr;
3608 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3612 btnPtr = &infoPtr->buttons[nIndex];
3613 if (LOWORD(lParam) == FALSE)
3614 btnPtr->fsState &= ~TBSTATE_PRESSED;
3616 btnPtr->fsState |= TBSTATE_PRESSED;
3618 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3624 /* << TOOLBAR_ReplaceBitmap >> */
3628 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3631 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3632 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
3634 if (lpSave == NULL) return 0;
3637 /* save toolbar information */
3638 FIXME("save to \"%s\" \"%s\"\n",
3639 lpSave->pszSubKey, lpSave->pszValueName);
3644 /* restore toolbar information */
3646 FIXME("restore from \"%s\" \"%s\"\n",
3647 lpSave->pszSubKey, lpSave->pszValueName);
3658 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3661 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3662 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
3668 /* save toolbar information */
3669 FIXME("save to \"%s\" \"%s\"\n",
3670 lpSave->pszSubKey, lpSave->pszValueName);
3675 /* restore toolbar information */
3677 FIXME("restore from \"%s\" \"%s\"\n",
3678 lpSave->pszSubKey, lpSave->pszValueName);
3689 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
3691 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3692 BOOL bOldAnchor = infoPtr->bAnchor;
3694 infoPtr->bAnchor = (BOOL)wParam;
3696 return (LRESULT)bOldAnchor;
3701 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3703 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3705 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
3708 if (infoPtr->nNumButtons > 0)
3709 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
3710 infoPtr->nNumButtons,
3711 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
3712 LOWORD(lParam), HIWORD(lParam));
3714 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
3715 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
3717 /* uses image list internals directly */
3718 if (infoPtr->himlDef) {
3719 infoPtr->himlDef->cx = infoPtr->nBitmapWidth;
3720 infoPtr->himlDef->cy = infoPtr->nBitmapHeight;
3728 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3730 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3731 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
3732 TBUTTON_INFO *btnPtr;
3737 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
3740 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3741 lptbbi->dwMask & 0x80000000);
3745 btnPtr = &infoPtr->buttons[nIndex];
3746 if (lptbbi->dwMask & TBIF_COMMAND)
3747 btnPtr->idCommand = lptbbi->idCommand;
3748 if (lptbbi->dwMask & TBIF_IMAGE)
3749 btnPtr->iBitmap = lptbbi->iImage;
3750 if (lptbbi->dwMask & TBIF_LPARAM)
3751 btnPtr->dwData = lptbbi->lParam;
3752 /* if (lptbbi->dwMask & TBIF_SIZE) */
3753 /* btnPtr->cx = lptbbi->cx; */
3754 if (lptbbi->dwMask & TBIF_STATE)
3755 btnPtr->fsState = lptbbi->fsState;
3756 if (lptbbi->dwMask & TBIF_STYLE)
3757 btnPtr->fsStyle = lptbbi->fsStyle;
3759 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3760 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3761 /* iString is index, zero it to make Str_SetPtr succeed */
3764 Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
3771 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3773 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3774 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
3775 TBUTTON_INFO *btnPtr;
3780 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
3783 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3784 lptbbi->dwMask & 0x80000000);
3788 btnPtr = &infoPtr->buttons[nIndex];
3789 if (lptbbi->dwMask & TBIF_COMMAND)
3790 btnPtr->idCommand = lptbbi->idCommand;
3791 if (lptbbi->dwMask & TBIF_IMAGE)
3792 btnPtr->iBitmap = lptbbi->iImage;
3793 if (lptbbi->dwMask & TBIF_LPARAM)
3794 btnPtr->dwData = lptbbi->lParam;
3795 /* if (lptbbi->dwMask & TBIF_SIZE) */
3796 /* btnPtr->cx = lptbbi->cx; */
3797 if (lptbbi->dwMask & TBIF_STATE)
3798 btnPtr->fsState = lptbbi->fsState;
3799 if (lptbbi->dwMask & TBIF_STYLE)
3800 btnPtr->fsStyle = lptbbi->fsStyle;
3802 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3803 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3804 /* iString is index, zero it to make Str_SetPtr succeed */
3806 Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
3813 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3815 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3816 INT cx = LOWORD(lParam), cy = HIWORD(lParam);
3818 if ((cx < 0) || (cy < 0))
3820 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
3824 /* The documentation claims you can only change the button size before
3825 * any button has been added. But this is wrong.
3826 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
3827 * it to the toolbar, and it checks that the return value is nonzero - mjm
3828 * Further testing shows that we must actually perform the change too.
3831 * The documentation also does not mention that if 0 is supplied for
3832 * either size, the system changes it to the default of 24 wide and
3833 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
3835 infoPtr->nButtonWidth = (cx) ? cx : 24;
3836 infoPtr->nButtonHeight = (cy) ? cy : 22;
3842 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
3844 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3846 if (infoPtr == NULL) {
3847 TRACE("Toolbar not initialized yet?????\n");
3851 /* if setting to current values, ignore */
3852 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
3853 (infoPtr->cxMax == (INT)HIWORD(lParam))) {
3854 TRACE("matches current width, min=%d, max=%d, no recalc\n",
3855 infoPtr->cxMin, infoPtr->cxMax);
3859 /* save new values */
3860 infoPtr->cxMin = (INT)LOWORD(lParam);
3861 infoPtr->cxMax = (INT)HIWORD(lParam);
3863 /* if both values are 0 then we are done */
3865 TRACE("setting both min and max to 0, norecalc\n");
3869 /* otherwise we need to recalc the toolbar and in some cases
3870 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
3871 which doesn't actually draw - GA). */
3872 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
3873 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
3875 TOOLBAR_CalcToolbar (hwnd);
3877 InvalidateRect (hwnd, NULL, TRUE);
3884 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
3886 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3887 INT nIndex = (INT)wParam;
3889 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3892 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
3894 if (infoPtr->hwndToolTip) {
3896 FIXME("change tool tip!\n");
3905 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3907 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3908 HIMAGELIST himlTemp;
3912 FIXME("no support for multiple image lists\n");
3916 himlTemp = infoPtr->himlDis;
3917 infoPtr->himlDis = (HIMAGELIST)lParam;
3919 /* FIXME: redraw ? */
3921 return (LRESULT)himlTemp;
3926 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
3928 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3931 dwTemp = infoPtr->dwDTFlags;
3932 infoPtr->dwDTFlags =
3933 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
3935 return (LRESULT)dwTemp;
3939 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3941 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3944 dwTemp = infoPtr->dwExStyle;
3945 infoPtr->dwExStyle = (DWORD)lParam;
3947 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
3948 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
3949 FIXME("Extended style not implemented %s %s\n",
3950 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
3951 "TBSTYLE_EX_MIXEDBUTTONS" : "",
3952 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
3953 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
3956 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
3957 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
3958 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
3960 return (LRESULT)dwTemp;
3965 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3967 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3968 HIMAGELIST himlTemp;
3971 FIXME("no support for multiple image lists\n");
3975 himlTemp = infoPtr->himlHot;
3976 infoPtr->himlHot = (HIMAGELIST)lParam;
3978 /* FIXME: redraw ? */
3980 return (LRESULT)himlTemp;
3985 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
3987 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
3988 INT nOldHotItem = infoPtr->nHotItem;
3989 TBUTTON_INFO *btnPtr;
3991 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
3994 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
3997 infoPtr->nHotItem = (INT)wParam;
3998 if ((INT)wParam >=0)
4000 btnPtr = &infoPtr->buttons[(INT)wParam];
4001 btnPtr->bHot = TRUE;
4002 InvalidateRect (hwnd, &btnPtr->rect,
4003 TOOLBAR_HasText(infoPtr, btnPtr));
4007 btnPtr = &infoPtr->buttons[nOldHotItem];
4008 btnPtr->bHot = FALSE;
4009 InvalidateRect (hwnd, &btnPtr->rect,
4010 TOOLBAR_HasText(infoPtr, btnPtr));
4014 if (nOldHotItem < 0)
4017 return (LRESULT)nOldHotItem;
4022 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4024 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4025 HIMAGELIST himlTemp;
4028 FIXME("no support for multiple image lists\n");
4032 himlTemp = infoPtr->himlDef;
4033 infoPtr->himlDef = (HIMAGELIST)lParam;
4035 infoPtr->nNumBitmaps = ImageList_GetImageCount(infoPtr->himlDef);
4037 ImageList_GetIconSize(infoPtr->himlDef, &infoPtr->nBitmapWidth,
4038 &infoPtr->nBitmapHeight);
4039 TRACE("hwnd %08x, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4040 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
4041 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
4043 /* FIXME: redraw ? */
4044 InvalidateRect(hwnd, NULL, TRUE);
4046 return (LRESULT)himlTemp;
4051 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4053 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4055 infoPtr->nIndent = (INT)wParam;
4059 /* process only on indent changing */
4060 if(infoPtr->nIndent != (INT)wParam)
4062 infoPtr->nIndent = (INT)wParam;
4063 TOOLBAR_CalcToolbar (hwnd);
4064 InvalidateRect(hwnd, NULL, FALSE);
4071 /* << TOOLBAR_SetInsertMark >> */
4075 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
4077 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4079 infoPtr->clrInsertMark = (COLORREF)lParam;
4081 /* FIXME : redraw ??*/
4088 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4090 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4092 if (infoPtr == NULL)
4095 infoPtr->nMaxTextRows = (INT)wParam;
4102 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
4104 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4107 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4108 infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
4109 infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
4110 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
4111 infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4112 return (LRESULT) oldPad;
4117 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4119 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4124 if (infoPtr == NULL)
4126 hwndOldNotify = infoPtr->hwndNotify;
4127 infoPtr->hwndNotify = (HWND)wParam;
4129 return hwndOldNotify;
4134 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4136 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4137 LPRECT lprc = (LPRECT)lParam;
4141 if (LOWORD(wParam) > 1) {
4142 FIXME("multiple rows not supported!\n");
4145 if(infoPtr->nRows != LOWORD(wParam))
4147 infoPtr->nRows = LOWORD(wParam);
4149 /* recalculate toolbar */
4150 TOOLBAR_CalcToolbar (hwnd);
4152 /* repaint toolbar */
4153 InvalidateRect(hwnd, NULL, FALSE);
4156 /* return bounding rectangle */
4158 lprc->left = infoPtr->rcBound.left;
4159 lprc->right = infoPtr->rcBound.right;
4160 lprc->top = infoPtr->rcBound.top;
4161 lprc->bottom = infoPtr->rcBound.bottom;
4169 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
4171 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4172 TBUTTON_INFO *btnPtr;
4175 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4179 btnPtr = &infoPtr->buttons[nIndex];
4181 /* if hidden state has changed the invalidate entire window and recalc */
4182 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
4183 btnPtr->fsState = LOWORD(lParam);
4184 TOOLBAR_CalcToolbar (hwnd);
4185 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
4189 /* process state changing if current state doesn't match new state */
4190 if(btnPtr->fsState != LOWORD(lParam))
4192 btnPtr->fsState = LOWORD(lParam);
4193 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4202 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4204 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4205 TBUTTON_INFO *btnPtr;
4208 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4212 btnPtr = &infoPtr->buttons[nIndex];
4214 /* process style change if current style doesn't match new style */
4215 if(btnPtr->fsStyle != LOWORD(lParam))
4217 btnPtr->fsStyle = LOWORD(lParam);
4218 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4221 if (infoPtr->hwndToolTip) {
4222 FIXME("change tool tip!\n");
4230 inline static LRESULT
4231 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
4233 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4235 if (infoPtr == NULL)
4237 infoPtr->hwndToolTip = (HWND)wParam;
4243 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
4245 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4248 TRACE("%s hwnd=0x%04x stub!\n",
4249 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
4251 bTemp = infoPtr->bUnicode;
4252 infoPtr->bUnicode = (BOOL)wParam;
4259 TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4261 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4263 lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
4264 comctl32_color.clrBtnHighlight :
4265 infoPtr->clrBtnHighlight;
4266 lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
4267 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
4273 TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4275 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4277 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4278 lParam->clrBtnHighlight, lParam->clrBtnShadow,
4279 infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow);
4281 infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
4282 infoPtr->clrBtnShadow = lParam->clrBtnShadow;
4283 InvalidateRect(hwnd, 0, 0);
4289 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
4291 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4292 INT iOldVersion = infoPtr->iVersion;
4294 infoPtr->iVersion = iVersion;
4300 /*********************************************************************/
4302 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */
4303 /* without the restriction of TBSTYLE_FLAT. This implementation is */
4304 /* based on relay traces of the native control and IE 5.5 */
4306 /*********************************************************************/
4308 TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam)
4310 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4311 INT nOldHotItem = infoPtr->nHotItem;
4312 TBUTTON_INFO *btnPtr;
4314 NMTBHOTITEM nmhotitem;
4316 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4319 infoPtr->nHotItem = (INT)wParam;
4320 if (nOldHotItem != infoPtr->nHotItem) {
4321 nmhotitem.dwFlags = (DWORD)lParam;
4322 if ( !(nmhotitem.dwFlags & HICF_ENTERING) )
4323 nmhotitem.idOld = (nOldHotItem >= 0) ?
4324 infoPtr->buttons[nOldHotItem].idCommand : 0;
4325 if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
4326 nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
4327 infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
4328 no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
4330 if ((INT)wParam >=0) {
4331 btnPtr = &infoPtr->buttons[(INT)wParam];
4332 btnPtr->bHot = (no_hi) ? FALSE : TRUE;
4333 InvalidateRect (hwnd, &btnPtr->rect,
4334 TOOLBAR_HasText(infoPtr, btnPtr));
4336 if (nOldHotItem>=0) {
4337 btnPtr = &infoPtr->buttons[nOldHotItem];
4338 btnPtr->bHot = FALSE;
4339 InvalidateRect (hwnd, &btnPtr->rect,
4340 TOOLBAR_HasText(infoPtr, btnPtr));
4343 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
4344 nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi);
4346 if (nOldHotItem < 0)
4349 return (LRESULT)nOldHotItem;
4354 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
4356 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4357 LPSIZE lpsize = (LPSIZE)lParam;
4363 * Testing shows the following:
4364 * wParam = 0 adjust cx value
4365 * = 1 set cy value to max size.
4366 * lParam pointer to SIZE structure
4369 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4370 wParam, lParam, lpsize->cx, lpsize->cy);
4374 if (lpsize->cx == -1) {
4375 /* **** this is wrong, native measures each button and sets it */
4376 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4378 else if(HIWORD(lpsize->cx)) {
4380 HWND hwndParent = GetParent(hwnd);
4382 InvalidateRect(hwnd, 0, 1);
4383 GetWindowRect(hwnd, &rc);
4384 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
4385 TRACE("mapped to (%d,%d)-(%d,%d)\n",
4386 rc.left, rc.top, rc.right, rc.bottom);
4387 lpsize->cx = max(rc.right-rc.left,
4388 infoPtr->rcBound.right - infoPtr->rcBound.left);
4391 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4395 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4396 /* lpsize->cy = infoPtr->nHeight; */
4399 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4403 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4404 lpsize->cx, lpsize->cy);
4410 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
4412 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4413 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4416 /* initialize info structure */
4417 infoPtr->nButtonHeight = 22;
4418 infoPtr->nButtonWidth = 24;
4419 infoPtr->nBitmapHeight = 15;
4420 infoPtr->nBitmapWidth = 16;
4422 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
4424 infoPtr->nMaxTextRows = 1;
4425 infoPtr->cxMin = -1;
4426 infoPtr->cxMax = -1;
4427 infoPtr->nNumBitmaps = 0;
4428 infoPtr->nNumStrings = 0;
4430 infoPtr->bCaptured = FALSE;
4431 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4432 infoPtr->nButtonDown = -1;
4433 infoPtr->nOldHit = -1;
4434 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4435 infoPtr->hwndNotify = GetParent (hwnd);
4436 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
4437 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
4438 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
4439 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
4440 infoPtr->iVersion = 0;
4441 infoPtr->hwndSelf = hwnd;
4442 infoPtr->bDoRedraw = TRUE;
4443 infoPtr->clrBtnHighlight = CLR_DEFAULT;
4444 infoPtr->clrBtnShadow = CLR_DEFAULT;
4445 infoPtr->szPadding.cx = 7;
4446 infoPtr->szPadding.cy = 6;
4447 TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
4449 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
4450 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
4452 if (dwStyle & TBSTYLE_TOOLTIPS) {
4453 /* Create tooltip control */
4454 infoPtr->hwndToolTip =
4455 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
4456 CW_USEDEFAULT, CW_USEDEFAULT,
4457 CW_USEDEFAULT, CW_USEDEFAULT,
4460 /* Send NM_TOOLTIPSCREATED notification */
4461 if (infoPtr->hwndToolTip) {
4462 NMTOOLTIPSCREATED nmttc;
4464 nmttc.hwndToolTips = infoPtr->hwndToolTip;
4466 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
4467 NM_TOOLTIPSCREATED);
4471 TOOLBAR_CheckStyle (hwnd, dwStyle);
4473 TOOLBAR_CalcToolbar(hwnd);
4480 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
4482 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4484 /* delete tooltip control */
4485 if (infoPtr->hwndToolTip)
4486 DestroyWindow (infoPtr->hwndToolTip);
4488 /* delete button data */
4489 if (infoPtr->buttons)
4490 COMCTL32_Free (infoPtr->buttons);
4492 /* delete strings */
4493 if (infoPtr->strings) {
4495 for (i = 0; i < infoPtr->nNumStrings; i++)
4496 if (infoPtr->strings[i])
4497 COMCTL32_Free (infoPtr->strings[i]);
4499 COMCTL32_Free (infoPtr->strings);
4502 /* destroy internal image list */
4503 if (infoPtr->himlInt)
4504 ImageList_Destroy (infoPtr->himlInt);
4506 /* delete default font */
4508 DeleteObject (infoPtr->hDefaultFont);
4510 /* free toolbar info data */
4511 COMCTL32_Free (infoPtr);
4512 SetWindowLongA (hwnd, 0, 0);
4519 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
4521 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4522 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4523 NMTBCUSTOMDRAW tbcd;
4527 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4528 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4529 tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
4530 tbcd.nmcd.hdc = (HDC)wParam;
4531 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4532 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4534 /* FIXME: in general the return flags *can* be or'ed together */
4535 switch (infoPtr->dwBaseCustDraw)
4537 case CDRF_DODEFAULT:
4539 case CDRF_SKIPDEFAULT:
4542 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4547 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4548 * to my parent for processing.
4550 if (infoPtr->bTransparent) {
4552 HDC hdc = (HDC)wParam;
4557 parent = GetParent(hwnd);
4558 MapWindowPoints(hwnd, parent, &pt, 1);
4559 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
4560 ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
4561 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
4564 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
4566 if ((dwStyle & TBSTYLE_CUSTOMERASE) &&
4567 (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) {
4568 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4569 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
4570 tbcd.nmcd.hdc = (HDC)wParam;
4571 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4572 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4573 switch (infoPtr->dwBaseCustDraw)
4575 case CDRF_DODEFAULT:
4577 case CDRF_SKIPDEFAULT:
4580 FIXME("[%04x] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4589 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
4591 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4593 return infoPtr->hFont;
4598 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
4600 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4601 TBUTTON_INFO *btnPtr;
4605 pt.x = (INT)LOWORD(lParam);
4606 pt.y = (INT)HIWORD(lParam);
4607 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4610 btnPtr = &infoPtr->buttons[nHit];
4611 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4614 infoPtr->bCaptured = TRUE;
4615 infoPtr->nButtonDown = nHit;
4617 btnPtr->fsState |= TBSTATE_PRESSED;
4619 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4622 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
4623 TOOLBAR_Customize (hwnd);
4630 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
4632 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4633 TBUTTON_INFO *btnPtr;
4638 if (infoPtr->hwndToolTip)
4639 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4640 WM_LBUTTONDOWN, wParam, lParam);
4642 pt.x = (INT)LOWORD(lParam);
4643 pt.y = (INT)HIWORD(lParam);
4644 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4648 btnPtr = &infoPtr->buttons[nHit];
4649 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4652 infoPtr->nOldHit = nHit;
4654 CopyRect(&arrowRect, &btnPtr->rect);
4655 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
4657 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4658 if ((btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
4659 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
4660 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
4664 * this time we must force a Redraw, so the btn is
4665 * painted down before CaptureChanged repaints it up
4667 RedrawWindow(hwnd,&btnPtr->rect,0,
4668 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
4670 nmtb.iItem = btnPtr->idCommand;
4671 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
4674 memset(&nmtb.rcButton, 0, sizeof(RECT));
4675 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4677 if (res != TBDDRET_TREATPRESSED)
4678 /* ??? guess (GA) */
4680 /* otherwise drop through and process as pushed */
4682 /* SetCapture (hwnd); */
4683 infoPtr->bCaptured = TRUE;
4684 infoPtr->nButtonDown = nHit;
4686 btnPtr->fsState |= TBSTATE_PRESSED;
4687 btnPtr->bHot = FALSE;
4689 InvalidateRect(hwnd, &btnPtr->rect,
4690 TOOLBAR_HasText(infoPtr, btnPtr));
4694 /* native issues the TBN_BEGINDRAG here */
4695 nmtb.iItem = btnPtr->idCommand;
4696 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4697 nmtb.tbButton.idCommand = btnPtr->idCommand;
4698 nmtb.tbButton.fsState = btnPtr->fsState;
4699 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4700 nmtb.tbButton.dwData = btnPtr->dwData;
4701 nmtb.tbButton.iString = btnPtr->iString;
4702 nmtb.cchText = 0; /* !!! not correct */
4703 nmtb.pszText = 0; /* !!! not correct */
4704 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4712 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
4714 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4715 TBUTTON_INFO *btnPtr;
4719 BOOL bSendMessage = TRUE;
4724 if (infoPtr->hwndToolTip)
4725 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4726 WM_LBUTTONUP, wParam, lParam);
4728 pt.x = (INT)LOWORD(lParam);
4729 pt.y = (INT)HIWORD(lParam);
4730 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4732 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
4733 /* if the cursor is still inside of the toolbar */
4734 if((infoPtr->nHotItem >= 0) && (nHit != -1))
4735 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
4737 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4738 btnPtr->fsState &= ~TBSTATE_PRESSED;
4740 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
4741 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
4742 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
4744 if (nOldIndex == nHit)
4745 bSendMessage = FALSE;
4746 if ((nOldIndex != nHit) &&
4748 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
4749 btnPtr->fsState |= TBSTATE_CHECKED;
4752 if (btnPtr->fsState & TBSTATE_CHECKED)
4753 btnPtr->fsState &= ~TBSTATE_CHECKED;
4755 btnPtr->fsState |= TBSTATE_CHECKED;
4759 if (nOldIndex != -1)
4761 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
4762 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
4766 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
4767 * that resets bCaptured and btn TBSTATE_PRESSED flags,
4768 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
4770 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
4773 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
4774 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
4775 NM_RELEASEDCAPTURE);
4777 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
4780 nmtb.iItem = btnPtr->idCommand;
4781 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4782 nmtb.tbButton.idCommand = btnPtr->idCommand;
4783 nmtb.tbButton.fsState = btnPtr->fsState;
4784 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4785 nmtb.tbButton.dwData = btnPtr->dwData;
4786 nmtb.tbButton.iString = btnPtr->iString;
4787 nmtb.cchText = 0; /* !!! not correct */
4788 nmtb.pszText = 0; /* !!! not correct */
4789 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4792 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
4793 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
4795 /* !!! Undocumented - toolbar at 4.71 level and above sends
4796 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
4797 * Only NM_RCLICK is documented.
4799 nmmouse.dwItemSpec = btnPtr->idCommand;
4800 nmmouse.dwItemData = btnPtr->dwData;
4801 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr,
4807 TOOLBAR_CaptureChanged(HWND hwnd)
4809 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4810 TBUTTON_INFO *btnPtr;
4812 infoPtr->bCaptured = FALSE;
4814 if (infoPtr->nButtonDown >= 0)
4816 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4817 btnPtr->fsState &= ~TBSTATE_PRESSED;
4819 infoPtr->nButtonDown = -1;
4820 infoPtr->nOldHit = -1;
4822 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4829 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
4831 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4832 TBUTTON_INFO *hotBtnPtr, *btnPtr;
4835 if (infoPtr->nOldHit < 0)
4838 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
4840 /* Redraw the button if the last button we were over is the hot button and it
4842 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
4844 hotBtnPtr->bHot = FALSE;
4845 rc1 = hotBtnPtr->rect;
4846 InflateRect (&rc1, 1, 1);
4847 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
4851 /* If the last button we were over is depressed then make it not */
4852 /* depressed and redraw it */
4853 if(infoPtr->nOldHit == infoPtr->nButtonDown)
4855 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4857 btnPtr->fsState &= ~TBSTATE_PRESSED;
4859 rc1 = hotBtnPtr->rect;
4860 InflateRect (&rc1, 1, 1);
4861 InvalidateRect (hwnd, &rc1, TRUE);
4864 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
4865 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4871 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
4873 TBUTTON_INFO *btnPtr, *oldBtnPtr;
4874 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4877 TRACKMOUSEEVENT trackinfo;
4879 /* fill in the TRACKMOUSEEVENT struct */
4880 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
4881 trackinfo.dwFlags = TME_QUERY;
4882 trackinfo.hwndTrack = hwnd;
4883 trackinfo.dwHoverTime = HOVER_DEFAULT;
4885 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
4886 _TrackMouseEvent(&trackinfo);
4888 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
4889 if(!(trackinfo.dwFlags & TME_LEAVE)) {
4890 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
4892 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
4893 /* and can properly deactivate the hot toolbar button */
4894 _TrackMouseEvent(&trackinfo);
4897 if (infoPtr->hwndToolTip)
4898 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4899 WM_MOUSEMOVE, wParam, lParam);
4901 pt.x = (INT)LOWORD(lParam);
4902 pt.y = (INT)HIWORD(lParam);
4904 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4906 if (infoPtr->nOldHit != nHit)
4908 /* Remove the effect of an old hot button if the button was enabled and was
4909 drawn with the hot button effect */
4910 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
4911 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
4913 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
4914 oldBtnPtr->bHot = FALSE;
4916 InvalidateRect (hwnd, &oldBtnPtr->rect,
4917 TOOLBAR_HasText(infoPtr, oldBtnPtr));
4920 /* It's not a separator or in nowhere. It's a hot button. */
4923 btnPtr = &infoPtr->buttons[nHit];
4925 infoPtr->nHotItem = nHit;
4927 /* only enabled buttons show hot effect */
4928 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
4930 btnPtr->bHot = TRUE;
4931 InvalidateRect(hwnd, &btnPtr->rect,
4932 TOOLBAR_HasText(infoPtr, btnPtr));
4937 if (infoPtr->bCaptured) {
4938 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4939 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
4940 btnPtr->fsState &= ~TBSTATE_PRESSED;
4941 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
4943 else if (nHit == infoPtr->nButtonDown) {
4944 btnPtr->fsState |= TBSTATE_PRESSED;
4945 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
4948 infoPtr->nOldHit = nHit;
4954 inline static LRESULT
4955 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4957 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
4958 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
4960 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
4964 inline static LRESULT
4965 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
4967 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
4968 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
4970 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
4975 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
4977 TOOLBAR_INFO *infoPtr;
4978 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
4981 /* allocate memory for info structure */
4982 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
4983 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
4986 infoPtr->dwStructSize = sizeof(TBBUTTON);
4988 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
4989 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
4990 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
4991 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
4994 /* native control does:
4995 * Get a lot of colors and brushes
4997 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
4998 * CreateFontIndirectA(adr1)
4999 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5000 * hdc = GetDC(toolbar)
5001 * GetSystemMetrics(0x48)
5002 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5003 * 0, 0, 0, 0, "MARLETT")
5004 * oldfnt = SelectObject(hdc, fnt2)
5005 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5006 * GetTextMetricsA(hdc, adr3)
5007 * SelectObject(hdc, oldfnt)
5008 * DeleteObject(fnt2)
5010 * InvalidateRect(toolbar, 0, 1)
5011 * SetWindowLongA(toolbar, 0, addr)
5012 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5015 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5016 * ie 2 0x4600094c 0x4600094c 0x4600894d
5017 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5018 * rebar 0x50008844 0x40008844 0x50008845
5019 * pager 0x50000844 0x40000844 0x50008845
5020 * IC35mgr 0x5400084e **nochange**
5021 * on entry to _NCCREATE 0x5400084e
5022 * rowlist 0x5400004e **nochange**
5023 * on entry to _NCCREATE 0x5400004e
5027 /* I think the code below is a bug, but it is the way that the native
5028 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5029 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5030 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5031 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5032 * Some how, the only cases of this seem to be MFC programs.
5034 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5035 * does not occur in the WM_STYLECHANGING routine.
5036 * (Guy Albertelli 9/2001)
5039 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
5040 styleadd |= TBSTYLE_TRANSPARENT;
5041 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
5042 styleadd |= CCS_TOP; /* default to top */
5043 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
5046 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
5051 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
5053 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5057 if (dwStyle & WS_MINIMIZE)
5058 return 0; /* Nothing to do */
5060 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
5062 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
5065 if (!(dwStyle & CCS_NODIVIDER))
5067 GetWindowRect (hwnd, &rcWindow);
5068 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
5069 if( dwStyle & WS_BORDER )
5070 OffsetRect (&rcWindow, 1, 1);
5071 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
5074 ReleaseDC( hwnd, hdc );
5080 inline static LRESULT
5081 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
5083 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5084 LPNMHDR lpnmh = (LPNMHDR)lParam;
5086 if (lpnmh->code == PGN_CALCSIZE) {
5087 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
5089 if (lppgc->dwFlag == PGF_CALCWIDTH) {
5090 lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
5091 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5095 lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
5096 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5103 TRACE("passing WM_NOTIFY!\n");
5105 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
5106 if (infoPtr->bNtfUnicode)
5107 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
5110 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
5114 if (lpnmh->code == TTN_GETDISPINFOA) {
5115 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
5117 FIXME("retrieving ASCII string\n");
5120 else if (lpnmh->code == TTN_GETDISPINFOW) {
5121 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
5123 FIXME("retrieving UNICODE string\n");
5134 TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
5136 /* remove this routine when Toolbar is improved to pass infoPtr
5137 * around instead of hwnd.
5139 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5140 return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
5145 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
5149 if (lParam == NF_REQUERY) {
5150 i = SendMessageA(GetParent(infoPtr->hwndSelf),
5151 WM_NOTIFYFORMAT, infoPtr->hwndSelf, NF_QUERY);
5152 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
5153 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5157 infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
5160 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
5165 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
5167 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5171 /* fill ps.rcPaint with a default rect */
5172 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
5174 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
5176 TRACE("psrect=(%d,%d)-(%d,%d)\n",
5177 ps.rcPaint.left, ps.rcPaint.top,
5178 ps.rcPaint.right, ps.rcPaint.bottom);
5180 TOOLBAR_Refresh (hwnd, hdc, &ps);
5181 if (!wParam) EndPaint (hwnd, &ps);
5188 TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
5189 /*****************************************************
5192 * Handles the WM_SETREDRAW message.
5195 * According to testing V4.71 of COMCTL32 returns the
5196 * *previous* status of the redraw flag (either 0 or 1)
5197 * instead of the MSDN documented value of 0 if handled.
5198 * (For laughs see the "consistancy" with same function
5201 *****************************************************/
5203 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5204 BOOL oldredraw = infoPtr->bDoRedraw;
5206 TRACE("set to %s\n",
5207 (wParam) ? "TRUE" : "FALSE");
5208 infoPtr->bDoRedraw = (BOOL) wParam;
5210 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
5212 return (oldredraw) ? 1 : 0;
5217 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
5219 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5220 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5229 /* Resize deadlock check */
5230 if (infoPtr->bAutoSize) {
5231 infoPtr->bAutoSize = FALSE;
5235 /* FIXME: optimize to only update size if the new size doesn't */
5236 /* match the current size */
5238 flags = (INT) wParam;
5240 /* FIXME for flags =
5241 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5244 TRACE("sizing toolbar!\n");
5246 if (flags == SIZE_RESTORED) {
5247 /* width and height don't apply */
5248 parent = GetParent (hwnd);
5249 GetClientRect(parent, &parent_rect);
5250 x = parent_rect.left;
5251 y = parent_rect.top;
5253 if (dwStyle & CCS_NORESIZE) {
5254 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
5257 * this sets the working width of the toolbar, and
5258 * Calc Toolbar will not adjust it, only the height
5260 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5261 cy = infoPtr->nHeight;
5262 cx = infoPtr->nWidth;
5263 TOOLBAR_CalcToolbar (hwnd);
5264 infoPtr->nWidth = cx;
5265 infoPtr->nHeight = cy;
5268 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5269 TOOLBAR_CalcToolbar (hwnd);
5270 cy = infoPtr->nHeight;
5271 cx = infoPtr->nWidth;
5273 if (dwStyle & CCS_NOMOVEY) {
5274 GetWindowRect(hwnd, &window_rect);
5275 ScreenToClient(parent, (LPPOINT)&window_rect.left);
5276 y = window_rect.top;
5280 if (dwStyle & CCS_NOPARENTALIGN) {
5281 uPosFlags |= SWP_NOMOVE;
5282 cy = infoPtr->nHeight;
5283 cx = infoPtr->nWidth;
5286 if (!(dwStyle & CCS_NODIVIDER))
5287 cy += GetSystemMetrics(SM_CYEDGE);
5289 if (dwStyle & WS_BORDER)
5292 cy += GetSystemMetrics(SM_CYEDGE);
5293 cx += GetSystemMetrics(SM_CYEDGE);
5296 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
5297 cx, cy, uPosFlags | SWP_NOZORDER);
5304 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
5306 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5308 if (nType == GWL_STYLE) {
5309 if (lpStyle->styleNew & TBSTYLE_LIST) {
5310 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
5313 infoPtr->dwDTFlags = DT_CENTER;
5315 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
5316 infoPtr->bBtnTranspnt = (lpStyle->styleNew &
5317 (TBSTYLE_FLAT | TBSTYLE_LIST));
5318 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
5321 TOOLBAR_AutoSize (hwnd);
5323 InvalidateRect(hwnd, NULL, FALSE);
5330 TOOLBAR_SysColorChange (HWND hwnd)
5332 COMCTL32_RefreshSysColors();
5339 static LRESULT WINAPI
5340 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5342 TRACE("hwnd=%x msg=%x wparam=%x lparam=%lx\n",
5343 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
5345 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
5346 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
5351 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
5353 case TB_ADDBUTTONSA:
5354 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
5356 case TB_ADDBUTTONSW:
5357 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
5360 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
5363 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
5366 return TOOLBAR_AutoSize (hwnd);
5368 case TB_BUTTONCOUNT:
5369 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
5371 case TB_BUTTONSTRUCTSIZE:
5372 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
5374 case TB_CHANGEBITMAP:
5375 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
5377 case TB_CHECKBUTTON:
5378 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
5380 case TB_COMMANDTOINDEX:
5381 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
5384 return TOOLBAR_Customize (hwnd);
5386 case TB_DELETEBUTTON:
5387 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
5389 case TB_ENABLEBUTTON:
5390 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
5392 case TB_GETANCHORHIGHLIGHT:
5393 return TOOLBAR_GetAnchorHighlight (hwnd);
5396 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
5398 case TB_GETBITMAPFLAGS:
5399 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
5402 return TOOLBAR_GetButton (hwnd, wParam, lParam);
5404 case TB_GETBUTTONINFOA:
5405 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
5407 case TB_GETBUTTONINFOW:
5408 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
5410 case TB_GETBUTTONSIZE:
5411 return TOOLBAR_GetButtonSize (hwnd);
5413 case TB_GETBUTTONTEXTA:
5414 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
5416 case TB_GETBUTTONTEXTW:
5417 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
5419 case TB_GETDISABLEDIMAGELIST:
5420 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
5422 case TB_GETEXTENDEDSTYLE:
5423 return TOOLBAR_GetExtendedStyle (hwnd);
5425 case TB_GETHOTIMAGELIST:
5426 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
5429 return TOOLBAR_GetHotItem (hwnd);
5431 case TB_GETIMAGELIST:
5432 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
5434 /* case TB_GETINSERTMARK: */ /* 4.71 */
5435 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5437 case TB_GETITEMRECT:
5438 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
5441 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
5443 /* case TB_GETOBJECT: */ /* 4.71 */
5446 return TOOLBAR_GetPadding (hwnd);
5449 return TOOLBAR_GetRect (hwnd, wParam, lParam);
5452 return TOOLBAR_GetRows (hwnd, wParam, lParam);
5455 return TOOLBAR_GetState (hwnd, wParam, lParam);
5458 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
5460 case TB_GETTEXTROWS:
5461 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
5463 case TB_GETTOOLTIPS:
5464 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
5466 case TB_GETUNICODEFORMAT:
5467 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
5470 return TOOLBAR_HideButton (hwnd, wParam, lParam);
5473 return TOOLBAR_HitTest (hwnd, wParam, lParam);
5475 case TB_INDETERMINATE:
5476 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
5478 case TB_INSERTBUTTONA:
5479 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
5481 case TB_INSERTBUTTONW:
5482 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
5484 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5486 case TB_ISBUTTONCHECKED:
5487 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
5489 case TB_ISBUTTONENABLED:
5490 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
5492 case TB_ISBUTTONHIDDEN:
5493 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
5495 case TB_ISBUTTONHIGHLIGHTED:
5496 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
5498 case TB_ISBUTTONINDETERMINATE:
5499 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
5501 case TB_ISBUTTONPRESSED:
5502 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
5504 case TB_LOADIMAGES: /* 4.70 */
5505 FIXME("missing standard imagelists\n");
5508 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5509 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5510 /* case TB_MARKBUTTON: */ /* 4.71 */
5511 /* case TB_MOVEBUTTON: */ /* 4.71 */
5513 case TB_PRESSBUTTON:
5514 return TOOLBAR_PressButton (hwnd, wParam, lParam);
5516 /* case TB_REPLACEBITMAP: */
5518 case TB_SAVERESTOREA:
5519 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
5521 case TB_SAVERESTOREW:
5522 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
5524 case TB_SETANCHORHIGHLIGHT:
5525 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
5527 case TB_SETBITMAPSIZE:
5528 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
5530 case TB_SETBUTTONINFOA:
5531 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
5533 case TB_SETBUTTONINFOW:
5534 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
5536 case TB_SETBUTTONSIZE:
5537 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
5539 case TB_SETBUTTONWIDTH:
5540 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
5543 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
5545 case TB_SETDISABLEDIMAGELIST:
5546 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
5548 case TB_SETDRAWTEXTFLAGS:
5549 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
5551 case TB_SETEXTENDEDSTYLE:
5552 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
5554 case TB_SETHOTIMAGELIST:
5555 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
5558 return TOOLBAR_SetHotItem (hwnd, wParam);
5560 case TB_SETIMAGELIST:
5561 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
5564 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
5566 /* case TB_SETINSERTMARK: */ /* 4.71 */
5568 case TB_SETINSERTMARKCOLOR:
5569 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
5571 case TB_SETMAXTEXTROWS:
5572 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
5575 return TOOLBAR_SetPadding (hwnd, wParam, lParam);
5578 return TOOLBAR_SetParent (hwnd, wParam, lParam);
5581 return TOOLBAR_SetRows (hwnd, wParam, lParam);
5584 return TOOLBAR_SetState (hwnd, wParam, lParam);
5587 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
5589 case TB_SETTOOLTIPS:
5590 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
5592 case TB_SETUNICODEFORMAT:
5593 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
5596 return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
5599 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
5602 /* Common Control Messages */
5604 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
5605 case CCM_GETCOLORSCHEME:
5606 return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5608 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
5609 case CCM_SETCOLORSCHEME:
5610 return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5612 case CCM_GETVERSION:
5613 return TOOLBAR_GetVersion (hwnd);
5615 case CCM_SETVERSION:
5616 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
5622 return TOOLBAR_Create (hwnd, wParam, lParam);
5625 return TOOLBAR_Destroy (hwnd, wParam, lParam);
5628 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
5631 return TOOLBAR_GetFont (hwnd, wParam, lParam);
5633 /* case WM_KEYDOWN: */
5634 /* case WM_KILLFOCUS: */
5636 case WM_LBUTTONDBLCLK:
5637 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
5639 case WM_LBUTTONDOWN:
5640 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
5643 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
5646 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
5649 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
5651 case WM_CAPTURECHANGED:
5652 return TOOLBAR_CaptureChanged(hwnd);
5655 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
5658 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
5661 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
5664 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
5667 return TOOLBAR_Notify (hwnd, wParam, lParam);
5669 case WM_NOTIFYFORMAT:
5670 TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
5673 return TOOLBAR_Paint (hwnd, wParam);
5676 return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
5679 return TOOLBAR_Size (hwnd, wParam, lParam);
5681 case WM_STYLECHANGED:
5682 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
5684 case WM_SYSCOLORCHANGE:
5685 return TOOLBAR_SysColorChange (hwnd);
5687 /* case WM_WININICHANGE: */
5692 case WM_MEASUREITEM:
5695 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5697 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
5699 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
5702 /* We see this in Outlook Express 5.x and just does DefWindowProc */
5703 case PGM_FORWARDMOUSE:
5704 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5707 if (uMsg >= WM_USER)
5708 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
5709 uMsg, wParam, lParam);
5710 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5717 TOOLBAR_Register (void)
5721 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
5722 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
5723 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
5724 wndClass.cbClsExtra = 0;
5725 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
5726 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
5727 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
5728 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
5730 RegisterClassA (&wndClass);
5735 TOOLBAR_Unregister (void)
5737 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);