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 * - Button wrapping (under construction).
34 * - Notifications (under construction).
36 * - Tooltip support (almost complete).
37 * - Unicode suppport (under construction).
38 * - Fix TOOLBAR_SetButtonInfo32A/W.
39 * - TBSTYLE_AUTOSIZE for toolbar and buttons.
40 * - I_IMAGECALLBACK support.
41 * - iString of -1 is undocumented
42 * - Customization dialog:
44 * - Minor buglet in 'available buttons' list:
45 * Buttons are not listed in M$-like order. M$ seems to use a single
46 * internal list to store the button information of both listboxes.
47 * - Drag list support.
48 * - Help and Reset button support.
51 * - Run tests using Waite Group Windows95 API Bible Volume 2.
52 * The second cdrom contains executables addstr.exe, btncount.exe,
53 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
54 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
55 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
56 * setparnt.exe, setrows.exe, toolwnd.exe.
57 * - Microsofts controlspy examples.
58 * - Charles Petzold's 'Programming Windows': gadgets.exe
67 #include "wine/unicode.h"
69 #include "imagelist.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 /* uses image list internals directly */
3958 himlDef->cx = infoPtr->nBitmapWidth;
3959 himlDef->cy = infoPtr->nBitmapHeight;
3967 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3969 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3970 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
3971 TBUTTON_INFO *btnPtr;
3976 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
3979 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3980 lptbbi->dwMask & 0x80000000);
3984 btnPtr = &infoPtr->buttons[nIndex];
3985 if (lptbbi->dwMask & TBIF_COMMAND)
3986 btnPtr->idCommand = lptbbi->idCommand;
3987 if (lptbbi->dwMask & TBIF_IMAGE)
3988 btnPtr->iBitmap = lptbbi->iImage;
3989 if (lptbbi->dwMask & TBIF_LPARAM)
3990 btnPtr->dwData = lptbbi->lParam;
3991 /* if (lptbbi->dwMask & TBIF_SIZE) */
3992 /* btnPtr->cx = lptbbi->cx; */
3993 if (lptbbi->dwMask & TBIF_STATE)
3994 btnPtr->fsState = lptbbi->fsState;
3995 if (lptbbi->dwMask & TBIF_STYLE)
3996 btnPtr->fsStyle = lptbbi->fsStyle;
3998 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
3999 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
4000 /* iString is index, zero it to make Str_SetPtr succeed */
4003 Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
4010 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
4012 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4013 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
4014 TBUTTON_INFO *btnPtr;
4019 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
4022 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
4023 lptbbi->dwMask & 0x80000000);
4027 btnPtr = &infoPtr->buttons[nIndex];
4028 if (lptbbi->dwMask & TBIF_COMMAND)
4029 btnPtr->idCommand = lptbbi->idCommand;
4030 if (lptbbi->dwMask & TBIF_IMAGE)
4031 btnPtr->iBitmap = lptbbi->iImage;
4032 if (lptbbi->dwMask & TBIF_LPARAM)
4033 btnPtr->dwData = lptbbi->lParam;
4034 /* if (lptbbi->dwMask & TBIF_SIZE) */
4035 /* btnPtr->cx = lptbbi->cx; */
4036 if (lptbbi->dwMask & TBIF_STATE)
4037 btnPtr->fsState = lptbbi->fsState;
4038 if (lptbbi->dwMask & TBIF_STYLE)
4039 btnPtr->fsStyle = lptbbi->fsStyle;
4041 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
4042 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
4043 /* iString is index, zero it to make Str_SetPtr succeed */
4045 Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
4052 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
4054 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4055 INT cx = LOWORD(lParam), cy = HIWORD(lParam);
4057 if ((cx < 0) || (cy < 0))
4059 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
4063 /* The documentation claims you can only change the button size before
4064 * any button has been added. But this is wrong.
4065 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4066 * it to the toolbar, and it checks that the return value is nonzero - mjm
4067 * Further testing shows that we must actually perform the change too.
4070 * The documentation also does not mention that if 0 is supplied for
4071 * either size, the system changes it to the default of 24 wide and
4072 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4074 infoPtr->nButtonWidth = (cx) ? cx : 24;
4075 infoPtr->nButtonHeight = (cy) ? cy : 22;
4081 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
4083 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4085 if (infoPtr == NULL) {
4086 TRACE("Toolbar not initialized yet?????\n");
4090 /* if setting to current values, ignore */
4091 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
4092 (infoPtr->cxMax == (INT)HIWORD(lParam))) {
4093 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4094 infoPtr->cxMin, infoPtr->cxMax);
4098 /* save new values */
4099 infoPtr->cxMin = (INT)LOWORD(lParam);
4100 infoPtr->cxMax = (INT)HIWORD(lParam);
4102 /* if both values are 0 then we are done */
4104 TRACE("setting both min and max to 0, norecalc\n");
4108 /* otherwise we need to recalc the toolbar and in some cases
4109 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4110 which doesn't actually draw - GA). */
4111 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4112 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
4114 TOOLBAR_CalcToolbar (hwnd);
4116 InvalidateRect (hwnd, NULL, TRUE);
4123 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
4125 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4126 INT nIndex = (INT)wParam;
4128 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
4131 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
4133 if (infoPtr->hwndToolTip) {
4135 FIXME("change tool tip!\n");
4144 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4146 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4147 HIMAGELIST himl = (HIMAGELIST)lParam;
4148 HIMAGELIST himlTemp;
4151 if (infoPtr->iVersion >= 5)
4154 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlDis,
4155 &infoPtr->cimlDis, himl, id);
4157 /* FIXME: redraw ? */
4159 return (LRESULT)himlTemp;
4164 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
4166 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4169 dwTemp = infoPtr->dwDTFlags;
4170 infoPtr->dwDTFlags =
4171 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
4173 return (LRESULT)dwTemp;
4177 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4179 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4182 dwTemp = infoPtr->dwExStyle;
4183 infoPtr->dwExStyle = (DWORD)lParam;
4185 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
4186 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
4187 FIXME("Extended style not implemented %s %s\n",
4188 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
4189 "TBSTYLE_EX_MIXEDBUTTONS" : "",
4190 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
4191 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
4194 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
4195 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4196 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
4198 return (LRESULT)dwTemp;
4203 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4205 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4206 HIMAGELIST himlTemp;
4207 HIMAGELIST himl = (HIMAGELIST)lParam;
4210 if (infoPtr->iVersion >= 5)
4213 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlHot,
4214 &infoPtr->cimlHot, himl, id);
4216 /* FIXME: redraw ? */
4218 return (LRESULT)himlTemp;
4223 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
4225 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4226 INT nOldHotItem = infoPtr->nHotItem;
4227 TBUTTON_INFO *btnPtr;
4229 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4232 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
4235 infoPtr->nHotItem = (INT)wParam;
4236 if ((INT)wParam >=0)
4238 btnPtr = &infoPtr->buttons[(INT)wParam];
4239 btnPtr->bHot = TRUE;
4240 InvalidateRect (hwnd, &btnPtr->rect,
4241 TOOLBAR_HasText(infoPtr, btnPtr));
4245 btnPtr = &infoPtr->buttons[nOldHotItem];
4246 btnPtr->bHot = FALSE;
4247 InvalidateRect (hwnd, &btnPtr->rect,
4248 TOOLBAR_HasText(infoPtr, btnPtr));
4252 if (nOldHotItem < 0)
4255 return (LRESULT)nOldHotItem;
4260 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4262 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4263 HIMAGELIST himlTemp;
4264 HIMAGELIST himl = (HIMAGELIST)lParam;
4267 if (infoPtr->iVersion >= 5)
4270 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlDef,
4271 &infoPtr->cimlDef, himl, id);
4273 infoPtr->nNumBitmaps = 0;
4274 for (i = 0; i < infoPtr->cimlDef; i++)
4275 infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl);
4277 ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth,
4278 &infoPtr->nBitmapHeight);
4279 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4280 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
4281 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
4283 /* FIXME: redraw ? */
4284 InvalidateRect(hwnd, NULL, TRUE);
4286 return (LRESULT)himlTemp;
4291 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4293 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4295 infoPtr->nIndent = (INT)wParam;
4299 /* process only on indent changing */
4300 if(infoPtr->nIndent != (INT)wParam)
4302 infoPtr->nIndent = (INT)wParam;
4303 TOOLBAR_CalcToolbar (hwnd);
4304 InvalidateRect(hwnd, NULL, FALSE);
4311 /* << TOOLBAR_SetInsertMark >> */
4315 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
4317 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4319 infoPtr->clrInsertMark = (COLORREF)lParam;
4321 /* FIXME : redraw ??*/
4328 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4330 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4332 if (infoPtr == NULL)
4335 infoPtr->nMaxTextRows = (INT)wParam;
4342 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
4344 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4347 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4348 infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
4349 infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
4350 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
4351 infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4352 return (LRESULT) oldPad;
4357 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4359 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4364 if (infoPtr == NULL)
4366 hwndOldNotify = infoPtr->hwndNotify;
4367 infoPtr->hwndNotify = (HWND)wParam;
4369 return (LRESULT)hwndOldNotify;
4374 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4376 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4377 LPRECT lprc = (LPRECT)lParam;
4381 if (LOWORD(wParam) > 1) {
4382 FIXME("multiple rows not supported!\n");
4385 if(infoPtr->nRows != LOWORD(wParam))
4387 infoPtr->nRows = LOWORD(wParam);
4389 /* recalculate toolbar */
4390 TOOLBAR_CalcToolbar (hwnd);
4392 /* repaint toolbar */
4393 InvalidateRect(hwnd, NULL, FALSE);
4396 /* return bounding rectangle */
4398 lprc->left = infoPtr->rcBound.left;
4399 lprc->right = infoPtr->rcBound.right;
4400 lprc->top = infoPtr->rcBound.top;
4401 lprc->bottom = infoPtr->rcBound.bottom;
4409 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
4411 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4412 TBUTTON_INFO *btnPtr;
4415 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4419 btnPtr = &infoPtr->buttons[nIndex];
4421 /* if hidden state has changed the invalidate entire window and recalc */
4422 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
4423 btnPtr->fsState = LOWORD(lParam);
4424 TOOLBAR_CalcToolbar (hwnd);
4425 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
4429 /* process state changing if current state doesn't match new state */
4430 if(btnPtr->fsState != LOWORD(lParam))
4432 btnPtr->fsState = LOWORD(lParam);
4433 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4442 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4444 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4445 TBUTTON_INFO *btnPtr;
4448 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4452 btnPtr = &infoPtr->buttons[nIndex];
4454 /* process style change if current style doesn't match new style */
4455 if(btnPtr->fsStyle != LOWORD(lParam))
4457 btnPtr->fsStyle = LOWORD(lParam);
4458 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4461 if (infoPtr->hwndToolTip) {
4462 FIXME("change tool tip!\n");
4470 inline static LRESULT
4471 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
4473 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4475 if (infoPtr == NULL)
4477 infoPtr->hwndToolTip = (HWND)wParam;
4483 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
4485 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4488 TRACE("%s hwnd=%p stub!\n",
4489 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
4491 bTemp = infoPtr->bUnicode;
4492 infoPtr->bUnicode = (BOOL)wParam;
4499 TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4501 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4503 lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
4504 comctl32_color.clrBtnHighlight :
4505 infoPtr->clrBtnHighlight;
4506 lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
4507 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
4513 TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4515 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4517 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4518 lParam->clrBtnHighlight, lParam->clrBtnShadow,
4519 infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow);
4521 infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
4522 infoPtr->clrBtnShadow = lParam->clrBtnShadow;
4523 InvalidateRect(hwnd, 0, 0);
4529 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
4531 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4532 INT iOldVersion = infoPtr->iVersion;
4534 infoPtr->iVersion = iVersion;
4536 if (infoPtr->iVersion >= 5)
4537 TOOLBAR_SetUnicodeFormat(hwnd, (WPARAM)TRUE, (LPARAM)0);
4543 /*********************************************************************/
4545 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */
4546 /* without the restriction of TBSTYLE_FLAT. This implementation is */
4547 /* based on relay traces of the native control and IE 5.5 */
4549 /*********************************************************************/
4551 TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam)
4553 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4554 INT nOldHotItem = infoPtr->nHotItem;
4555 TBUTTON_INFO *btnPtr;
4557 NMTBHOTITEM nmhotitem;
4559 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4562 infoPtr->nHotItem = (INT)wParam;
4563 if (nOldHotItem != infoPtr->nHotItem) {
4564 nmhotitem.dwFlags = (DWORD)lParam;
4565 if ( !(nmhotitem.dwFlags & HICF_ENTERING) )
4566 nmhotitem.idOld = (nOldHotItem >= 0) ?
4567 infoPtr->buttons[nOldHotItem].idCommand : 0;
4568 if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
4569 nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
4570 infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
4571 no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
4573 if ((INT)wParam >=0) {
4574 btnPtr = &infoPtr->buttons[(INT)wParam];
4575 btnPtr->bHot = (no_hi) ? FALSE : TRUE;
4576 InvalidateRect (hwnd, &btnPtr->rect,
4577 TOOLBAR_HasText(infoPtr, btnPtr));
4579 if (nOldHotItem>=0) {
4580 btnPtr = &infoPtr->buttons[nOldHotItem];
4581 btnPtr->bHot = FALSE;
4582 InvalidateRect (hwnd, &btnPtr->rect,
4583 TOOLBAR_HasText(infoPtr, btnPtr));
4586 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
4587 nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi);
4589 if (nOldHotItem < 0)
4592 return (LRESULT)nOldHotItem;
4597 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
4599 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4600 LPSIZE lpsize = (LPSIZE)lParam;
4606 * Testing shows the following:
4607 * wParam = 0 adjust cx value
4608 * = 1 set cy value to max size.
4609 * lParam pointer to SIZE structure
4612 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4613 wParam, lParam, lpsize->cx, lpsize->cy);
4617 if (lpsize->cx == -1) {
4618 /* **** this is wrong, native measures each button and sets it */
4619 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4621 else if(HIWORD(lpsize->cx)) {
4623 HWND hwndParent = GetParent(hwnd);
4625 InvalidateRect(hwnd, 0, 1);
4626 GetWindowRect(hwnd, &rc);
4627 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
4628 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
4629 rc.left, rc.top, rc.right, rc.bottom);
4630 lpsize->cx = max(rc.right-rc.left,
4631 infoPtr->rcBound.right - infoPtr->rcBound.left);
4634 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4638 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4639 /* lpsize->cy = infoPtr->nHeight; */
4642 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4646 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4647 lpsize->cx, lpsize->cy);
4653 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
4655 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4656 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4659 /* initialize info structure */
4660 infoPtr->nButtonHeight = 22;
4661 infoPtr->nButtonWidth = 24;
4662 infoPtr->nBitmapHeight = 15;
4663 infoPtr->nBitmapWidth = 16;
4665 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
4667 infoPtr->nMaxTextRows = 1;
4668 infoPtr->cxMin = -1;
4669 infoPtr->cxMax = -1;
4670 infoPtr->nNumBitmaps = 0;
4671 infoPtr->nNumStrings = 0;
4673 infoPtr->bCaptured = FALSE;
4674 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4675 infoPtr->nButtonDown = -1;
4676 infoPtr->nOldHit = -1;
4677 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4678 infoPtr->hwndNotify = GetParent (hwnd);
4679 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
4680 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
4681 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
4682 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
4683 infoPtr->iVersion = 0;
4684 infoPtr->hwndSelf = hwnd;
4685 infoPtr->bDoRedraw = TRUE;
4686 infoPtr->clrBtnHighlight = CLR_DEFAULT;
4687 infoPtr->clrBtnShadow = CLR_DEFAULT;
4688 infoPtr->szPadding.cx = 7;
4689 infoPtr->szPadding.cy = 6;
4690 TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
4692 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
4693 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
4695 if (dwStyle & TBSTYLE_TOOLTIPS) {
4696 /* Create tooltip control */
4697 infoPtr->hwndToolTip =
4698 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
4699 CW_USEDEFAULT, CW_USEDEFAULT,
4700 CW_USEDEFAULT, CW_USEDEFAULT,
4703 /* Send NM_TOOLTIPSCREATED notification */
4704 if (infoPtr->hwndToolTip) {
4705 NMTOOLTIPSCREATED nmttc;
4707 nmttc.hwndToolTips = infoPtr->hwndToolTip;
4709 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
4710 NM_TOOLTIPSCREATED);
4714 TOOLBAR_CheckStyle (hwnd, dwStyle);
4716 TOOLBAR_CalcToolbar(hwnd);
4723 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
4725 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4727 /* delete tooltip control */
4728 if (infoPtr->hwndToolTip)
4729 DestroyWindow (infoPtr->hwndToolTip);
4731 /* delete button data */
4732 if (infoPtr->buttons)
4733 COMCTL32_Free (infoPtr->buttons);
4735 /* delete strings */
4736 if (infoPtr->strings) {
4738 for (i = 0; i < infoPtr->nNumStrings; i++)
4739 if (infoPtr->strings[i])
4740 COMCTL32_Free (infoPtr->strings[i]);
4742 COMCTL32_Free (infoPtr->strings);
4745 /* destroy internal image list */
4746 if (infoPtr->himlInt)
4747 ImageList_Destroy (infoPtr->himlInt);
4749 TOOLBAR_DeleteImageList(&infoPtr->himlDef, &infoPtr->cimlDef);
4750 TOOLBAR_DeleteImageList(&infoPtr->himlDis, &infoPtr->cimlDis);
4751 TOOLBAR_DeleteImageList(&infoPtr->himlHot, &infoPtr->cimlHot);
4753 /* delete default font */
4755 DeleteObject (infoPtr->hDefaultFont);
4757 /* free toolbar info data */
4758 COMCTL32_Free (infoPtr);
4759 SetWindowLongA (hwnd, 0, 0);
4766 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
4768 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4769 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4770 NMTBCUSTOMDRAW tbcd;
4774 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4775 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4776 tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
4777 tbcd.nmcd.hdc = (HDC)wParam;
4778 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4779 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4781 /* FIXME: in general the return flags *can* be or'ed together */
4782 switch (infoPtr->dwBaseCustDraw)
4784 case CDRF_DODEFAULT:
4786 case CDRF_SKIPDEFAULT:
4789 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4794 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4795 * to my parent for processing.
4797 if (infoPtr->bTransparent) {
4799 HDC hdc = (HDC)wParam;
4804 parent = GetParent(hwnd);
4805 MapWindowPoints(hwnd, parent, &pt, 1);
4806 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
4807 ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
4808 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
4811 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
4813 if ((dwStyle & TBSTYLE_CUSTOMERASE) &&
4814 (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) {
4815 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4816 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
4817 tbcd.nmcd.hdc = (HDC)wParam;
4818 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4819 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4820 switch (infoPtr->dwBaseCustDraw)
4822 case CDRF_DODEFAULT:
4824 case CDRF_SKIPDEFAULT:
4827 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4836 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
4838 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4840 return (LRESULT)infoPtr->hFont;
4845 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
4847 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4848 TBUTTON_INFO *btnPtr;
4852 pt.x = (INT)LOWORD(lParam);
4853 pt.y = (INT)HIWORD(lParam);
4854 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4857 btnPtr = &infoPtr->buttons[nHit];
4858 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4861 infoPtr->bCaptured = TRUE;
4862 infoPtr->nButtonDown = nHit;
4864 btnPtr->fsState |= TBSTATE_PRESSED;
4866 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4869 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
4870 TOOLBAR_Customize (hwnd);
4877 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
4879 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4880 TBUTTON_INFO *btnPtr;
4885 if (infoPtr->hwndToolTip)
4886 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4887 WM_LBUTTONDOWN, wParam, lParam);
4889 pt.x = (INT)LOWORD(lParam);
4890 pt.y = (INT)HIWORD(lParam);
4891 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4895 btnPtr = &infoPtr->buttons[nHit];
4896 infoPtr->nOldHit = nHit;
4898 CopyRect(&arrowRect, &btnPtr->rect);
4899 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
4901 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4902 if ((btnPtr->fsState & TBSTATE_ENABLED) && (btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
4903 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
4904 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
4908 * this time we must force a Redraw, so the btn is
4909 * painted down before CaptureChanged repaints it up
4911 RedrawWindow(hwnd,&btnPtr->rect,0,
4912 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
4914 nmtb.iItem = btnPtr->idCommand;
4915 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
4918 memset(&nmtb.rcButton, 0, sizeof(RECT));
4919 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4921 if (res != TBDDRET_TREATPRESSED)
4922 /* ??? guess (GA) */
4924 /* otherwise drop through and process as pushed */
4926 /* SetCapture (hwnd); */
4927 infoPtr->bCaptured = TRUE;
4928 infoPtr->nButtonDown = nHit;
4930 btnPtr->fsState |= TBSTATE_PRESSED;
4931 btnPtr->bHot = FALSE;
4933 if (btnPtr->fsState & TBSTATE_ENABLED)
4934 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
4938 /* native issues the TBN_BEGINDRAG here */
4939 nmtb.iItem = btnPtr->idCommand;
4940 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4941 nmtb.tbButton.idCommand = btnPtr->idCommand;
4942 nmtb.tbButton.fsState = btnPtr->fsState;
4943 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4944 nmtb.tbButton.dwData = btnPtr->dwData;
4945 nmtb.tbButton.iString = btnPtr->iString;
4946 nmtb.cchText = 0; /* !!! not correct */
4947 nmtb.pszText = 0; /* !!! not correct */
4948 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4956 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
4958 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4959 TBUTTON_INFO *btnPtr;
4963 BOOL bSendMessage = TRUE;
4968 if (infoPtr->hwndToolTip)
4969 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4970 WM_LBUTTONUP, wParam, lParam);
4972 pt.x = (INT)LOWORD(lParam);
4973 pt.y = (INT)HIWORD(lParam);
4974 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4976 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
4977 /* if the cursor is still inside of the toolbar */
4978 if((infoPtr->nHotItem >= 0) && (nHit != -1))
4979 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
4981 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
4982 btnPtr->fsState &= ~TBSTATE_PRESSED;
4984 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
4985 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
4986 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
4988 if (nOldIndex == nHit)
4989 bSendMessage = FALSE;
4990 if ((nOldIndex != nHit) &&
4992 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
4993 btnPtr->fsState |= TBSTATE_CHECKED;
4996 if (btnPtr->fsState & TBSTATE_CHECKED)
4997 btnPtr->fsState &= ~TBSTATE_CHECKED;
4999 btnPtr->fsState |= TBSTATE_CHECKED;
5003 if (nOldIndex != -1)
5005 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
5006 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
5010 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5011 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5012 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5014 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
5016 infoPtr->nButtonDown = -1;
5018 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5019 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
5020 NM_RELEASEDCAPTURE);
5022 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5025 nmtb.iItem = btnPtr->idCommand;
5026 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
5027 nmtb.tbButton.idCommand = btnPtr->idCommand;
5028 nmtb.tbButton.fsState = btnPtr->fsState;
5029 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
5030 nmtb.tbButton.dwData = btnPtr->dwData;
5031 nmtb.tbButton.iString = btnPtr->iString;
5032 nmtb.cchText = 0; /* !!! not correct */
5033 nmtb.pszText = 0; /* !!! not correct */
5034 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
5037 if (btnPtr->fsState & TBSTATE_ENABLED)
5039 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
5040 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
5042 /* !!! Undocumented - toolbar at 4.71 level and above sends
5043 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
5044 * Only NM_RCLICK is documented.
5046 nmmouse.dwItemSpec = btnPtr->idCommand;
5047 nmmouse.dwItemData = btnPtr->dwData;
5048 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, NM_CLICK);
5054 TOOLBAR_CaptureChanged(HWND hwnd)
5056 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5057 TBUTTON_INFO *btnPtr;
5059 infoPtr->bCaptured = FALSE;
5061 if (infoPtr->nButtonDown >= 0)
5063 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5064 btnPtr->fsState &= ~TBSTATE_PRESSED;
5066 infoPtr->nOldHit = -1;
5068 if (btnPtr->fsState & TBSTATE_ENABLED)
5069 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
5076 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
5078 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5079 TBUTTON_INFO *hotBtnPtr, *btnPtr;
5082 if (infoPtr->nOldHit < 0)
5085 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
5087 /* Redraw the button if the last button we were over is the hot button and it
5089 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
5091 hotBtnPtr->bHot = FALSE;
5092 rc1 = hotBtnPtr->rect;
5093 InflateRect (&rc1, 1, 1);
5094 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
5098 /* If the last button we were over is depressed then make it not */
5099 /* depressed and redraw it */
5100 if(infoPtr->nOldHit == infoPtr->nButtonDown)
5102 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5104 btnPtr->fsState &= ~TBSTATE_PRESSED;
5106 rc1 = hotBtnPtr->rect;
5107 InflateRect (&rc1, 1, 1);
5108 InvalidateRect (hwnd, &rc1, TRUE);
5111 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
5112 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
5118 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
5120 TBUTTON_INFO *btnPtr = NULL, *oldBtnPtr = NULL;
5121 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5124 TRACKMOUSEEVENT trackinfo;
5125 NMTBHOTITEM nmhotitem;
5127 /* fill in the TRACKMOUSEEVENT struct */
5128 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
5129 trackinfo.dwFlags = TME_QUERY;
5130 trackinfo.hwndTrack = hwnd;
5131 trackinfo.dwHoverTime = HOVER_DEFAULT;
5133 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
5134 _TrackMouseEvent(&trackinfo);
5136 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
5137 if(!(trackinfo.dwFlags & TME_LEAVE)) {
5138 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
5140 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
5141 /* and can properly deactivate the hot toolbar button */
5142 _TrackMouseEvent(&trackinfo);
5145 if (infoPtr->hwndToolTip)
5146 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
5147 WM_MOUSEMOVE, wParam, lParam);
5149 pt.x = (INT)LOWORD(lParam);
5150 pt.y = (INT)HIWORD(lParam);
5152 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
5154 if (infoPtr->nOldHit != nHit)
5156 /* Remove the effect of an old hot button if the button was enabled and was
5157 drawn with the hot button effect */
5158 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem &&
5159 (infoPtr->buttons[infoPtr->nOldHit].fsState & TBSTATE_ENABLED))
5161 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
5162 oldBtnPtr->bHot = FALSE;
5165 /* It's not a separator or in nowhere. It's a hot button. */
5168 btnPtr = &infoPtr->buttons[nHit];
5170 infoPtr->nHotItem = nHit;
5172 /* only enabled buttons show hot effect */
5173 if(infoPtr->buttons[nHit].fsState & TBSTATE_ENABLED)
5175 btnPtr->bHot = TRUE;
5179 nmhotitem.dwFlags = HICF_MOUSE;
5181 nmhotitem.idOld = oldBtnPtr->idCommand;
5183 nmhotitem.dwFlags |= HICF_ENTERING;
5185 nmhotitem.idNew = btnPtr->idCommand;
5187 nmhotitem.dwFlags |= HICF_LEAVING;
5188 TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
5190 /* now invalidate the old and new buttons so they will be painted */
5192 InvalidateRect (hwnd, &oldBtnPtr->rect,
5193 TOOLBAR_HasText(infoPtr, oldBtnPtr));
5194 if (btnPtr && (btnPtr->fsState & TBSTATE_ENABLED))
5195 InvalidateRect(hwnd, &btnPtr->rect,
5196 TOOLBAR_HasText(infoPtr, btnPtr));
5198 if (infoPtr->bCaptured) {
5199 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5200 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
5201 btnPtr->fsState &= ~TBSTATE_PRESSED;
5202 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
5204 else if (nHit == infoPtr->nButtonDown) {
5205 btnPtr->fsState |= TBSTATE_PRESSED;
5206 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
5209 infoPtr->nOldHit = nHit;
5215 inline static LRESULT
5216 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
5218 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
5219 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
5221 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
5225 inline static LRESULT
5226 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
5228 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
5229 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
5231 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
5236 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
5238 TOOLBAR_INFO *infoPtr;
5239 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
5242 /* allocate memory for info structure */
5243 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
5244 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
5247 infoPtr->dwStructSize = sizeof(TBBUTTON);
5249 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5250 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
5251 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
5252 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
5255 /* native control does:
5256 * Get a lot of colors and brushes
5258 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5259 * CreateFontIndirectA(adr1)
5260 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5261 * hdc = GetDC(toolbar)
5262 * GetSystemMetrics(0x48)
5263 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5264 * 0, 0, 0, 0, "MARLETT")
5265 * oldfnt = SelectObject(hdc, fnt2)
5266 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5267 * GetTextMetricsA(hdc, adr3)
5268 * SelectObject(hdc, oldfnt)
5269 * DeleteObject(fnt2)
5271 * InvalidateRect(toolbar, 0, 1)
5272 * SetWindowLongA(toolbar, 0, addr)
5273 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5276 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5277 * ie 2 0x4600094c 0x4600094c 0x4600894d
5278 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5279 * rebar 0x50008844 0x40008844 0x50008845
5280 * pager 0x50000844 0x40000844 0x50008845
5281 * IC35mgr 0x5400084e **nochange**
5282 * on entry to _NCCREATE 0x5400084e
5283 * rowlist 0x5400004e **nochange**
5284 * on entry to _NCCREATE 0x5400004e
5288 /* I think the code below is a bug, but it is the way that the native
5289 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5290 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5291 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5292 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5293 * Some how, the only cases of this seem to be MFC programs.
5295 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5296 * does not occur in the WM_STYLECHANGING routine.
5297 * (Guy Albertelli 9/2001)
5300 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
5301 styleadd |= TBSTYLE_TRANSPARENT;
5302 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
5303 styleadd |= CCS_TOP; /* default to top */
5304 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
5307 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
5312 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
5314 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5318 if (dwStyle & WS_MINIMIZE)
5319 return 0; /* Nothing to do */
5321 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
5323 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
5326 if (!(dwStyle & CCS_NODIVIDER))
5328 GetWindowRect (hwnd, &rcWindow);
5329 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
5330 if( dwStyle & WS_BORDER )
5331 OffsetRect (&rcWindow, 1, 1);
5332 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
5335 ReleaseDC( hwnd, hdc );
5341 inline static LRESULT
5342 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
5344 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5345 LPNMHDR lpnmh = (LPNMHDR)lParam;
5347 if (lpnmh->code == PGN_CALCSIZE) {
5348 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
5350 if (lppgc->dwFlag == PGF_CALCWIDTH) {
5351 lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
5352 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5356 lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
5357 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5363 if (lpnmh->code == PGN_SCROLL) {
5364 LPNMPGSCROLL lppgs = (LPNMPGSCROLL)lParam;
5366 lppgs->iScroll = (lppgs->iDir & (PGF_SCROLLLEFT | PGF_SCROLLRIGHT)) ?
5367 infoPtr->nButtonWidth : infoPtr->nButtonHeight;
5368 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
5369 lppgs->iScroll, lppgs->iDir);
5374 TRACE("passing WM_NOTIFY!\n");
5376 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
5377 if (infoPtr->bNtfUnicode)
5378 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
5381 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
5385 if (lpnmh->code == TTN_GETDISPINFOA) {
5386 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
5388 FIXME("retrieving ASCII string\n");
5391 else if (lpnmh->code == TTN_GETDISPINFOW) {
5392 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
5394 FIXME("retrieving UNICODE string\n");
5405 TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
5407 /* remove this routine when Toolbar is improved to pass infoPtr
5408 * around instead of hwnd.
5410 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5411 return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
5416 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
5420 if (lParam == NF_REQUERY) {
5421 i = SendMessageA(GetParent(infoPtr->hwndSelf),
5422 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
5423 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
5424 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5428 infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
5431 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
5436 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
5438 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5442 /* fill ps.rcPaint with a default rect */
5443 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
5445 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
5447 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
5448 ps.rcPaint.left, ps.rcPaint.top,
5449 ps.rcPaint.right, ps.rcPaint.bottom);
5451 TOOLBAR_Refresh (hwnd, hdc, &ps);
5452 if (!wParam) EndPaint (hwnd, &ps);
5459 TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
5460 /*****************************************************
5463 * Handles the WM_SETREDRAW message.
5466 * According to testing V4.71 of COMCTL32 returns the
5467 * *previous* status of the redraw flag (either 0 or 1)
5468 * instead of the MSDN documented value of 0 if handled.
5469 * (For laughs see the "consistancy" with same function
5472 *****************************************************/
5474 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5475 BOOL oldredraw = infoPtr->bDoRedraw;
5477 TRACE("set to %s\n",
5478 (wParam) ? "TRUE" : "FALSE");
5479 infoPtr->bDoRedraw = (BOOL) wParam;
5481 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
5483 return (oldredraw) ? 1 : 0;
5488 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
5490 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5491 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5500 /* Resize deadlock check */
5501 if (infoPtr->bAutoSize) {
5502 infoPtr->bAutoSize = FALSE;
5506 /* FIXME: optimize to only update size if the new size doesn't */
5507 /* match the current size */
5509 flags = (INT) wParam;
5511 /* FIXME for flags =
5512 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5515 TRACE("sizing toolbar!\n");
5517 if (flags == SIZE_RESTORED) {
5518 /* width and height don't apply */
5519 parent = GetParent (hwnd);
5520 GetClientRect(parent, &parent_rect);
5521 x = parent_rect.left;
5522 y = parent_rect.top;
5524 if (dwStyle & CCS_NORESIZE) {
5525 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
5528 * this sets the working width of the toolbar, and
5529 * Calc Toolbar will not adjust it, only the height
5531 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5532 cy = infoPtr->nHeight;
5533 cx = infoPtr->nWidth;
5534 TOOLBAR_CalcToolbar (hwnd);
5535 infoPtr->nWidth = cx;
5536 infoPtr->nHeight = cy;
5539 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5540 TOOLBAR_CalcToolbar (hwnd);
5541 cy = infoPtr->nHeight;
5542 cx = infoPtr->nWidth;
5544 if (dwStyle & CCS_NOMOVEY) {
5545 GetWindowRect(hwnd, &window_rect);
5546 ScreenToClient(parent, (LPPOINT)&window_rect.left);
5547 y = window_rect.top;
5551 if (dwStyle & CCS_NOPARENTALIGN) {
5552 uPosFlags |= SWP_NOMOVE;
5553 cy = infoPtr->nHeight;
5554 cx = infoPtr->nWidth;
5557 if (!(dwStyle & CCS_NODIVIDER))
5558 cy += GetSystemMetrics(SM_CYEDGE);
5560 if (dwStyle & WS_BORDER)
5563 cy += GetSystemMetrics(SM_CYEDGE);
5564 cx += GetSystemMetrics(SM_CYEDGE);
5567 SetWindowPos (hwnd, 0, parent_rect.left - x, parent_rect.top - y,
5568 cx, cy, uPosFlags | SWP_NOZORDER);
5575 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
5577 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5579 if (nType == GWL_STYLE) {
5580 if (lpStyle->styleNew & TBSTYLE_LIST) {
5581 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
5584 infoPtr->dwDTFlags = DT_CENTER;
5586 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
5587 infoPtr->bBtnTranspnt = (lpStyle->styleNew &
5588 (TBSTYLE_FLAT | TBSTYLE_LIST));
5589 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
5592 TOOLBAR_AutoSize (hwnd);
5594 InvalidateRect(hwnd, NULL, FALSE);
5601 TOOLBAR_SysColorChange (HWND hwnd)
5603 COMCTL32_RefreshSysColors();
5610 static LRESULT WINAPI
5611 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5613 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
5614 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
5616 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
5617 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
5622 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
5624 case TB_ADDBUTTONSA:
5625 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
5627 case TB_ADDBUTTONSW:
5628 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
5631 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
5634 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
5637 return TOOLBAR_AutoSize (hwnd);
5639 case TB_BUTTONCOUNT:
5640 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
5642 case TB_BUTTONSTRUCTSIZE:
5643 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
5645 case TB_CHANGEBITMAP:
5646 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
5648 case TB_CHECKBUTTON:
5649 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
5651 case TB_COMMANDTOINDEX:
5652 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
5655 return TOOLBAR_Customize (hwnd);
5657 case TB_DELETEBUTTON:
5658 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
5660 case TB_ENABLEBUTTON:
5661 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
5663 case TB_GETANCHORHIGHLIGHT:
5664 return TOOLBAR_GetAnchorHighlight (hwnd);
5667 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
5669 case TB_GETBITMAPFLAGS:
5670 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
5673 return TOOLBAR_GetButton (hwnd, wParam, lParam);
5675 case TB_GETBUTTONINFOA:
5676 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
5678 case TB_GETBUTTONINFOW:
5679 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
5681 case TB_GETBUTTONSIZE:
5682 return TOOLBAR_GetButtonSize (hwnd);
5684 case TB_GETBUTTONTEXTA:
5685 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
5687 case TB_GETBUTTONTEXTW:
5688 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
5690 case TB_GETDISABLEDIMAGELIST:
5691 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
5693 case TB_GETEXTENDEDSTYLE:
5694 return TOOLBAR_GetExtendedStyle (hwnd);
5696 case TB_GETHOTIMAGELIST:
5697 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
5700 return TOOLBAR_GetHotItem (hwnd);
5702 case TB_GETIMAGELIST:
5703 return TOOLBAR_GetDefImageList (hwnd, wParam, lParam);
5705 /* case TB_GETINSERTMARK: */ /* 4.71 */
5706 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5708 case TB_GETITEMRECT:
5709 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
5712 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
5714 /* case TB_GETOBJECT: */ /* 4.71 */
5717 return TOOLBAR_GetPadding (hwnd);
5720 return TOOLBAR_GetRect (hwnd, wParam, lParam);
5723 return TOOLBAR_GetRows (hwnd, wParam, lParam);
5726 return TOOLBAR_GetState (hwnd, wParam, lParam);
5729 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
5731 case TB_GETTEXTROWS:
5732 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
5734 case TB_GETTOOLTIPS:
5735 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
5737 case TB_GETUNICODEFORMAT:
5738 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
5741 return TOOLBAR_HideButton (hwnd, wParam, lParam);
5744 return TOOLBAR_HitTest (hwnd, wParam, lParam);
5746 case TB_INDETERMINATE:
5747 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
5749 case TB_INSERTBUTTONA:
5750 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
5752 case TB_INSERTBUTTONW:
5753 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
5755 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5757 case TB_ISBUTTONCHECKED:
5758 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
5760 case TB_ISBUTTONENABLED:
5761 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
5763 case TB_ISBUTTONHIDDEN:
5764 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
5766 case TB_ISBUTTONHIGHLIGHTED:
5767 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
5769 case TB_ISBUTTONINDETERMINATE:
5770 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
5772 case TB_ISBUTTONPRESSED:
5773 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
5775 case TB_LOADIMAGES: /* 4.70 */
5776 FIXME("missing standard imagelists\n");
5779 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5780 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5781 /* case TB_MARKBUTTON: */ /* 4.71 */
5782 /* case TB_MOVEBUTTON: */ /* 4.71 */
5784 case TB_PRESSBUTTON:
5785 return TOOLBAR_PressButton (hwnd, wParam, lParam);
5787 case TB_REPLACEBITMAP:
5788 return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam);
5790 case TB_SAVERESTOREA:
5791 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
5793 case TB_SAVERESTOREW:
5794 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
5796 case TB_SETANCHORHIGHLIGHT:
5797 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
5799 case TB_SETBITMAPSIZE:
5800 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
5802 case TB_SETBUTTONINFOA:
5803 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
5805 case TB_SETBUTTONINFOW:
5806 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
5808 case TB_SETBUTTONSIZE:
5809 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
5811 case TB_SETBUTTONWIDTH:
5812 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
5815 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
5817 case TB_SETDISABLEDIMAGELIST:
5818 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
5820 case TB_SETDRAWTEXTFLAGS:
5821 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
5823 case TB_SETEXTENDEDSTYLE:
5824 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
5826 case TB_SETHOTIMAGELIST:
5827 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
5830 return TOOLBAR_SetHotItem (hwnd, wParam);
5832 case TB_SETIMAGELIST:
5833 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
5836 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
5838 /* case TB_SETINSERTMARK: */ /* 4.71 */
5840 case TB_SETINSERTMARKCOLOR:
5841 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
5843 case TB_SETMAXTEXTROWS:
5844 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
5847 return TOOLBAR_SetPadding (hwnd, wParam, lParam);
5850 return TOOLBAR_SetParent (hwnd, wParam, lParam);
5853 return TOOLBAR_SetRows (hwnd, wParam, lParam);
5856 return TOOLBAR_SetState (hwnd, wParam, lParam);
5859 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
5861 case TB_SETTOOLTIPS:
5862 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
5864 case TB_SETUNICODEFORMAT:
5865 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
5868 return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
5871 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
5874 /* Common Control Messages */
5876 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
5877 case CCM_GETCOLORSCHEME:
5878 return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5880 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
5881 case CCM_SETCOLORSCHEME:
5882 return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5884 case CCM_GETVERSION:
5885 return TOOLBAR_GetVersion (hwnd);
5887 case CCM_SETVERSION:
5888 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
5894 return TOOLBAR_Create (hwnd, wParam, lParam);
5897 return TOOLBAR_Destroy (hwnd, wParam, lParam);
5900 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
5903 return TOOLBAR_GetFont (hwnd, wParam, lParam);
5905 /* case WM_KEYDOWN: */
5906 /* case WM_KILLFOCUS: */
5908 case WM_LBUTTONDBLCLK:
5909 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
5911 case WM_LBUTTONDOWN:
5912 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
5915 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
5918 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
5921 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
5923 case WM_CAPTURECHANGED:
5924 return TOOLBAR_CaptureChanged(hwnd);
5927 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
5930 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
5933 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
5936 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
5939 return TOOLBAR_Notify (hwnd, wParam, lParam);
5941 case WM_NOTIFYFORMAT:
5942 TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
5945 return TOOLBAR_Paint (hwnd, wParam);
5948 return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
5951 return TOOLBAR_Size (hwnd, wParam, lParam);
5953 case WM_STYLECHANGED:
5954 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
5956 case WM_SYSCOLORCHANGE:
5957 return TOOLBAR_SysColorChange (hwnd);
5959 /* case WM_WININICHANGE: */
5964 case WM_MEASUREITEM:
5967 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5969 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
5971 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
5974 /* We see this in Outlook Express 5.x and just does DefWindowProc */
5975 case PGM_FORWARDMOUSE:
5976 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5979 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
5980 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
5981 uMsg, wParam, lParam);
5982 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
5989 TOOLBAR_Register (void)
5993 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
5994 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
5995 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
5996 wndClass.cbClsExtra = 0;
5997 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
5998 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
5999 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
6000 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
6002 RegisterClassA (&wndClass);
6007 TOOLBAR_Unregister (void)
6009 UnregisterClassA (TOOLBARCLASSNAMEA, NULL);
6012 static HIMAGELIST TOOLBAR_InsertImageList(PIMLENTRY **pies, INT *cies, HIMAGELIST himl, INT id)
6017 /* Check if the entry already exists */
6018 c = TOOLBAR_GetImageListEntry(*pies, *cies, id);
6020 /* If this is a new entry we must create it and insert into the array */
6025 c = (PIMLENTRY) COMCTL32_Alloc(sizeof(IMLENTRY));
6028 pnies = COMCTL32_Alloc((*cies + 1) * sizeof(PIMLENTRY));
6029 memcpy(pnies, *pies, ((*cies) * sizeof(PIMLENTRY)));
6033 COMCTL32_Free(*pies);
6044 static VOID TOOLBAR_DeleteImageList(PIMLENTRY **pies, INT *cies)
6048 for (i = 0; i < *cies; i++)
6049 COMCTL32_Free((*pies)[i]);
6051 COMCTL32_Free(*pies);
6058 static PIMLENTRY TOOLBAR_GetImageListEntry(PIMLENTRY *pies, INT cies, INT id)
6066 for (i = 0; i < cies; i++)
6068 if (pies[i]->id == id)
6080 static HIMAGELIST TOOLBAR_GetImageList(PIMLENTRY *pies, INT cies, INT id)
6082 HIMAGELIST himlDef = 0;
6083 PIMLENTRY pie = TOOLBAR_GetImageListEntry(pies, cies, id);
6086 himlDef = pie->himl;
6092 static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb)
6094 if (infoPtr->bUnicode)
6095 return TOOLBAR_SendNotify ((NMHDR *) nmtb, infoPtr, TBN_GETBUTTONINFOW);
6102 nmtba.iItem = nmtb->iItem;
6103 nmtba.pszText = Buffer;
6104 nmtba.cchText = 256;
6105 ZeroMemory(nmtba.pszText, nmtba.cchText);
6107 if (TOOLBAR_SendNotify ((NMHDR *) &nmtba, infoPtr, TBN_GETBUTTONINFOA))
6109 int ccht = strlen(nmtba.pszText);
6111 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)nmtba.pszText, -1,
6112 nmtb->pszText, nmtb->cchText);
6114 memcpy(&nmtb->tbButton, &nmtba.tbButton, sizeof(TBBUTTON));
6123 static BOOL TOOLBAR_IsButtonRemovable(TOOLBAR_INFO *infoPtr,
6124 int iItem, PCUSTOMBUTTON btnInfo)
6129 memcpy(&nmtb.tbButton, &btnInfo->btn, sizeof(TBBUTTON));
6131 return TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYDELETE);