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"
71 #include "wine/debug.h"
73 WINE_DEFAULT_DEBUG_CHANNEL(toolbar);
100 } IMLENTRY, *PIMLENTRY;
104 DWORD dwStructSize; /* size of TBBUTTON struct */
105 INT nHeight; /* height of the toolbar */
106 INT nWidth; /* width of the toolbar */
112 INT nRows; /* number of button rows */
113 INT nMaxTextRows; /* maximum number of text rows */
114 INT cxMin; /* minimum button width */
115 INT cxMax; /* maximum button width */
116 INT nNumButtons; /* number of buttons */
117 INT nNumBitmaps; /* number of bitmaps */
118 INT nNumStrings; /* number of strings */
120 BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
121 BOOL bCaptured; /* mouse captured? */
124 INT nHotItem; /* index of the "hot" item */
125 DWORD dwBaseCustDraw; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
126 DWORD dwItemCustDraw; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
127 DWORD dwItemCDFlag; /* TBCDRF_ flags from last ITEMPREPAINT */
128 SIZE szPadding; /* padding values around button */
130 HFONT hFont; /* text font */
131 HIMAGELIST himlInt; /* image list created internally */
132 PIMLENTRY *himlDef; /* default image list array */
133 INT cimlDef; /* default image list array count */
134 PIMLENTRY *himlHot; /* hot image list array */
135 INT cimlHot; /* hot image list array count */
136 PIMLENTRY *himlDis; /* disabled image list array */
137 INT cimlDis; /* disabled image list array count */
138 HWND hwndToolTip; /* handle to tool tip control */
139 HWND hwndNotify; /* handle to the window that gets notifications */
140 HWND hwndSelf; /* my own handle */
141 BOOL bTransparent; /* background transparency flag */
142 BOOL bBtnTranspnt; /* button transparency flag */
143 BOOL bAutoSize; /* auto size deadlock indicator */
144 BOOL bAnchor; /* anchor highlight enabled */
145 BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
146 BOOL bDoRedraw; /* Redraw status */
147 DWORD dwExStyle; /* extended toolbar style */
148 DWORD dwDTFlags; /* DrawText flags */
150 COLORREF clrInsertMark; /* insert mark color */
151 COLORREF clrBtnHighlight; /* color for Flat Separator */
152 COLORREF clrBtnShadow; /* color for Flag Separator */
153 RECT rcBound; /* bounding rectangle */
156 TBUTTON_INFO *buttons; /* pointer to button array */
157 LPWSTR *strings; /* pointer to string array */
158 TBITMAP_INFO *bitmaps;
159 } TOOLBAR_INFO, *PTOOLBAR_INFO;
162 /* used by customization dialog */
165 PTOOLBAR_INFO tbInfo;
167 } CUSTDLG_INFO, *PCUSTDLG_INFO;
175 } CUSTOMBUTTON, *PCUSTOMBUTTON;
178 #define SEPARATOR_WIDTH 8
180 #define BOTTOM_BORDER 2
181 #define DDARROW_WIDTH 11
183 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
184 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
185 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
187 /* Used to find undocumented extended styles */
188 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
189 TBSTYLE_EX_UNDOC1 | \
190 TBSTYLE_EX_MIXEDBUTTONS | \
191 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
193 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
194 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
195 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
196 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
197 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
199 static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb);
200 static BOOL TOOLBAR_IsButtonRemovable(TOOLBAR_INFO *infoPtr, int iItem, PCUSTOMBUTTON btnInfo);
201 static HIMAGELIST TOOLBAR_GetImageList(PIMLENTRY *pies, INT cies, INT id);
202 static PIMLENTRY TOOLBAR_GetImageListEntry(PIMLENTRY *pies, INT cies, INT id);
203 static VOID TOOLBAR_DeleteImageList(PIMLENTRY **pies, INT *cies);
204 static HIMAGELIST TOOLBAR_InsertImageList(PIMLENTRY **pies, INT *cies, HIMAGELIST himl, INT id);
207 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
211 TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
213 LPWSTR lpText = NULL;
215 /* FIXME: iString == -1 is undocumented */
216 if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
217 lpText = (LPWSTR)btnPtr->iString;
218 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
219 lpText = infoPtr->strings[btnPtr->iString];
225 TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
227 if (TRACE_ON(toolbar)){
228 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
229 btn_num, bP->idCommand, GETIBITMAP(infoPtr, bP->iBitmap),
230 bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
231 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr,bP)));
233 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
234 btn_num, bP->idCommand,
235 (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
236 bP->rect.left, bP->rect.top,
237 bP->rect.right, bP->rect.bottom);
243 TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
245 if (TRACE_ON(toolbar)) {
249 dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
250 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
252 iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
253 iP->nNumStrings, dwStyle);
254 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
256 iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
257 (iP->bDoRedraw) ? "TRUE" : "FALSE");
258 for(i=0; i<iP->nNumButtons; i++) {
259 TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
265 /***********************************************************************
268 * This function validates that the styles set are implemented and
269 * issues FIXME's warning of possible problems. In a perfect world this
270 * function should be null.
273 TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
275 if (dwStyle & TBSTYLE_ALTDRAG)
276 FIXME("[%p] TBSTYLE_ALTDRAG not implemented\n", hwnd);
277 if (dwStyle & TBSTYLE_REGISTERDROP)
278 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
283 TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
285 if(!IsWindow(infoPtr->hwndSelf))
286 return 0; /* we have just been destroyed */
288 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
289 nmhdr->hwndFrom = infoPtr->hwndSelf;
292 TRACE("to window %p, code=%08x, %s\n", infoPtr->hwndNotify, code,
293 (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
295 if (infoPtr->bNtfUnicode)
296 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
297 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
299 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
300 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
303 /***********************************************************************
304 * TOOLBAR_GetBitmapIndex
306 * This function returns the bitmap index associated with a button.
307 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
308 * is issued to retrieve the index.
311 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
313 INT ret = btnPtr->iBitmap;
315 if (ret == I_IMAGECALLBACK) {
316 /* issue TBN_GETDISPINFO */
319 nmgd.idCommand = btnPtr->idCommand;
320 nmgd.lParam = btnPtr->dwData;
321 nmgd.dwMask = TBNF_IMAGE;
322 TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
323 (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
325 if (nmgd.dwMask & TBNF_DI_SETITEM) {
326 btnPtr->iBitmap = nmgd.iImage;
329 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
330 ret, nmgd.dwMask, infoPtr->nNumBitmaps);
333 if (ret != I_IMAGENONE)
334 ret = GETIBITMAP(infoPtr, ret);
341 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
344 INT id = GETHIMLID(infoPtr, index);
345 INT iBitmap = GETIBITMAP(infoPtr, index);
347 if (((himl = GETDEFIMAGELIST(infoPtr, id)) &&
348 iBitmap >= 0 && iBitmap < ImageList_GetImageCount(himl)) ||
349 (index == I_IMAGECALLBACK))
356 /***********************************************************************
357 * TOOLBAR_DrawImageList
359 * This function validates the bitmap index (including I_IMAGECALLBACK
360 * functionality). It then draws the image via the ImageList_Draw
361 * function. It returns TRUE if the image was drawn, FALSE otherwise.
364 TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl,
365 HDC hdc, UINT left, UINT top, UINT draw_flags)
369 if (!himl) return FALSE;
371 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
372 if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
373 ERR("index %d is not valid, max %d\n",
374 btnPtr->iBitmap, infoPtr->nNumBitmaps);
378 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
379 if ((index == I_IMAGECALLBACK) ||
380 (index == I_IMAGENONE)) return FALSE;
381 ERR("TBN_GETDISPINFO returned invalid index %d\n",
385 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
386 index, himl, left, top, draw_flags);
388 ImageList_Draw (himl, index, hdc, left, top, draw_flags);
393 /***********************************************************************
394 * TOOLBAR_TestImageExist
396 * This function is similar to TOOLBAR_DrawImageList, except it does not
397 * draw the image. The I_IMAGECALLBACK functionality is implemented.
400 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
404 if (!himl) return FALSE;
406 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
407 if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
408 ERR("index %d is not valid, max %d\n",
409 btnPtr->iBitmap, infoPtr->nNumBitmaps);
413 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
414 if ((index == I_IMAGECALLBACK) ||
415 (index == I_IMAGENONE)) return FALSE;
416 ERR("TBN_GETDISPINFO returned invalid index %d\n",
425 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr)
428 COLORREF oldcolor, newcolor;
430 myrect.left = (lpRect->left + lpRect->right) / 2 - 1;
431 myrect.right = myrect.left + 1;
432 myrect.top = lpRect->top + 2;
433 myrect.bottom = lpRect->bottom - 2;
435 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
436 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
437 oldcolor = SetBkColor (hdc, newcolor);
438 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
440 myrect.left = myrect.right;
441 myrect.right = myrect.left + 1;
443 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
444 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
445 SetBkColor (hdc, newcolor);
446 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
448 SetBkColor (hdc, oldcolor);
452 /***********************************************************************
453 * TOOLBAR_DrawDDFlatSeparator
455 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
456 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
457 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
458 * are horizontal as opposed to the vertical separators for not dropdown
461 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
464 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLBAR_INFO *infoPtr)
467 COLORREF oldcolor, newcolor;
469 myrect.left = lpRect->left;
470 myrect.right = lpRect->right;
471 myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
472 myrect.bottom = myrect.top + 1;
474 InflateRect (&myrect, -2, 0);
476 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
477 myrect.left, myrect.top, myrect.right, myrect.bottom);
479 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
480 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
481 oldcolor = SetBkColor (hdc, newcolor);
482 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
484 myrect.top = myrect.bottom;
485 myrect.bottom = myrect.top + 1;
487 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
488 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
489 SetBkColor (hdc, newcolor);
490 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
492 SetBkColor (hdc, oldcolor);
497 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
502 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
503 hOldPen = SelectObject ( hdc, hPen );
506 MoveToEx (hdc, x, y, NULL);
507 LineTo (hdc, x+5, y++); x++;
508 MoveToEx (hdc, x, y, NULL);
509 LineTo (hdc, x+3, y++); x++;
510 MoveToEx (hdc, x, y, NULL);
511 LineTo (hdc, x+1, y++);
512 SelectObject( hdc, hOldPen );
513 DeleteObject( hPen );
517 * Draw the text string for this button.
518 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
519 * is non-zero, so we can simply check himlDef to see if we have
523 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
524 HDC hdc, INT nState, DWORD dwStyle,
525 RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd)
532 TRACE("string rect=(%ld,%ld)-(%ld,%ld)\n",
533 rcText->left, rcText->top, rcText->right, rcText->bottom);
535 hOldFont = SelectObject (hdc, infoPtr->hFont);
536 if (!(nState & TBSTATE_ENABLED)) {
537 clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight);
538 OffsetRect (rcText, 1, 1);
539 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
540 SetTextColor (hdc, comctl32_color.clr3dShadow);
541 OffsetRect (rcText, -1, -1);
543 else if (nState & TBSTATE_INDETERMINATE) {
544 clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
546 else if (btnPtr->bHot && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
547 clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
550 clrOld = SetTextColor (hdc, tbcd->clrText);
553 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
554 SetTextColor (hdc, clrOld);
555 SelectObject (hdc, hOldFont);
561 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
563 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
564 INT cx = lpRect->right - lpRect->left;
565 INT cy = lpRect->bottom - lpRect->top;
566 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
567 SelectObject (hdc, hbr);
572 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
573 HDC hdc, INT x, INT y)
575 HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, 0);
583 ImageList_GetIconSize(himl, &cx, &cy);
585 /* create new dc's */
586 hdcMask = CreateCompatibleDC (0);
588 /* create new bitmap */
589 hbmMask = CreateBitmap (cx, cy, 1, 1, NULL);
590 SelectObject (hdcMask, hbmMask);
592 /* copy the mask bitmap */
593 ImageList_DrawEx(himl, btnPtr->iBitmap, hdcMask, 0, 0, 0, 0, RGB(255, 255, 255), RGB(0, 0, 0), ILD_MASK);
595 /* draw the new mask */
596 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
597 BitBlt (hdc, x+1, y+1, cx, cy, hdcMask, 0, 0, 0xB8074A);
599 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
600 BitBlt (hdc, x, y, cx, cy, hdcMask, 0, 0, 0xB8074A);
602 DeleteObject (hbmMask);
608 TOOLBAR_TranslateState(TBUTTON_INFO *btnPtr)
612 retstate |= (btnPtr->fsState & TBSTATE_CHECKED) ? CDIS_CHECKED : 0;
613 retstate |= (btnPtr->fsState & TBSTATE_PRESSED) ? CDIS_SELECTED : 0;
614 retstate |= (btnPtr->fsState & TBSTATE_ENABLED) ? 0 : CDIS_DISABLED;
615 retstate |= (btnPtr->fsState & TBSTATE_MARKED ) ? CDIS_MARKED : 0;
616 retstate |= (btnPtr->bHot ) ? CDIS_HOT : 0;
617 retstate |= (btnPtr->fsState & TBSTATE_INDETERMINATE) ? CDIS_INDETERMINATE : 0;
618 /* FIXME: don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
619 /* don't test TBSTATE_HIDDEN */
625 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
627 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
628 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
629 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
630 (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
631 RECT rc, rcArrow, rcBitmap, rcText, rcFill;
632 LPWSTR lpText = NULL;
638 if (btnPtr->fsState & TBSTATE_HIDDEN)
642 CopyRect (&rcFill, &rc);
643 CopyRect (&rcArrow, &rc);
644 CopyRect(&rcBitmap, &rc);
645 CopyRect(&rcText, &rc);
647 /* get a pointer to the text */
648 lpText = TOOLBAR_GetText(infoPtr, btnPtr);
650 if (hasDropDownArrow)
652 if (dwStyle & TBSTYLE_FLAT)
653 rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
655 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
656 rcArrow.left = rc.right;
659 /* Center the bitmap horizontally and vertically */
660 if (dwStyle & TBSTYLE_LIST)
663 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
666 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
668 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
670 TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
671 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
672 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
673 TRACE ("iString: %x\n", btnPtr->iString);
674 TRACE ("Stringtext: %s\n", debugstr_w(lpText));
679 InflateRect (&rcText, -3, -3);
681 if (GETDEFIMAGELIST(infoPtr, 0) &&
682 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
683 /* The following test looked like this before
684 * I changed it. IE4 "Links" toolbar would not
685 * draw correctly with the original code. - GA 8/01
686 * ((dwStyle & TBSTYLE_LIST) &&
687 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
688 * (btnPtr->iBitmap != I_IMAGENONE))
690 if (dwStyle & TBSTYLE_LIST) {
691 /* LIST style w/ ICON offset is by matching native. */
692 /* Matches IE4 "Links" bar. - GA 8/01 */
693 rcText.left += (infoPtr->nBitmapWidth + 2);
696 rcText.top += infoPtr->nBitmapHeight + 1;
700 if (dwStyle & TBSTYLE_LIST) {
701 /* LIST style w/o ICON offset is by matching native. */
702 /* Matches IE4 "menu" bar. - GA 8/01 */
707 if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
708 OffsetRect (&rcText, 1, 1);
711 /* Initialize fields in all cases, because we use these later */
712 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
713 tbcd.clrText = comctl32_color.clrBtnText;
714 tbcd.clrTextHighlight = comctl32_color.clrHighlightText;
715 tbcd.clrBtnFace = comctl32_color.clrBtnFace;
716 tbcd.clrBtnHighlight = comctl32_color.clrBtnHighlight;
717 tbcd.clrMark = comctl32_color.clrHighlight;
718 tbcd.clrHighlightHotTrack = 0;
719 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
720 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
721 /* MSDN says that this is the text rectangle. */
722 /* But (why always a but) tracing of v5.7 of native shows */
723 /* that this is really a *relative* rectangle based on the */
724 /* the nmcd.rc. Also the left and top are always 0 ignoring*/
725 /* any bitmap that might be present. */
726 tbcd.rcText.left = 0;
728 tbcd.rcText.right = rcText.right - rc.left;
729 tbcd.rcText.bottom = rcText.bottom - rc.top;
731 /* FIXME: what should these be set to ????? */
732 tbcd.hbrMonoDither = 0;
736 /* Issue Item Prepaint notify */
737 infoPtr->dwItemCustDraw = 0;
738 infoPtr->dwItemCDFlag = 0;
739 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYITEMDRAW)
741 tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
744 tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
745 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
746 tbcd.nmcd.lItemlParam = btnPtr->dwData;
747 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
748 infoPtr->dwItemCustDraw = ntfret & 0xffff;
749 infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
750 if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT)
752 /* save the only part of the rect that the user can change */
753 rcText.right = tbcd.rcText.right + rc.left;
754 rcText.bottom = tbcd.rcText.bottom + rc.top;
757 if (!infoPtr->bBtnTranspnt)
758 FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE));
761 if (btnPtr->fsStyle & TBSTYLE_SEP) {
762 /* with the FLAT style, iBitmap is the width and has already */
763 /* been taken into consideration in calculating the width */
764 /* so now we need to draw the vertical separator */
765 /* empirical tests show that iBitmap can/will be non-zero */
766 /* when drawing the vertical bar... */
767 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
768 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
769 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
771 TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
773 else if (btnPtr->fsStyle != TBSTYLE_SEP) {
774 FIXME("Draw some kind of separator: fsStyle=%x\n",
780 /* Determine index of image list */
781 himlDef = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
784 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
785 HIMAGELIST himlDis = GETDISIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
786 if (!(dwStyle & TBSTYLE_FLAT) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
788 DrawEdge (hdc, &rc, EDGE_RAISED,
789 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
790 if (hasDropDownArrow)
791 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
792 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
795 if (hasDropDownArrow)
797 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT);
798 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW);
801 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDis,
802 hdc, rcBitmap.left, rcBitmap.top,
804 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
806 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
810 /* pressed TBSTYLE_BUTTON */
811 if (btnPtr->fsState & TBSTATE_PRESSED) {
812 offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
813 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
815 if (dwStyle & TBSTYLE_FLAT)
817 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
818 if (hasDropDownArrow)
819 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
823 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
824 if (hasDropDownArrow)
825 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
829 if (hasDropDownArrow)
830 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
832 TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
833 hdc, rcBitmap.left+offset, rcBitmap.top+offset,
836 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
840 /* checked TBSTYLE_CHECK */
841 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
842 (btnPtr->fsState & TBSTATE_CHECKED)) {
843 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
845 if (dwStyle & TBSTYLE_FLAT)
846 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
847 BF_RECT | BF_ADJUST);
849 DrawEdge (hdc, &rc, EDGE_SUNKEN,
850 BF_RECT | BF_MIDDLE | BF_ADJUST);
853 TOOLBAR_DrawPattern (hdc, &rc);
855 TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
856 hdc, rcBitmap.left+1, rcBitmap.top+1,
859 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
864 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
865 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
866 DrawEdge (hdc, &rc, EDGE_RAISED,
867 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
869 TOOLBAR_DrawPattern (hdc, &rc);
870 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
871 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
876 if (dwStyle & TBSTYLE_FLAT)
880 if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )
884 oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack);
885 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
886 if (hasDropDownArrow)
887 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
888 SetBkColor(hdc, oldclr);
892 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
894 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
895 if (hasDropDownArrow)
896 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
901 else /* The following code needs to be removed after
902 * "hot item" support has been implemented for the
903 * case where it is being de-selected.
906 FrameRect(hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
907 if (hasDropDownArrow)
908 FrameRect(hdc, &rcArrow, GetSysColorBrush(COLOR_BTNFACE));
912 if (hasDropDownArrow)
913 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top, COLOR_WINDOWFRAME);
916 HIMAGELIST himlHot = GETHOTIMAGELIST(infoPtr,
917 GETHIMLID(infoPtr, btnPtr->iBitmap));
918 /* if hot, attempt to draw with himlHot, if fails, use himlDef */
919 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
922 rcBitmap.top, ILD_NORMAL))
923 TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
924 hdc, rcBitmap.left, rcBitmap.top,
928 TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
929 hdc, rcBitmap.left, rcBitmap.top,
934 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
935 DrawEdge (hdc, &rc, EDGE_RAISED,
936 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
938 if (hasDropDownArrow)
940 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
941 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
942 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
943 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME);
946 TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
947 hdc, rcBitmap.left, rcBitmap.top,
951 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle, &rcText, lpText, &tbcd);
954 if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT)
956 tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
959 tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
960 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
961 tbcd.nmcd.lItemlParam = btnPtr->dwData;
962 tbcd.rcText = rcText;
963 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
964 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
965 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
972 TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
974 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
975 TBUTTON_INFO *btnPtr;
976 INT i, oldBKmode = 0;
981 /* if imagelist belongs to the app, it can be changed
982 by the app after setting it */
983 if (GETDEFIMAGELIST(infoPtr, 0) != infoPtr->himlInt)
985 infoPtr->nNumBitmaps = 0;
986 for (i = 0; i < infoPtr->cimlDef; i++)
987 infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl);
990 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
992 /* Send initial notify */
993 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
994 tbcd.nmcd.dwDrawStage = CDDS_PREPAINT;
996 tbcd.nmcd.rc = ps->rcPaint;
997 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
998 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
1000 if (infoPtr->bBtnTranspnt)
1001 oldBKmode = SetBkMode (hdc, TRANSPARENT);
1003 /* redraw necessary buttons */
1004 btnPtr = infoPtr->buttons;
1005 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
1007 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
1008 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1011 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
1012 SetBkMode (hdc, oldBKmode);
1014 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTPAINT)
1016 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
1017 tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT;
1018 tbcd.nmcd.hdc = hdc;
1019 tbcd.nmcd.rc = ps->rcPaint;
1020 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
1024 /***********************************************************************
1025 * TOOLBAR_MeasureString
1027 * This function gets the width and height of a string in pixels. This
1028 * is done first by using GetTextExtentPoint to get the basic width
1029 * and height. The DrawText is called with DT_CALCRECT to get the exact
1030 * width. The reason is because the text may have more than one "&" (or
1031 * prefix characters as M$ likes to call them). The prefix character
1032 * indicates where the underline goes, except for the string "&&" which
1033 * is reduced to a single "&". GetTextExtentPoint does not process these
1034 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
1037 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
1038 HDC hdc, LPSIZE lpSize)
1045 if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
1047 LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
1049 if(lpText != NULL) {
1050 /* first get size of all the text */
1051 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
1053 /* feed above size into the rectangle for DrawText */
1054 myrect.left = myrect.top = 0;
1055 myrect.right = lpSize->cx;
1056 myrect.bottom = lpSize->cy;
1058 /* Use DrawText to get true size as drawn (less pesky "&") */
1059 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
1060 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
1063 /* feed back to caller */
1064 lpSize->cx = myrect.right;
1065 lpSize->cy = myrect.bottom;
1069 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
1072 /***********************************************************************
1073 * TOOLBAR_CalcStrings
1075 * This function walks through each string and measures it and returns
1076 * the largest height and width to caller.
1079 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
1081 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1082 TBUTTON_INFO *btnPtr;
1092 hOldFont = SelectObject (hdc, infoPtr->hFont);
1094 btnPtr = infoPtr->buttons;
1095 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1096 if(TOOLBAR_HasText(infoPtr, btnPtr))
1098 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1099 if (sz.cx > lpSize->cx)
1101 if (sz.cy > lpSize->cy)
1106 SelectObject (hdc, hOldFont);
1107 ReleaseDC (hwnd, hdc);
1109 TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
1112 /***********************************************************************
1113 * TOOLBAR_WrapToolbar
1115 * This function walks through the buttons and seperators in the
1116 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1117 * wrapping should occur based on the width of the toolbar window.
1118 * It does *not* calculate button placement itself. That task
1119 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1120 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1121 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1123 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1124 * vertical toolbar lists.
1128 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
1130 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1131 TBUTTON_INFO *btnPtr;
1134 BOOL bWrap, bButtonWrap;
1136 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1137 /* no layout is necessary. Applications may use this style */
1138 /* to perform their own layout on the toolbar. */
1139 if( !(dwStyle & TBSTYLE_WRAPABLE) &&
1140 !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) ) return;
1142 btnPtr = infoPtr->buttons;
1143 x = infoPtr->nIndent;
1145 /* this can get the parents width, to know how far we can extend
1146 * this toolbar. We cannot use its height, as there may be multiple
1147 * toolbars in a rebar control
1149 GetClientRect( GetParent(hwnd), &rc );
1150 infoPtr->nWidth = rc.right - rc.left;
1151 bButtonWrap = FALSE;
1153 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1154 infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
1157 for (i = 0; i < infoPtr->nNumButtons; i++ )
1160 btnPtr[i].fsState &= ~TBSTATE_WRAP;
1162 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
1165 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1166 /* it is the actual width of the separator. This is used for */
1167 /* custom controls in toolbars. */
1169 /* TBSTYLE_DROPDOWN separators are treated as buttons for */
1170 /* width. - GA 8/01 */
1171 if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1172 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
1173 cx = (btnPtr[i].iBitmap > 0) ?
1174 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
1176 cx = infoPtr->nButtonWidth;
1178 /* Two or more adjacent separators form a separator group. */
1179 /* The first separator in a group should be wrapped to the */
1180 /* next row if the previous wrapping is on a button. */
1182 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1183 (i + 1 < infoPtr->nNumButtons ) &&
1184 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
1186 TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
1187 btnPtr[i].fsState |= TBSTATE_WRAP;
1188 x = infoPtr->nIndent;
1190 bButtonWrap = FALSE;
1194 /* The layout makes sure the bitmap is visible, but not the button. */
1195 /* Test added to also wrap after a button that starts a row but */
1196 /* is bigger than the area. - GA 8/01 */
1197 if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
1198 > infoPtr->nWidth ) ||
1199 ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
1201 BOOL bFound = FALSE;
1203 /* If the current button is a separator and not hidden, */
1204 /* go to the next until it reaches a non separator. */
1205 /* Wrap the last separator if it is before a button. */
1206 while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1207 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
1208 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
1209 i < infoPtr->nNumButtons )
1215 if( bFound && i < infoPtr->nNumButtons )
1218 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1219 i, btnPtr[i].fsStyle, x, cx);
1220 btnPtr[i].fsState |= TBSTATE_WRAP;
1221 x = infoPtr->nIndent;
1222 bButtonWrap = FALSE;
1225 else if ( i >= infoPtr->nNumButtons)
1228 /* If the current button is not a separator, find the last */
1229 /* separator and wrap it. */
1230 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1232 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
1233 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
1237 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1238 i, btnPtr[i].fsStyle, x, cx);
1239 x = infoPtr->nIndent;
1240 btnPtr[j].fsState |= TBSTATE_WRAP;
1241 bButtonWrap = FALSE;
1246 /* If no separator available for wrapping, wrap one of */
1247 /* non-hidden previous button. */
1251 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1253 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
1258 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1259 i, btnPtr[i].fsStyle, x, cx);
1260 x = infoPtr->nIndent;
1261 btnPtr[j].fsState |= TBSTATE_WRAP;
1267 /* If all above failed, wrap the current button. */
1270 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1271 i, btnPtr[i].fsStyle, x, cx);
1272 btnPtr[i].fsState |= TBSTATE_WRAP;
1274 x = infoPtr->nIndent;
1275 if (btnPtr[i].fsStyle & TBSTYLE_SEP )
1276 bButtonWrap = FALSE;
1282 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1283 i, btnPtr[i].fsStyle, x, cx);
1290 /***********************************************************************
1291 * TOOLBAR_CalcToolbar
1293 * This function calculates button and separator placement. It first
1294 * calculates the button sizes, gets the toolbar window width and then
1295 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1296 * on. It assigns a new location to each item and sends this location to
1297 * the tooltip window if appropriate. Finally, it updates the rcBound
1298 * rect and calculates the new required toolbar window height.
1302 TOOLBAR_CalcToolbar (HWND hwnd)
1304 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
1305 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1306 TBUTTON_INFO *btnPtr;
1307 INT i, nRows, nSepRows;
1311 BOOL usesBitmaps = FALSE;
1312 BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
1314 TOOLBAR_CalcStrings (hwnd, &sizeString);
1316 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
1318 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
1321 if (dwStyle & TBSTYLE_LIST)
1323 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
1324 0, sizeString.cy) + infoPtr->szPadding.cy;
1325 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
1326 0) + sizeString.cx + 6;
1327 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1328 infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
1329 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
1330 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
1333 if (sizeString.cy > 0)
1336 infoPtr->nButtonHeight = sizeString.cy +
1337 2 + /* this is the space to separate text from bitmap */
1338 infoPtr->nBitmapHeight + 6;
1340 infoPtr->nButtonHeight = sizeString.cy + 6;
1342 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
1343 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
1345 if (sizeString.cx > infoPtr->nBitmapWidth)
1346 infoPtr->nButtonWidth = sizeString.cx + 6;
1347 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
1348 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
1351 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
1352 infoPtr->nButtonWidth = infoPtr->cxMin;
1353 if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
1354 infoPtr->nButtonWidth = infoPtr->cxMax;
1356 TOOLBAR_WrapToolbar( hwnd, dwStyle );
1358 x = infoPtr->nIndent;
1362 * We will set the height below, and we set the width on entry
1363 * so we do not reset them here..
1366 GetClientRect( hwnd, &rc );
1367 /* get initial values for toolbar */
1368 infoPtr->nWidth = rc.right - rc.left;
1369 infoPtr->nHeight = rc.bottom - rc.top;
1372 /* from above, minimum is a button, and possible text */
1373 cx = infoPtr->nButtonWidth;
1375 /* cannot use just ButtonHeight, we may have no buttons! */
1376 if (infoPtr->nNumButtons > 0)
1377 infoPtr->nHeight = infoPtr->nButtonHeight;
1379 cy = infoPtr->nHeight;
1381 nRows = nSepRows = 0;
1383 infoPtr->rcBound.top = y;
1384 infoPtr->rcBound.left = x;
1385 infoPtr->rcBound.bottom = y + cy;
1386 infoPtr->rcBound.right = x;
1388 btnPtr = infoPtr->buttons;
1390 /* do not base height/width on parent, if the parent is a */
1391 /* rebar control it could have multiple rows of toolbars */
1392 /* GetClientRect( GetParent(hwnd), &rc ); */
1393 /* cx = rc.right - rc.left; */
1394 /* cy = rc.bottom - rc.top; */
1396 TRACE("cy=%d\n", cy);
1398 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
1401 if (btnPtr->fsState & TBSTATE_HIDDEN)
1403 SetRectEmpty (&btnPtr->rect);
1407 cy = infoPtr->nHeight;
1409 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1410 /* it is the actual width of the separator. This is used for */
1411 /* custom controls in toolbars. */
1412 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1413 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
1414 cy = (btnPtr->iBitmap > 0) ?
1415 btnPtr->iBitmap : SEPARATOR_WIDTH;
1416 cx = infoPtr->nButtonWidth;
1419 cx = (btnPtr->iBitmap > 0) ?
1420 btnPtr->iBitmap : SEPARATOR_WIDTH;
1424 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
1431 hOldFont = SelectObject (hdc, infoPtr->hFont);
1433 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1435 SelectObject (hdc, hOldFont);
1436 ReleaseDC (hwnd, hdc);
1438 /* Fudge amount measured against IE4 "menu" and "Links" */
1439 /* toolbars with native control (v4.71). - GA 8/01 */
1440 cx = sz.cx + 6 + 5 + 5;
1441 if ((dwStyle & TBSTYLE_LIST) &&
1442 (TOOLBAR_TestImageExist (infoPtr, btnPtr, GETDEFIMAGELIST(infoPtr,0))))
1443 cx += infoPtr->nBitmapWidth;
1446 cx = infoPtr->nButtonWidth;
1448 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1449 cx += DDARROW_WIDTH;
1451 if (btnPtr->fsState & TBSTATE_WRAP )
1454 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
1456 if (infoPtr->rcBound.left > x)
1457 infoPtr->rcBound.left = x;
1458 if (infoPtr->rcBound.right < x + cx)
1459 infoPtr->rcBound.right = x + cx;
1460 if (infoPtr->rcBound.bottom < y + cy)
1461 infoPtr->rcBound.bottom = y + cy;
1463 /* Set the toolTip only for non-hidden, non-separator button */
1464 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
1468 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1469 ti.cbSize = sizeof(TTTOOLINFOA);
1471 ti.uId = btnPtr->idCommand;
1472 ti.rect = btnPtr->rect;
1473 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
1477 /* btnPtr->nRow is zero based. The space between the rows is */
1478 /* also considered as a row. */
1479 btnPtr->nRow = nRows + nSepRows;
1481 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1482 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow,
1487 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
1491 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1492 /* it is the actual width of the separator. This is used for */
1493 /* custom controls in toolbars. */
1494 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1495 y += cy + ( (btnPtr->iBitmap > 0 ) ?
1496 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
1500 /* nSepRows is used to calculate the extra height follwoing */
1504 x = infoPtr->nIndent;
1506 /* Increment row number unless this is the last button */
1507 /* and it has Wrap set. */
1508 if (i != infoPtr->nNumButtons-1)
1515 /* infoPtr->nRows is the number of rows on the toolbar */
1516 infoPtr->nRows = nRows + nSepRows + 1;
1519 /********************************************************************
1520 * The following while interesting, does not match the values *
1521 * created above for the button rectangles, nor the rcBound rect. *
1522 * We will comment it out and remove it later. *
1524 * The problem showed up as heights in the pager control that was *
1526 ********************************************************************/
1528 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1530 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
1531 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
1532 nSepRows * (infoPtr->nBitmapHeight + 1) +
1536 infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1538 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
1543 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
1545 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1546 TBUTTON_INFO *btnPtr;
1549 btnPtr = infoPtr->buttons;
1550 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1551 if (btnPtr->fsState & TBSTATE_HIDDEN)
1554 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1555 if (PtInRect (&btnPtr->rect, *lpPt)) {
1556 TRACE(" ON SEPARATOR %d!\n", i);
1561 if (PtInRect (&btnPtr->rect, *lpPt)) {
1562 TRACE(" ON BUTTON %d!\n", i);
1568 TRACE(" NOWHERE!\n");
1574 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
1576 TBUTTON_INFO *btnPtr;
1579 if (CommandIsIndex) {
1580 TRACE("command is really index command=%d\n", idCommand);
1581 if (idCommand >= infoPtr->nNumButtons) return -1;
1584 btnPtr = infoPtr->buttons;
1585 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1586 if (btnPtr->idCommand == idCommand) {
1587 TRACE("command=%d index=%d\n", idCommand, i);
1591 TRACE("no index found for command=%d\n", idCommand);
1597 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
1599 TBUTTON_INFO *btnPtr;
1602 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
1605 /* check index button */
1606 btnPtr = &infoPtr->buttons[nIndex];
1607 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1608 if (btnPtr->fsState & TBSTATE_CHECKED)
1612 /* check previous buttons */
1613 nRunIndex = nIndex - 1;
1614 while (nRunIndex >= 0) {
1615 btnPtr = &infoPtr->buttons[nRunIndex];
1616 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1617 if (btnPtr->fsState & TBSTATE_CHECKED)
1625 /* check next buttons */
1626 nRunIndex = nIndex + 1;
1627 while (nRunIndex < infoPtr->nNumButtons) {
1628 btnPtr = &infoPtr->buttons[nRunIndex];
1629 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1630 if (btnPtr->fsState & TBSTATE_CHECKED)
1643 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
1644 WPARAM wParam, LPARAM lParam)
1650 msg.wParam = wParam;
1651 msg.lParam = lParam;
1652 msg.time = GetMessageTime ();
1653 msg.pt.x = LOWORD(GetMessagePos ());
1654 msg.pt.y = HIWORD(GetMessagePos ());
1656 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
1660 /***********************************************************************
1661 * TOOLBAR_CustomizeDialogProc
1662 * This function implements the toolbar customization dialog.
1664 static INT_PTR CALLBACK
1665 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1667 PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
1668 PCUSTOMBUTTON btnInfo;
1670 TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
1675 custInfo = (PCUSTDLG_INFO)lParam;
1676 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
1684 infoPtr = custInfo->tbInfo;
1686 /* send TBN_QUERYINSERT notification */
1687 nmtb.iItem = custInfo->tbInfo->nNumButtons;
1689 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
1692 /* Send TBN_INITCUSTOMIZE notification */
1693 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) ==
1696 FIXME("TBNRF_HIDEHELP not supported\n");
1699 /* add items to 'toolbar buttons' list and check if removable */
1700 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
1702 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1703 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1704 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1705 btnInfo->bVirtual = FALSE;
1706 LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1708 /* send TBN_QUERYDELETE notification */
1709 btnInfo->bRemovable = TOOLBAR_IsButtonRemovable(infoPtr, i, btnInfo);
1711 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
1712 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1715 /* insert separator button into 'available buttons' list */
1716 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1717 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1718 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1719 btnInfo->bVirtual = FALSE;
1720 btnInfo->bRemovable = TRUE;
1721 LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1722 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1723 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1725 /* insert all buttons into dsa */
1728 /* send TBN_GETBUTTONINFO notification */
1731 nmtb.pszText = Buffer;
1734 /* Clear previous button's text */
1735 ZeroMemory(nmtb.pszText, nmtb.cchText * sizeof(WCHAR));
1737 if (!TOOLBAR_GetButtonInfo(infoPtr, &nmtb))
1740 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
1741 nmtb.tbButton.fsStyle, i,
1742 nmtb.tbButton.idCommand,
1743 nmtb.tbButton.iString,
1744 nmtb.tbButton.iString >= 0 ? debugstr_w(infoPtr->strings[nmtb.tbButton.iString])
1747 /* insert button into the apropriate list */
1748 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
1751 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1752 btnInfo->bVirtual = FALSE;
1753 btnInfo->bRemovable = TRUE;
1755 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1756 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX,
1757 LB_SETITEMDATA, index, (LPARAM)btnInfo);
1761 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd,
1762 IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1765 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1766 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1768 if (lstrlenW(nmtb.pszText))
1769 lstrcpyW(btnInfo->text, nmtb.pszText);
1770 else if (nmtb.tbButton.iString >= 0 &&
1771 nmtb.tbButton.iString < infoPtr->nNumStrings)
1773 lstrcpyW(btnInfo->text,
1774 infoPtr->strings[nmtb.tbButton.iString]);
1779 /* select first item in the 'available' list */
1780 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
1782 /* append 'virtual' separator button to the 'toolbar buttons' list */
1783 btnInfo = (PCUSTOMBUTTON)COMCTL32_Alloc(sizeof(CUSTOMBUTTON));
1784 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1785 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1786 btnInfo->bVirtual = TRUE;
1787 btnInfo->bRemovable = FALSE;
1788 LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1789 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1790 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1792 /* select last item in the 'toolbar' list */
1793 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
1794 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
1796 /* set focus and disable buttons */
1797 PostMessageA (hwnd, WM_USER, 0, 0);
1802 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1803 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1804 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
1805 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
1809 EndDialog(hwnd, FALSE);
1813 switch (LOWORD(wParam))
1815 case IDC_TOOLBARBTN_LBOX:
1816 if (HIWORD(wParam) == LBN_SELCHANGE)
1818 PCUSTOMBUTTON btnInfo;
1823 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1824 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1826 /* send TBN_QUERYINSERT notification */
1828 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1831 /* get list box item */
1832 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1834 if (index == (count - 1))
1836 /* last item (virtual separator) */
1837 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1838 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1840 else if (index == (count - 2))
1842 /* second last item (last non-virtual item) */
1843 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1844 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1846 else if (index == 0)
1849 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1850 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1854 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1855 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1858 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
1862 case IDC_MOVEUP_BTN:
1864 PCUSTOMBUTTON btnInfo;
1868 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1869 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1870 TRACE("Move up: index %d\n", index);
1872 /* send TBN_QUERYINSERT notification */
1875 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1878 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1880 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1881 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
1882 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
1883 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1886 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1887 else if (index >= (count - 3))
1888 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1890 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1891 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
1896 case IDC_MOVEDN_BTN: /* move down */
1898 PCUSTOMBUTTON btnInfo;
1902 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1903 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1904 TRACE("Move up: index %d\n", index);
1906 /* send TBN_QUERYINSERT notification */
1908 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1911 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1913 /* move button down */
1914 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1915 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
1916 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
1917 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
1920 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1921 else if (index >= (count - 3))
1922 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1924 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1925 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
1930 case IDC_REMOVE_BTN: /* remove button */
1932 PCUSTOMBUTTON btnInfo;
1935 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1937 if (LB_ERR == index)
1940 TRACE("Remove: index %d\n", index);
1942 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX,
1943 LB_GETITEMDATA, index, 0);
1945 /* send TBN_QUERYDELETE notification */
1946 if (TOOLBAR_IsButtonRemovable(infoPtr, index, btnInfo))
1948 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1949 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1950 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
1952 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1954 /* insert into 'available button' list */
1955 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
1957 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1958 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1961 COMCTL32_Free (btnInfo);
1966 case IDOK: /* Add button */
1971 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
1972 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
1973 TRACE("Add: index %d\n", index);
1975 /* send TBN_QUERYINSERT notification */
1977 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1980 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
1984 /* remove from 'available buttons' list */
1985 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
1986 if (index == count-1)
1987 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1989 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
1993 PCUSTOMBUTTON btnNew;
1995 /* duplicate 'separator' button */
1996 btnNew = (PCUSTOMBUTTON)COMCTL32_Alloc (sizeof(CUSTOMBUTTON));
1997 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
2001 /* insert into 'toolbar button' list */
2002 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
2003 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
2004 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
2006 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
2012 EndDialog(hwnd, FALSE);
2022 /* delete items from 'toolbar buttons' listbox*/
2023 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
2024 for (i = 0; i < count; i++)
2026 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
2027 COMCTL32_Free(btnInfo);
2028 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
2030 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
2033 /* delete items from 'available buttons' listbox*/
2034 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
2035 for (i = 0; i < count; i++)
2037 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
2038 COMCTL32_Free(btnInfo);
2039 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
2041 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
2046 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
2048 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
2049 DWORD dwStyle = GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE);
2054 COLORREF oldText = 0;
2058 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
2059 if (btnInfo == NULL)
2061 FIXME("btnInfo invalid!\n");
2065 /* set colors and select objects */
2066 oldBk = SetBkColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlight:comctl32_color.clrWindow);
2067 if (btnInfo->bVirtual)
2068 oldText = SetTextColor (lpdis->hDC, comctl32_color.clrGrayText);
2070 oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText);
2071 hPen = CreatePen( PS_SOLID, 1,
2072 GetSysColor( (lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
2073 hOldPen = SelectObject (lpdis->hDC, hPen );
2074 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
2076 /* fill background rectangle */
2077 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
2078 lpdis->rcItem.right, lpdis->rcItem.bottom);
2080 /* calculate button and text rectangles */
2081 CopyRect (&rcButton, &lpdis->rcItem);
2082 InflateRect (&rcButton, -1, -1);
2083 CopyRect (&rcText, &rcButton);
2084 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
2085 rcText.left = rcButton.right + 2;
2087 /* draw focus rectangle */
2088 if (lpdis->itemState & ODS_FOCUS)
2089 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
2092 if (!(dwStyle & TBSTYLE_FLAT))
2093 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
2095 /* draw image and text */
2096 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) {
2097 HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr,
2098 btnInfo->btn.iBitmap));
2099 ImageList_Draw (himl, GETIBITMAP(infoPtr, btnInfo->btn.iBitmap),
2100 lpdis->hDC, rcButton.left+3, rcButton.top+3, ILD_NORMAL);
2102 DrawTextW (lpdis->hDC, btnInfo->text, -1, &rcText,
2103 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
2105 /* delete objects and reset colors */
2106 SelectObject (lpdis->hDC, hOldBrush);
2107 SelectObject (lpdis->hDC, hOldPen);
2108 SetBkColor (lpdis->hDC, oldBk);
2109 SetTextColor (lpdis->hDC, oldText);
2110 DeleteObject( hPen );
2115 case WM_MEASUREITEM:
2116 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
2118 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
2120 if (custInfo && custInfo->tbInfo)
2121 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
2123 lpmis->itemHeight = 15 + 8; /* default height */
2135 /***********************************************************************
2136 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2140 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2142 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2143 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
2144 INT nIndex = 0, nButtons, nCount;
2148 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
2152 if (lpAddBmp->hInst == HINST_COMMCTRL)
2154 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
2156 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
2158 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
2163 TRACE ("adding %d internal bitmaps!\n", nButtons);
2165 /* Windows resize all the buttons to the size of a newly added standard image */
2166 if (lpAddBmp->nID & 1)
2169 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2170 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2172 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
2173 MAKELPARAM((WORD)24, (WORD)24));
2174 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
2175 MAKELPARAM((WORD)31, (WORD)30));
2180 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
2181 MAKELPARAM((WORD)16, (WORD)16));
2182 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
2183 MAKELPARAM((WORD)22, (WORD)22));
2186 TOOLBAR_CalcToolbar (hwnd);
2190 nButtons = (INT)wParam;
2194 TRACE ("adding %d bitmaps!\n", nButtons);
2197 if (!infoPtr->cimlDef) {
2198 /* create new default image list */
2199 TRACE ("creating default image list!\n");
2201 himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
2202 ILC_COLOR | ILC_MASK, nButtons, 2);
2203 TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
2204 infoPtr->himlInt = himlDef;
2207 himlDef = GETDEFIMAGELIST(infoPtr, 0);
2211 WARN("No default image list available\n");
2215 nCount = ImageList_GetImageCount(himlDef);
2217 /* Add bitmaps to the default image list */
2218 if (lpAddBmp->hInst == NULL)
2221 HBITMAP hOldBitmapBitmap, hOldBitmapLoad;
2222 HDC hdcImage, hdcBitmap;
2224 /* copy the bitmap before adding it so that the user's bitmap
2225 * doesn't get modified.
2227 GetObjectA ((HBITMAP)lpAddBmp->nID, sizeof(BITMAP), (LPVOID)&bmp);
2229 hdcImage = CreateCompatibleDC(0);
2230 hdcBitmap = CreateCompatibleDC(0);
2232 /* create new bitmap */
2233 hbmLoad = CreateBitmap (bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
2234 hOldBitmapBitmap = SelectObject(hdcBitmap, (HBITMAP)lpAddBmp->nID);
2235 hOldBitmapLoad = SelectObject(hdcImage, hbmLoad);
2237 /* Copy the user's image */
2238 BitBlt (hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight,
2239 hdcBitmap, 0, 0, SRCCOPY);
2241 SelectObject (hdcImage, hOldBitmapLoad);
2242 SelectObject (hdcBitmap, hOldBitmapBitmap);
2243 DeleteDC (hdcImage);
2244 DeleteDC (hdcBitmap);
2246 nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
2247 DeleteObject (hbmLoad);
2249 else if (lpAddBmp->hInst == HINST_COMMCTRL)
2251 /* Add system bitmaps */
2252 switch (lpAddBmp->nID)
2254 case IDB_STD_SMALL_COLOR:
2255 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2256 MAKEINTRESOURCEA(IDB_STD_SMALL));
2257 nIndex = ImageList_AddMasked (himlDef,
2258 hbmLoad, CLR_DEFAULT);
2259 DeleteObject (hbmLoad);
2262 case IDB_STD_LARGE_COLOR:
2263 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2264 MAKEINTRESOURCEA(IDB_STD_LARGE));
2265 nIndex = ImageList_AddMasked (himlDef,
2266 hbmLoad, CLR_DEFAULT);
2267 DeleteObject (hbmLoad);
2270 case IDB_VIEW_SMALL_COLOR:
2271 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2272 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
2273 nIndex = ImageList_AddMasked (himlDef,
2274 hbmLoad, CLR_DEFAULT);
2275 DeleteObject (hbmLoad);
2278 case IDB_VIEW_LARGE_COLOR:
2279 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2280 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
2281 nIndex = ImageList_AddMasked (himlDef,
2282 hbmLoad, CLR_DEFAULT);
2283 DeleteObject (hbmLoad);
2286 case IDB_HIST_SMALL_COLOR:
2287 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2288 MAKEINTRESOURCEA(IDB_HIST_SMALL));
2289 nIndex = ImageList_AddMasked (himlDef,
2290 hbmLoad, CLR_DEFAULT);
2291 DeleteObject (hbmLoad);
2294 case IDB_HIST_LARGE_COLOR:
2295 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2296 MAKEINTRESOURCEA(IDB_HIST_LARGE));
2297 nIndex = ImageList_AddMasked (himlDef,
2298 hbmLoad, CLR_DEFAULT);
2299 DeleteObject (hbmLoad);
2303 nIndex = ImageList_GetImageCount (himlDef);
2304 ERR ("invalid imagelist!\n");
2310 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
2311 nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
2312 DeleteObject (hbmLoad);
2315 TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos);
2317 if (infoPtr->nNumBitmapInfos == 0)
2319 infoPtr->bitmaps = COMCTL32_Alloc(sizeof(TBITMAP_INFO));
2323 TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps;
2324 infoPtr->bitmaps = COMCTL32_Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
2325 memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos);
2328 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nButtons = nButtons;
2329 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].hInst = lpAddBmp->hInst;
2330 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nID = lpAddBmp->nID;
2332 infoPtr->nNumBitmapInfos++;
2333 TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos);
2337 INT imagecount = ImageList_GetImageCount(himlDef);
2339 if (infoPtr->nNumBitmaps + nButtons != imagecount)
2341 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",
2342 infoPtr->nNumBitmaps, nCount, imagecount - nCount,
2343 infoPtr->nNumBitmaps+nButtons,imagecount);
2345 infoPtr->nNumBitmaps = imagecount;
2348 infoPtr->nNumBitmaps += nButtons;
2351 InvalidateRect(hwnd, NULL, FALSE);
2358 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2360 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2361 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2362 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2364 TRACE("adding %d buttons!\n", wParam);
2366 nAddButtons = (UINT)wParam;
2367 nOldButtons = infoPtr->nNumButtons;
2368 nNewButtons = nOldButtons + nAddButtons;
2370 if (infoPtr->nNumButtons == 0) {
2372 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2375 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2377 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2378 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2379 nOldButtons * sizeof(TBUTTON_INFO));
2380 COMCTL32_Free (oldButtons);
2383 infoPtr->nNumButtons = nNewButtons;
2385 /* insert new button data */
2386 for (nCount = 0; nCount < nAddButtons; nCount++) {
2387 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2388 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2389 btnPtr->idCommand = lpTbb[nCount].idCommand;
2390 btnPtr->fsState = lpTbb[nCount].fsState;
2391 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2392 btnPtr->dwData = lpTbb[nCount].dwData;
2393 btnPtr->iString = lpTbb[nCount].iString;
2394 btnPtr->bHot = FALSE;
2396 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2399 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2400 ti.cbSize = sizeof (TTTOOLINFOA);
2402 ti.uId = btnPtr->idCommand;
2404 ti.lpszText = LPSTR_TEXTCALLBACKA;
2406 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2411 TOOLBAR_CalcToolbar (hwnd);
2413 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2415 InvalidateRect(hwnd, NULL, FALSE);
2422 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2424 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2425 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2426 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2428 TRACE("adding %d buttons!\n", wParam);
2430 nAddButtons = (UINT)wParam;
2431 nOldButtons = infoPtr->nNumButtons;
2432 nNewButtons = nOldButtons + nAddButtons;
2434 if (infoPtr->nNumButtons == 0) {
2436 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2439 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2441 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2442 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2443 nOldButtons * sizeof(TBUTTON_INFO));
2444 COMCTL32_Free (oldButtons);
2447 infoPtr->nNumButtons = nNewButtons;
2449 /* insert new button data */
2450 for (nCount = 0; nCount < nAddButtons; nCount++) {
2451 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2452 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2453 btnPtr->idCommand = lpTbb[nCount].idCommand;
2454 btnPtr->fsState = lpTbb[nCount].fsState;
2455 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2456 btnPtr->dwData = lpTbb[nCount].dwData;
2457 btnPtr->iString = lpTbb[nCount].iString;
2458 btnPtr->bHot = FALSE;
2460 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2463 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2464 ti.cbSize = sizeof (TTTOOLINFOW);
2466 ti.uId = btnPtr->idCommand;
2468 ti.lpszText = LPSTR_TEXTCALLBACKW;
2471 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2476 TOOLBAR_CalcToolbar (hwnd);
2478 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2480 InvalidateRect(hwnd, NULL, FALSE);
2487 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2489 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2492 if ((wParam) && (HIWORD(lParam) == 0)) {
2495 TRACE("adding string from resource!\n");
2497 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
2500 TRACE("len=%d \"%s\"\n", len, szString);
2501 nIndex = infoPtr->nNumStrings;
2502 if (infoPtr->nNumStrings == 0) {
2504 COMCTL32_Alloc (sizeof(LPWSTR));
2507 LPWSTR *oldStrings = infoPtr->strings;
2509 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2510 memcpy (&infoPtr->strings[0], &oldStrings[0],
2511 sizeof(LPWSTR) * infoPtr->nNumStrings);
2512 COMCTL32_Free (oldStrings);
2515 /*COMCTL32_Alloc zeros out the allocated memory*/
2516 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
2517 infoPtr->nNumStrings++;
2520 LPSTR p = (LPSTR)lParam;
2525 TRACE("adding string(s) from array!\n");
2527 nIndex = infoPtr->nNumStrings;
2530 TRACE("len=%d \"%s\"\n", len, p);
2532 if (infoPtr->nNumStrings == 0) {
2534 COMCTL32_Alloc (sizeof(LPWSTR));
2537 LPWSTR *oldStrings = infoPtr->strings;
2539 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2540 memcpy (&infoPtr->strings[0], &oldStrings[0],
2541 sizeof(LPWSTR) * infoPtr->nNumStrings);
2542 COMCTL32_Free (oldStrings);
2545 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
2546 infoPtr->nNumStrings++;
2557 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2559 #define MAX_RESOURCE_STRING_LENGTH 512
2560 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2563 if ((wParam) && (HIWORD(lParam) == 0)) {
2564 WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
2566 TRACE("adding string from resource!\n");
2568 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
2569 szString, MAX_RESOURCE_STRING_LENGTH);
2571 TRACE("len=%d %s\n", len, debugstr_w(szString));
2572 TRACE("First char: 0x%x\n", *szString);
2573 if (szString[0] == L'|')
2575 PWSTR p = szString + 1;
2577 nIndex = infoPtr->nNumStrings;
2578 while (*p != L'|' && *p != L'\0') {
2581 if (infoPtr->nNumStrings == 0) {
2582 infoPtr->strings = COMCTL32_Alloc (sizeof(LPWSTR));
2586 LPWSTR *oldStrings = infoPtr->strings;
2587 infoPtr->strings = COMCTL32_Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2588 memcpy(&infoPtr->strings[0], &oldStrings[0],
2589 sizeof(LPWSTR) * infoPtr->nNumStrings);
2590 COMCTL32_Free(oldStrings);
2593 np=COMCTL32_StrChrW (p, L'|');
2601 TRACE("len=%d %s\n", len, debugstr_w(p));
2602 infoPtr->strings[infoPtr->nNumStrings] =
2603 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
2604 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
2605 infoPtr->nNumStrings++;
2612 nIndex = infoPtr->nNumStrings;
2613 if (infoPtr->nNumStrings == 0) {
2615 COMCTL32_Alloc (sizeof(LPWSTR));
2618 LPWSTR *oldStrings = infoPtr->strings;
2620 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2621 memcpy (&infoPtr->strings[0], &oldStrings[0],
2622 sizeof(LPWSTR) * infoPtr->nNumStrings);
2623 COMCTL32_Free (oldStrings);
2626 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
2627 infoPtr->nNumStrings++;
2631 LPWSTR p = (LPWSTR)lParam;
2636 TRACE("adding string(s) from array!\n");
2637 nIndex = infoPtr->nNumStrings;
2641 TRACE("len=%d %s\n", len, debugstr_w(p));
2642 if (infoPtr->nNumStrings == 0) {
2644 COMCTL32_Alloc (sizeof(LPWSTR));
2647 LPWSTR *oldStrings = infoPtr->strings;
2649 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2650 memcpy (&infoPtr->strings[0], &oldStrings[0],
2651 sizeof(LPWSTR) * infoPtr->nNumStrings);
2652 COMCTL32_Free (oldStrings);
2655 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
2656 infoPtr->nNumStrings++;
2667 TOOLBAR_AutoSize (HWND hwnd)
2669 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2670 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2676 UINT uPosFlags = SWP_NOZORDER;
2678 TRACE("resize forced, style=%lx!\n", dwStyle);
2680 parent = GetParent (hwnd);
2681 GetClientRect(parent, &parent_rect);
2683 x = parent_rect.left;
2684 y = parent_rect.top;
2686 /* FIXME: we should be able to early out if nothing */
2687 /* has changed with nWidth != parent_rect width */
2689 if (dwStyle & CCS_NORESIZE) {
2690 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2693 TOOLBAR_CalcToolbar (hwnd);
2696 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2697 TOOLBAR_CalcToolbar (hwnd);
2698 InvalidateRect( hwnd, NULL, TRUE );
2699 cy = infoPtr->nHeight;
2700 cx = infoPtr->nWidth;
2702 if (dwStyle & CCS_NOMOVEY) {
2703 GetWindowRect(hwnd, &window_rect);
2704 ScreenToClient(parent, (LPPOINT)&window_rect.left);
2705 y = window_rect.top;
2709 if (dwStyle & CCS_NOPARENTALIGN)
2710 uPosFlags |= SWP_NOMOVE;
2712 if (!(dwStyle & CCS_NODIVIDER))
2713 cy += GetSystemMetrics(SM_CYEDGE);
2715 if (dwStyle & WS_BORDER)
2718 cy += GetSystemMetrics(SM_CYEDGE);
2719 cx += GetSystemMetrics(SM_CYEDGE);
2722 infoPtr->bAutoSize = TRUE;
2723 SetWindowPos (hwnd, HWND_TOP, parent_rect.left - x, parent_rect.top - y,
2725 /* The following line makes sure that the infoPtr->bAutoSize is turned off after
2726 * the setwindowpos calls */
2727 infoPtr->bAutoSize = FALSE;
2734 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
2736 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2738 return infoPtr->nNumButtons;
2743 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2745 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2747 if (infoPtr == NULL) {
2748 ERR("(%p, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
2749 ERR("infoPtr == NULL!\n");
2753 infoPtr->dwStructSize = (DWORD)wParam;
2760 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2762 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2763 TBUTTON_INFO *btnPtr;
2766 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2770 btnPtr = &infoPtr->buttons[nIndex];
2771 btnPtr->iBitmap = LOWORD(lParam);
2773 /* we HAVE to erase the background, the new bitmap could be */
2775 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2782 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2784 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2785 TBUTTON_INFO *btnPtr;
2788 BOOL bChecked = FALSE;
2790 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2794 btnPtr = &infoPtr->buttons[nIndex];
2796 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
2799 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
2801 if (LOWORD(lParam) == FALSE)
2802 btnPtr->fsState &= ~TBSTATE_CHECKED;
2804 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2806 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
2807 if (nOldIndex == nIndex)
2809 if (nOldIndex != -1)
2810 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2812 btnPtr->fsState |= TBSTATE_CHECKED;
2815 if( bChecked != LOWORD(lParam) )
2817 if (nOldIndex != -1)
2819 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
2820 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
2822 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2825 /* FIXME: Send a WM_NOTIFY?? */
2832 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
2834 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2836 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2841 TOOLBAR_Customize (HWND hwnd)
2843 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2844 CUSTDLG_INFO custInfo;
2850 custInfo.tbInfo = infoPtr;
2851 custInfo.tbHwnd = hwnd;
2853 /* send TBN_BEGINADJUST notification */
2854 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2857 if (!(hRes = FindResourceA (COMCTL32_hModule,
2858 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
2862 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
2865 ret = DialogBoxIndirectParamA ((HINSTANCE)GetWindowLongA(hwnd, GWL_HINSTANCE),
2866 (LPDLGTEMPLATEA)template,
2868 TOOLBAR_CustomizeDialogProc,
2871 /* send TBN_ENDADJUST notification */
2872 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2880 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2882 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2883 INT nIndex = (INT)wParam;
2885 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2888 if ((infoPtr->hwndToolTip) &&
2889 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
2892 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2893 ti.cbSize = sizeof (TTTOOLINFOA);
2895 ti.uId = infoPtr->buttons[nIndex].idCommand;
2897 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
2900 if (infoPtr->nNumButtons == 1) {
2901 TRACE(" simple delete!\n");
2902 COMCTL32_Free (infoPtr->buttons);
2903 infoPtr->buttons = NULL;
2904 infoPtr->nNumButtons = 0;
2907 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2908 TRACE("complex delete! [nIndex=%d]\n", nIndex);
2910 infoPtr->nNumButtons--;
2911 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2913 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2914 nIndex * sizeof(TBUTTON_INFO));
2917 if (nIndex < infoPtr->nNumButtons) {
2918 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
2919 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
2922 COMCTL32_Free (oldButtons);
2925 TOOLBAR_CalcToolbar (hwnd);
2927 InvalidateRect (hwnd, NULL, TRUE);
2934 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2936 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2937 TBUTTON_INFO *btnPtr;
2941 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2945 btnPtr = &infoPtr->buttons[nIndex];
2947 bState = btnPtr->fsState & TBSTATE_ENABLED;
2949 /* update the toolbar button state */
2950 if(LOWORD(lParam) == FALSE) {
2951 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
2953 btnPtr->fsState |= TBSTATE_ENABLED;
2956 /* redraw the button only if the state of the button changed */
2957 if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
2959 InvalidateRect(hwnd, &btnPtr->rect,
2960 TOOLBAR_HasText(infoPtr, btnPtr));
2967 static inline LRESULT
2968 TOOLBAR_GetAnchorHighlight (HWND hwnd)
2970 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2972 return infoPtr->bAnchor;
2977 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2979 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2982 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2986 return infoPtr->buttons[nIndex].iBitmap;
2990 static inline LRESULT
2991 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2993 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
2998 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3000 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3001 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3002 INT nIndex = (INT)wParam;
3003 TBUTTON_INFO *btnPtr;
3005 if (infoPtr == NULL)
3011 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3014 btnPtr = &infoPtr->buttons[nIndex];
3015 lpTbb->iBitmap = btnPtr->iBitmap;
3016 lpTbb->idCommand = btnPtr->idCommand;
3017 lpTbb->fsState = btnPtr->fsState;
3018 lpTbb->fsStyle = btnPtr->fsStyle;
3019 lpTbb->bReserved[0] = 0;
3020 lpTbb->bReserved[1] = 0;
3021 lpTbb->dwData = btnPtr->dwData;
3022 lpTbb->iString = btnPtr->iString;
3029 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3031 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3032 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
3033 TBUTTON_INFO *btnPtr;
3036 if (infoPtr == NULL)
3038 if (lpTbInfo == NULL)
3040 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
3043 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3044 lpTbInfo->dwMask & 0x80000000);
3048 if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
3050 if (lpTbInfo->dwMask & TBIF_COMMAND)
3051 lpTbInfo->idCommand = btnPtr->idCommand;
3052 if (lpTbInfo->dwMask & TBIF_IMAGE)
3053 lpTbInfo->iImage = btnPtr->iBitmap;
3054 if (lpTbInfo->dwMask & TBIF_LPARAM)
3055 lpTbInfo->lParam = btnPtr->dwData;
3056 if (lpTbInfo->dwMask & TBIF_SIZE)
3057 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
3058 if (lpTbInfo->dwMask & TBIF_STATE)
3059 lpTbInfo->fsState = btnPtr->fsState;
3060 if (lpTbInfo->dwMask & TBIF_STYLE)
3061 lpTbInfo->fsStyle = btnPtr->fsStyle;
3062 if (lpTbInfo->dwMask & TBIF_TEXT) {
3063 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
3064 Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
3071 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3073 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3074 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
3075 TBUTTON_INFO *btnPtr;
3078 if (infoPtr == NULL)
3080 if (lpTbInfo == NULL)
3082 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
3085 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3086 lpTbInfo->dwMask & 0x80000000);
3090 btnPtr = &infoPtr->buttons[nIndex];
3095 if (lpTbInfo->dwMask & TBIF_COMMAND)
3096 lpTbInfo->idCommand = btnPtr->idCommand;
3097 if (lpTbInfo->dwMask & TBIF_IMAGE)
3098 lpTbInfo->iImage = btnPtr->iBitmap;
3099 if (lpTbInfo->dwMask & TBIF_LPARAM)
3100 lpTbInfo->lParam = btnPtr->dwData;
3101 if (lpTbInfo->dwMask & TBIF_SIZE)
3102 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
3103 if (lpTbInfo->dwMask & TBIF_STATE)
3104 lpTbInfo->fsState = btnPtr->fsState;
3105 if (lpTbInfo->dwMask & TBIF_STYLE)
3106 lpTbInfo->fsStyle = btnPtr->fsStyle;
3107 if (lpTbInfo->dwMask & TBIF_TEXT) {
3108 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
3109 Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
3117 TOOLBAR_GetButtonSize (HWND hwnd)
3119 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3121 if (infoPtr->nNumButtons > 0)
3122 return MAKELONG((WORD)infoPtr->nButtonWidth,
3123 (WORD)infoPtr->nButtonHeight);
3125 return MAKELONG(8,7);
3130 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3132 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3139 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3143 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
3145 return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
3146 (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
3151 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3153 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3160 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3164 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
3166 strcpyW ((LPWSTR)lParam, lpText);
3168 return strlenW (lpText);
3173 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3175 return (LRESULT)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
3179 inline static LRESULT
3180 TOOLBAR_GetExtendedStyle (HWND hwnd)
3182 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3184 return infoPtr->dwExStyle;
3189 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3191 return (LRESULT)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
3196 TOOLBAR_GetHotItem (HWND hwnd)
3198 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3200 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
3203 if (infoPtr->nHotItem < 0)
3206 return (LRESULT)infoPtr->nHotItem;
3211 TOOLBAR_GetDefImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3213 return (LRESULT) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd), 0);
3217 /* << TOOLBAR_GetInsertMark >> */
3218 /* << TOOLBAR_GetInsertMarkColor >> */
3222 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3224 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3225 TBUTTON_INFO *btnPtr;
3229 if (infoPtr == NULL)
3231 nIndex = (INT)wParam;
3232 btnPtr = &infoPtr->buttons[nIndex];
3233 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3235 lpRect = (LPRECT)lParam;
3238 if (btnPtr->fsState & TBSTATE_HIDDEN)
3241 lpRect->left = btnPtr->rect.left;
3242 lpRect->right = btnPtr->rect.right;
3243 lpRect->bottom = btnPtr->rect.bottom;
3244 lpRect->top = btnPtr->rect.top;
3251 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3253 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3254 LPSIZE lpSize = (LPSIZE)lParam;
3259 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
3260 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
3262 TRACE("maximum size %ld x %ld\n",
3263 infoPtr->rcBound.right - infoPtr->rcBound.left,
3264 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
3270 /* << TOOLBAR_GetObject >> */
3274 TOOLBAR_GetPadding (HWND hwnd)
3276 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3279 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
3280 return (LRESULT) oldPad;
3285 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3287 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3288 TBUTTON_INFO *btnPtr;
3292 if (infoPtr == NULL)
3294 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3295 btnPtr = &infoPtr->buttons[nIndex];
3296 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3298 lpRect = (LPRECT)lParam;
3302 lpRect->left = btnPtr->rect.left;
3303 lpRect->right = btnPtr->rect.right;
3304 lpRect->bottom = btnPtr->rect.bottom;
3305 lpRect->top = btnPtr->rect.top;
3312 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3314 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3316 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
3317 return infoPtr->nRows;
3324 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
3326 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3329 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3333 return infoPtr->buttons[nIndex].fsState;
3338 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3340 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3343 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3347 return infoPtr->buttons[nIndex].fsStyle;
3352 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3354 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3356 if (infoPtr == NULL)
3359 return infoPtr->nMaxTextRows;
3364 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
3366 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3368 if (infoPtr == NULL)
3370 return (LRESULT)infoPtr->hwndToolTip;
3375 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
3377 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3379 TRACE("%s hwnd=%p stub!\n",
3380 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
3382 return infoPtr->bUnicode;
3386 inline static LRESULT
3387 TOOLBAR_GetVersion (HWND hwnd)
3389 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3390 return infoPtr->iVersion;
3395 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3397 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3398 TBUTTON_INFO *btnPtr;
3403 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3407 btnPtr = &infoPtr->buttons[nIndex];
3408 if (LOWORD(lParam) == FALSE)
3409 btnPtr->fsState &= ~TBSTATE_HIDDEN;
3411 btnPtr->fsState |= TBSTATE_HIDDEN;
3413 TOOLBAR_CalcToolbar (hwnd);
3415 InvalidateRect (hwnd, NULL, TRUE);
3421 inline static LRESULT
3422 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
3424 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
3429 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3431 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3432 TBUTTON_INFO *btnPtr;
3435 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3439 btnPtr = &infoPtr->buttons[nIndex];
3440 if (LOWORD(lParam) == FALSE)
3441 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
3443 btnPtr->fsState |= TBSTATE_INDETERMINATE;
3445 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3452 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3454 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3455 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3456 INT nIndex = (INT)wParam;
3457 TBUTTON_INFO *oldButtons;
3462 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3465 /* EPP: this seems to be an undocumented call (from my IE4)
3466 * I assume in that case that:
3467 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3468 * - index of insertion is at the end of existing buttons
3469 * I only see this happen with nIndex == -1, but it could have a special
3470 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3472 nIndex = infoPtr->nNumButtons;
3474 } else if (nIndex < 0)
3477 /* If the string passed is not an index, assume address of string
3478 and do our own AddString */
3479 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3483 TRACE("string %s passed instead of index, adding string\n",
3484 debugstr_a((LPSTR)lpTbb->iString));
3485 len = strlen((LPSTR)lpTbb->iString) + 2;
3486 ptr = COMCTL32_Alloc(len);
3487 strcpy(ptr, (LPSTR)lpTbb->iString);
3488 ptr[len - 1] = 0; /* ended by two '\0' */
3489 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
3493 TRACE("inserting button index=%d\n", nIndex);
3494 if (nIndex > infoPtr->nNumButtons) {
3495 nIndex = infoPtr->nNumButtons;
3496 TRACE("adjust index=%d\n", nIndex);
3499 oldButtons = infoPtr->buttons;
3500 infoPtr->nNumButtons++;
3501 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3502 /* pre insert copy */
3504 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3505 nIndex * sizeof(TBUTTON_INFO));
3508 /* insert new button */
3509 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3510 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3511 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3512 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3513 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3514 /* if passed string and not index, then add string */
3515 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3516 Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
3519 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3521 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3524 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
3525 ti.cbSize = sizeof (TTTOOLINFOA);
3527 ti.uId = lpTbb->idCommand;
3529 ti.lpszText = LPSTR_TEXTCALLBACKA;
3531 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
3535 /* post insert copy */
3536 if (nIndex < infoPtr->nNumButtons - 1) {
3537 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3538 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3541 COMCTL32_Free (oldButtons);
3543 TOOLBAR_CalcToolbar (hwnd);
3545 InvalidateRect (hwnd, NULL, TRUE);
3552 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3554 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3555 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3556 INT nIndex = (INT)wParam;
3557 TBUTTON_INFO *oldButtons;
3562 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3565 /* EPP: this seems to be an undocumented call (from my IE4)
3566 * I assume in that case that:
3567 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3568 * - index of insertion is at the end of existing buttons
3569 * I only see this happen with nIndex == -1, but it could have a special
3570 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3572 nIndex = infoPtr->nNumButtons;
3574 } else if (nIndex < 0)
3577 /* If the string passed is not an index, assume address of string
3578 and do our own AddString */
3579 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3583 TRACE("string %s passed instead of index, adding string\n",
3584 debugstr_w((LPWSTR)lpTbb->iString));
3585 len = strlenW((LPWSTR)lpTbb->iString) + 2;
3586 ptr = COMCTL32_Alloc(len*sizeof(WCHAR));
3587 strcpyW(ptr, (LPWSTR)lpTbb->iString);
3588 ptr[len - 1] = 0; /* ended by two '\0' */
3589 lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
3593 TRACE("inserting button index=%d\n", nIndex);
3594 if (nIndex > infoPtr->nNumButtons) {
3595 nIndex = infoPtr->nNumButtons;
3596 TRACE("adjust index=%d\n", nIndex);
3599 oldButtons = infoPtr->buttons;
3600 infoPtr->nNumButtons++;
3601 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3602 /* pre insert copy */
3604 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3605 nIndex * sizeof(TBUTTON_INFO));
3608 /* insert new button */
3609 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3610 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3611 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3612 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3613 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3614 /* if passed string and not index, then add string */
3615 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3616 Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
3619 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3621 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3624 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
3625 ti.cbSize = sizeof (TTTOOLINFOW);
3627 ti.uId = lpTbb->idCommand;
3629 ti.lpszText = LPSTR_TEXTCALLBACKW;
3631 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
3635 /* post insert copy */
3636 if (nIndex < infoPtr->nNumButtons - 1) {
3637 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3638 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3641 COMCTL32_Free (oldButtons);
3643 TOOLBAR_CalcToolbar (hwnd);
3645 InvalidateRect (hwnd, NULL, TRUE);
3651 /* << TOOLBAR_InsertMarkHitTest >> */
3655 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
3657 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3660 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3664 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
3669 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
3671 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3674 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3678 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
3683 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
3685 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3688 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3692 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
3697 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
3699 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3702 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3706 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
3711 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3713 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3716 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3720 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
3725 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
3727 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3730 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3734 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
3738 /* << TOOLBAR_LoadImages >> */
3739 /* << TOOLBAR_MapAccelerator >> */
3740 /* << TOOLBAR_MarkButton >> */
3741 /* << TOOLBAR_MoveButton >> */
3745 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3747 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3748 TBUTTON_INFO *btnPtr;
3751 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3755 btnPtr = &infoPtr->buttons[nIndex];
3756 if (LOWORD(lParam) == FALSE)
3757 btnPtr->fsState &= ~TBSTATE_PRESSED;
3759 btnPtr->fsState |= TBSTATE_PRESSED;
3761 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3768 TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
3770 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3771 LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam;
3773 int i = 0, nOldButtons = 0, pos = 0;
3774 HIMAGELIST himlDef = 0;
3776 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
3777 lpReplace->hInstOld, lpReplace->nIDOld, lpReplace->hInstNew, lpReplace->nIDNew,
3778 lpReplace->nButtons);
3780 if (lpReplace->hInstOld == HINST_COMMCTRL)
3782 FIXME("changing standard bitmaps not implemented\n");
3785 else if (lpReplace->hInstOld != 0)
3787 FIXME("resources not in the current module not implemented\n");
3792 hBitmap = (HBITMAP) lpReplace->nIDNew;
3795 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
3796 for (i = 0; i < infoPtr->nNumBitmapInfos; i++) {
3797 TBITMAP_INFO *tbi = &infoPtr->bitmaps[i];
3798 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i, tbi->hInst, tbi->nID);
3799 if (tbi->hInst == lpReplace->hInstOld && tbi->nID == lpReplace->nIDOld)
3801 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID);
3802 nOldButtons = tbi->nButtons;
3803 tbi->nButtons = lpReplace->nButtons;
3804 tbi->hInst = lpReplace->hInstNew;
3805 tbi->nID = lpReplace->nIDNew;
3806 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i, tbi->hInst, tbi->nID);
3809 pos += tbi->nButtons;
3812 if (nOldButtons == 0)
3814 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
3818 infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons;
3820 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
3823 himlDef = GETDEFIMAGELIST(infoPtr, 0);
3824 for (i = pos + nOldButtons - 1; i >= pos; i--) {
3825 ImageList_Remove(himlDef, i);
3830 HBITMAP hOldBitmapBitmap, hOldBitmapLoad, hbmLoad;
3831 HDC hdcImage, hdcBitmap;
3833 /* copy the bitmap before adding it so that the user's bitmap
3834 * doesn't get modified.
3836 GetObjectA (hBitmap, sizeof(BITMAP), (LPVOID)&bmp);
3838 hdcImage = CreateCompatibleDC(0);
3839 hdcBitmap = CreateCompatibleDC(0);
3841 /* create new bitmap */
3842 hbmLoad = CreateBitmap (bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
3843 hOldBitmapBitmap = SelectObject(hdcBitmap, hBitmap);
3844 hOldBitmapLoad = SelectObject(hdcImage, hbmLoad);
3846 /* Copy the user's image */
3847 BitBlt (hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight,
3848 hdcBitmap, 0, 0, SRCCOPY);
3850 SelectObject (hdcImage, hOldBitmapLoad);
3851 SelectObject (hdcBitmap, hOldBitmapBitmap);
3852 DeleteDC (hdcImage);
3853 DeleteDC (hdcBitmap);
3855 ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
3856 DeleteObject (hbmLoad);
3859 InvalidateRect(hwnd, NULL, FALSE);
3865 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3868 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3869 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
3871 if (lpSave == NULL) return 0;
3874 /* save toolbar information */
3875 FIXME("save to \"%s\" \"%s\"\n",
3876 lpSave->pszSubKey, lpSave->pszValueName);
3881 /* restore toolbar information */
3883 FIXME("restore from \"%s\" \"%s\"\n",
3884 lpSave->pszSubKey, lpSave->pszValueName);
3895 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3898 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3899 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
3905 /* save toolbar information */
3906 FIXME("save to \"%s\" \"%s\"\n",
3907 lpSave->pszSubKey, lpSave->pszValueName);
3912 /* restore toolbar information */
3914 FIXME("restore from \"%s\" \"%s\"\n",
3915 lpSave->pszSubKey, lpSave->pszValueName);
3926 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
3928 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3929 BOOL bOldAnchor = infoPtr->bAnchor;
3931 infoPtr->bAnchor = (BOOL)wParam;
3933 return (LRESULT)bOldAnchor;
3938 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3940 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3941 HIMAGELIST himlDef = GETDEFIMAGELIST(infoPtr, 0);
3943 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
3946 if (infoPtr->nNumButtons > 0)
3947 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
3948 infoPtr->nNumButtons,
3949 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
3950 LOWORD(lParam), HIWORD(lParam));
3952 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
3953 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
3956 ImageList_SetIconSize(himlDef, infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
3963 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3965 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3966 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
3967 TBUTTON_INFO *btnPtr;
3972 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
3975 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3976 lptbbi->dwMask & 0x80000000);
3980 btnPtr = &infoPtr->buttons[nIndex];
3981 if (lptbbi->dwMask & TBIF_COMMAND)
3982 btnPtr->idCommand = lptbbi->idCommand;
3983 if (lptbbi->dwMask & TBIF_IMAGE)
3984 btnPtr->iBitmap = lptbbi->iImage;
3985 if (lptbbi->dwMask & TBIF_LPARAM)
3986 btnPtr->dwData = lptbbi->lParam;
3987 /* if (lptbbi->dwMask & TBIF_SIZE) */
3988 /* btnPtr->cx = lptbbi->cx; */
3989 if (lptbbi->dwMask & TBIF_STATE)
3990 btnPtr->fsState = lptbbi->fsState;
3991 if (lptbbi->dwMask & TBIF_STYLE)
3992 btnPtr->fsStyle = lptbbi->fsStyle;
3994 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3995 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
3996 /* iString is index, zero it to make Str_SetPtr succeed */
3999 Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
4006 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
4008 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4009 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
4010 TBUTTON_INFO *btnPtr;
4015 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
4018 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
4019 lptbbi->dwMask & 0x80000000);
4023 btnPtr = &infoPtr->buttons[nIndex];
4024 if (lptbbi->dwMask & TBIF_COMMAND)
4025 btnPtr->idCommand = lptbbi->idCommand;
4026 if (lptbbi->dwMask & TBIF_IMAGE)
4027 btnPtr->iBitmap = lptbbi->iImage;
4028 if (lptbbi->dwMask & TBIF_LPARAM)
4029 btnPtr->dwData = lptbbi->lParam;
4030 /* if (lptbbi->dwMask & TBIF_SIZE) */
4031 /* btnPtr->cx = lptbbi->cx; */
4032 if (lptbbi->dwMask & TBIF_STATE)
4033 btnPtr->fsState = lptbbi->fsState;
4034 if (lptbbi->dwMask & TBIF_STYLE)
4035 btnPtr->fsStyle = lptbbi->fsStyle;
4037 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
4038 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
4039 /* iString is index, zero it to make Str_SetPtr succeed */
4041 Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
4048 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
4050 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4051 INT cx = LOWORD(lParam), cy = HIWORD(lParam);
4053 if ((cx < 0) || (cy < 0))
4055 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
4059 /* The documentation claims you can only change the button size before
4060 * any button has been added. But this is wrong.
4061 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4062 * it to the toolbar, and it checks that the return value is nonzero - mjm
4063 * Further testing shows that we must actually perform the change too.
4066 * The documentation also does not mention that if 0 is supplied for
4067 * either size, the system changes it to the default of 24 wide and
4068 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4070 infoPtr->nButtonWidth = (cx) ? cx : 24;
4071 infoPtr->nButtonHeight = (cy) ? cy : 22;
4077 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
4079 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4081 if (infoPtr == NULL) {
4082 TRACE("Toolbar not initialized yet?????\n");
4086 /* if setting to current values, ignore */
4087 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
4088 (infoPtr->cxMax == (INT)HIWORD(lParam))) {
4089 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4090 infoPtr->cxMin, infoPtr->cxMax);
4094 /* save new values */
4095 infoPtr->cxMin = (INT)LOWORD(lParam);
4096 infoPtr->cxMax = (INT)HIWORD(lParam);
4098 /* if both values are 0 then we are done */
4100 TRACE("setting both min and max to 0, norecalc\n");
4104 /* otherwise we need to recalc the toolbar and in some cases
4105 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4106 which doesn't actually draw - GA). */
4107 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4108 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
4110 TOOLBAR_CalcToolbar (hwnd);
4112 InvalidateRect (hwnd, NULL, TRUE);
4119 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
4121 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4122 INT nIndex = (INT)wParam;
4124 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
4127 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
4129 if (infoPtr->hwndToolTip) {
4131 FIXME("change tool tip!\n");
4140 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4142 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4143 HIMAGELIST himl = (HIMAGELIST)lParam;
4144 HIMAGELIST himlTemp;
4147 if (infoPtr->iVersion >= 5)
4150 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlDis,
4151 &infoPtr->cimlDis, himl, id);
4153 /* FIXME: redraw ? */
4155 return (LRESULT)himlTemp;
4160 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
4162 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4165 dwTemp = infoPtr->dwDTFlags;
4166 infoPtr->dwDTFlags =
4167 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
4169 return (LRESULT)dwTemp;
4173 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4175 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4178 dwTemp = infoPtr->dwExStyle;
4179 infoPtr->dwExStyle = (DWORD)lParam;
4181 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
4182 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
4183 FIXME("Extended style not implemented %s %s\n",
4184 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
4185 "TBSTYLE_EX_MIXEDBUTTONS" : "",
4186 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
4187 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
4190 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
4191 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4192 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
4194 return (LRESULT)dwTemp;
4199 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4201 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4202 HIMAGELIST himlTemp;
4203 HIMAGELIST himl = (HIMAGELIST)lParam;
4206 if (infoPtr->iVersion >= 5)
4209 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlHot,
4210 &infoPtr->cimlHot, himl, id);
4212 /* FIXME: redraw ? */
4214 return (LRESULT)himlTemp;
4219 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
4221 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4222 INT nOldHotItem = infoPtr->nHotItem;
4223 TBUTTON_INFO *btnPtr;
4225 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4228 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
4231 infoPtr->nHotItem = (INT)wParam;
4232 if ((INT)wParam >=0)
4234 btnPtr = &infoPtr->buttons[(INT)wParam];
4235 btnPtr->bHot = TRUE;
4236 InvalidateRect (hwnd, &btnPtr->rect,
4237 TOOLBAR_HasText(infoPtr, btnPtr));
4241 btnPtr = &infoPtr->buttons[nOldHotItem];
4242 btnPtr->bHot = FALSE;
4243 InvalidateRect (hwnd, &btnPtr->rect,
4244 TOOLBAR_HasText(infoPtr, btnPtr));
4248 if (nOldHotItem < 0)
4251 return (LRESULT)nOldHotItem;
4256 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4258 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4259 HIMAGELIST himlTemp;
4260 HIMAGELIST himl = (HIMAGELIST)lParam;
4263 if (infoPtr->iVersion >= 5)
4266 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlDef,
4267 &infoPtr->cimlDef, himl, id);
4269 infoPtr->nNumBitmaps = 0;
4270 for (i = 0; i < infoPtr->cimlDef; i++)
4271 infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl);
4273 ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth,
4274 &infoPtr->nBitmapHeight);
4275 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4276 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
4277 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
4279 /* FIXME: redraw ? */
4280 InvalidateRect(hwnd, NULL, TRUE);
4282 return (LRESULT)himlTemp;
4287 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4289 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4291 infoPtr->nIndent = (INT)wParam;
4295 /* process only on indent changing */
4296 if(infoPtr->nIndent != (INT)wParam)
4298 infoPtr->nIndent = (INT)wParam;
4299 TOOLBAR_CalcToolbar (hwnd);
4300 InvalidateRect(hwnd, NULL, FALSE);
4307 /* << TOOLBAR_SetInsertMark >> */
4311 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
4313 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4315 infoPtr->clrInsertMark = (COLORREF)lParam;
4317 /* FIXME : redraw ??*/
4324 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4326 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4328 if (infoPtr == NULL)
4331 infoPtr->nMaxTextRows = (INT)wParam;
4338 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
4340 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4343 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4344 infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
4345 infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
4346 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
4347 infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4348 return (LRESULT) oldPad;
4353 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4355 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4360 if (infoPtr == NULL)
4362 hwndOldNotify = infoPtr->hwndNotify;
4363 infoPtr->hwndNotify = (HWND)wParam;
4365 return (LRESULT)hwndOldNotify;
4370 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4372 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4373 LPRECT lprc = (LPRECT)lParam;
4377 if (LOWORD(wParam) > 1) {
4378 FIXME("multiple rows not supported!\n");
4381 if(infoPtr->nRows != LOWORD(wParam))
4383 infoPtr->nRows = LOWORD(wParam);
4385 /* recalculate toolbar */
4386 TOOLBAR_CalcToolbar (hwnd);
4388 /* repaint toolbar */
4389 InvalidateRect(hwnd, NULL, FALSE);
4392 /* return bounding rectangle */
4394 lprc->left = infoPtr->rcBound.left;
4395 lprc->right = infoPtr->rcBound.right;
4396 lprc->top = infoPtr->rcBound.top;
4397 lprc->bottom = infoPtr->rcBound.bottom;
4405 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
4407 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4408 TBUTTON_INFO *btnPtr;
4411 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4415 btnPtr = &infoPtr->buttons[nIndex];
4417 /* if hidden state has changed the invalidate entire window and recalc */
4418 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
4419 btnPtr->fsState = LOWORD(lParam);
4420 TOOLBAR_CalcToolbar (hwnd);
4421 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
4425 /* process state changing if current state doesn't match new state */
4426 if(btnPtr->fsState != LOWORD(lParam))
4428 btnPtr->fsState = LOWORD(lParam);
4429 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4438 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4440 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4441 TBUTTON_INFO *btnPtr;
4444 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4448 btnPtr = &infoPtr->buttons[nIndex];
4450 /* process style change if current style doesn't match new style */
4451 if(btnPtr->fsStyle != LOWORD(lParam))
4453 btnPtr->fsStyle = LOWORD(lParam);
4454 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4457 if (infoPtr->hwndToolTip) {
4458 FIXME("change tool tip!\n");
4466 inline static LRESULT
4467 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
4469 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4471 if (infoPtr == NULL)
4473 infoPtr->hwndToolTip = (HWND)wParam;
4479 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
4481 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4484 TRACE("%s hwnd=%p stub!\n",
4485 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
4487 bTemp = infoPtr->bUnicode;
4488 infoPtr->bUnicode = (BOOL)wParam;
4495 TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4497 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4499 lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
4500 comctl32_color.clrBtnHighlight :
4501 infoPtr->clrBtnHighlight;
4502 lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
4503 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
4509 TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4511 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4513 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4514 lParam->clrBtnHighlight, lParam->clrBtnShadow,
4515 infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow);
4517 infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
4518 infoPtr->clrBtnShadow = lParam->clrBtnShadow;
4519 InvalidateRect(hwnd, 0, 0);
4525 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
4527 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4528 INT iOldVersion = infoPtr->iVersion;
4530 infoPtr->iVersion = iVersion;
4532 if (infoPtr->iVersion >= 5)
4533 TOOLBAR_SetUnicodeFormat(hwnd, (WPARAM)TRUE, (LPARAM)0);
4539 /*********************************************************************/
4541 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */
4542 /* without the restriction of TBSTYLE_FLAT. This implementation is */
4543 /* based on relay traces of the native control and IE 5.5 */
4545 /*********************************************************************/
4547 TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam)
4549 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4550 INT nOldHotItem = infoPtr->nHotItem;
4551 TBUTTON_INFO *btnPtr;
4553 NMTBHOTITEM nmhotitem;
4555 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4558 infoPtr->nHotItem = (INT)wParam;
4559 if (nOldHotItem != infoPtr->nHotItem) {
4560 nmhotitem.dwFlags = (DWORD)lParam;
4561 if ( !(nmhotitem.dwFlags & HICF_ENTERING) )
4562 nmhotitem.idOld = (nOldHotItem >= 0) ?
4563 infoPtr->buttons[nOldHotItem].idCommand : 0;
4564 if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
4565 nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
4566 infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
4567 no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
4569 if ((INT)wParam >=0) {
4570 btnPtr = &infoPtr->buttons[(INT)wParam];
4571 btnPtr->bHot = (no_hi) ? FALSE : TRUE;
4572 InvalidateRect (hwnd, &btnPtr->rect,
4573 TOOLBAR_HasText(infoPtr, btnPtr));
4575 if (nOldHotItem>=0) {
4576 btnPtr = &infoPtr->buttons[nOldHotItem];
4577 btnPtr->bHot = FALSE;
4578 InvalidateRect (hwnd, &btnPtr->rect,
4579 TOOLBAR_HasText(infoPtr, btnPtr));
4582 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
4583 nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi);
4585 if (nOldHotItem < 0)
4588 return (LRESULT)nOldHotItem;
4593 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
4595 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4596 LPSIZE lpsize = (LPSIZE)lParam;
4602 * Testing shows the following:
4603 * wParam = 0 adjust cx value
4604 * = 1 set cy value to max size.
4605 * lParam pointer to SIZE structure
4608 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4609 wParam, lParam, lpsize->cx, lpsize->cy);
4613 if (lpsize->cx == -1) {
4614 /* **** this is wrong, native measures each button and sets it */
4615 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4617 else if(HIWORD(lpsize->cx)) {
4619 HWND hwndParent = GetParent(hwnd);
4621 InvalidateRect(hwnd, 0, 1);
4622 GetWindowRect(hwnd, &rc);
4623 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
4624 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
4625 rc.left, rc.top, rc.right, rc.bottom);
4626 lpsize->cx = max(rc.right-rc.left,
4627 infoPtr->rcBound.right - infoPtr->rcBound.left);
4630 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4634 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4635 /* lpsize->cy = infoPtr->nHeight; */
4638 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4642 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4643 lpsize->cx, lpsize->cy);
4649 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
4651 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4652 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4655 /* initialize info structure */
4656 infoPtr->nButtonHeight = 22;
4657 infoPtr->nButtonWidth = 24;
4658 infoPtr->nBitmapHeight = 15;
4659 infoPtr->nBitmapWidth = 16;
4661 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
4663 infoPtr->nMaxTextRows = 1;
4664 infoPtr->cxMin = -1;
4665 infoPtr->cxMax = -1;
4666 infoPtr->nNumBitmaps = 0;
4667 infoPtr->nNumStrings = 0;
4669 infoPtr->bCaptured = FALSE;
4670 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4671 infoPtr->nButtonDown = -1;
4672 infoPtr->nOldHit = -1;
4673 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4674 infoPtr->hwndNotify = GetParent (hwnd);
4675 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
4676 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
4677 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
4678 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
4679 infoPtr->iVersion = 0;
4680 infoPtr->hwndSelf = hwnd;
4681 infoPtr->bDoRedraw = TRUE;
4682 infoPtr->clrBtnHighlight = CLR_DEFAULT;
4683 infoPtr->clrBtnShadow = CLR_DEFAULT;
4684 infoPtr->szPadding.cx = 7;
4685 infoPtr->szPadding.cy = 6;
4686 TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
4688 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
4689 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
4691 if (dwStyle & TBSTYLE_TOOLTIPS) {
4692 /* Create tooltip control */
4693 infoPtr->hwndToolTip =
4694 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
4695 CW_USEDEFAULT, CW_USEDEFAULT,
4696 CW_USEDEFAULT, CW_USEDEFAULT,
4699 /* Send NM_TOOLTIPSCREATED notification */
4700 if (infoPtr->hwndToolTip) {
4701 NMTOOLTIPSCREATED nmttc;
4703 nmttc.hwndToolTips = infoPtr->hwndToolTip;
4705 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
4706 NM_TOOLTIPSCREATED);
4710 TOOLBAR_CheckStyle (hwnd, dwStyle);
4712 TOOLBAR_CalcToolbar(hwnd);
4719 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
4721 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4723 /* delete tooltip control */
4724 if (infoPtr->hwndToolTip)
4725 DestroyWindow (infoPtr->hwndToolTip);
4727 /* delete button data */
4728 if (infoPtr->buttons)
4729 COMCTL32_Free (infoPtr->buttons);
4731 /* delete strings */
4732 if (infoPtr->strings) {
4734 for (i = 0; i < infoPtr->nNumStrings; i++)
4735 if (infoPtr->strings[i])
4736 COMCTL32_Free (infoPtr->strings[i]);
4738 COMCTL32_Free (infoPtr->strings);
4741 /* destroy internal image list */
4742 if (infoPtr->himlInt)
4743 ImageList_Destroy (infoPtr->himlInt);
4745 TOOLBAR_DeleteImageList(&infoPtr->himlDef, &infoPtr->cimlDef);
4746 TOOLBAR_DeleteImageList(&infoPtr->himlDis, &infoPtr->cimlDis);
4747 TOOLBAR_DeleteImageList(&infoPtr->himlHot, &infoPtr->cimlHot);
4749 /* delete default font */
4751 DeleteObject (infoPtr->hDefaultFont);
4753 /* free toolbar info data */
4754 COMCTL32_Free (infoPtr);
4755 SetWindowLongA (hwnd, 0, 0);
4762 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
4764 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4765 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4766 NMTBCUSTOMDRAW tbcd;
4770 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4771 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4772 tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
4773 tbcd.nmcd.hdc = (HDC)wParam;
4774 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4775 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4777 /* FIXME: in general the return flags *can* be or'ed together */
4778 switch (infoPtr->dwBaseCustDraw)
4780 case CDRF_DODEFAULT:
4782 case CDRF_SKIPDEFAULT:
4785 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4790 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4791 * to my parent for processing.
4793 if (infoPtr->bTransparent) {
4795 HDC hdc = (HDC)wParam;
4800 parent = GetParent(hwnd);
4801 MapWindowPoints(hwnd, parent, &pt, 1);
4802 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
4803 ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
4804 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
4807 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
4809 if ((dwStyle & TBSTYLE_CUSTOMERASE) &&
4810 (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) {
4811 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4812 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
4813 tbcd.nmcd.hdc = (HDC)wParam;
4814 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4815 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4816 switch (infoPtr->dwBaseCustDraw)
4818 case CDRF_DODEFAULT:
4820 case CDRF_SKIPDEFAULT:
4823 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4832 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
4834 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4836 return (LRESULT)infoPtr->hFont;
4841 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
4843 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4844 TBUTTON_INFO *btnPtr;
4848 pt.x = (INT)LOWORD(lParam);
4849 pt.y = (INT)HIWORD(lParam);
4850 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4853 btnPtr = &infoPtr->buttons[nHit];
4854 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4857 infoPtr->bCaptured = TRUE;
4858 infoPtr->nButtonDown = nHit;
4860 btnPtr->fsState |= TBSTATE_PRESSED;
4862 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4865 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
4866 TOOLBAR_Customize (hwnd);
4873 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
4875 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4876 TBUTTON_INFO *btnPtr;
4881 if (infoPtr->hwndToolTip)
4882 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4883 WM_LBUTTONDOWN, wParam, lParam);
4885 pt.x = (INT)LOWORD(lParam);
4886 pt.y = (INT)HIWORD(lParam);
4887 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4891 btnPtr = &infoPtr->buttons[nHit];
4892 infoPtr->nOldHit = nHit;
4894 CopyRect(&arrowRect, &btnPtr->rect);
4895 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
4897 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4898 if ((btnPtr->fsState & TBSTATE_ENABLED) && (btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
4899 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
4900 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
4904 * this time we must force a Redraw, so the btn is
4905 * painted down before CaptureChanged repaints it up
4907 RedrawWindow(hwnd,&btnPtr->rect,0,
4908 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
4910 nmtb.iItem = btnPtr->idCommand;
4911 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
4914 memset(&nmtb.rcButton, 0, sizeof(RECT));
4915 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4917 if (res != TBDDRET_TREATPRESSED)
4918 /* ??? guess (GA) */
4920 /* otherwise drop through and process as pushed */
4922 /* SetCapture (hwnd); */
4923 infoPtr->bCaptured = TRUE;
4924 infoPtr->nButtonDown = nHit;
4926 btnPtr->fsState |= TBSTATE_PRESSED;
4927 btnPtr->bHot = FALSE;
4929 if (btnPtr->fsState & TBSTATE_ENABLED)
4930 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
4934 /* native issues the TBN_BEGINDRAG here */
4935 nmtb.iItem = btnPtr->idCommand;
4936 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4937 nmtb.tbButton.idCommand = btnPtr->idCommand;
4938 nmtb.tbButton.fsState = btnPtr->fsState;
4939 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4940 nmtb.tbButton.dwData = btnPtr->dwData;
4941 nmtb.tbButton.iString = btnPtr->iString;
4942 nmtb.cchText = 0; /* !!! not correct */
4943 nmtb.pszText = 0; /* !!! not correct */
4944 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4952 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
4954 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4955 TBUTTON_INFO *btnPtr;
4959 BOOL bSendMessage = TRUE;
4964 if (infoPtr->hwndToolTip)
4965 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4966 WM_LBUTTONUP, wParam, lParam);
4968 pt.x = (INT)LOWORD(lParam);
4969 pt.y = (INT)HIWORD(lParam);
4970 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4972 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
4973 /* if the cursor is still inside of the toolbar */
4974 if((infoPtr->nHotItem >= 0) && (nHit != -1))
4975 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
4977 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4978 btnPtr->fsState &= ~TBSTATE_PRESSED;
4980 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
4981 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
4982 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
4984 if (nOldIndex == nHit)
4985 bSendMessage = FALSE;
4986 if ((nOldIndex != nHit) &&
4988 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
4989 btnPtr->fsState |= TBSTATE_CHECKED;
4992 if (btnPtr->fsState & TBSTATE_CHECKED)
4993 btnPtr->fsState &= ~TBSTATE_CHECKED;
4995 btnPtr->fsState |= TBSTATE_CHECKED;
4999 if (nOldIndex != -1)
5001 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
5002 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
5006 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5007 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5008 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5010 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
5012 infoPtr->nButtonDown = -1;
5014 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5015 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
5016 NM_RELEASEDCAPTURE);
5018 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5021 nmtb.iItem = btnPtr->idCommand;
5022 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
5023 nmtb.tbButton.idCommand = btnPtr->idCommand;
5024 nmtb.tbButton.fsState = btnPtr->fsState;
5025 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
5026 nmtb.tbButton.dwData = btnPtr->dwData;
5027 nmtb.tbButton.iString = btnPtr->iString;
5028 nmtb.cchText = 0; /* !!! not correct */
5029 nmtb.pszText = 0; /* !!! not correct */
5030 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
5033 if (btnPtr->fsState & TBSTATE_ENABLED)
5035 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
5036 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
5038 /* !!! Undocumented - toolbar at 4.71 level and above sends
5039 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
5040 * Only NM_RCLICK is documented.
5042 nmmouse.dwItemSpec = btnPtr->idCommand;
5043 nmmouse.dwItemData = btnPtr->dwData;
5044 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, NM_CLICK);
5050 TOOLBAR_CaptureChanged(HWND hwnd)
5052 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5053 TBUTTON_INFO *btnPtr;
5055 infoPtr->bCaptured = FALSE;
5057 if (infoPtr->nButtonDown >= 0)
5059 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5060 btnPtr->fsState &= ~TBSTATE_PRESSED;
5062 infoPtr->nOldHit = -1;
5064 if (btnPtr->fsState & TBSTATE_ENABLED)
5065 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
5072 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
5074 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5075 TBUTTON_INFO *hotBtnPtr, *btnPtr;
5078 if (infoPtr->nOldHit < 0)
5081 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
5083 /* Redraw the button if the last button we were over is the hot button and it
5085 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
5087 hotBtnPtr->bHot = FALSE;
5088 rc1 = hotBtnPtr->rect;
5089 InflateRect (&rc1, 1, 1);
5090 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
5094 /* If the last button we were over is depressed then make it not */
5095 /* depressed and redraw it */
5096 if(infoPtr->nOldHit == infoPtr->nButtonDown)
5098 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5100 btnPtr->fsState &= ~TBSTATE_PRESSED;
5102 rc1 = hotBtnPtr->rect;
5103 InflateRect (&rc1, 1, 1);
5104 InvalidateRect (hwnd, &rc1, TRUE);
5107 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
5108 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
5114 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
5116 TBUTTON_INFO *btnPtr = NULL, *oldBtnPtr = NULL;
5117 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5120 TRACKMOUSEEVENT trackinfo;
5121 NMTBHOTITEM nmhotitem;
5123 /* fill in the TRACKMOUSEEVENT struct */
5124 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
5125 trackinfo.dwFlags = TME_QUERY;
5126 trackinfo.hwndTrack = hwnd;
5127 trackinfo.dwHoverTime = HOVER_DEFAULT;
5129 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
5130 _TrackMouseEvent(&trackinfo);
5132 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
5133 if(!(trackinfo.dwFlags & TME_LEAVE)) {
5134 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
5136 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
5137 /* and can properly deactivate the hot toolbar button */
5138 _TrackMouseEvent(&trackinfo);
5141 if (infoPtr->hwndToolTip)
5142 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
5143 WM_MOUSEMOVE, wParam, lParam);
5145 pt.x = (INT)LOWORD(lParam);
5146 pt.y = (INT)HIWORD(lParam);
5148 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
5150 if (infoPtr->nOldHit != nHit)
5152 /* Remove the effect of an old hot button if the button was enabled and was
5153 drawn with the hot button effect */
5154 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
5155 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
5157 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
5158 oldBtnPtr->bHot = FALSE;
5161 /* It's not a separator or in nowhere. It's a hot button. */
5164 btnPtr = &infoPtr->buttons[nHit];
5166 infoPtr->nHotItem = nHit;
5168 /* only enabled buttons show hot effect */
5169 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
5171 btnPtr->bHot = TRUE;
5175 nmhotitem.dwFlags = HICF_MOUSE;
5177 nmhotitem.idOld = oldBtnPtr->idCommand;
5179 nmhotitem.dwFlags |= HICF_ENTERING;
5181 nmhotitem.idNew = btnPtr->idCommand;
5183 nmhotitem.dwFlags |= HICF_LEAVING;
5184 TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
5186 /* now invalidate the old and new buttons so they will be painted */
5188 InvalidateRect (hwnd, &oldBtnPtr->rect,
5189 TOOLBAR_HasText(infoPtr, oldBtnPtr));
5190 if (btnPtr && (btnPtr->fsState & TBSTATE_ENABLED))
5191 InvalidateRect(hwnd, &btnPtr->rect,
5192 TOOLBAR_HasText(infoPtr, btnPtr));
5194 if (infoPtr->bCaptured) {
5195 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5196 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
5197 btnPtr->fsState &= ~TBSTATE_PRESSED;
5198 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
5200 else if (nHit == infoPtr->nButtonDown) {
5201 btnPtr->fsState |= TBSTATE_PRESSED;
5202 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
5205 infoPtr->nOldHit = nHit;
5211 inline static LRESULT
5212 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
5214 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
5215 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
5217 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
5221 inline static LRESULT
5222 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
5224 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
5225 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
5227 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
5232 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
5234 TOOLBAR_INFO *infoPtr;
5235 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
5238 /* allocate memory for info structure */
5239 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
5240 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
5243 infoPtr->dwStructSize = sizeof(TBBUTTON);
5245 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5246 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
5247 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
5248 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
5251 /* native control does:
5252 * Get a lot of colors and brushes
5254 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5255 * CreateFontIndirectA(adr1)
5256 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5257 * hdc = GetDC(toolbar)
5258 * GetSystemMetrics(0x48)
5259 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5260 * 0, 0, 0, 0, "MARLETT")
5261 * oldfnt = SelectObject(hdc, fnt2)
5262 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5263 * GetTextMetricsA(hdc, adr3)
5264 * SelectObject(hdc, oldfnt)
5265 * DeleteObject(fnt2)
5267 * InvalidateRect(toolbar, 0, 1)
5268 * SetWindowLongA(toolbar, 0, addr)
5269 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5272 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5273 * ie 2 0x4600094c 0x4600094c 0x4600894d
5274 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5275 * rebar 0x50008844 0x40008844 0x50008845
5276 * pager 0x50000844 0x40000844 0x50008845
5277 * IC35mgr 0x5400084e **nochange**
5278 * on entry to _NCCREATE 0x5400084e
5279 * rowlist 0x5400004e **nochange**
5280 * on entry to _NCCREATE 0x5400004e
5284 /* I think the code below is a bug, but it is the way that the native
5285 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5286 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5287 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5288 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5289 * Some how, the only cases of this seem to be MFC programs.
5291 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5292 * does not occur in the WM_STYLECHANGING routine.
5293 * (Guy Albertelli 9/2001)
5296 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
5297 styleadd |= TBSTYLE_TRANSPARENT;
5298 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
5299 styleadd |= CCS_TOP; /* default to top */
5300 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
5303 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
5308 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
5310 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5314 if (dwStyle & WS_MINIMIZE)
5315 return 0; /* Nothing to do */
5317 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
5319 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
5322 if (!(dwStyle & CCS_NODIVIDER))
5324 GetWindowRect (hwnd, &rcWindow);
5325 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
5326 if( dwStyle & WS_BORDER )
5327 OffsetRect (&rcWindow, 1, 1);
5328 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
5331 ReleaseDC( hwnd, hdc );
5337 inline static LRESULT
5338 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
5340 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5341 LPNMHDR lpnmh = (LPNMHDR)lParam;
5343 if (lpnmh->code == PGN_CALCSIZE) {
5344 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
5346 if (lppgc->dwFlag == PGF_CALCWIDTH) {
5347 lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
5348 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5352 lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
5353 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5359 if (lpnmh->code == PGN_SCROLL) {
5360 LPNMPGSCROLL lppgs = (LPNMPGSCROLL)lParam;
5362 lppgs->iScroll = (lppgs->iDir & (PGF_SCROLLLEFT | PGF_SCROLLRIGHT)) ?
5363 infoPtr->nButtonWidth : infoPtr->nButtonHeight;
5364 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
5365 lppgs->iScroll, lppgs->iDir);
5370 TRACE("passing WM_NOTIFY!\n");
5372 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
5373 if (infoPtr->bNtfUnicode)
5374 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
5377 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
5381 if (lpnmh->code == TTN_GETDISPINFOA) {
5382 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
5384 FIXME("retrieving ASCII string\n");
5387 else if (lpnmh->code == TTN_GETDISPINFOW) {
5388 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
5390 FIXME("retrieving UNICODE string\n");
5401 TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
5403 /* remove this routine when Toolbar is improved to pass infoPtr
5404 * around instead of hwnd.
5406 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5407 return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
5412 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
5416 if (lParam == NF_REQUERY) {
5417 i = SendMessageA(GetParent(infoPtr->hwndSelf),
5418 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
5419 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
5420 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5424 infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
5427 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
5432 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
5434 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5438 /* fill ps.rcPaint with a default rect */
5439 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
5441 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
5443 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
5444 ps.rcPaint.left, ps.rcPaint.top,
5445 ps.rcPaint.right, ps.rcPaint.bottom);
5447 TOOLBAR_Refresh (hwnd, hdc, &ps);
5448 if (!wParam) EndPaint (hwnd, &ps);
5455 TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
5456 /*****************************************************
5459 * Handles the WM_SETREDRAW message.
5462 * According to testing V4.71 of COMCTL32 returns the
5463 * *previous* status of the redraw flag (either 0 or 1)
5464 * instead of the MSDN documented value of 0 if handled.
5465 * (For laughs see the "consistancy" with same function
5468 *****************************************************/
5470 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5471 BOOL oldredraw = infoPtr->bDoRedraw;
5473 TRACE("set to %s\n",
5474 (wParam) ? "TRUE" : "FALSE");
5475 infoPtr->bDoRedraw = (BOOL) wParam;
5477 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
5479 return (oldredraw) ? 1 : 0;
5484 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
5486 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5487 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5496 /* Resize deadlock check */
5497 if (infoPtr->bAutoSize) {
5498 infoPtr->bAutoSize = FALSE;
5502 /* FIXME: optimize to only update size if the new size doesn't */
5503 /* match the current size */
5505 flags = (INT) wParam;
5507 /* FIXME for flags =
5508 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5511 TRACE("sizing toolbar!\n");
5513 if (flags == SIZE_RESTORED) {
5514 /* width and height don't apply */
5515 parent = GetParent (hwnd);
5516 GetClientRect(parent, &parent_rect);
5517 x = parent_rect.left;
5518 y = parent_rect.top;
5520 if (dwStyle & CCS_NORESIZE) {
5521 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
5524 * this sets the working width of the toolbar, and
5525 * Calc Toolbar will not adjust it, only the height
5527 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5528 cy = infoPtr->nHeight;
5529 cx = infoPtr->nWidth;
5530 TOOLBAR_CalcToolbar (hwnd);
5531 infoPtr->nWidth = cx;
5532 infoPtr->nHeight = cy;
5535 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5536 TOOLBAR_CalcToolbar (hwnd);
5537 cy = infoPtr->nHeight;
5538 cx = infoPtr->nWidth;
5540 if (dwStyle & CCS_NOMOVEY) {
5541 GetWindowRect(hwnd, &window_rect);
5542 ScreenToClient(parent, (LPPOINT)&window_rect.left);
5543 y = window_rect.top;
5547 if (dwStyle & CCS_NOPARENTALIGN) {
5548 uPosFlags |= SWP_NOMOVE;
5549 cy = infoPtr->nHeight;
5550 cx = infoPtr->nWidth;
5553 if (!(dwStyle & CCS_NODIVIDER))
5554 cy += GetSystemMetrics(SM_CYEDGE);
5556 if (dwStyle & WS_BORDER)
5559 cy += GetSystemMetrics(SM_CYEDGE);
5560 cx += GetSystemMetrics(SM_CYEDGE);
5563 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
5564 cx, cy, uPosFlags | SWP_NOZORDER);
5571 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
5573 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5575 if (nType == GWL_STYLE) {
5576 if (lpStyle->styleNew & TBSTYLE_LIST) {
5577 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
5580 infoPtr->dwDTFlags = DT_CENTER;
5582 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
5583 infoPtr->bBtnTranspnt = (lpStyle->styleNew &
5584 (TBSTYLE_FLAT | TBSTYLE_LIST));
5585 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
5588 TOOLBAR_AutoSize (hwnd);
5590 InvalidateRect(hwnd, NULL, FALSE);
5597 TOOLBAR_SysColorChange (HWND hwnd)
5599 COMCTL32_RefreshSysColors();
5606 static LRESULT WINAPI
5607 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5609 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
5610 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
5612 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
5613 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
5618 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
5620 case TB_ADDBUTTONSA:
5621 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
5623 case TB_ADDBUTTONSW:
5624 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
5627 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
5630 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
5633 return TOOLBAR_AutoSize (hwnd);
5635 case TB_BUTTONCOUNT:
5636 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
5638 case TB_BUTTONSTRUCTSIZE:
5639 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
5641 case TB_CHANGEBITMAP:
5642 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
5644 case TB_CHECKBUTTON:
5645 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
5647 case TB_COMMANDTOINDEX:
5648 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
5651 return TOOLBAR_Customize (hwnd);
5653 case TB_DELETEBUTTON:
5654 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
5656 case TB_ENABLEBUTTON:
5657 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
5659 case TB_GETANCHORHIGHLIGHT:
5660 return TOOLBAR_GetAnchorHighlight (hwnd);
5663 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
5665 case TB_GETBITMAPFLAGS:
5666 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
5669 return TOOLBAR_GetButton (hwnd, wParam, lParam);
5671 case TB_GETBUTTONINFOA:
5672 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
5674 case TB_GETBUTTONINFOW:
5675 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
5677 case TB_GETBUTTONSIZE:
5678 return TOOLBAR_GetButtonSize (hwnd);
5680 case TB_GETBUTTONTEXTA:
5681 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
5683 case TB_GETBUTTONTEXTW:
5684 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
5686 case TB_GETDISABLEDIMAGELIST:
5687 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
5689 case TB_GETEXTENDEDSTYLE:
5690 return TOOLBAR_GetExtendedStyle (hwnd);
5692 case TB_GETHOTIMAGELIST:
5693 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
5696 return TOOLBAR_GetHotItem (hwnd);
5698 case TB_GETIMAGELIST:
5699 return TOOLBAR_GetDefImageList (hwnd, wParam, lParam);
5701 /* case TB_GETINSERTMARK: */ /* 4.71 */
5702 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5704 case TB_GETITEMRECT:
5705 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
5708 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
5710 /* case TB_GETOBJECT: */ /* 4.71 */
5713 return TOOLBAR_GetPadding (hwnd);
5716 return TOOLBAR_GetRect (hwnd, wParam, lParam);
5719 return TOOLBAR_GetRows (hwnd, wParam, lParam);
5722 return TOOLBAR_GetState (hwnd, wParam, lParam);
5725 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
5727 case TB_GETTEXTROWS:
5728 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
5730 case TB_GETTOOLTIPS:
5731 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
5733 case TB_GETUNICODEFORMAT:
5734 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
5737 return TOOLBAR_HideButton (hwnd, wParam, lParam);
5740 return TOOLBAR_HitTest (hwnd, wParam, lParam);
5742 case TB_INDETERMINATE:
5743 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
5745 case TB_INSERTBUTTONA:
5746 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
5748 case TB_INSERTBUTTONW:
5749 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
5751 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5753 case TB_ISBUTTONCHECKED:
5754 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
5756 case TB_ISBUTTONENABLED:
5757 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
5759 case TB_ISBUTTONHIDDEN:
5760 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
5762 case TB_ISBUTTONHIGHLIGHTED:
5763 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
5765 case TB_ISBUTTONINDETERMINATE:
5766 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
5768 case TB_ISBUTTONPRESSED:
5769 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
5771 case TB_LOADIMAGES: /* 4.70 */
5772 FIXME("missing standard imagelists\n");
5775 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5776 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5777 /* case TB_MARKBUTTON: */ /* 4.71 */
5778 /* case TB_MOVEBUTTON: */ /* 4.71 */
5780 case TB_PRESSBUTTON:
5781 return TOOLBAR_PressButton (hwnd, wParam, lParam);
5783 case TB_REPLACEBITMAP:
5784 return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam);
5786 case TB_SAVERESTOREA:
5787 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
5789 case TB_SAVERESTOREW:
5790 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
5792 case TB_SETANCHORHIGHLIGHT:
5793 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
5795 case TB_SETBITMAPSIZE:
5796 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
5798 case TB_SETBUTTONINFOA:
5799 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
5801 case TB_SETBUTTONINFOW:
5802 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
5804 case TB_SETBUTTONSIZE:
5805 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
5807 case TB_SETBUTTONWIDTH:
5808 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
5811 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
5813 case TB_SETDISABLEDIMAGELIST:
5814 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
5816 case TB_SETDRAWTEXTFLAGS:
5817 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
5819 case TB_SETEXTENDEDSTYLE:
5820 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
5822 case TB_SETHOTIMAGELIST:
5823 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
5826 return TOOLBAR_SetHotItem (hwnd, wParam);
5828 case TB_SETIMAGELIST:
5829 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
5832 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
5834 /* case TB_SETINSERTMARK: */ /* 4.71 */
5836 case TB_SETINSERTMARKCOLOR:
5837 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
5839 case TB_SETMAXTEXTROWS:
5840 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
5843 return TOOLBAR_SetPadding (hwnd, wParam, lParam);
5846 return TOOLBAR_SetParent (hwnd, wParam, lParam);
5849 return TOOLBAR_SetRows (hwnd, wParam, lParam);
5852 return TOOLBAR_SetState (hwnd, wParam, lParam);
5855 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
5857 case TB_SETTOOLTIPS:
5858 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
5860 case TB_SETUNICODEFORMAT:
5861 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
5864 return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
5867 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
5870 /* Common Control Messages */
5872 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
5873 case CCM_GETCOLORSCHEME:
5874 return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5876 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
5877 case CCM_SETCOLORSCHEME:
5878 return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5880 case CCM_GETVERSION:
5881 return TOOLBAR_GetVersion (hwnd);
5883 case CCM_SETVERSION:
5884 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
5890 return TOOLBAR_Create (hwnd, wParam, lParam);
5893 return TOOLBAR_Destroy (hwnd, wParam, lParam);
5896 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
5899 return TOOLBAR_GetFont (hwnd, wParam, lParam);
5901 /* case WM_KEYDOWN: */
5902 /* case WM_KILLFOCUS: */
5904 case WM_LBUTTONDBLCLK:
5905 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
5907 case WM_LBUTTONDOWN:
5908 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
5911 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
5914 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
5917 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
5919 case WM_CAPTURECHANGED:
5920 return TOOLBAR_CaptureChanged(hwnd);
5923 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
5926 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
5929 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
5932 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
5935 return TOOLBAR_Notify (hwnd, wParam, lParam);
5937 case WM_NOTIFYFORMAT:
5938 TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
5941 return TOOLBAR_Paint (hwnd, wParam);
5944 return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
5947 return TOOLBAR_Size (hwnd, wParam, lParam);
5949 case WM_STYLECHANGED:
5950 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
5952 case WM_SYSCOLORCHANGE:
5953 return TOOLBAR_SysColorChange (hwnd);
5955 /* case WM_WININICHANGE: */
5960 case WM_MEASUREITEM:
5963 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5965 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
5967 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
5970 /* We see this in Outlook Express 5.x and just does DefWindowProc */
5971 case PGM_FORWARDMOUSE:
5972 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5975 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
5976 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
5977 uMsg, wParam, lParam);
5978 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5985 TOOLBAR_Register (void)
5989 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
5990 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
5991 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
5992 wndClass.cbClsExtra = 0;
5993 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
5994 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
5995 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
5996 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
5998 RegisterClassA (&wndClass);
6003 TOOLBAR_Unregister (void)
6005 UnregisterClassA (TOOLBARCLASSNAMEA, NULL);
6008 static HIMAGELIST TOOLBAR_InsertImageList(PIMLENTRY **pies, INT *cies, HIMAGELIST himl, INT id)
6013 /* Check if the entry already exists */
6014 c = TOOLBAR_GetImageListEntry(*pies, *cies, id);
6016 /* If this is a new entry we must create it and insert into the array */
6021 c = (PIMLENTRY) COMCTL32_Alloc(sizeof(IMLENTRY));
6024 pnies = COMCTL32_Alloc((*cies + 1) * sizeof(PIMLENTRY));
6025 memcpy(pnies, *pies, ((*cies) * sizeof(PIMLENTRY)));
6029 COMCTL32_Free(*pies);
6040 static VOID TOOLBAR_DeleteImageList(PIMLENTRY **pies, INT *cies)
6044 for (i = 0; i < *cies; i++)
6045 COMCTL32_Free((*pies)[i]);
6047 COMCTL32_Free(*pies);
6054 static PIMLENTRY TOOLBAR_GetImageListEntry(PIMLENTRY *pies, INT cies, INT id)
6062 for (i = 0; i < cies; i++)
6064 if (pies[i]->id == id)
6076 static HIMAGELIST TOOLBAR_GetImageList(PIMLENTRY *pies, INT cies, INT id)
6078 HIMAGELIST himlDef = 0;
6079 PIMLENTRY pie = TOOLBAR_GetImageListEntry(pies, cies, id);
6082 himlDef = pie->himl;
6088 static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb)
6090 if (infoPtr->bUnicode)
6091 return TOOLBAR_SendNotify ((NMHDR *) nmtb, infoPtr, TBN_GETBUTTONINFOW);
6098 nmtba.iItem = nmtb->iItem;
6099 nmtba.pszText = Buffer;
6100 nmtba.cchText = 256;
6101 ZeroMemory(nmtba.pszText, nmtba.cchText);
6103 if (TOOLBAR_SendNotify ((NMHDR *) &nmtba, infoPtr, TBN_GETBUTTONINFOA))
6105 int ccht = strlen(nmtba.pszText);
6107 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)nmtba.pszText, -1,
6108 nmtb->pszText, nmtb->cchText);
6110 memcpy(&nmtb->tbButton, &nmtba.tbButton, sizeof(TBBUTTON));
6119 static BOOL TOOLBAR_IsButtonRemovable(TOOLBAR_INFO *infoPtr,
6120 int iItem, PCUSTOMBUTTON btnInfo)
6125 memcpy(&nmtb.tbButton, &btnInfo->btn, sizeof(TBBUTTON));
6127 return TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYDELETE);