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
68 #include "wine/unicode.h"
71 #include "imagelist.h"
73 #include "wine/debug.h"
75 WINE_DEFAULT_DEBUG_CHANNEL(toolbar);
102 } IMLENTRY, *PIMLENTRY;
106 DWORD dwStructSize; /* size of TBBUTTON struct */
107 INT nHeight; /* height of the toolbar */
108 INT nWidth; /* width of the toolbar */
114 INT nRows; /* number of button rows */
115 INT nMaxTextRows; /* maximum number of text rows */
116 INT cxMin; /* minimum button width */
117 INT cxMax; /* maximum button width */
118 INT nNumButtons; /* number of buttons */
119 INT nNumBitmaps; /* number of bitmaps */
120 INT nNumStrings; /* number of strings */
122 BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */
123 BOOL bCaptured; /* mouse captured? */
126 INT nHotItem; /* index of the "hot" item */
127 DWORD dwBaseCustDraw; /* CDRF_ response (w/o TBCDRF_) from PREPAINT */
128 DWORD dwItemCustDraw; /* CDRF_ response (w/o TBCDRF_) from ITEMPREP */
129 DWORD dwItemCDFlag; /* TBCDRF_ flags from last ITEMPREPAINT */
130 SIZE szPadding; /* padding values around button */
132 HFONT hFont; /* text font */
133 HIMAGELIST himlInt; /* image list created internally */
134 PIMLENTRY *himlDef; /* default image list array */
135 INT cimlDef; /* default image list array count */
136 PIMLENTRY *himlHot; /* hot image list array */
137 INT cimlHot; /* hot image list array count */
138 PIMLENTRY *himlDis; /* disabled image list array */
139 INT cimlDis; /* disabled image list array count */
140 HWND hwndToolTip; /* handle to tool tip control */
141 HWND hwndNotify; /* handle to the window that gets notifications */
142 HWND hwndSelf; /* my own handle */
143 BOOL bTransparent; /* background transparency flag */
144 BOOL bBtnTranspnt; /* button transparency flag */
145 BOOL bAutoSize; /* auto size deadlock indicator */
146 BOOL bAnchor; /* anchor highlight enabled */
147 BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */
148 BOOL bDoRedraw; /* Redraw status */
149 DWORD dwExStyle; /* extended toolbar style */
150 DWORD dwDTFlags; /* DrawText flags */
152 COLORREF clrInsertMark; /* insert mark color */
153 COLORREF clrBtnHighlight; /* color for Flat Separator */
154 COLORREF clrBtnShadow; /* color for Flag Separator */
155 RECT rcBound; /* bounding rectangle */
158 TBUTTON_INFO *buttons; /* pointer to button array */
159 LPWSTR *strings; /* pointer to string array */
160 TBITMAP_INFO *bitmaps;
161 } TOOLBAR_INFO, *PTOOLBAR_INFO;
164 /* used by customization dialog */
167 PTOOLBAR_INFO tbInfo;
169 } CUSTDLG_INFO, *PCUSTDLG_INFO;
177 } CUSTOMBUTTON, *PCUSTOMBUTTON;
186 #define SEPARATOR_WIDTH 8
188 #define BOTTOM_BORDER 2
189 #define DDARROW_WIDTH 11
190 #define ARROW_HEIGHT 3
192 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
193 #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
194 #define TOOLBAR_HasDropDownArrows(exStyle) ((exStyle & TBSTYLE_EX_DRAWDDARROWS) ? TRUE : FALSE)
196 /* Used to find undocumented extended styles */
197 #define TBSTYLE_EX_ALL (TBSTYLE_EX_DRAWDDARROWS | \
198 TBSTYLE_EX_UNDOC1 | \
199 TBSTYLE_EX_MIXEDBUTTONS | \
200 TBSTYLE_EX_HIDECLIPPEDBUTTONS)
202 #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i)
203 #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0)
204 #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id)
205 #define GETHOTIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlHot, infoPtr->cimlHot, id)
206 #define GETDISIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDis, infoPtr->cimlDis, id)
208 static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb);
209 static BOOL TOOLBAR_IsButtonRemovable(TOOLBAR_INFO *infoPtr, int iItem, PCUSTOMBUTTON btnInfo);
210 static HIMAGELIST TOOLBAR_GetImageList(PIMLENTRY *pies, INT cies, INT id);
211 static PIMLENTRY TOOLBAR_GetImageListEntry(PIMLENTRY *pies, INT cies, INT id);
212 static VOID TOOLBAR_DeleteImageList(PIMLENTRY **pies, INT *cies);
213 static HIMAGELIST TOOLBAR_InsertImageList(PIMLENTRY **pies, INT *cies, HIMAGELIST himl, INT id);
216 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam);
220 TOOLBAR_GetText(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
222 LPWSTR lpText = NULL;
224 /* FIXME: iString == -1 is undocumented */
225 if ((HIWORD(btnPtr->iString) != 0) && (btnPtr->iString != -1))
226 lpText = (LPWSTR)btnPtr->iString;
227 else if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings))
228 lpText = infoPtr->strings[btnPtr->iString];
234 TOOLBAR_DumpButton(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *bP, INT btn_num, BOOL internal)
236 if (TRACE_ON(toolbar)){
237 TRACE("button %d id %d, bitmap=%d, state=%02x, style=%02x, data=%08lx, stringid=0x%08x\n",
238 btn_num, bP->idCommand, GETIBITMAP(infoPtr, bP->iBitmap),
239 bP->fsState, bP->fsStyle, bP->dwData, bP->iString);
240 TRACE("string %s\n", debugstr_w(TOOLBAR_GetText(infoPtr,bP)));
242 TRACE("button %d id %d, hot=%s, row=%d, rect=(%ld,%ld)-(%ld,%ld)\n",
243 btn_num, bP->idCommand,
244 (bP->bHot) ? "TRUE":"FALSE", bP->nRow,
245 bP->rect.left, bP->rect.top,
246 bP->rect.right, bP->rect.bottom);
252 TOOLBAR_DumpToolbar(TOOLBAR_INFO *iP, INT line)
254 if (TRACE_ON(toolbar)) {
258 dwStyle = GetWindowLongA (iP->hwndSelf, GWL_STYLE);
259 TRACE("toolbar %p at line %d, exStyle=%08lx, buttons=%d, bitmaps=%d, strings=%d, style=%08lx\n",
261 iP->dwExStyle, iP->nNumButtons, iP->nNumBitmaps,
262 iP->nNumStrings, dwStyle);
263 TRACE("toolbar %p at line %d, himlInt=%p, himlDef=%p, himlHot=%p, himlDis=%p, redrawable=%s\n",
265 iP->himlInt, iP->himlDef, iP->himlHot, iP->himlDis,
266 (iP->bDoRedraw) ? "TRUE" : "FALSE");
267 for(i=0; i<iP->nNumButtons; i++) {
268 TOOLBAR_DumpButton(iP, &iP->buttons[i], i, TRUE);
274 /***********************************************************************
277 * This function validates that the styles set are implemented and
278 * issues FIXME's warning of possible problems. In a perfect world this
279 * function should be null.
282 TOOLBAR_CheckStyle (HWND hwnd, DWORD dwStyle)
284 if (dwStyle & TBSTYLE_ALTDRAG)
285 FIXME("[%p] TBSTYLE_ALTDRAG not implemented\n", hwnd);
286 if (dwStyle & TBSTYLE_REGISTERDROP)
287 FIXME("[%p] TBSTYLE_REGISTERDROP not implemented\n", hwnd);
292 TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code)
294 if(!IsWindow(infoPtr->hwndSelf))
295 return 0; /* we have just been destroyed */
297 nmhdr->idFrom = GetDlgCtrlID (infoPtr->hwndSelf);
298 nmhdr->hwndFrom = infoPtr->hwndSelf;
301 TRACE("to window %p, code=%08x, %s\n", infoPtr->hwndNotify, code,
302 (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI");
304 if (infoPtr->bNtfUnicode)
305 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
306 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
308 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
309 (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr);
312 /***********************************************************************
313 * TOOLBAR_GetBitmapIndex
315 * This function returns the bitmap index associated with a button.
316 * If the button specifies I_IMAGECALLBACK, then the TBN_GETDISPINFO
317 * is issued to retrieve the index.
320 TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr)
322 INT ret = btnPtr->iBitmap;
324 if (ret == I_IMAGECALLBACK) {
325 /* issue TBN_GETDISPINFO */
328 nmgd.idCommand = btnPtr->idCommand;
329 nmgd.lParam = btnPtr->dwData;
330 nmgd.dwMask = TBNF_IMAGE;
331 TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr,
332 (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW :
334 if (nmgd.dwMask & TBNF_DI_SETITEM) {
335 btnPtr->iBitmap = nmgd.iImage;
338 TRACE("TBN_GETDISPINFOA returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n",
339 ret, nmgd.dwMask, infoPtr->nNumBitmaps);
342 if (ret != I_IMAGENONE)
343 ret = GETIBITMAP(infoPtr, ret);
350 TOOLBAR_IsValidBitmapIndex(TOOLBAR_INFO *infoPtr, INT index)
353 INT id = GETHIMLID(infoPtr, index);
354 INT iBitmap = GETIBITMAP(infoPtr, index);
356 if (((himl = GETDEFIMAGELIST(infoPtr, id)) &&
357 iBitmap >= 0 && iBitmap < ImageList_GetImageCount(himl)) ||
358 (index == I_IMAGECALLBACK))
365 /***********************************************************************
366 * TOOLBAR_DrawImageList
368 * This function validates the bitmap index (including I_IMAGECALLBACK
369 * functionality). It then draws the image via the ImageList_Draw
370 * function. It returns TRUE if the image was drawn, FALSE otherwise.
373 TOOLBAR_DrawImageList (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, IMAGE_LIST_TYPE imagelist,
374 HDC hdc, UINT left, UINT top, UINT draw_flags)
379 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
380 if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
381 ERR("index %d is not valid, max %d\n",
382 btnPtr->iBitmap, infoPtr->nNumBitmaps);
386 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
387 if ((index == I_IMAGECALLBACK) ||
388 (index == I_IMAGENONE)) return FALSE;
389 ERR("TBN_GETDISPINFO returned invalid index %d\n",
396 case IMAGE_LIST_DEFAULT:
397 himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
400 himl = GETHOTIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
402 case IMAGE_LIST_DISABLED:
403 himl = GETDISIMAGELIST(infoPtr, GETHIMLID(infoPtr, btnPtr->iBitmap));
407 FIXME("Shouldn't reach here\n");
412 TRACE("no image list, returning FALSE\n");
416 TRACE("drawing index=%d, himl=%p, left=%d, top=%d, flags=%08x\n",
417 index, himl, left, top, draw_flags);
419 ImageList_Draw (himl, index, hdc, left, top, draw_flags);
424 /***********************************************************************
425 * TOOLBAR_TestImageExist
427 * This function is similar to TOOLBAR_DrawImageList, except it does not
428 * draw the image. The I_IMAGECALLBACK functionality is implemented.
431 TOOLBAR_TestImageExist (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, HIMAGELIST himl)
435 if (!himl) return FALSE;
437 if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
438 if (btnPtr->iBitmap == I_IMAGENONE) return FALSE;
439 ERR("index %d is not valid, max %d\n",
440 btnPtr->iBitmap, infoPtr->nNumBitmaps);
444 if ((index = TOOLBAR_GetBitmapIndex(infoPtr, btnPtr)) < 0) {
445 if ((index == I_IMAGECALLBACK) ||
446 (index == I_IMAGENONE)) return FALSE;
447 ERR("TBN_GETDISPINFO returned invalid index %d\n",
456 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr)
459 COLORREF oldcolor, newcolor;
461 myrect.left = (lpRect->left + lpRect->right) / 2 - 1;
462 myrect.right = myrect.left + 1;
463 myrect.top = lpRect->top + 2;
464 myrect.bottom = lpRect->bottom - 2;
466 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
467 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
468 oldcolor = SetBkColor (hdc, newcolor);
469 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
471 myrect.left = myrect.right;
472 myrect.right = myrect.left + 1;
474 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
475 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
476 SetBkColor (hdc, newcolor);
477 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
479 SetBkColor (hdc, oldcolor);
483 /***********************************************************************
484 * TOOLBAR_DrawDDFlatSeparator
486 * This function draws the separator that was flaged as TBSTYLE_DROPDOWN.
487 * In this case, the separator is a pixel high line of COLOR_BTNSHADOW,
488 * followed by a pixel high line of COLOR_BTNHIGHLIGHT. These separators
489 * are horizontal as opposed to the vertical separators for not dropdown
492 * FIXME: It is possible that the height of each line is really SM_CYBORDER.
495 TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLBAR_INFO *infoPtr)
498 COLORREF oldcolor, newcolor;
500 myrect.left = lpRect->left;
501 myrect.right = lpRect->right;
502 myrect.top = lpRect->top + (lpRect->bottom - lpRect->top - 2)/2;
503 myrect.bottom = myrect.top + 1;
505 InflateRect (&myrect, -2, 0);
507 TRACE("rect=(%ld,%ld)-(%ld,%ld)\n",
508 myrect.left, myrect.top, myrect.right, myrect.bottom);
510 newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
511 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
512 oldcolor = SetBkColor (hdc, newcolor);
513 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
515 myrect.top = myrect.bottom;
516 myrect.bottom = myrect.top + 1;
518 newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
519 comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight;
520 SetBkColor (hdc, newcolor);
521 ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0);
523 SetBkColor (hdc, oldcolor);
528 TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
533 if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
534 hOldPen = SelectObject ( hdc, hPen );
537 MoveToEx (hdc, x, y, NULL);
538 LineTo (hdc, x+5, y++); x++;
539 MoveToEx (hdc, x, y, NULL);
540 LineTo (hdc, x+3, y++); x++;
541 MoveToEx (hdc, x, y, NULL);
542 LineTo (hdc, x+1, y++);
543 SelectObject( hdc, hOldPen );
544 DeleteObject( hPen );
548 * Draw the text string for this button.
549 * note: infoPtr->himlDis *SHOULD* be non-zero when infoPtr->himlDef
550 * is non-zero, so we can simply check himlDef to see if we have
554 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
555 HDC hdc, DWORD dwStyle,
556 RECT *rcText, LPWSTR lpText, NMTBCUSTOMDRAW *tbcd)
560 UINT state = tbcd->nmcd.uItemState;
564 TRACE("string=%s rect=(%ld,%ld)-(%ld,%ld)\n", debugstr_w(lpText),
565 rcText->left, rcText->top, rcText->right, rcText->bottom);
567 hOldFont = SelectObject (hdc, infoPtr->hFont);
568 if ((state & CDIS_HOT) && (infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )) {
569 clrOld = SetTextColor (hdc, tbcd->clrTextHighlight);
571 else if (state & CDIS_DISABLED) {
572 clrOld = SetTextColor (hdc, tbcd->clrBtnHighlight);
573 OffsetRect (rcText, 1, 1);
574 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
575 SetTextColor (hdc, comctl32_color.clr3dShadow);
576 OffsetRect (rcText, -1, -1);
578 else if (state & CDIS_INDETERMINATE) {
579 clrOld = SetTextColor (hdc, comctl32_color.clr3dShadow);
582 clrOld = SetTextColor (hdc, tbcd->clrText);
585 DrawTextW (hdc, lpText, -1, rcText, infoPtr->dwDTFlags);
586 SetTextColor (hdc, clrOld);
587 SelectObject (hdc, hOldFont);
593 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
595 HBRUSH hbr = SelectObject (hdc, COMCTL32_hPattern55AABrush);
596 INT cx = lpRect->right - lpRect->left;
597 INT cy = lpRect->bottom - lpRect->top;
598 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
599 SelectObject (hdc, hbr);
604 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
605 HDC hdc, INT x, INT y)
607 HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, 0);
615 ImageList_GetIconSize(himl, &cx, &cy);
617 /* create new dc's */
618 hdcMask = CreateCompatibleDC (0);
620 /* create new bitmap */
621 hbmMask = CreateBitmap (cx, cy, 1, 1, NULL);
622 SelectObject (hdcMask, hbmMask);
624 /* copy the mask bitmap */
625 ImageList_DrawEx(himl, btnPtr->iBitmap, hdcMask, 0, 0, 0, 0, RGB(255, 255, 255), RGB(0, 0, 0), ILD_MASK);
627 /* draw the new mask */
628 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
629 BitBlt (hdc, x+1, y+1, cx, cy, hdcMask, 0, 0, 0xB8074A);
631 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
632 BitBlt (hdc, x, y, cx, cy, hdcMask, 0, 0, 0xB8074A);
634 DeleteObject (hbmMask);
640 TOOLBAR_TranslateState(TBUTTON_INFO *btnPtr)
644 retstate |= (btnPtr->fsState & TBSTATE_CHECKED) ? CDIS_CHECKED : 0;
645 retstate |= (btnPtr->fsState & TBSTATE_PRESSED) ? CDIS_SELECTED : 0;
646 retstate |= (btnPtr->fsState & TBSTATE_ENABLED) ? 0 : CDIS_DISABLED;
647 retstate |= (btnPtr->fsState & TBSTATE_MARKED ) ? CDIS_MARKED : 0;
648 retstate |= (btnPtr->bHot ) ? CDIS_HOT : 0;
649 retstate |= (btnPtr->fsState & TBSTATE_INDETERMINATE) ? CDIS_INDETERMINATE : 0;
650 /* FIXME: don't set CDIS_GRAYED, CDIS_FOCUS, CDIS_DEFAULT */
651 /* don't test TBSTATE_HIDDEN */
657 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
659 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
660 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
661 BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
662 (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
663 RECT rc, rcArrow, rcBitmap, rcText, rcFill;
664 LPWSTR lpText = NULL;
669 if (btnPtr->fsState & TBSTATE_HIDDEN)
673 CopyRect (&rcFill, &rc);
674 CopyRect (&rcArrow, &rc);
675 CopyRect(&rcBitmap, &rc);
677 /* get a pointer to the text */
678 lpText = TOOLBAR_GetText(infoPtr, btnPtr);
680 if (hasDropDownArrow)
682 if (dwStyle & TBSTYLE_FLAT)
683 rc.right = max(rc.left, rc.right - DDARROW_WIDTH);
685 rc.right = max(rc.left, rc.right - DDARROW_WIDTH - 2);
686 rcArrow.left = rc.right;
689 /* copy text rect after adjusting for drop-down arrow
690 * so that text is centred in the rectangle not containing
692 CopyRect(&rcText, &rc);
694 /* Center the bitmap horizontally and vertically */
695 if (dwStyle & TBSTYLE_LIST)
698 rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2;
701 rcBitmap.top+=2; /* this looks to be the correct value from vmware comparison - cmm */
703 rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2;
705 TRACE("iBitmap: %d, start=(%ld,%ld) w=%d, h=%d\n",
706 btnPtr->iBitmap, rcBitmap.left, rcBitmap.top,
707 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
708 TRACE ("iString: %x\n", btnPtr->iString);
709 TRACE ("Stringtext: %s\n", debugstr_w(lpText));
714 InflateRect (&rcText, -3, -3);
716 if (GETDEFIMAGELIST(infoPtr, 0) &&
717 TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
718 /* The following test looked like this before
719 * I changed it. IE4 "Links" toolbar would not
720 * draw correctly with the original code. - GA 8/01
721 * ((dwStyle & TBSTYLE_LIST) &&
722 * ((btnPtr->fsStyle & TBSTYLE_AUTOSIZE) == 0) &&
723 * (btnPtr->iBitmap != I_IMAGENONE))
725 if (dwStyle & TBSTYLE_LIST) {
726 /* LIST style w/ ICON offset is by matching native. */
727 /* Matches IE4 "Links" bar. - GA 8/01 */
728 rcText.left += (infoPtr->nBitmapWidth + 2);
731 rcText.top += infoPtr->nBitmapHeight + 1;
735 if (dwStyle & TBSTYLE_LIST) {
736 /* LIST style w/o ICON offset is by matching native. */
737 /* Matches IE4 "menu" bar. - GA 8/01 */
742 if (btnPtr->fsState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
743 OffsetRect (&rcText, 1, 1);
746 /* Initialize fields in all cases, because we use these later */
747 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
748 tbcd.clrText = comctl32_color.clrBtnText;
749 tbcd.clrTextHighlight = comctl32_color.clrHighlightText;
750 tbcd.clrBtnFace = comctl32_color.clrBtnFace;
751 tbcd.clrBtnHighlight = comctl32_color.clrBtnHighlight;
752 tbcd.clrMark = comctl32_color.clrHighlight;
753 tbcd.clrHighlightHotTrack = 0;
754 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
755 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
756 /* MSDN says that this is the text rectangle. */
757 /* But (why always a but) tracing of v5.7 of native shows */
758 /* that this is really a *relative* rectangle based on the */
759 /* the nmcd.rc. Also the left and top are always 0 ignoring*/
760 /* any bitmap that might be present. */
761 tbcd.rcText.left = 0;
763 tbcd.rcText.right = rcText.right - rc.left;
764 tbcd.rcText.bottom = rcText.bottom - rc.top;
765 /* we use this state later on to decide how to draw the buttons */
766 /* NOTE: applications can and do alter this to customize their */
768 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
770 /* FIXME: what should these be set to ????? */
771 tbcd.hbrMonoDither = 0;
775 /* Issue Item Prepaint notify */
776 infoPtr->dwItemCustDraw = 0;
777 infoPtr->dwItemCDFlag = 0;
778 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYITEMDRAW)
780 tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT;
783 tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
784 tbcd.nmcd.lItemlParam = btnPtr->dwData;
785 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
786 infoPtr->dwItemCustDraw = ntfret & 0xffff;
787 infoPtr->dwItemCDFlag = ntfret & 0xffff0000;
788 if (infoPtr->dwItemCustDraw & CDRF_SKIPDEFAULT)
790 /* save the only part of the rect that the user can change */
791 rcText.right = tbcd.rcText.right + rc.left;
792 rcText.bottom = tbcd.rcText.bottom + rc.top;
795 if (!infoPtr->bBtnTranspnt)
796 FillRect( hdc, &rcFill, GetSysColorBrush(COLOR_BTNFACE));
799 if (btnPtr->fsStyle & TBSTYLE_SEP) {
800 /* with the FLAT style, iBitmap is the width and has already */
801 /* been taken into consideration in calculating the width */
802 /* so now we need to draw the vertical separator */
803 /* empirical tests show that iBitmap can/will be non-zero */
804 /* when drawing the vertical bar... */
805 if ((dwStyle & TBSTYLE_FLAT) /* && (btnPtr->iBitmap == 0) */) {
806 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
807 TOOLBAR_DrawDDFlatSeparator (&rc, hdc, btnPtr, infoPtr);
809 TOOLBAR_DrawFlatSeparator (&rc, hdc, infoPtr);
811 else if (btnPtr->fsStyle != TBSTYLE_SEP) {
812 FIXME("Draw some kind of separator: fsStyle=%x\n",
818 if ((dwStyle & TBSTYLE_FLAT) && (tbcd.nmcd.uItemState & CDIS_HOT))
820 if ( infoPtr->dwItemCDFlag & TBCDRF_HILITEHOTTRACK )
824 oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack);
825 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0);
826 if (hasDropDownArrow)
827 ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0);
828 SetBkColor(hdc, oldclr);
832 if (!(tbcd.nmcd.uItemState & CDIS_DISABLED) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
834 DrawEdge (hdc, &rc, BDR_RAISEDINNER, BF_RECT);
835 if (hasDropDownArrow)
836 DrawEdge (hdc, &rcArrow, BDR_RAISEDINNER, BF_RECT);
842 if (tbcd.nmcd.uItemState & CDIS_DISABLED) {
843 if (!(dwStyle & TBSTYLE_FLAT) && !(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
845 DrawEdge (hdc, &rc, EDGE_RAISED,
846 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
847 if (hasDropDownArrow)
848 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
849 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
852 if (hasDropDownArrow)
854 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1 + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_3DHIGHLIGHT);
855 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_3DSHADOW);
858 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, IMAGE_LIST_DISABLED,
859 hdc, rcBitmap.left, rcBitmap.top,
861 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
863 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, dwStyle, &rcText, lpText, &tbcd);
867 /* pressed TBSTYLE_BUTTON */
868 if (tbcd.nmcd.uItemState & CDIS_SELECTED) {
869 offset = (infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) ? 0 : 1;
870 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
872 if (dwStyle & TBSTYLE_FLAT)
874 DrawEdge (hdc, &rc, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
875 if (hasDropDownArrow)
876 DrawEdge (hdc, &rcArrow, BDR_SUNKENOUTER, BF_RECT | BF_ADJUST);
880 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
881 if (hasDropDownArrow)
882 DrawEdge (hdc, &rcArrow, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
886 if (hasDropDownArrow)
887 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_WINDOWFRAME);
889 TOOLBAR_DrawImageList (infoPtr, btnPtr, IMAGE_LIST_DEFAULT,
890 hdc, rcBitmap.left+offset, rcBitmap.top+offset,
893 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, dwStyle, &rcText, lpText, &tbcd);
897 /* checked TBSTYLE_CHECK */
898 if ((tbcd.nmcd.uItemState & CDIS_CHECKED) &&
899 (btnPtr->fsStyle & TBSTYLE_CHECK)) {
900 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
902 if (dwStyle & TBSTYLE_FLAT)
903 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
904 BF_RECT | BF_ADJUST);
906 DrawEdge (hdc, &rc, EDGE_SUNKEN,
907 BF_RECT | BF_MIDDLE | BF_ADJUST);
910 TOOLBAR_DrawPattern (hdc, &rc);
912 TOOLBAR_DrawImageList (infoPtr, btnPtr, IMAGE_LIST_DEFAULT,
913 hdc, rcBitmap.left+1, rcBitmap.top+1,
916 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, dwStyle, &rcText, lpText, &tbcd);
921 if (tbcd.nmcd.uItemState & CDIS_INDETERMINATE) {
922 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
923 DrawEdge (hdc, &rc, EDGE_RAISED,
924 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
926 TOOLBAR_DrawPattern (hdc, &rc);
927 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
928 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, dwStyle, &rcText, lpText, &tbcd);
933 if (dwStyle & TBSTYLE_FLAT)
935 if (hasDropDownArrow)
936 TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_WINDOWFRAME);
938 if (tbcd.nmcd.uItemState & CDIS_HOT) {
939 /* if hot, attempt to draw with hot image list, if fails,
940 use default image list */
941 if (!TOOLBAR_DrawImageList (infoPtr, btnPtr,
944 rcBitmap.top, ILD_NORMAL))
945 TOOLBAR_DrawImageList (infoPtr, btnPtr, IMAGE_LIST_DEFAULT,
946 hdc, rcBitmap.left, rcBitmap.top,
950 TOOLBAR_DrawImageList (infoPtr, btnPtr, IMAGE_LIST_DEFAULT,
951 hdc, rcBitmap.left, rcBitmap.top,
956 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
957 DrawEdge (hdc, &rc, EDGE_RAISED,
958 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
960 if (hasDropDownArrow)
962 if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
963 DrawEdge (hdc, &rcArrow, EDGE_RAISED,
964 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
965 TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_WINDOWFRAME);
968 TOOLBAR_DrawImageList (infoPtr, btnPtr, IMAGE_LIST_DEFAULT,
969 hdc, rcBitmap.left, rcBitmap.top,
974 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, dwStyle, &rcText, lpText, &tbcd);
977 if (infoPtr->dwItemCustDraw & CDRF_NOTIFYPOSTPAINT)
979 tbcd.nmcd.dwDrawStage = CDDS_ITEMPOSTPAINT;
982 tbcd.nmcd.dwItemSpec = btnPtr->idCommand;
983 tbcd.nmcd.uItemState = TOOLBAR_TranslateState(btnPtr);
984 tbcd.nmcd.lItemlParam = btnPtr->dwData;
985 tbcd.rcText = rcText;
986 tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
987 tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE;
988 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
995 TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps)
997 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
998 TBUTTON_INFO *btnPtr;
999 INT i, oldBKmode = 0;
1001 NMTBCUSTOMDRAW tbcd;
1004 /* if imagelist belongs to the app, it can be changed
1005 by the app after setting it */
1006 if (GETDEFIMAGELIST(infoPtr, 0) != infoPtr->himlInt)
1008 infoPtr->nNumBitmaps = 0;
1009 for (i = 0; i < infoPtr->cimlDef; i++)
1010 infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl);
1013 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
1015 /* Send initial notify */
1016 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
1017 tbcd.nmcd.dwDrawStage = CDDS_PREPAINT;
1018 tbcd.nmcd.hdc = hdc;
1019 tbcd.nmcd.rc = ps->rcPaint;
1020 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
1021 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
1023 if (infoPtr->bBtnTranspnt)
1024 oldBKmode = SetBkMode (hdc, TRANSPARENT);
1026 /* redraw necessary buttons */
1027 btnPtr = infoPtr->buttons;
1028 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
1030 if(IntersectRect(&rcTemp, &(ps->rcPaint), &(btnPtr->rect)))
1031 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1034 if (infoPtr->bBtnTranspnt && (oldBKmode != TRANSPARENT))
1035 SetBkMode (hdc, oldBKmode);
1037 if (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTPAINT)
1039 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
1040 tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT;
1041 tbcd.nmcd.hdc = hdc;
1042 tbcd.nmcd.rc = ps->rcPaint;
1043 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
1047 /***********************************************************************
1048 * TOOLBAR_MeasureString
1050 * This function gets the width and height of a string in pixels. This
1051 * is done first by using GetTextExtentPoint to get the basic width
1052 * and height. The DrawText is called with DT_CALCRECT to get the exact
1053 * width. The reason is because the text may have more than one "&" (or
1054 * prefix characters as M$ likes to call them). The prefix character
1055 * indicates where the underline goes, except for the string "&&" which
1056 * is reduced to a single "&". GetTextExtentPoint does not process these
1057 * only DrawText does. Note that the TBSTYLE_NOPREFIX is handled here.
1060 TOOLBAR_MeasureString(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
1061 HDC hdc, LPSIZE lpSize)
1068 if (!(btnPtr->fsState & TBSTATE_HIDDEN) )
1070 LPWSTR lpText = TOOLBAR_GetText(infoPtr, btnPtr);
1072 if(lpText != NULL) {
1073 /* first get size of all the text */
1074 GetTextExtentPoint32W (hdc, lpText, strlenW (lpText), lpSize);
1076 /* feed above size into the rectangle for DrawText */
1077 myrect.left = myrect.top = 0;
1078 myrect.right = lpSize->cx;
1079 myrect.bottom = lpSize->cy;
1081 /* Use DrawText to get true size as drawn (less pesky "&") */
1082 DrawTextW (hdc, lpText, -1, &myrect, DT_VCENTER | DT_SINGLELINE |
1083 DT_CALCRECT | ((btnPtr->fsStyle & TBSTYLE_NOPREFIX) ?
1086 /* feed back to caller */
1087 lpSize->cx = myrect.right;
1088 lpSize->cy = myrect.bottom;
1092 TRACE("string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
1095 /***********************************************************************
1096 * TOOLBAR_CalcStrings
1098 * This function walks through each string and measures it and returns
1099 * the largest height and width to caller.
1102 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
1104 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1105 TBUTTON_INFO *btnPtr;
1115 hOldFont = SelectObject (hdc, infoPtr->hFont);
1117 btnPtr = infoPtr->buttons;
1118 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1119 if(TOOLBAR_HasText(infoPtr, btnPtr))
1121 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1122 if (sz.cx > lpSize->cx)
1124 if (sz.cy > lpSize->cy)
1129 SelectObject (hdc, hOldFont);
1130 ReleaseDC (hwnd, hdc);
1132 TRACE("max string size %ld x %ld!\n", lpSize->cx, lpSize->cy);
1135 /***********************************************************************
1136 * TOOLBAR_WrapToolbar
1138 * This function walks through the buttons and separators in the
1139 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
1140 * wrapping should occur based on the width of the toolbar window.
1141 * It does *not* calculate button placement itself. That task
1142 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
1143 * the toolbar wrapping on its own, it can use the TBSTYLE_WRAPABLE
1144 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
1146 * Note: TBSTYLE_WRAPABLE or TBSTYLE_EX_UNDOC1 can be used also to allow
1147 * vertical toolbar lists.
1151 TOOLBAR_WrapToolbar( HWND hwnd, DWORD dwStyle )
1153 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1154 TBUTTON_INFO *btnPtr;
1157 BOOL bWrap, bButtonWrap;
1159 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
1160 /* no layout is necessary. Applications may use this style */
1161 /* to perform their own layout on the toolbar. */
1162 if( !(dwStyle & TBSTYLE_WRAPABLE) &&
1163 !(infoPtr->dwExStyle & TBSTYLE_EX_UNDOC1) ) return;
1165 btnPtr = infoPtr->buttons;
1166 x = infoPtr->nIndent;
1168 /* this can get the parents width, to know how far we can extend
1169 * this toolbar. We cannot use its height, as there may be multiple
1170 * toolbars in a rebar control
1172 GetClientRect( GetParent(hwnd), &rc );
1173 infoPtr->nWidth = rc.right - rc.left;
1174 bButtonWrap = FALSE;
1176 TRACE("start ButtonWidth=%d, BitmapWidth=%d, nWidth=%d, nIndent=%d\n",
1177 infoPtr->nButtonWidth, infoPtr->nBitmapWidth, infoPtr->nWidth,
1180 for (i = 0; i < infoPtr->nNumButtons; i++ )
1183 btnPtr[i].fsState &= ~TBSTATE_WRAP;
1185 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
1188 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1189 /* it is the actual width of the separator. This is used for */
1190 /* custom controls in toolbars. */
1192 /* TBSTYLE_DROPDOWN separators are treated as buttons for */
1193 /* width. - GA 8/01 */
1194 if ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1195 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN))
1196 cx = (btnPtr[i].iBitmap > 0) ?
1197 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
1199 cx = infoPtr->nButtonWidth;
1201 /* Two or more adjacent separators form a separator group. */
1202 /* The first separator in a group should be wrapped to the */
1203 /* next row if the previous wrapping is on a button. */
1205 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1206 (i + 1 < infoPtr->nNumButtons ) &&
1207 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
1209 TRACE("wrap point 1 btn %d style %02x\n", i, btnPtr[i].fsStyle);
1210 btnPtr[i].fsState |= TBSTATE_WRAP;
1211 x = infoPtr->nIndent;
1213 bButtonWrap = FALSE;
1217 /* The layout makes sure the bitmap is visible, but not the button. */
1218 /* Test added to also wrap after a button that starts a row but */
1219 /* is bigger than the area. - GA 8/01 */
1220 if (( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
1221 > infoPtr->nWidth ) ||
1222 ((x == infoPtr->nIndent) && (cx > infoPtr->nWidth)))
1224 BOOL bFound = FALSE;
1226 /* If the current button is a separator and not hidden, */
1227 /* go to the next until it reaches a non separator. */
1228 /* Wrap the last separator if it is before a button. */
1229 while( ( ((btnPtr[i].fsStyle & TBSTYLE_SEP) &&
1230 !(btnPtr[i].fsStyle & TBSTYLE_DROPDOWN)) ||
1231 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
1232 i < infoPtr->nNumButtons )
1238 if( bFound && i < infoPtr->nNumButtons )
1241 TRACE("wrap point 2 btn %d style %02x, x=%d, cx=%d\n",
1242 i, btnPtr[i].fsStyle, x, cx);
1243 btnPtr[i].fsState |= TBSTATE_WRAP;
1244 x = infoPtr->nIndent;
1245 bButtonWrap = FALSE;
1248 else if ( i >= infoPtr->nNumButtons)
1251 /* If the current button is not a separator, find the last */
1252 /* separator and wrap it. */
1253 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1255 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
1256 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
1260 TRACE("wrap point 3 btn %d style %02x, x=%d, cx=%d\n",
1261 i, btnPtr[i].fsStyle, x, cx);
1262 x = infoPtr->nIndent;
1263 btnPtr[j].fsState |= TBSTATE_WRAP;
1264 bButtonWrap = FALSE;
1269 /* If no separator available for wrapping, wrap one of */
1270 /* non-hidden previous button. */
1274 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
1276 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
1281 TRACE("wrap point 4 btn %d style %02x, x=%d, cx=%d\n",
1282 i, btnPtr[i].fsStyle, x, cx);
1283 x = infoPtr->nIndent;
1284 btnPtr[j].fsState |= TBSTATE_WRAP;
1290 /* If all above failed, wrap the current button. */
1293 TRACE("wrap point 5 btn %d style %02x, x=%d, cx=%d\n",
1294 i, btnPtr[i].fsStyle, x, cx);
1295 btnPtr[i].fsState |= TBSTATE_WRAP;
1297 x = infoPtr->nIndent;
1298 if (btnPtr[i].fsStyle & TBSTYLE_SEP )
1299 bButtonWrap = FALSE;
1305 TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
1306 i, btnPtr[i].fsStyle, x, cx);
1313 /***********************************************************************
1314 * TOOLBAR_CalcToolbar
1316 * This function calculates button and separator placement. It first
1317 * calculates the button sizes, gets the toolbar window width and then
1318 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
1319 * on. It assigns a new location to each item and sends this location to
1320 * the tooltip window if appropriate. Finally, it updates the rcBound
1321 * rect and calculates the new required toolbar window height.
1325 TOOLBAR_CalcToolbar (HWND hwnd)
1327 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
1328 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1329 TBUTTON_INFO *btnPtr;
1330 INT i, nRows, nSepRows;
1334 BOOL usesBitmaps = FALSE;
1335 BOOL hasDropDownArrows = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle);
1337 TOOLBAR_CalcStrings (hwnd, &sizeString);
1339 for (i = 0; i < infoPtr->nNumButtons && !usesBitmaps; i++)
1341 if (TOOLBAR_IsValidBitmapIndex(infoPtr,infoPtr->buttons[i].iBitmap))
1344 if (dwStyle & TBSTYLE_LIST)
1346 infoPtr->nButtonHeight = max((usesBitmaps) ? infoPtr->nBitmapHeight :
1347 0, sizeString.cy) + infoPtr->szPadding.cy;
1348 infoPtr->nButtonWidth = ((usesBitmaps) ? infoPtr->nBitmapWidth :
1349 0) + sizeString.cx + 6;
1350 TRACE("LIST style, But w=%d h=%d, useBitmaps=%d, Bit w=%d h=%d\n",
1351 infoPtr->nButtonWidth, infoPtr->nButtonHeight, usesBitmaps,
1352 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
1353 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
1356 if (sizeString.cy > 0)
1359 infoPtr->nButtonHeight = sizeString.cy +
1360 2 + /* this is the space to separate text from bitmap */
1361 infoPtr->nBitmapHeight + 6;
1363 infoPtr->nButtonHeight = sizeString.cy + 6;
1365 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
1366 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
1368 if (sizeString.cx > infoPtr->nBitmapWidth)
1369 infoPtr->nButtonWidth = sizeString.cx + 6;
1370 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
1371 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
1374 if ( infoPtr->cxMin >= 0 && infoPtr->nButtonWidth < infoPtr->cxMin )
1375 infoPtr->nButtonWidth = infoPtr->cxMin;
1376 if ( infoPtr->cxMax > 0 && infoPtr->nButtonWidth > infoPtr->cxMax )
1377 infoPtr->nButtonWidth = infoPtr->cxMax;
1379 TOOLBAR_WrapToolbar( hwnd, dwStyle );
1381 x = infoPtr->nIndent;
1385 * We will set the height below, and we set the width on entry
1386 * so we do not reset them here..
1389 GetClientRect( hwnd, &rc );
1390 /* get initial values for toolbar */
1391 infoPtr->nWidth = rc.right - rc.left;
1392 infoPtr->nHeight = rc.bottom - rc.top;
1395 /* from above, minimum is a button, and possible text */
1396 cx = infoPtr->nButtonWidth;
1398 /* cannot use just ButtonHeight, we may have no buttons! */
1399 if (infoPtr->nNumButtons > 0)
1400 infoPtr->nHeight = infoPtr->nButtonHeight;
1402 cy = infoPtr->nHeight;
1404 nRows = nSepRows = 0;
1406 infoPtr->rcBound.top = y;
1407 infoPtr->rcBound.left = x;
1408 infoPtr->rcBound.bottom = y + cy;
1409 infoPtr->rcBound.right = x;
1411 btnPtr = infoPtr->buttons;
1413 /* do not base height/width on parent, if the parent is a */
1414 /* rebar control it could have multiple rows of toolbars */
1415 /* GetClientRect( GetParent(hwnd), &rc ); */
1416 /* cx = rc.right - rc.left; */
1417 /* cy = rc.bottom - rc.top; */
1419 TRACE("cy=%d\n", cy);
1421 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
1424 if (btnPtr->fsState & TBSTATE_HIDDEN)
1426 SetRectEmpty (&btnPtr->rect);
1430 cy = infoPtr->nHeight;
1432 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1433 /* it is the actual width of the separator. This is used for */
1434 /* custom controls in toolbars. */
1435 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1436 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN) {
1437 cy = (btnPtr->iBitmap > 0) ?
1438 btnPtr->iBitmap : SEPARATOR_WIDTH;
1439 cx = infoPtr->nButtonWidth;
1442 cx = (btnPtr->iBitmap > 0) ?
1443 btnPtr->iBitmap : SEPARATOR_WIDTH;
1447 if (btnPtr->fsStyle & TBSTYLE_AUTOSIZE)
1454 hOldFont = SelectObject (hdc, infoPtr->hFont);
1456 TOOLBAR_MeasureString(infoPtr, btnPtr, hdc, &sz);
1458 SelectObject (hdc, hOldFont);
1459 ReleaseDC (hwnd, hdc);
1461 /* Fudge amount measured against IE4 "menu" and "Links" */
1462 /* toolbars with native control (v4.71). - GA 8/01 */
1463 cx = sz.cx + 6 + 5 + 5;
1464 if (TOOLBAR_TestImageExist (infoPtr, btnPtr, GETDEFIMAGELIST(infoPtr,0)))
1466 if (dwStyle & TBSTYLE_LIST)
1467 cx += infoPtr->nBitmapWidth;
1468 else if (cx < (infoPtr->nBitmapWidth+7))
1469 cx = infoPtr->nBitmapWidth+7;
1473 cx = infoPtr->nButtonWidth;
1475 if (hasDropDownArrows && (btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1476 cx += DDARROW_WIDTH;
1478 if (btnPtr->fsState & TBSTATE_WRAP )
1481 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
1483 if (infoPtr->rcBound.left > x)
1484 infoPtr->rcBound.left = x;
1485 if (infoPtr->rcBound.right < x + cx)
1486 infoPtr->rcBound.right = x + cx;
1487 if (infoPtr->rcBound.bottom < y + cy)
1488 infoPtr->rcBound.bottom = y + cy;
1490 /* Set the toolTip only for non-hidden, non-separator button */
1491 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
1495 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1496 ti.cbSize = sizeof(TTTOOLINFOA);
1498 ti.uId = btnPtr->idCommand;
1499 ti.rect = btnPtr->rect;
1500 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
1504 /* btnPtr->nRow is zero based. The space between the rows is */
1505 /* also considered as a row. */
1506 btnPtr->nRow = nRows + nSepRows;
1508 TRACE("button %d style=%x, bWrap=%d, nRows=%d, nSepRows=%d, btnrow=%d, (%d,%d)-(%d,%d)\n",
1509 i, btnPtr->fsStyle, bWrap, nRows, nSepRows, btnPtr->nRow,
1514 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
1518 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
1519 /* it is the actual width of the separator. This is used for */
1520 /* custom controls in toolbars. */
1521 if ( !(btnPtr->fsStyle & TBSTYLE_DROPDOWN))
1522 y += cy + ( (btnPtr->iBitmap > 0 ) ?
1523 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
1527 /* nSepRows is used to calculate the extra height follwoing */
1531 x = infoPtr->nIndent;
1533 /* Increment row number unless this is the last button */
1534 /* and it has Wrap set. */
1535 if (i != infoPtr->nNumButtons-1)
1542 /* infoPtr->nRows is the number of rows on the toolbar */
1543 infoPtr->nRows = nRows + nSepRows + 1;
1546 /********************************************************************
1547 * The following while interesting, does not match the values *
1548 * created above for the button rectangles, nor the rcBound rect. *
1549 * We will comment it out and remove it later. *
1551 * The problem showed up as heights in the pager control that was *
1553 ********************************************************************/
1555 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
1557 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
1558 nSepRows * (SEPARATOR_WIDTH * 2 / 3) +
1559 nSepRows * (infoPtr->nBitmapHeight + 1) +
1563 infoPtr->nHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1565 TRACE("toolbar height %d, button width %d\n", infoPtr->nHeight, infoPtr->nButtonWidth);
1570 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
1572 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1573 TBUTTON_INFO *btnPtr;
1576 btnPtr = infoPtr->buttons;
1577 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1578 if (btnPtr->fsState & TBSTATE_HIDDEN)
1581 if (btnPtr->fsStyle & TBSTYLE_SEP) {
1582 if (PtInRect (&btnPtr->rect, *lpPt)) {
1583 TRACE(" ON SEPARATOR %d!\n", i);
1588 if (PtInRect (&btnPtr->rect, *lpPt)) {
1589 TRACE(" ON BUTTON %d!\n", i);
1595 TRACE(" NOWHERE!\n");
1601 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand, BOOL CommandIsIndex)
1603 TBUTTON_INFO *btnPtr;
1606 if (CommandIsIndex) {
1607 TRACE("command is really index command=%d\n", idCommand);
1608 if (idCommand >= infoPtr->nNumButtons) return -1;
1611 btnPtr = infoPtr->buttons;
1612 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
1613 if (btnPtr->idCommand == idCommand) {
1614 TRACE("command=%d index=%d\n", idCommand, i);
1618 TRACE("no index found for command=%d\n", idCommand);
1624 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
1626 TBUTTON_INFO *btnPtr;
1629 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
1632 /* check index button */
1633 btnPtr = &infoPtr->buttons[nIndex];
1634 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1635 if (btnPtr->fsState & TBSTATE_CHECKED)
1639 /* check previous buttons */
1640 nRunIndex = nIndex - 1;
1641 while (nRunIndex >= 0) {
1642 btnPtr = &infoPtr->buttons[nRunIndex];
1643 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1644 if (btnPtr->fsState & TBSTATE_CHECKED)
1652 /* check next buttons */
1653 nRunIndex = nIndex + 1;
1654 while (nRunIndex < infoPtr->nNumButtons) {
1655 btnPtr = &infoPtr->buttons[nRunIndex];
1656 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
1657 if (btnPtr->fsState & TBSTATE_CHECKED)
1670 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
1671 WPARAM wParam, LPARAM lParam)
1677 msg.wParam = wParam;
1678 msg.lParam = lParam;
1679 msg.time = GetMessageTime ();
1680 msg.pt.x = LOWORD(GetMessagePos ());
1681 msg.pt.y = HIWORD(GetMessagePos ());
1683 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
1687 /***********************************************************************
1688 * TOOLBAR_CustomizeDialogProc
1689 * This function implements the toolbar customization dialog.
1691 static INT_PTR CALLBACK
1692 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1694 PCUSTDLG_INFO custInfo = (PCUSTDLG_INFO)GetWindowLongA (hwnd, DWL_USER);
1695 PCUSTOMBUTTON btnInfo;
1697 TOOLBAR_INFO *infoPtr = custInfo ? custInfo->tbInfo : NULL;
1702 custInfo = (PCUSTDLG_INFO)lParam;
1703 SetWindowLongA (hwnd, DWL_USER, (DWORD)custInfo);
1711 infoPtr = custInfo->tbInfo;
1713 /* send TBN_QUERYINSERT notification */
1714 nmtb.iItem = custInfo->tbInfo->nNumButtons;
1716 if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT))
1719 /* Send TBN_INITCUSTOMIZE notification */
1720 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) ==
1723 TRACE("TBNRF_HIDEHELP requested\n");
1724 ShowWindow(GetDlgItem(hwnd, IDC_HELP_BTN), SW_HIDE);
1728 FIXME("Help button not implemented\n");
1729 EnableWindow(GetDlgItem(hwnd, IDC_HELP_BTN), FALSE);
1732 /* add items to 'toolbar buttons' list and check if removable */
1733 for (i = 0; i < custInfo->tbInfo->nNumButtons; i++)
1735 btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
1736 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1737 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1738 btnInfo->bVirtual = FALSE;
1739 LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1741 /* send TBN_QUERYDELETE notification */
1742 btnInfo->bRemovable = TOOLBAR_IsButtonRemovable(infoPtr, i, btnInfo);
1744 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, 0);
1745 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1748 /* insert separator button into 'available buttons' list */
1749 btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
1750 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1751 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1752 btnInfo->bVirtual = FALSE;
1753 btnInfo->bRemovable = TRUE;
1754 LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1755 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1756 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1758 /* insert all buttons into dsa */
1761 /* send TBN_GETBUTTONINFO notification */
1764 nmtb.pszText = Buffer;
1767 /* Clear previous button's text */
1768 ZeroMemory(nmtb.pszText, nmtb.cchText * sizeof(WCHAR));
1770 if (!TOOLBAR_GetButtonInfo(infoPtr, &nmtb))
1773 TRACE("WM_INITDIALOG style: %x iItem(%d) idCommand(%d) iString(%d) %s\n",
1774 nmtb.tbButton.fsStyle, i,
1775 nmtb.tbButton.idCommand,
1776 nmtb.tbButton.iString,
1777 nmtb.tbButton.iString >= 0 ? debugstr_w(infoPtr->strings[nmtb.tbButton.iString])
1780 /* insert button into the apropriate list */
1781 index = TOOLBAR_GetButtonIndex (custInfo->tbInfo, nmtb.tbButton.idCommand, FALSE);
1784 btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
1785 btnInfo->bVirtual = FALSE;
1786 btnInfo->bRemovable = TRUE;
1788 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1789 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX,
1790 LB_SETITEMDATA, index, (LPARAM)btnInfo);
1794 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd,
1795 IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1798 memcpy (&btnInfo->btn, &nmtb.tbButton, sizeof(TBBUTTON));
1799 if (!(nmtb.tbButton.fsStyle & TBSTYLE_SEP))
1801 if (lstrlenW(nmtb.pszText))
1802 lstrcpyW(btnInfo->text, nmtb.pszText);
1803 else if (nmtb.tbButton.iString >= 0 &&
1804 nmtb.tbButton.iString < infoPtr->nNumStrings)
1806 lstrcpyW(btnInfo->text,
1807 infoPtr->strings[nmtb.tbButton.iString]);
1812 /* select first item in the 'available' list */
1813 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, 0, 0);
1815 /* append 'virtual' separator button to the 'toolbar buttons' list */
1816 btnInfo = (PCUSTOMBUTTON)Alloc(sizeof(CUSTOMBUTTON));
1817 memset (&btnInfo->btn, 0, sizeof(TBBUTTON));
1818 btnInfo->btn.fsStyle = TBSTYLE_SEP;
1819 btnInfo->bVirtual = TRUE;
1820 btnInfo->bRemovable = FALSE;
1821 LoadStringW (COMCTL32_hModule, IDS_SEPARATOR, btnInfo->text, 64);
1822 index = (int)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)btnInfo);
1823 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1825 /* select last item in the 'toolbar' list */
1826 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index, 0);
1827 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETTOPINDEX, index, 0);
1829 /* set focus and disable buttons */
1830 PostMessageA (hwnd, WM_USER, 0, 0);
1835 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1836 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1837 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), FALSE);
1838 SetFocus (GetDlgItem (hwnd, IDC_TOOLBARBTN_LBOX));
1842 EndDialog(hwnd, FALSE);
1846 switch (LOWORD(wParam))
1848 case IDC_TOOLBARBTN_LBOX:
1849 if (HIWORD(wParam) == LBN_SELCHANGE)
1851 PCUSTOMBUTTON btnInfo;
1856 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1857 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1859 /* send TBN_QUERYINSERT notification */
1861 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1864 /* get list box item */
1865 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1867 if (index == (count - 1))
1869 /* last item (virtual separator) */
1870 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1871 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1873 else if (index == (count - 2))
1875 /* second last item (last non-virtual item) */
1876 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1877 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1879 else if (index == 0)
1882 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1883 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1887 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1888 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1891 EnableWindow (GetDlgItem (hwnd,IDC_REMOVE_BTN), btnInfo->bRemovable);
1895 case IDC_MOVEUP_BTN:
1897 PCUSTOMBUTTON btnInfo;
1901 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1902 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1903 TRACE("Move up: index %d\n", index);
1905 /* send TBN_QUERYINSERT notification */
1908 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1911 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1913 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1914 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index-1, 0);
1915 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index-1, (LPARAM)btnInfo);
1916 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index-1 , 0);
1919 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), FALSE);
1920 else if (index >= (count - 3))
1921 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), TRUE);
1923 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1924 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index-1, (LPARAM)&(btnInfo->btn));
1929 case IDC_MOVEDN_BTN: /* move down */
1931 PCUSTOMBUTTON btnInfo;
1935 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
1936 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1937 TRACE("Move up: index %d\n", index);
1939 /* send TBN_QUERYINSERT notification */
1941 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
1944 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1946 /* move button down */
1947 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1948 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index+1, 0);
1949 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index+1, (LPARAM)btnInfo);
1950 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index+1 , 0);
1953 EnableWindow (GetDlgItem (hwnd,IDC_MOVEUP_BTN), TRUE);
1954 else if (index >= (count - 3))
1955 EnableWindow (GetDlgItem (hwnd,IDC_MOVEDN_BTN), FALSE);
1957 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1958 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index+1, (LPARAM)&(btnInfo->btn));
1963 case IDC_REMOVE_BTN: /* remove button */
1965 PCUSTOMBUTTON btnInfo;
1968 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
1970 if (LB_ERR == index)
1973 TRACE("Remove: index %d\n", index);
1975 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX,
1976 LB_GETITEMDATA, index, 0);
1978 /* send TBN_QUERYDELETE notification */
1979 if (TOOLBAR_IsButtonRemovable(infoPtr, index, btnInfo))
1981 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0);
1982 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_DELETESTRING, index, 0);
1983 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETCURSEL, index , 0);
1985 SendMessageA (custInfo->tbHwnd, TB_DELETEBUTTON, index, 0);
1987 /* insert into 'available button' list */
1988 if (!(btnInfo->btn.fsStyle & TBSTYLE_SEP))
1990 index = (int)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, 0);
1991 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
1999 case IDOK: /* Add button */
2004 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
2005 index = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCURSEL, 0, 0);
2006 TRACE("Add: index %d\n", index);
2008 /* send TBN_QUERYINSERT notification */
2010 if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
2013 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, index, 0);
2017 /* remove from 'available buttons' list */
2018 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_DELETESTRING, index, 0);
2019 if (index == count-1)
2020 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index-1 , 0);
2022 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETCURSEL, index , 0);
2026 PCUSTOMBUTTON btnNew;
2028 /* duplicate 'separator' button */
2029 btnNew = (PCUSTOMBUTTON)Alloc (sizeof(CUSTOMBUTTON));
2030 memcpy (btnNew, btnInfo, sizeof(CUSTOMBUTTON));
2034 /* insert into 'toolbar button' list */
2035 index = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCURSEL, 0, 0);
2036 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_INSERTSTRING, index, 0);
2037 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, index, (LPARAM)btnInfo);
2039 SendMessageA (custInfo->tbHwnd, TB_INSERTBUTTONA, index, (LPARAM)&(btnInfo->btn));
2045 EndDialog(hwnd, FALSE);
2055 /* delete items from 'toolbar buttons' listbox*/
2056 count = SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETCOUNT, 0, 0);
2057 for (i = 0; i < count; i++)
2059 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, i, 0);
2061 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_SETITEMDATA, 0, 0);
2063 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_RESETCONTENT, 0, 0);
2066 /* delete items from 'available buttons' listbox*/
2067 count = SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETCOUNT, 0, 0);
2068 for (i = 0; i < count; i++)
2070 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_GETITEMDATA, i, 0);
2072 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_SETITEMDATA, i, 0);
2074 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_RESETCONTENT, 0, 0);
2079 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
2081 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
2082 DWORD dwStyle = GetWindowLongA (infoPtr->hwndSelf, GWL_STYLE);
2087 COLORREF oldText = 0;
2091 btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageA (hwnd, wParam, LB_GETITEMDATA, (WPARAM)lpdis->itemID, 0);
2092 if (btnInfo == NULL)
2094 FIXME("btnInfo invalid!\n");
2098 /* set colors and select objects */
2099 oldBk = SetBkColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlight:comctl32_color.clrWindow);
2100 if (btnInfo->bVirtual)
2101 oldText = SetTextColor (lpdis->hDC, comctl32_color.clrGrayText);
2103 oldText = SetTextColor (lpdis->hDC, (lpdis->itemState & ODS_FOCUS)?comctl32_color.clrHighlightText:comctl32_color.clrWindowText);
2104 hPen = CreatePen( PS_SOLID, 1,
2105 GetSysColor( (lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
2106 hOldPen = SelectObject (lpdis->hDC, hPen );
2107 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
2109 /* fill background rectangle */
2110 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
2111 lpdis->rcItem.right, lpdis->rcItem.bottom);
2113 /* calculate button and text rectangles */
2114 CopyRect (&rcButton, &lpdis->rcItem);
2115 InflateRect (&rcButton, -1, -1);
2116 CopyRect (&rcText, &rcButton);
2117 rcButton.right = rcButton.left + custInfo->tbInfo->nBitmapWidth + 6;
2118 rcText.left = rcButton.right + 2;
2120 /* draw focus rectangle */
2121 if (lpdis->itemState & ODS_FOCUS)
2122 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
2125 if (!(dwStyle & TBSTYLE_FLAT))
2126 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
2128 /* draw image and text */
2129 if ((btnInfo->btn.fsStyle & TBSTYLE_SEP) == 0) {
2130 HIMAGELIST himl = GETDEFIMAGELIST(infoPtr, GETHIMLID(infoPtr,
2131 btnInfo->btn.iBitmap));
2132 ImageList_Draw (himl, GETIBITMAP(infoPtr, btnInfo->btn.iBitmap),
2133 lpdis->hDC, rcButton.left+3, rcButton.top+3, ILD_NORMAL);
2135 DrawTextW (lpdis->hDC, btnInfo->text, -1, &rcText,
2136 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
2138 /* delete objects and reset colors */
2139 SelectObject (lpdis->hDC, hOldBrush);
2140 SelectObject (lpdis->hDC, hOldPen);
2141 SetBkColor (lpdis->hDC, oldBk);
2142 SetTextColor (lpdis->hDC, oldText);
2143 DeleteObject( hPen );
2148 case WM_MEASUREITEM:
2149 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
2151 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
2153 if (custInfo && custInfo->tbInfo)
2154 lpmis->itemHeight = custInfo->tbInfo->nBitmapHeight + 8;
2156 lpmis->itemHeight = 15 + 8; /* default height */
2168 /***********************************************************************
2169 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
2173 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2175 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2176 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
2177 INT nIndex = 0, nButtons, nCount;
2181 TRACE("hwnd=%p wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
2185 if (lpAddBmp->hInst == HINST_COMMCTRL)
2187 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
2189 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
2191 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
2196 TRACE ("adding %d internal bitmaps!\n", nButtons);
2198 /* Windows resize all the buttons to the size of a newly added standard image */
2199 if (lpAddBmp->nID & 1)
2202 /* FIXME: on windows the size of the images is 25x24 but the size of the bitmap
2203 * in rsrc is only 24x24. Fix the bitmap (how?) and then fix this
2205 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
2206 MAKELPARAM((WORD)24, (WORD)24));
2207 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
2208 MAKELPARAM((WORD)31, (WORD)30));
2213 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
2214 MAKELPARAM((WORD)16, (WORD)16));
2215 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
2216 MAKELPARAM((WORD)22, (WORD)22));
2219 TOOLBAR_CalcToolbar (hwnd);
2223 nButtons = (INT)wParam;
2227 TRACE ("adding %d bitmaps!\n", nButtons);
2230 if (!infoPtr->cimlDef) {
2231 /* create new default image list */
2232 TRACE ("creating default image list!\n");
2234 himlDef = ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
2235 ILC_COLOR | ILC_MASK, nButtons, 2);
2236 TOOLBAR_InsertImageList(&infoPtr->himlDef, &infoPtr->cimlDef, himlDef, 0);
2237 infoPtr->himlInt = himlDef;
2240 himlDef = GETDEFIMAGELIST(infoPtr, 0);
2244 WARN("No default image list available\n");
2248 nCount = ImageList_GetImageCount(himlDef);
2250 /* Add bitmaps to the default image list */
2251 if (lpAddBmp->hInst == NULL)
2254 HBITMAP hOldBitmapBitmap, hOldBitmapLoad;
2255 HDC hdcImage, hdcBitmap;
2257 /* copy the bitmap before adding it so that the user's bitmap
2258 * doesn't get modified.
2260 GetObjectA ((HBITMAP)lpAddBmp->nID, sizeof(BITMAP), (LPVOID)&bmp);
2262 hdcImage = CreateCompatibleDC(0);
2263 hdcBitmap = CreateCompatibleDC(0);
2265 /* create new bitmap */
2266 hbmLoad = CreateBitmap (bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
2267 hOldBitmapBitmap = SelectObject(hdcBitmap, (HBITMAP)lpAddBmp->nID);
2268 hOldBitmapLoad = SelectObject(hdcImage, hbmLoad);
2270 /* Copy the user's image */
2271 BitBlt (hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight,
2272 hdcBitmap, 0, 0, SRCCOPY);
2274 SelectObject (hdcImage, hOldBitmapLoad);
2275 SelectObject (hdcBitmap, hOldBitmapBitmap);
2276 DeleteDC (hdcImage);
2277 DeleteDC (hdcBitmap);
2279 nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
2280 DeleteObject (hbmLoad);
2282 else if (lpAddBmp->hInst == HINST_COMMCTRL)
2284 /* Add system bitmaps */
2285 switch (lpAddBmp->nID)
2287 case IDB_STD_SMALL_COLOR:
2288 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2289 MAKEINTRESOURCEA(IDB_STD_SMALL));
2290 nIndex = ImageList_AddMasked (himlDef,
2291 hbmLoad, CLR_DEFAULT);
2292 DeleteObject (hbmLoad);
2295 case IDB_STD_LARGE_COLOR:
2296 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2297 MAKEINTRESOURCEA(IDB_STD_LARGE));
2298 nIndex = ImageList_AddMasked (himlDef,
2299 hbmLoad, CLR_DEFAULT);
2300 DeleteObject (hbmLoad);
2303 case IDB_VIEW_SMALL_COLOR:
2304 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2305 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
2306 nIndex = ImageList_AddMasked (himlDef,
2307 hbmLoad, CLR_DEFAULT);
2308 DeleteObject (hbmLoad);
2311 case IDB_VIEW_LARGE_COLOR:
2312 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2313 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
2314 nIndex = ImageList_AddMasked (himlDef,
2315 hbmLoad, CLR_DEFAULT);
2316 DeleteObject (hbmLoad);
2319 case IDB_HIST_SMALL_COLOR:
2320 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2321 MAKEINTRESOURCEA(IDB_HIST_SMALL));
2322 nIndex = ImageList_AddMasked (himlDef,
2323 hbmLoad, CLR_DEFAULT);
2324 DeleteObject (hbmLoad);
2327 case IDB_HIST_LARGE_COLOR:
2328 hbmLoad = LoadBitmapA (COMCTL32_hModule,
2329 MAKEINTRESOURCEA(IDB_HIST_LARGE));
2330 nIndex = ImageList_AddMasked (himlDef,
2331 hbmLoad, CLR_DEFAULT);
2332 DeleteObject (hbmLoad);
2336 nIndex = ImageList_GetImageCount (himlDef);
2337 ERR ("invalid imagelist!\n");
2343 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
2344 nIndex = ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
2345 DeleteObject (hbmLoad);
2348 TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos);
2350 if (infoPtr->nNumBitmapInfos == 0)
2352 infoPtr->bitmaps = Alloc(sizeof(TBITMAP_INFO));
2356 TBITMAP_INFO *oldBitmaps = infoPtr->bitmaps;
2357 infoPtr->bitmaps = Alloc((infoPtr->nNumBitmapInfos + 1) * sizeof(TBITMAP_INFO));
2358 memcpy(&infoPtr->bitmaps[0], &oldBitmaps[0], infoPtr->nNumBitmapInfos);
2361 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nButtons = nButtons;
2362 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].hInst = lpAddBmp->hInst;
2363 infoPtr->bitmaps[infoPtr->nNumBitmapInfos].nID = lpAddBmp->nID;
2365 infoPtr->nNumBitmapInfos++;
2366 TRACE("Number of bitmap infos: %d\n", infoPtr->nNumBitmapInfos);
2370 INT imagecount = ImageList_GetImageCount(himlDef);
2372 if (infoPtr->nNumBitmaps + nButtons != imagecount)
2374 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",
2375 infoPtr->nNumBitmaps, nCount, imagecount - nCount,
2376 infoPtr->nNumBitmaps+nButtons,imagecount);
2378 infoPtr->nNumBitmaps = imagecount;
2381 infoPtr->nNumBitmaps += nButtons;
2384 InvalidateRect(hwnd, NULL, FALSE);
2391 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2393 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2394 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2395 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2397 TRACE("adding %d buttons!\n", wParam);
2399 nAddButtons = (UINT)wParam;
2400 nOldButtons = infoPtr->nNumButtons;
2401 nNewButtons = nOldButtons + nAddButtons;
2403 if (infoPtr->nNumButtons == 0) {
2405 Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2408 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2410 Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2411 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2412 nOldButtons * sizeof(TBUTTON_INFO));
2416 infoPtr->nNumButtons = nNewButtons;
2418 /* insert new button data */
2419 for (nCount = 0; nCount < nAddButtons; nCount++) {
2420 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2421 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2422 btnPtr->idCommand = lpTbb[nCount].idCommand;
2423 btnPtr->fsState = lpTbb[nCount].fsState;
2424 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2425 btnPtr->dwData = lpTbb[nCount].dwData;
2426 btnPtr->iString = lpTbb[nCount].iString;
2427 btnPtr->bHot = FALSE;
2429 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2432 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2433 ti.cbSize = sizeof (TTTOOLINFOA);
2435 ti.uId = btnPtr->idCommand;
2437 ti.lpszText = LPSTR_TEXTCALLBACKA;
2439 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2444 TOOLBAR_CalcToolbar (hwnd);
2446 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2448 InvalidateRect(hwnd, NULL, FALSE);
2455 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2457 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2458 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2459 INT nOldButtons, nNewButtons, nAddButtons, nCount;
2461 TRACE("adding %d buttons!\n", wParam);
2463 nAddButtons = (UINT)wParam;
2464 nOldButtons = infoPtr->nNumButtons;
2465 nNewButtons = nOldButtons + nAddButtons;
2467 if (infoPtr->nNumButtons == 0) {
2469 Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2472 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2474 Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
2475 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2476 nOldButtons * sizeof(TBUTTON_INFO));
2480 infoPtr->nNumButtons = nNewButtons;
2482 /* insert new button data */
2483 for (nCount = 0; nCount < nAddButtons; nCount++) {
2484 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
2485 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
2486 btnPtr->idCommand = lpTbb[nCount].idCommand;
2487 btnPtr->fsState = lpTbb[nCount].fsState;
2488 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
2489 btnPtr->dwData = lpTbb[nCount].dwData;
2490 btnPtr->iString = lpTbb[nCount].iString;
2491 btnPtr->bHot = FALSE;
2493 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
2496 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2497 ti.cbSize = sizeof (TTTOOLINFOW);
2499 ti.uId = btnPtr->idCommand;
2501 ti.lpszText = LPSTR_TEXTCALLBACKW;
2504 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2509 TOOLBAR_CalcToolbar (hwnd);
2511 TOOLBAR_DumpToolbar (infoPtr, __LINE__);
2513 InvalidateRect(hwnd, NULL, FALSE);
2520 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2522 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2525 if ((wParam) && (HIWORD(lParam) == 0)) {
2528 TRACE("adding string from resource!\n");
2530 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
2533 TRACE("len=%d \"%s\"\n", len, szString);
2534 nIndex = infoPtr->nNumStrings;
2535 if (infoPtr->nNumStrings == 0) {
2537 Alloc (sizeof(LPWSTR));
2540 LPWSTR *oldStrings = infoPtr->strings;
2542 Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2543 memcpy (&infoPtr->strings[0], &oldStrings[0],
2544 sizeof(LPWSTR) * infoPtr->nNumStrings);
2548 /*Alloc zeros out the allocated memory*/
2549 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], szString );
2550 infoPtr->nNumStrings++;
2553 LPSTR p = (LPSTR)lParam;
2558 TRACE("adding string(s) from array!\n");
2560 nIndex = infoPtr->nNumStrings;
2563 TRACE("len=%d \"%s\"\n", len, p);
2565 if (infoPtr->nNumStrings == 0) {
2567 Alloc (sizeof(LPWSTR));
2570 LPWSTR *oldStrings = infoPtr->strings;
2572 Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2573 memcpy (&infoPtr->strings[0], &oldStrings[0],
2574 sizeof(LPWSTR) * infoPtr->nNumStrings);
2578 Str_SetPtrAtoW (&infoPtr->strings[infoPtr->nNumStrings], p );
2579 infoPtr->nNumStrings++;
2590 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2592 #define MAX_RESOURCE_STRING_LENGTH 512
2593 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2596 if ((wParam) && (HIWORD(lParam) == 0)) {
2597 WCHAR szString[MAX_RESOURCE_STRING_LENGTH];
2599 TRACE("adding string from resource!\n");
2601 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
2602 szString, MAX_RESOURCE_STRING_LENGTH);
2604 TRACE("len=%d %s\n", len, debugstr_w(szString));
2605 TRACE("First char: 0x%x\n", *szString);
2606 if (szString[0] == L'|')
2608 PWSTR p = szString + 1;
2610 nIndex = infoPtr->nNumStrings;
2611 while (*p != L'|' && *p != L'\0') {
2614 if (infoPtr->nNumStrings == 0) {
2615 infoPtr->strings = Alloc (sizeof(LPWSTR));
2619 LPWSTR *oldStrings = infoPtr->strings;
2620 infoPtr->strings = Alloc(sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2621 memcpy(&infoPtr->strings[0], &oldStrings[0],
2622 sizeof(LPWSTR) * infoPtr->nNumStrings);
2626 np=strchrW (p, '|');
2634 TRACE("len=%d %s\n", len, debugstr_w(p));
2635 infoPtr->strings[infoPtr->nNumStrings] =
2636 Alloc (sizeof(WCHAR)*(len+1));
2637 lstrcpynW (infoPtr->strings[infoPtr->nNumStrings], p, len+1);
2638 infoPtr->nNumStrings++;
2645 nIndex = infoPtr->nNumStrings;
2646 if (infoPtr->nNumStrings == 0) {
2648 Alloc (sizeof(LPWSTR));
2651 LPWSTR *oldStrings = infoPtr->strings;
2653 Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2654 memcpy (&infoPtr->strings[0], &oldStrings[0],
2655 sizeof(LPWSTR) * infoPtr->nNumStrings);
2659 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], szString);
2660 infoPtr->nNumStrings++;
2664 LPWSTR p = (LPWSTR)lParam;
2669 TRACE("adding string(s) from array!\n");
2670 nIndex = infoPtr->nNumStrings;
2674 TRACE("len=%d %s\n", len, debugstr_w(p));
2675 if (infoPtr->nNumStrings == 0) {
2677 Alloc (sizeof(LPWSTR));
2680 LPWSTR *oldStrings = infoPtr->strings;
2682 Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
2683 memcpy (&infoPtr->strings[0], &oldStrings[0],
2684 sizeof(LPWSTR) * infoPtr->nNumStrings);
2688 Str_SetPtrW (&infoPtr->strings[infoPtr->nNumStrings], p);
2689 infoPtr->nNumStrings++;
2700 TOOLBAR_AutoSize (HWND hwnd)
2702 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2703 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2709 UINT uPosFlags = SWP_NOZORDER;
2711 TRACE("resize forced, style=%lx!\n", dwStyle);
2713 parent = GetParent (hwnd);
2714 GetClientRect(parent, &parent_rect);
2716 x = parent_rect.left;
2717 y = parent_rect.top;
2719 /* FIXME: we should be able to early out if nothing */
2720 /* has changed with nWidth != parent_rect width */
2722 if (dwStyle & CCS_NORESIZE) {
2723 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2726 TOOLBAR_CalcToolbar (hwnd);
2729 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2730 TOOLBAR_CalcToolbar (hwnd);
2731 InvalidateRect( hwnd, NULL, TRUE );
2732 cy = infoPtr->nHeight;
2733 cx = infoPtr->nWidth;
2735 if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) {
2736 GetWindowRect(hwnd, &window_rect);
2737 ScreenToClient(parent, (LPPOINT)&window_rect.left);
2738 y = window_rect.top;
2740 if ((dwStyle & CCS_BOTTOM) == CCS_BOTTOM) {
2741 GetWindowRect(hwnd, &window_rect);
2742 y = parent_rect.bottom - ( window_rect.bottom - window_rect.top);
2746 if (dwStyle & CCS_NOPARENTALIGN)
2747 uPosFlags |= SWP_NOMOVE;
2749 if (!(dwStyle & CCS_NODIVIDER))
2750 cy += GetSystemMetrics(SM_CYEDGE);
2752 if (dwStyle & WS_BORDER)
2755 cy += GetSystemMetrics(SM_CYEDGE);
2756 cx += GetSystemMetrics(SM_CYEDGE);
2759 infoPtr->bAutoSize = TRUE;
2760 SetWindowPos (hwnd, HWND_TOP, x, y, cx, cy, uPosFlags);
2761 /* The following line makes sure that the infoPtr->bAutoSize is turned off
2762 * after the setwindowpos calls */
2763 infoPtr->bAutoSize = FALSE;
2770 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
2772 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2774 return infoPtr->nNumButtons;
2779 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2781 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2783 if (infoPtr == NULL) {
2784 ERR("(%p, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
2785 ERR("infoPtr == NULL!\n");
2789 infoPtr->dwStructSize = (DWORD)wParam;
2796 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
2798 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2799 TBUTTON_INFO *btnPtr;
2802 TRACE("button %d, iBitmap now %d\n", wParam, LOWORD(lParam));
2804 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2808 btnPtr = &infoPtr->buttons[nIndex];
2809 btnPtr->iBitmap = LOWORD(lParam);
2811 /* we HAVE to erase the background, the new bitmap could be */
2813 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2820 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2822 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2823 TBUTTON_INFO *btnPtr;
2826 BOOL bChecked = FALSE;
2828 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2832 btnPtr = &infoPtr->buttons[nIndex];
2834 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
2837 bChecked = (btnPtr->fsState & TBSTATE_CHECKED) ? TRUE : FALSE;
2839 if (LOWORD(lParam) == FALSE)
2840 btnPtr->fsState &= ~TBSTATE_CHECKED;
2842 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2844 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
2845 if (nOldIndex == nIndex)
2847 if (nOldIndex != -1)
2848 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2850 btnPtr->fsState |= TBSTATE_CHECKED;
2853 if( bChecked != LOWORD(lParam) )
2855 if (nOldIndex != -1)
2857 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
2858 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
2860 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
2863 /* FIXME: Send a WM_NOTIFY?? */
2870 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
2872 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2874 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2879 TOOLBAR_Customize (HWND hwnd)
2881 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2882 CUSTDLG_INFO custInfo;
2888 custInfo.tbInfo = infoPtr;
2889 custInfo.tbHwnd = hwnd;
2891 /* send TBN_BEGINADJUST notification */
2892 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2895 if (!(hRes = FindResourceA (COMCTL32_hModule,
2896 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
2900 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
2903 ret = DialogBoxIndirectParamA ((HINSTANCE)GetWindowLongA(hwnd, GWL_HINSTANCE),
2904 (LPDLGTEMPLATEA)template,
2906 TOOLBAR_CustomizeDialogProc,
2909 /* send TBN_ENDADJUST notification */
2910 TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr,
2918 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2920 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2921 INT nIndex = (INT)wParam;
2923 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2926 if ((infoPtr->hwndToolTip) &&
2927 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
2930 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2931 ti.cbSize = sizeof (TTTOOLINFOA);
2933 ti.uId = infoPtr->buttons[nIndex].idCommand;
2935 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
2938 if (infoPtr->nNumButtons == 1) {
2939 TRACE(" simple delete!\n");
2940 Free (infoPtr->buttons);
2941 infoPtr->buttons = NULL;
2942 infoPtr->nNumButtons = 0;
2945 TBUTTON_INFO *oldButtons = infoPtr->buttons;
2946 TRACE("complex delete! [nIndex=%d]\n", nIndex);
2948 infoPtr->nNumButtons--;
2949 infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2951 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2952 nIndex * sizeof(TBUTTON_INFO));
2955 if (nIndex < infoPtr->nNumButtons) {
2956 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
2957 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
2963 TOOLBAR_CalcToolbar (hwnd);
2965 InvalidateRect (hwnd, NULL, TRUE);
2972 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2974 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2975 TBUTTON_INFO *btnPtr;
2979 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
2983 btnPtr = &infoPtr->buttons[nIndex];
2985 bState = btnPtr->fsState & TBSTATE_ENABLED;
2987 /* update the toolbar button state */
2988 if(LOWORD(lParam) == FALSE) {
2989 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
2991 btnPtr->fsState |= TBSTATE_ENABLED;
2994 /* redraw the button only if the state of the button changed */
2995 if(bState != (btnPtr->fsState & TBSTATE_ENABLED))
2997 InvalidateRect(hwnd, &btnPtr->rect,
2998 TOOLBAR_HasText(infoPtr, btnPtr));
3005 static inline LRESULT
3006 TOOLBAR_GetAnchorHighlight (HWND hwnd)
3008 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3010 return infoPtr->bAnchor;
3015 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
3017 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3020 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3024 return infoPtr->buttons[nIndex].iBitmap;
3028 static inline LRESULT
3029 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
3031 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
3036 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3038 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3039 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3040 INT nIndex = (INT)wParam;
3041 TBUTTON_INFO *btnPtr;
3043 if (infoPtr == NULL)
3049 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3052 btnPtr = &infoPtr->buttons[nIndex];
3053 lpTbb->iBitmap = btnPtr->iBitmap;
3054 lpTbb->idCommand = btnPtr->idCommand;
3055 lpTbb->fsState = btnPtr->fsState;
3056 lpTbb->fsStyle = btnPtr->fsStyle;
3057 lpTbb->bReserved[0] = 0;
3058 lpTbb->bReserved[1] = 0;
3059 lpTbb->dwData = btnPtr->dwData;
3060 lpTbb->iString = btnPtr->iString;
3067 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3069 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3070 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
3071 TBUTTON_INFO *btnPtr;
3074 if (infoPtr == NULL)
3076 if (lpTbInfo == NULL)
3078 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
3081 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3082 lpTbInfo->dwMask & 0x80000000);
3086 if (!(btnPtr = &infoPtr->buttons[nIndex])) return -1;
3088 if (lpTbInfo->dwMask & TBIF_COMMAND)
3089 lpTbInfo->idCommand = btnPtr->idCommand;
3090 if (lpTbInfo->dwMask & TBIF_IMAGE)
3091 lpTbInfo->iImage = btnPtr->iBitmap;
3092 if (lpTbInfo->dwMask & TBIF_LPARAM)
3093 lpTbInfo->lParam = btnPtr->dwData;
3094 if (lpTbInfo->dwMask & TBIF_SIZE)
3095 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
3096 if (lpTbInfo->dwMask & TBIF_STATE)
3097 lpTbInfo->fsState = btnPtr->fsState;
3098 if (lpTbInfo->dwMask & TBIF_STYLE)
3099 lpTbInfo->fsStyle = btnPtr->fsStyle;
3100 if (lpTbInfo->dwMask & TBIF_TEXT) {
3101 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
3102 Str_GetPtrWtoA (lpText, lpTbInfo->pszText,lpTbInfo->cchText);
3109 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3111 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3112 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
3113 TBUTTON_INFO *btnPtr;
3116 if (infoPtr == NULL)
3118 if (lpTbInfo == NULL)
3120 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
3123 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
3124 lpTbInfo->dwMask & 0x80000000);
3128 btnPtr = &infoPtr->buttons[nIndex];
3133 if (lpTbInfo->dwMask & TBIF_COMMAND)
3134 lpTbInfo->idCommand = btnPtr->idCommand;
3135 if (lpTbInfo->dwMask & TBIF_IMAGE)
3136 lpTbInfo->iImage = btnPtr->iBitmap;
3137 if (lpTbInfo->dwMask & TBIF_LPARAM)
3138 lpTbInfo->lParam = btnPtr->dwData;
3139 if (lpTbInfo->dwMask & TBIF_SIZE)
3140 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
3141 if (lpTbInfo->dwMask & TBIF_STATE)
3142 lpTbInfo->fsState = btnPtr->fsState;
3143 if (lpTbInfo->dwMask & TBIF_STYLE)
3144 lpTbInfo->fsStyle = btnPtr->fsStyle;
3145 if (lpTbInfo->dwMask & TBIF_TEXT) {
3146 LPWSTR lpText = TOOLBAR_GetText(infoPtr,btnPtr);
3147 Str_GetPtrW (lpText,lpTbInfo->pszText,lpTbInfo->cchText);
3155 TOOLBAR_GetButtonSize (HWND hwnd)
3157 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3159 if (infoPtr->nNumButtons > 0)
3160 return MAKELONG((WORD)infoPtr->nButtonWidth,
3161 (WORD)infoPtr->nButtonHeight);
3163 return MAKELONG(8,7);
3168 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3170 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3177 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3181 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
3183 return WideCharToMultiByte( CP_ACP, 0, lpText, -1,
3184 (LPSTR)lParam, 0x7fffffff, NULL, NULL ) - 1;
3189 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3191 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3198 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3202 lpText = TOOLBAR_GetText(infoPtr,&infoPtr->buttons[nIndex]);
3204 strcpyW ((LPWSTR)lParam, lpText);
3206 return strlenW (lpText);
3211 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3213 return (LRESULT)GETDISIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
3217 inline static LRESULT
3218 TOOLBAR_GetExtendedStyle (HWND hwnd)
3220 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3222 return infoPtr->dwExStyle;
3227 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3229 return (LRESULT)GETHOTIMAGELIST(TOOLBAR_GetInfoPtr (hwnd), 0);
3234 TOOLBAR_GetHotItem (HWND hwnd)
3236 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3238 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
3241 if (infoPtr->nHotItem < 0)
3244 return (LRESULT)infoPtr->nHotItem;
3249 TOOLBAR_GetDefImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
3251 return (LRESULT) GETDEFIMAGELIST(TOOLBAR_GetInfoPtr(hwnd), 0);
3255 /* << TOOLBAR_GetInsertMark >> */
3256 /* << TOOLBAR_GetInsertMarkColor >> */
3260 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3262 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3263 TBUTTON_INFO *btnPtr;
3267 if (infoPtr == NULL)
3269 nIndex = (INT)wParam;
3270 btnPtr = &infoPtr->buttons[nIndex];
3271 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3273 lpRect = (LPRECT)lParam;
3276 if (btnPtr->fsState & TBSTATE_HIDDEN)
3279 lpRect->left = btnPtr->rect.left;
3280 lpRect->right = btnPtr->rect.right;
3281 lpRect->bottom = btnPtr->rect.bottom;
3282 lpRect->top = btnPtr->rect.top;
3289 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3291 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3292 LPSIZE lpSize = (LPSIZE)lParam;
3297 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
3298 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
3300 TRACE("maximum size %ld x %ld\n",
3301 infoPtr->rcBound.right - infoPtr->rcBound.left,
3302 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
3308 /* << TOOLBAR_GetObject >> */
3312 TOOLBAR_GetPadding (HWND hwnd)
3314 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3317 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
3318 return (LRESULT) oldPad;
3323 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
3325 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3326 TBUTTON_INFO *btnPtr;
3330 if (infoPtr == NULL)
3332 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3333 btnPtr = &infoPtr->buttons[nIndex];
3334 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
3336 lpRect = (LPRECT)lParam;
3340 lpRect->left = btnPtr->rect.left;
3341 lpRect->right = btnPtr->rect.right;
3342 lpRect->bottom = btnPtr->rect.bottom;
3343 lpRect->top = btnPtr->rect.top;
3350 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3352 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3354 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
3355 return infoPtr->nRows;
3362 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
3364 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3367 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3371 return infoPtr->buttons[nIndex].fsState;
3376 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
3378 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3381 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3385 return infoPtr->buttons[nIndex].fsStyle;
3390 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
3392 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3394 if (infoPtr == NULL)
3397 return infoPtr->nMaxTextRows;
3402 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
3404 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3406 if (infoPtr == NULL)
3408 return (LRESULT)infoPtr->hwndToolTip;
3413 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
3415 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3417 TRACE("%s hwnd=%p stub!\n",
3418 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
3420 return infoPtr->bUnicode;
3424 inline static LRESULT
3425 TOOLBAR_GetVersion (HWND hwnd)
3427 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3428 return infoPtr->iVersion;
3433 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3435 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3436 TBUTTON_INFO *btnPtr;
3441 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3445 btnPtr = &infoPtr->buttons[nIndex];
3446 if (LOWORD(lParam) == FALSE)
3447 btnPtr->fsState &= ~TBSTATE_HIDDEN;
3449 btnPtr->fsState |= TBSTATE_HIDDEN;
3451 TOOLBAR_CalcToolbar (hwnd);
3453 InvalidateRect (hwnd, NULL, TRUE);
3459 inline static LRESULT
3460 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
3462 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
3467 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3469 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3470 TBUTTON_INFO *btnPtr;
3473 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3477 btnPtr = &infoPtr->buttons[nIndex];
3478 if (LOWORD(lParam) == FALSE)
3479 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
3481 btnPtr->fsState |= TBSTATE_INDETERMINATE;
3483 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3490 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3492 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3493 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3494 INT nIndex = (INT)wParam;
3495 TBUTTON_INFO *oldButtons;
3500 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3503 /* EPP: this seems to be an undocumented call (from my IE4)
3504 * I assume in that case that:
3505 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3506 * - index of insertion is at the end of existing buttons
3507 * I only see this happen with nIndex == -1, but it could have a special
3508 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3510 nIndex = infoPtr->nNumButtons;
3512 } else if (nIndex < 0)
3515 /* If the string passed is not an index, assume address of string
3516 and do our own AddString */
3517 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3521 TRACE("string %s passed instead of index, adding string\n",
3522 debugstr_a((LPSTR)lpTbb->iString));
3523 len = strlen((LPSTR)lpTbb->iString) + 2;
3525 strcpy(ptr, (LPSTR)lpTbb->iString);
3526 ptr[len - 1] = 0; /* ended by two '\0' */
3527 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
3531 TRACE("inserting button index=%d\n", nIndex);
3532 if (nIndex > infoPtr->nNumButtons) {
3533 nIndex = infoPtr->nNumButtons;
3534 TRACE("adjust index=%d\n", nIndex);
3537 oldButtons = infoPtr->buttons;
3538 infoPtr->nNumButtons++;
3539 infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3540 /* pre insert copy */
3542 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3543 nIndex * sizeof(TBUTTON_INFO));
3546 /* insert new button */
3547 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3548 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3549 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3550 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3551 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3552 /* if passed string and not index, then add string */
3553 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3554 Str_SetPtrAtoW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPCSTR )lpTbb->iString);
3557 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3559 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3562 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
3563 ti.cbSize = sizeof (TTTOOLINFOA);
3565 ti.uId = lpTbb->idCommand;
3567 ti.lpszText = LPSTR_TEXTCALLBACKA;
3569 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
3573 /* post insert copy */
3574 if (nIndex < infoPtr->nNumButtons - 1) {
3575 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3576 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3581 TOOLBAR_CalcToolbar (hwnd);
3583 InvalidateRect (hwnd, NULL, TRUE);
3590 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3592 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3593 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
3594 INT nIndex = (INT)wParam;
3595 TBUTTON_INFO *oldButtons;
3600 TOOLBAR_DumpButton(infoPtr, (TBUTTON_INFO *)lpTbb, nIndex, FALSE);
3603 /* EPP: this seems to be an undocumented call (from my IE4)
3604 * I assume in that case that:
3605 * - lpTbb->iString is a string pointer (not a string index in strings[] table
3606 * - index of insertion is at the end of existing buttons
3607 * I only see this happen with nIndex == -1, but it could have a special
3608 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
3610 nIndex = infoPtr->nNumButtons;
3612 } else if (nIndex < 0)
3615 /* If the string passed is not an index, assume address of string
3616 and do our own AddString */
3617 if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) {
3621 TRACE("string %s passed instead of index, adding string\n",
3622 debugstr_w((LPWSTR)lpTbb->iString));
3623 len = strlenW((LPWSTR)lpTbb->iString) + 2;
3624 ptr = Alloc(len*sizeof(WCHAR));
3625 strcpyW(ptr, (LPWSTR)lpTbb->iString);
3626 ptr[len - 1] = 0; /* ended by two '\0' */
3627 lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr);
3631 TRACE("inserting button index=%d\n", nIndex);
3632 if (nIndex > infoPtr->nNumButtons) {
3633 nIndex = infoPtr->nNumButtons;
3634 TRACE("adjust index=%d\n", nIndex);
3637 oldButtons = infoPtr->buttons;
3638 infoPtr->nNumButtons++;
3639 infoPtr->buttons = Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
3640 /* pre insert copy */
3642 memcpy (&infoPtr->buttons[0], &oldButtons[0],
3643 nIndex * sizeof(TBUTTON_INFO));
3646 /* insert new button */
3647 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
3648 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
3649 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
3650 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
3651 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
3652 /* if passed string and not index, then add string */
3653 if(HIWORD(lpTbb->iString) && lpTbb->iString!=-1) {
3654 Str_SetPtrW ((LPWSTR *)&infoPtr->buttons[nIndex].iString, (LPWSTR)lpTbb->iString);
3657 infoPtr->buttons[nIndex].iString = lpTbb->iString;
3659 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
3662 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
3663 ti.cbSize = sizeof (TTTOOLINFOW);
3665 ti.uId = lpTbb->idCommand;
3667 ti.lpszText = LPSTR_TEXTCALLBACKW;
3669 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
3673 /* post insert copy */
3674 if (nIndex < infoPtr->nNumButtons - 1) {
3675 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
3676 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
3681 TOOLBAR_CalcToolbar (hwnd);
3683 InvalidateRect (hwnd, NULL, TRUE);
3689 /* << TOOLBAR_InsertMarkHitTest >> */
3693 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
3695 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3698 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3702 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
3707 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
3709 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3712 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3716 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
3721 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
3723 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3726 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3730 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
3735 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
3737 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3740 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3744 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
3749 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3751 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3754 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3758 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
3763 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
3765 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3768 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3772 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
3776 /* << TOOLBAR_LoadImages >> */
3777 /* << TOOLBAR_MapAccelerator >> */
3778 /* << TOOLBAR_MarkButton >> */
3779 /* << TOOLBAR_MoveButton >> */
3783 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
3785 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3786 TBUTTON_INFO *btnPtr;
3789 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
3793 btnPtr = &infoPtr->buttons[nIndex];
3794 if (LOWORD(lParam) == FALSE)
3795 btnPtr->fsState &= ~TBSTATE_PRESSED;
3797 btnPtr->fsState |= TBSTATE_PRESSED;
3799 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
3806 TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
3808 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3809 LPTBREPLACEBITMAP lpReplace = (LPTBREPLACEBITMAP) lParam;
3811 int i = 0, nOldButtons = 0, pos = 0;
3812 HIMAGELIST himlDef = 0;
3814 TRACE("hInstOld %p nIDOld %x hInstNew %p nIDNew %x nButtons %x\n",
3815 lpReplace->hInstOld, lpReplace->nIDOld, lpReplace->hInstNew, lpReplace->nIDNew,
3816 lpReplace->nButtons);
3818 if (lpReplace->hInstOld == HINST_COMMCTRL)
3820 FIXME("changing standard bitmaps not implemented\n");
3823 else if (lpReplace->hInstOld != 0)
3825 FIXME("resources not in the current module not implemented\n");
3830 hBitmap = (HBITMAP) lpReplace->nIDNew;
3833 TRACE("To be replaced hInstOld %p nIDOld %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
3834 for (i = 0; i < infoPtr->nNumBitmapInfos; i++) {
3835 TBITMAP_INFO *tbi = &infoPtr->bitmaps[i];
3836 TRACE("tbimapinfo %d hInstOld %p nIDOld %x\n", i, tbi->hInst, tbi->nID);
3837 if (tbi->hInst == lpReplace->hInstOld && tbi->nID == lpReplace->nIDOld)
3839 TRACE("Found: nButtons %d hInst %p nID %x\n", tbi->nButtons, tbi->hInst, tbi->nID);
3840 nOldButtons = tbi->nButtons;
3841 tbi->nButtons = lpReplace->nButtons;
3842 tbi->hInst = lpReplace->hInstNew;
3843 tbi->nID = lpReplace->nIDNew;
3844 TRACE("tbimapinfo changed %d hInstOld %p nIDOld %x\n", i, tbi->hInst, tbi->nID);
3847 pos += tbi->nButtons;
3850 if (nOldButtons == 0)
3852 WARN("No hinst/bitmap found! hInst %p nID %x\n", lpReplace->hInstOld, lpReplace->nIDOld);
3856 infoPtr->nNumBitmaps = infoPtr->nNumBitmaps - nOldButtons + lpReplace->nButtons;
3858 /* ImageList_Replace(GETDEFIMAGELIST(), pos, hBitmap, NULL); */
3861 himlDef = GETDEFIMAGELIST(infoPtr, 0);
3862 for (i = pos + nOldButtons - 1; i >= pos; i--) {
3863 ImageList_Remove(himlDef, i);
3868 HBITMAP hOldBitmapBitmap, hOldBitmapLoad, hbmLoad;
3869 HDC hdcImage, hdcBitmap;
3871 /* copy the bitmap before adding it so that the user's bitmap
3872 * doesn't get modified.
3874 GetObjectA (hBitmap, sizeof(BITMAP), (LPVOID)&bmp);
3876 hdcImage = CreateCompatibleDC(0);
3877 hdcBitmap = CreateCompatibleDC(0);
3879 /* create new bitmap */
3880 hbmLoad = CreateBitmap (bmp.bmWidth, bmp.bmHeight, bmp.bmPlanes, bmp.bmBitsPixel, NULL);
3881 hOldBitmapBitmap = SelectObject(hdcBitmap, hBitmap);
3882 hOldBitmapLoad = SelectObject(hdcImage, hbmLoad);
3884 /* Copy the user's image */
3885 BitBlt (hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight,
3886 hdcBitmap, 0, 0, SRCCOPY);
3888 SelectObject (hdcImage, hOldBitmapLoad);
3889 SelectObject (hdcBitmap, hOldBitmapBitmap);
3890 DeleteDC (hdcImage);
3891 DeleteDC (hdcBitmap);
3893 ImageList_AddMasked (himlDef, hbmLoad, CLR_DEFAULT);
3894 DeleteObject (hbmLoad);
3897 InvalidateRect(hwnd, NULL, FALSE);
3903 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
3906 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3907 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
3909 if (lpSave == NULL) return 0;
3912 /* save toolbar information */
3913 FIXME("save to \"%s\" \"%s\"\n",
3914 lpSave->pszSubKey, lpSave->pszValueName);
3919 /* restore toolbar information */
3921 FIXME("restore from \"%s\" \"%s\"\n",
3922 lpSave->pszSubKey, lpSave->pszValueName);
3933 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
3936 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3937 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
3943 /* save toolbar information */
3944 FIXME("save to \"%s\" \"%s\"\n",
3945 lpSave->pszSubKey, lpSave->pszValueName);
3950 /* restore toolbar information */
3952 FIXME("restore from \"%s\" \"%s\"\n",
3953 lpSave->pszSubKey, lpSave->pszValueName);
3964 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
3966 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3967 BOOL bOldAnchor = infoPtr->bAnchor;
3969 infoPtr->bAnchor = (BOOL)wParam;
3971 return (LRESULT)bOldAnchor;
3976 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3978 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3979 HIMAGELIST himlDef = GETDEFIMAGELIST(infoPtr, 0);
3981 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
3984 if (infoPtr->nNumButtons > 0)
3985 WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
3986 infoPtr->nNumButtons,
3987 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
3988 LOWORD(lParam), HIWORD(lParam));
3990 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
3991 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
3994 /* uses image list internals directly */
3996 himlDef->cx = infoPtr->nBitmapWidth;
3997 himlDef->cy = infoPtr->nBitmapHeight;
4005 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
4007 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4008 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
4009 TBUTTON_INFO *btnPtr;
4014 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
4017 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
4018 lptbbi->dwMask & 0x80000000);
4022 btnPtr = &infoPtr->buttons[nIndex];
4023 if (lptbbi->dwMask & TBIF_COMMAND)
4024 btnPtr->idCommand = lptbbi->idCommand;
4025 if (lptbbi->dwMask & TBIF_IMAGE)
4026 btnPtr->iBitmap = lptbbi->iImage;
4027 if (lptbbi->dwMask & TBIF_LPARAM)
4028 btnPtr->dwData = lptbbi->lParam;
4029 /* if (lptbbi->dwMask & TBIF_SIZE) */
4030 /* btnPtr->cx = lptbbi->cx; */
4031 if (lptbbi->dwMask & TBIF_STATE)
4032 btnPtr->fsState = lptbbi->fsState;
4033 if (lptbbi->dwMask & TBIF_STYLE)
4034 btnPtr->fsStyle = lptbbi->fsStyle;
4036 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
4037 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
4038 /* iString is index, zero it to make Str_SetPtr succeed */
4041 Str_SetPtrAtoW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
4048 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
4050 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4051 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
4052 TBUTTON_INFO *btnPtr;
4057 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
4060 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam,
4061 lptbbi->dwMask & 0x80000000);
4065 btnPtr = &infoPtr->buttons[nIndex];
4066 if (lptbbi->dwMask & TBIF_COMMAND)
4067 btnPtr->idCommand = lptbbi->idCommand;
4068 if (lptbbi->dwMask & TBIF_IMAGE)
4069 btnPtr->iBitmap = lptbbi->iImage;
4070 if (lptbbi->dwMask & TBIF_LPARAM)
4071 btnPtr->dwData = lptbbi->lParam;
4072 /* if (lptbbi->dwMask & TBIF_SIZE) */
4073 /* btnPtr->cx = lptbbi->cx; */
4074 if (lptbbi->dwMask & TBIF_STATE)
4075 btnPtr->fsState = lptbbi->fsState;
4076 if (lptbbi->dwMask & TBIF_STYLE)
4077 btnPtr->fsStyle = lptbbi->fsStyle;
4079 if ((lptbbi->dwMask & TBIF_TEXT) && ((INT)lptbbi->pszText != -1)) {
4080 if ((HIWORD(btnPtr->iString) == 0) || (btnPtr->iString == -1))
4081 /* iString is index, zero it to make Str_SetPtr succeed */
4083 Str_SetPtrW ((LPWSTR *)&btnPtr->iString, lptbbi->pszText);
4090 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
4092 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4093 INT cx = LOWORD(lParam), cy = HIWORD(lParam);
4095 if ((cx < 0) || (cy < 0))
4097 ERR("invalid parameter 0x%08lx\n", (DWORD)lParam);
4101 /* The documentation claims you can only change the button size before
4102 * any button has been added. But this is wrong.
4103 * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding
4104 * it to the toolbar, and it checks that the return value is nonzero - mjm
4105 * Further testing shows that we must actually perform the change too.
4108 * The documentation also does not mention that if 0 is supplied for
4109 * either size, the system changes it to the default of 24 wide and
4110 * 22 high. Demonstarted in ControlSpy Toolbar. GLA 3/02
4112 infoPtr->nButtonWidth = (cx) ? cx : 24;
4113 infoPtr->nButtonHeight = (cy) ? cy : 22;
4119 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
4121 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4123 if (infoPtr == NULL) {
4124 TRACE("Toolbar not initialized yet?????\n");
4128 /* if setting to current values, ignore */
4129 if ((infoPtr->cxMin == (INT)LOWORD(lParam)) &&
4130 (infoPtr->cxMax == (INT)HIWORD(lParam))) {
4131 TRACE("matches current width, min=%d, max=%d, no recalc\n",
4132 infoPtr->cxMin, infoPtr->cxMax);
4136 /* save new values */
4137 infoPtr->cxMin = (INT)LOWORD(lParam);
4138 infoPtr->cxMax = (INT)HIWORD(lParam);
4140 /* if both values are 0 then we are done */
4142 TRACE("setting both min and max to 0, norecalc\n");
4146 /* otherwise we need to recalc the toolbar and in some cases
4147 recalc the bounding rectangle (does DrawText w/ DT_CALCRECT
4148 which doesn't actually draw - GA). */
4149 TRACE("number of buttons %d, cx=%d, cy=%d, recalcing\n",
4150 infoPtr->nNumButtons, infoPtr->cxMin, infoPtr->cxMax);
4152 TOOLBAR_CalcToolbar (hwnd);
4154 InvalidateRect (hwnd, NULL, TRUE);
4161 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
4163 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4164 INT nIndex = (INT)wParam;
4166 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
4169 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
4171 if (infoPtr->hwndToolTip) {
4173 FIXME("change tool tip!\n");
4182 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4184 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4185 HIMAGELIST himl = (HIMAGELIST)lParam;
4186 HIMAGELIST himlTemp;
4189 if (infoPtr->iVersion >= 5)
4192 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlDis,
4193 &infoPtr->cimlDis, himl, id);
4195 /* FIXME: redraw ? */
4197 return (LRESULT)himlTemp;
4202 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
4204 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4207 dwTemp = infoPtr->dwDTFlags;
4208 infoPtr->dwDTFlags =
4209 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
4211 return (LRESULT)dwTemp;
4215 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4217 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4220 dwTemp = infoPtr->dwExStyle;
4221 infoPtr->dwExStyle = (DWORD)lParam;
4223 if (infoPtr->dwExStyle & (TBSTYLE_EX_MIXEDBUTTONS |
4224 TBSTYLE_EX_HIDECLIPPEDBUTTONS)) {
4225 FIXME("Extended style not implemented %s %s\n",
4226 (infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ?
4227 "TBSTYLE_EX_MIXEDBUTTONS" : "",
4228 (infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) ?
4229 "TBSTYLE_EX_HIDECLIPPEDBUTTONS" : "");
4232 if (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL)
4233 FIXME("Unknown Toolbar Extended Style 0x%08lx. Please report.\n",
4234 (infoPtr->dwExStyle & ~TBSTYLE_EX_ALL));
4236 return (LRESULT)dwTemp;
4241 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4243 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4244 HIMAGELIST himlTemp;
4245 HIMAGELIST himl = (HIMAGELIST)lParam;
4248 if (infoPtr->iVersion >= 5)
4251 TRACE("hwnd = %p, himl = %p, id = %d\n", hwnd, himl, id);
4253 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlHot,
4254 &infoPtr->cimlHot, himl, id);
4256 /* FIXME: redraw ? */
4258 return (LRESULT)himlTemp;
4263 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
4265 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4266 INT nOldHotItem = infoPtr->nHotItem;
4267 TBUTTON_INFO *btnPtr;
4269 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4272 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
4275 infoPtr->nHotItem = (INT)wParam;
4276 if ((INT)wParam >=0)
4278 btnPtr = &infoPtr->buttons[(INT)wParam];
4279 btnPtr->bHot = TRUE;
4280 InvalidateRect (hwnd, &btnPtr->rect,
4281 TOOLBAR_HasText(infoPtr, btnPtr));
4285 btnPtr = &infoPtr->buttons[nOldHotItem];
4286 btnPtr->bHot = FALSE;
4287 InvalidateRect (hwnd, &btnPtr->rect,
4288 TOOLBAR_HasText(infoPtr, btnPtr));
4292 if (nOldHotItem < 0)
4295 return (LRESULT)nOldHotItem;
4300 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
4302 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4303 HIMAGELIST himlTemp;
4304 HIMAGELIST himl = (HIMAGELIST)lParam;
4307 if (infoPtr->iVersion >= 5)
4310 himlTemp = TOOLBAR_InsertImageList(&infoPtr->himlDef,
4311 &infoPtr->cimlDef, himl, id);
4313 infoPtr->nNumBitmaps = 0;
4314 for (i = 0; i < infoPtr->cimlDef; i++)
4315 infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl);
4317 ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth,
4318 &infoPtr->nBitmapHeight);
4319 TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n",
4320 hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps,
4321 infoPtr->nBitmapWidth, infoPtr->nBitmapHeight);
4323 /* FIXME: redraw ? */
4324 InvalidateRect(hwnd, NULL, TRUE);
4326 return (LRESULT)himlTemp;
4331 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4333 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4335 infoPtr->nIndent = (INT)wParam;
4339 /* process only on indent changing */
4340 if(infoPtr->nIndent != (INT)wParam)
4342 infoPtr->nIndent = (INT)wParam;
4343 TOOLBAR_CalcToolbar (hwnd);
4344 InvalidateRect(hwnd, NULL, FALSE);
4351 /* << TOOLBAR_SetInsertMark >> */
4355 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
4357 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4359 infoPtr->clrInsertMark = (COLORREF)lParam;
4361 /* FIXME : redraw ??*/
4368 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4370 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4372 if (infoPtr == NULL)
4375 infoPtr->nMaxTextRows = (INT)wParam;
4382 TOOLBAR_SetPadding (HWND hwnd, WPARAM wParam, LPARAM lParam)
4384 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4387 oldPad = MAKELONG(infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4388 infoPtr->szPadding.cx = LOWORD((DWORD)lParam);
4389 infoPtr->szPadding.cy = HIWORD((DWORD)lParam);
4390 FIXME("stub - nothing done with values, cx=%ld, cy=%ld\n",
4391 infoPtr->szPadding.cx, infoPtr->szPadding.cy);
4392 return (LRESULT) oldPad;
4397 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
4399 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4404 if (infoPtr == NULL)
4406 hwndOldNotify = infoPtr->hwndNotify;
4407 infoPtr->hwndNotify = (HWND)wParam;
4409 return (LRESULT)hwndOldNotify;
4414 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
4416 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4417 LPRECT lprc = (LPRECT)lParam;
4421 if (LOWORD(wParam) > 1) {
4422 FIXME("multiple rows not supported!\n");
4425 if(infoPtr->nRows != LOWORD(wParam))
4427 infoPtr->nRows = LOWORD(wParam);
4429 /* recalculate toolbar */
4430 TOOLBAR_CalcToolbar (hwnd);
4432 /* repaint toolbar */
4433 InvalidateRect(hwnd, NULL, FALSE);
4436 /* return bounding rectangle */
4438 lprc->left = infoPtr->rcBound.left;
4439 lprc->right = infoPtr->rcBound.right;
4440 lprc->top = infoPtr->rcBound.top;
4441 lprc->bottom = infoPtr->rcBound.bottom;
4449 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
4451 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4452 TBUTTON_INFO *btnPtr;
4455 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4459 btnPtr = &infoPtr->buttons[nIndex];
4461 /* if hidden state has changed the invalidate entire window and recalc */
4462 if ((btnPtr->fsState & TBSTATE_HIDDEN) != (LOWORD(lParam) & TBSTATE_HIDDEN)) {
4463 btnPtr->fsState = LOWORD(lParam);
4464 TOOLBAR_CalcToolbar (hwnd);
4465 InvalidateRect(hwnd, 0, TOOLBAR_HasText(infoPtr, btnPtr));
4469 /* process state changing if current state doesn't match new state */
4470 if(btnPtr->fsState != LOWORD(lParam))
4472 btnPtr->fsState = LOWORD(lParam);
4473 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4482 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
4484 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4485 TBUTTON_INFO *btnPtr;
4488 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE);
4492 btnPtr = &infoPtr->buttons[nIndex];
4494 /* process style change if current style doesn't match new style */
4495 if(btnPtr->fsStyle != LOWORD(lParam))
4497 btnPtr->fsStyle = LOWORD(lParam);
4498 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4501 if (infoPtr->hwndToolTip) {
4502 FIXME("change tool tip!\n");
4510 inline static LRESULT
4511 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
4513 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4515 if (infoPtr == NULL)
4517 infoPtr->hwndToolTip = (HWND)wParam;
4523 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
4525 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4528 TRACE("%s hwnd=%p stub!\n",
4529 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
4531 bTemp = infoPtr->bUnicode;
4532 infoPtr->bUnicode = (BOOL)wParam;
4539 TOOLBAR_GetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4541 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4543 lParam->clrBtnHighlight = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ?
4544 comctl32_color.clrBtnHighlight :
4545 infoPtr->clrBtnHighlight;
4546 lParam->clrBtnShadow = (infoPtr->clrBtnShadow == CLR_DEFAULT) ?
4547 comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow;
4553 TOOLBAR_SetColorScheme (HWND hwnd, LPCOLORSCHEME lParam)
4555 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4557 TRACE("new colors Hl=%lx Shd=%lx, old colors Hl=%lx Shd=%lx\n",
4558 lParam->clrBtnHighlight, lParam->clrBtnShadow,
4559 infoPtr->clrBtnHighlight, infoPtr->clrBtnShadow);
4561 infoPtr->clrBtnHighlight = lParam->clrBtnHighlight;
4562 infoPtr->clrBtnShadow = lParam->clrBtnShadow;
4563 InvalidateRect(hwnd, 0, 0);
4569 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
4571 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4572 INT iOldVersion = infoPtr->iVersion;
4574 infoPtr->iVersion = iVersion;
4576 if (infoPtr->iVersion >= 5)
4577 TOOLBAR_SetUnicodeFormat(hwnd, (WPARAM)TRUE, (LPARAM)0);
4583 /*********************************************************************/
4585 /* This is undocumented and appears to be a "Super" TB_SETHOTITEM */
4586 /* without the restriction of TBSTYLE_FLAT. This implementation is */
4587 /* based on relay traces of the native control and IE 5.5 */
4589 /*********************************************************************/
4591 TOOLBAR_Unkwn45E (HWND hwnd, WPARAM wParam, LPARAM lParam)
4593 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
4594 INT nOldHotItem = infoPtr->nHotItem;
4595 TBUTTON_INFO *btnPtr;
4597 NMTBHOTITEM nmhotitem;
4599 if ((INT) wParam < 0 || (INT)wParam > infoPtr->nNumButtons)
4602 infoPtr->nHotItem = (INT)wParam;
4603 if (nOldHotItem != infoPtr->nHotItem) {
4604 nmhotitem.dwFlags = (DWORD)lParam;
4605 if ( !(nmhotitem.dwFlags & HICF_ENTERING) )
4606 nmhotitem.idOld = (nOldHotItem >= 0) ?
4607 infoPtr->buttons[nOldHotItem].idCommand : 0;
4608 if ( !(nmhotitem.dwFlags & HICF_LEAVING) )
4609 nmhotitem.idNew = (infoPtr->nHotItem >= 0) ?
4610 infoPtr->buttons[infoPtr->nHotItem].idCommand : 0;
4611 no_hi = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
4613 if ((INT)wParam >=0) {
4614 btnPtr = &infoPtr->buttons[(INT)wParam];
4615 btnPtr->bHot = (no_hi) ? FALSE : TRUE;
4616 InvalidateRect (hwnd, &btnPtr->rect,
4617 TOOLBAR_HasText(infoPtr, btnPtr));
4619 if (nOldHotItem>=0) {
4620 btnPtr = &infoPtr->buttons[nOldHotItem];
4621 btnPtr->bHot = FALSE;
4622 InvalidateRect (hwnd, &btnPtr->rect,
4623 TOOLBAR_HasText(infoPtr, btnPtr));
4626 TRACE("old item=%d, new item=%d, flags=%08lx, notify=%d\n",
4627 nOldHotItem, infoPtr->nHotItem, (DWORD)lParam, no_hi);
4629 if (nOldHotItem < 0)
4632 return (LRESULT)nOldHotItem;
4637 TOOLBAR_Unkwn463 (HWND hwnd, WPARAM wParam, LPARAM lParam)
4639 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4640 LPSIZE lpsize = (LPSIZE)lParam;
4646 * Testing shows the following:
4647 * wParam = 0 adjust cx value
4648 * = 1 set cy value to max size.
4649 * lParam pointer to SIZE structure
4652 TRACE("[0463] wParam %d, lParam 0x%08lx -> 0x%08lx 0x%08lx\n",
4653 wParam, lParam, lpsize->cx, lpsize->cy);
4657 if (lpsize->cx == -1) {
4658 /* **** this is wrong, native measures each button and sets it */
4659 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4661 else if(HIWORD(lpsize->cx)) {
4663 HWND hwndParent = GetParent(hwnd);
4665 InvalidateRect(hwnd, 0, 1);
4666 GetWindowRect(hwnd, &rc);
4667 MapWindowPoints(0, hwndParent, (LPPOINT)&rc, 2);
4668 TRACE("mapped to (%ld,%ld)-(%ld,%ld)\n",
4669 rc.left, rc.top, rc.right, rc.bottom);
4670 lpsize->cx = max(rc.right-rc.left,
4671 infoPtr->rcBound.right - infoPtr->rcBound.left);
4674 lpsize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
4678 lpsize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
4679 /* lpsize->cy = infoPtr->nHeight; */
4682 ERR("Unknown wParam %d for Toolbar message [0463]. Please report\n",
4686 TRACE("[0463] set to -> 0x%08lx 0x%08lx\n",
4687 lpsize->cx, lpsize->cy);
4693 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
4695 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4696 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4699 /* initialize info structure */
4700 infoPtr->nButtonHeight = 22;
4701 infoPtr->nButtonWidth = 24;
4702 infoPtr->nBitmapHeight = 15;
4703 infoPtr->nBitmapWidth = 16;
4705 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
4707 infoPtr->nMaxTextRows = 1;
4708 infoPtr->cxMin = -1;
4709 infoPtr->cxMax = -1;
4710 infoPtr->nNumBitmaps = 0;
4711 infoPtr->nNumStrings = 0;
4713 infoPtr->bCaptured = FALSE;
4714 infoPtr->bUnicode = IsWindowUnicode (hwnd);
4715 infoPtr->nButtonDown = -1;
4716 infoPtr->nOldHit = -1;
4717 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
4718 infoPtr->hwndNotify = GetParent (hwnd);
4719 infoPtr->bTransparent = (dwStyle & TBSTYLE_TRANSPARENT);
4720 infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST));
4721 infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE : DT_CENTER;
4722 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
4723 infoPtr->iVersion = 0;
4724 infoPtr->hwndSelf = hwnd;
4725 infoPtr->bDoRedraw = TRUE;
4726 infoPtr->clrBtnHighlight = CLR_DEFAULT;
4727 infoPtr->clrBtnShadow = CLR_DEFAULT;
4728 infoPtr->szPadding.cx = 7;
4729 infoPtr->szPadding.cy = 6;
4730 TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY);
4732 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
4733 infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont);
4735 if (dwStyle & TBSTYLE_TOOLTIPS) {
4736 /* Create tooltip control */
4737 infoPtr->hwndToolTip =
4738 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
4739 CW_USEDEFAULT, CW_USEDEFAULT,
4740 CW_USEDEFAULT, CW_USEDEFAULT,
4743 /* Send NM_TOOLTIPSCREATED notification */
4744 if (infoPtr->hwndToolTip) {
4745 NMTOOLTIPSCREATED nmttc;
4747 nmttc.hwndToolTips = infoPtr->hwndToolTip;
4749 TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr,
4750 NM_TOOLTIPSCREATED);
4754 TOOLBAR_CheckStyle (hwnd, dwStyle);
4756 TOOLBAR_CalcToolbar(hwnd);
4763 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
4765 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4767 /* delete tooltip control */
4768 if (infoPtr->hwndToolTip)
4769 DestroyWindow (infoPtr->hwndToolTip);
4771 /* delete button data */
4772 if (infoPtr->buttons)
4773 Free (infoPtr->buttons);
4775 /* delete strings */
4776 if (infoPtr->strings) {
4778 for (i = 0; i < infoPtr->nNumStrings; i++)
4779 if (infoPtr->strings[i])
4780 Free (infoPtr->strings[i]);
4782 Free (infoPtr->strings);
4785 /* destroy internal image list */
4786 if (infoPtr->himlInt)
4787 ImageList_Destroy (infoPtr->himlInt);
4789 TOOLBAR_DeleteImageList(&infoPtr->himlDef, &infoPtr->cimlDef);
4790 TOOLBAR_DeleteImageList(&infoPtr->himlDis, &infoPtr->cimlDis);
4791 TOOLBAR_DeleteImageList(&infoPtr->himlHot, &infoPtr->cimlHot);
4793 /* delete default font */
4795 DeleteObject (infoPtr->hDefaultFont);
4797 /* free toolbar info data */
4799 SetWindowLongA (hwnd, 0, 0);
4806 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
4808 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4809 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
4810 NMTBCUSTOMDRAW tbcd;
4814 if (dwStyle & TBSTYLE_CUSTOMERASE) {
4815 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4816 tbcd.nmcd.dwDrawStage = CDDS_PREERASE;
4817 tbcd.nmcd.hdc = (HDC)wParam;
4818 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4819 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4821 /* FIXME: in general the return flags *can* be or'ed together */
4822 switch (infoPtr->dwBaseCustDraw)
4824 case CDRF_DODEFAULT:
4826 case CDRF_SKIPDEFAULT:
4829 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4834 /* If the toolbar is "transparent" then pass the WM_ERASEBKGND up
4835 * to my parent for processing.
4837 if (infoPtr->bTransparent) {
4839 HDC hdc = (HDC)wParam;
4844 parent = GetParent(hwnd);
4845 MapWindowPoints(hwnd, parent, &pt, 1);
4846 OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig);
4847 ret = SendMessageA (parent, WM_ERASEBKGND, wParam, lParam);
4848 SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0);
4851 ret = DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
4853 if ((dwStyle & TBSTYLE_CUSTOMERASE) &&
4854 (infoPtr->dwBaseCustDraw & CDRF_NOTIFYPOSTERASE)) {
4855 ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW));
4856 tbcd.nmcd.dwDrawStage = CDDS_POSTERASE;
4857 tbcd.nmcd.hdc = (HDC)wParam;
4858 ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW);
4859 infoPtr->dwBaseCustDraw = ntfret & 0xffff;
4860 switch (infoPtr->dwBaseCustDraw)
4862 case CDRF_DODEFAULT:
4864 case CDRF_SKIPDEFAULT:
4867 FIXME("[%p] response %ld not handled to NM_CUSTOMDRAW (CDDS_PREERASE)\n",
4876 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
4878 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4880 return (LRESULT)infoPtr->hFont;
4885 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
4887 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4888 TBUTTON_INFO *btnPtr;
4892 pt.x = (INT)LOWORD(lParam);
4893 pt.y = (INT)HIWORD(lParam);
4894 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4897 btnPtr = &infoPtr->buttons[nHit];
4898 if (!(btnPtr->fsState & TBSTATE_ENABLED))
4901 infoPtr->bCaptured = TRUE;
4902 infoPtr->nButtonDown = nHit;
4904 btnPtr->fsState |= TBSTATE_PRESSED;
4906 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
4909 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
4910 TOOLBAR_Customize (hwnd);
4917 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
4919 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4920 TBUTTON_INFO *btnPtr;
4925 if (infoPtr->hwndToolTip)
4926 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
4927 WM_LBUTTONDOWN, wParam, lParam);
4929 pt.x = (INT)LOWORD(lParam);
4930 pt.y = (INT)HIWORD(lParam);
4931 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
4935 btnPtr = &infoPtr->buttons[nHit];
4936 infoPtr->nOldHit = nHit;
4938 CopyRect(&arrowRect, &btnPtr->rect);
4939 arrowRect.left = max(btnPtr->rect.left, btnPtr->rect.right - DDARROW_WIDTH);
4941 /* for EX_DRAWDDARROWS style, click must be in the drop-down arrow rect */
4942 if ((btnPtr->fsState & TBSTATE_ENABLED) && (btnPtr->fsStyle & TBSTYLE_DROPDOWN) &&
4943 ((TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && PtInRect(&arrowRect, pt)) ||
4944 (!TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle))))
4948 * this time we must force a Redraw, so the btn is
4949 * painted down before CaptureChanged repaints it up
4951 RedrawWindow(hwnd,&btnPtr->rect,0,
4952 RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW);
4954 nmtb.iItem = btnPtr->idCommand;
4955 memset(&nmtb.tbButton, 0, sizeof(TBBUTTON));
4958 memset(&nmtb.rcButton, 0, sizeof(RECT));
4959 res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4961 if (res != TBDDRET_TREATPRESSED)
4962 /* ??? guess (GA) */
4964 /* otherwise drop through and process as pushed */
4966 /* SetCapture (hwnd); */
4967 infoPtr->bCaptured = TRUE;
4968 infoPtr->nButtonDown = nHit;
4970 btnPtr->fsState |= TBSTATE_PRESSED;
4971 btnPtr->bHot = FALSE;
4973 if (btnPtr->fsState & TBSTATE_ENABLED)
4974 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr, btnPtr));
4978 /* native issues the TBN_BEGINDRAG here */
4979 nmtb.iItem = btnPtr->idCommand;
4980 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
4981 nmtb.tbButton.idCommand = btnPtr->idCommand;
4982 nmtb.tbButton.fsState = btnPtr->fsState;
4983 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
4984 nmtb.tbButton.dwData = btnPtr->dwData;
4985 nmtb.tbButton.iString = btnPtr->iString;
4986 nmtb.cchText = 0; /* !!! not correct */
4987 nmtb.pszText = 0; /* !!! not correct */
4988 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
4996 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
4998 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
4999 TBUTTON_INFO *btnPtr;
5003 BOOL bSendMessage = TRUE;
5008 if (infoPtr->hwndToolTip)
5009 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
5010 WM_LBUTTONUP, wParam, lParam);
5012 pt.x = (INT)LOWORD(lParam);
5013 pt.y = (INT)HIWORD(lParam);
5014 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
5016 /* restore hot effect to hot button disabled by TOOLBAR_LButtonDown() */
5017 /* if the cursor is still inside of the toolbar */
5018 if((infoPtr->nHotItem >= 0) && (nHit != -1))
5019 infoPtr->buttons[infoPtr->nHotItem].bHot = TRUE;
5021 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5022 btnPtr->fsState &= ~TBSTATE_PRESSED;
5024 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
5025 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
5026 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
5028 if (nOldIndex == nHit)
5029 bSendMessage = FALSE;
5030 if ((nOldIndex != nHit) &&
5032 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
5033 btnPtr->fsState |= TBSTATE_CHECKED;
5036 if (btnPtr->fsState & TBSTATE_CHECKED)
5037 btnPtr->fsState &= ~TBSTATE_CHECKED;
5039 btnPtr->fsState |= TBSTATE_CHECKED;
5043 if (nOldIndex != -1)
5045 InvalidateRect(hwnd, &infoPtr->buttons[nOldIndex].rect,
5046 TOOLBAR_HasText(infoPtr, &infoPtr->buttons[nOldIndex]));
5050 * now we can ReleaseCapture, which triggers CAPTURECHANGED msg,
5051 * that resets bCaptured and btn TBSTATE_PRESSED flags,
5052 * and obliterates nButtonDown and nOldHit (see TOOLBAR_CaptureChanged)
5054 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0))
5056 infoPtr->nButtonDown = -1;
5058 /* Issue NM_RELEASEDCAPTURE to parent to let him know it is released */
5059 TOOLBAR_SendNotify ((NMHDR *) &hdr, infoPtr,
5060 NM_RELEASEDCAPTURE);
5062 /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the
5065 nmtb.iItem = btnPtr->idCommand;
5066 nmtb.tbButton.iBitmap = btnPtr->iBitmap;
5067 nmtb.tbButton.idCommand = btnPtr->idCommand;
5068 nmtb.tbButton.fsState = btnPtr->fsState;
5069 nmtb.tbButton.fsStyle = btnPtr->fsStyle;
5070 nmtb.tbButton.dwData = btnPtr->dwData;
5071 nmtb.tbButton.iString = btnPtr->iString;
5072 nmtb.cchText = 0; /* !!! not correct */
5073 nmtb.pszText = 0; /* !!! not correct */
5074 TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr,
5077 if (btnPtr->fsState & TBSTATE_ENABLED)
5079 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
5080 MAKEWPARAM(infoPtr->buttons[nHit].idCommand, 0), (LPARAM)hwnd);
5082 /* !!! Undocumented - toolbar at 4.71 level and above sends
5083 * either NMRCLICK or NM_CLICK with the NMMOUSE structure.
5084 * Only NM_RCLICK is documented.
5086 nmmouse.dwItemSpec = btnPtr->idCommand;
5087 nmmouse.dwItemData = btnPtr->dwData;
5088 TOOLBAR_SendNotify ((NMHDR *) &nmmouse, infoPtr, NM_CLICK);
5094 TOOLBAR_CaptureChanged(HWND hwnd)
5096 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5097 TBUTTON_INFO *btnPtr;
5099 infoPtr->bCaptured = FALSE;
5101 if (infoPtr->nButtonDown >= 0)
5103 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5104 btnPtr->fsState &= ~TBSTATE_PRESSED;
5106 infoPtr->nOldHit = -1;
5108 if (btnPtr->fsState & TBSTATE_ENABLED)
5109 InvalidateRect(hwnd, &btnPtr->rect, TOOLBAR_HasText(infoPtr,
5116 TOOLBAR_MouseLeave (HWND hwnd, WPARAM wParam, LPARAM lParam)
5118 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5119 TBUTTON_INFO *hotBtnPtr, *btnPtr;
5122 if (infoPtr->nOldHit < 0)
5125 hotBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
5127 /* Redraw the button if the last button we were over is the hot button and it
5129 if((infoPtr->nOldHit == infoPtr->nHotItem) && (hotBtnPtr->fsState & TBSTATE_ENABLED))
5131 hotBtnPtr->bHot = FALSE;
5132 rc1 = hotBtnPtr->rect;
5133 InflateRect (&rc1, 1, 1);
5134 InvalidateRect (hwnd, &rc1, TOOLBAR_HasText(infoPtr,
5138 /* If the last button we were over is depressed then make it not */
5139 /* depressed and redraw it */
5140 if(infoPtr->nOldHit == infoPtr->nButtonDown)
5142 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5144 btnPtr->fsState &= ~TBSTATE_PRESSED;
5146 rc1 = hotBtnPtr->rect;
5147 InflateRect (&rc1, 1, 1);
5148 InvalidateRect (hwnd, &rc1, TRUE);
5151 infoPtr->nOldHit = -1; /* reset the old hit index as we've left the toolbar */
5152 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
5158 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
5160 TBUTTON_INFO *btnPtr = NULL, *oldBtnPtr = NULL;
5161 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5164 TRACKMOUSEEVENT trackinfo;
5165 NMTBHOTITEM nmhotitem;
5167 /* fill in the TRACKMOUSEEVENT struct */
5168 trackinfo.cbSize = sizeof(TRACKMOUSEEVENT);
5169 trackinfo.dwFlags = TME_QUERY;
5170 trackinfo.hwndTrack = hwnd;
5171 trackinfo.dwHoverTime = HOVER_DEFAULT;
5173 /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */
5174 _TrackMouseEvent(&trackinfo);
5176 /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */
5177 if(!(trackinfo.dwFlags & TME_LEAVE)) {
5178 trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */
5180 /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */
5181 /* and can properly deactivate the hot toolbar button */
5182 _TrackMouseEvent(&trackinfo);
5185 if (infoPtr->hwndToolTip)
5186 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
5187 WM_MOUSEMOVE, wParam, lParam);
5189 pt.x = (INT)LOWORD(lParam);
5190 pt.y = (INT)HIWORD(lParam);
5192 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
5194 if (infoPtr->nOldHit != nHit)
5196 /* Remove the effect of an old hot button if the button was
5197 drawn with the hot button effect */
5198 if(infoPtr->nOldHit >= 0 && infoPtr->nOldHit == infoPtr->nHotItem)
5200 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
5201 oldBtnPtr->bHot = FALSE;
5204 /* It's not a separator or in nowhere. It's a hot button. */
5207 btnPtr = &infoPtr->buttons[nHit];
5209 infoPtr->nHotItem = nHit;
5211 btnPtr->bHot = TRUE;
5214 nmhotitem.dwFlags = HICF_MOUSE;
5216 nmhotitem.idOld = oldBtnPtr->idCommand;
5218 nmhotitem.dwFlags |= HICF_ENTERING;
5220 nmhotitem.idNew = btnPtr->idCommand;
5222 nmhotitem.dwFlags |= HICF_LEAVING;
5223 TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE);
5225 /* now invalidate the old and new buttons so they will be painted */
5227 InvalidateRect (hwnd, &oldBtnPtr->rect,
5228 TOOLBAR_HasText(infoPtr, oldBtnPtr));
5230 InvalidateRect(hwnd, &btnPtr->rect,
5231 TOOLBAR_HasText(infoPtr, btnPtr));
5233 if (infoPtr->bCaptured) {
5234 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
5235 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
5236 btnPtr->fsState &= ~TBSTATE_PRESSED;
5237 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
5239 else if (nHit == infoPtr->nButtonDown) {
5240 btnPtr->fsState |= TBSTATE_PRESSED;
5241 InvalidateRect(hwnd, &btnPtr->rect, TRUE);
5244 infoPtr->nOldHit = nHit;
5250 inline static LRESULT
5251 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
5253 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
5254 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
5256 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
5260 inline static LRESULT
5261 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
5263 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
5264 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
5266 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
5271 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
5273 TOOLBAR_INFO *infoPtr;
5274 LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
5277 /* allocate memory for info structure */
5278 infoPtr = (TOOLBAR_INFO *)Alloc (sizeof(TOOLBAR_INFO));
5279 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
5282 infoPtr->dwStructSize = sizeof(TBBUTTON);
5284 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
5285 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
5286 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
5287 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
5290 /* native control does:
5291 * Get a lot of colors and brushes
5293 * SystemParametersInfoA(0x1f, 0x3c, adr1, 0)
5294 * CreateFontIndirectA(adr1)
5295 * CreateBitmap(0x27, 0x24, 1, 1, 0)
5296 * hdc = GetDC(toolbar)
5297 * GetSystemMetrics(0x48)
5298 * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2,
5299 * 0, 0, 0, 0, "MARLETT")
5300 * oldfnt = SelectObject(hdc, fnt2)
5301 * GetCharWidthA(hdc, 0x36, 0x36, adr2)
5302 * GetTextMetricsA(hdc, adr3)
5303 * SelectObject(hdc, oldfnt)
5304 * DeleteObject(fnt2)
5306 * InvalidateRect(toolbar, 0, 1)
5307 * SetWindowLongA(toolbar, 0, addr)
5308 * SetWindowLongA(toolbar, -16, xxx) **sometimes**
5311 * ie 1 0x56000a4c 0x46000a4c 0x56008a4d
5312 * ie 2 0x4600094c 0x4600094c 0x4600894d
5313 * ie 3 0x56000b4c 0x46000b4c 0x56008b4d
5314 * rebar 0x50008844 0x40008844 0x50008845
5315 * pager 0x50000844 0x40000844 0x50008845
5316 * IC35mgr 0x5400084e **nochange**
5317 * on entry to _NCCREATE 0x5400084e
5318 * rowlist 0x5400004e **nochange**
5319 * on entry to _NCCREATE 0x5400004e
5323 /* I think the code below is a bug, but it is the way that the native
5324 * controls seem to work. The effect is that if the user of TBSTYLE_FLAT
5325 * forgets to specify TBSTYLE_TRANSPARENT but does specify either
5326 * CCS_TOP or CCS_BOTTOM (_NOMOVEY and _TOP), then the control
5327 * does *not* set TBSTYLE_TRANSPARENT even though it should!!!!
5328 * Some how, the only cases of this seem to be MFC programs.
5330 * Note also that the addition of _TRANSPARENT occurs *only* here. It
5331 * does not occur in the WM_STYLECHANGING routine.
5332 * (Guy Albertelli 9/2001)
5335 if ((cs->style & TBSTYLE_FLAT) && !(cs->style & TBSTYLE_TRANSPARENT))
5336 styleadd |= TBSTYLE_TRANSPARENT;
5337 if (!(cs->style & (CCS_TOP | CCS_NOMOVEY))) {
5338 styleadd |= CCS_TOP; /* default to top */
5339 SetWindowLongA (hwnd, GWL_STYLE, cs->style | styleadd);
5342 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
5347 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
5349 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5353 if (dwStyle & WS_MINIMIZE)
5354 return 0; /* Nothing to do */
5356 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
5358 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
5361 if (!(dwStyle & CCS_NODIVIDER))
5363 GetWindowRect (hwnd, &rcWindow);
5364 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
5365 if( dwStyle & WS_BORDER )
5366 OffsetRect (&rcWindow, 1, 1);
5367 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
5370 ReleaseDC( hwnd, hdc );
5376 inline static LRESULT
5377 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
5379 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5380 LPNMHDR lpnmh = (LPNMHDR)lParam;
5382 if (lpnmh->code == PGN_CALCSIZE) {
5383 LPNMPGCALCSIZE lppgc = (LPNMPGCALCSIZE)lParam;
5385 if (lppgc->dwFlag == PGF_CALCWIDTH) {
5386 lppgc->iWidth = infoPtr->rcBound.right - infoPtr->rcBound.left;
5387 TRACE("processed PGN_CALCSIZE, returning horz size = %d\n",
5391 lppgc->iHeight = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
5392 TRACE("processed PGN_CALCSIZE, returning vert size = %d\n",
5398 if (lpnmh->code == PGN_SCROLL) {
5399 LPNMPGSCROLL lppgs = (LPNMPGSCROLL)lParam;
5401 lppgs->iScroll = (lppgs->iDir & (PGF_SCROLLLEFT | PGF_SCROLLRIGHT)) ?
5402 infoPtr->nButtonWidth : infoPtr->nButtonHeight;
5403 TRACE("processed PGN_SCROLL, returning scroll=%d, dir=%d\n",
5404 lppgs->iScroll, lppgs->iDir);
5409 TRACE("passing WM_NOTIFY!\n");
5411 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
5412 if (infoPtr->bNtfUnicode)
5413 return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY,
5416 return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
5420 if (lpnmh->code == TTN_GETDISPINFOA) {
5421 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
5423 FIXME("retrieving ASCII string\n");
5426 else if (lpnmh->code == TTN_GETDISPINFOW) {
5427 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
5429 FIXME("retrieving UNICODE string\n");
5440 TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam)
5442 /* remove this routine when Toolbar is improved to pass infoPtr
5443 * around instead of hwnd.
5445 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5446 return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam);
5451 TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam)
5455 if (lParam == NF_REQUERY) {
5456 i = SendMessageA(GetParent(infoPtr->hwndSelf),
5457 WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY);
5458 if ((i < NFR_ANSI) || (i > NFR_UNICODE)) {
5459 ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n",
5463 infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0;
5466 return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI);
5471 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
5473 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
5477 /* fill ps.rcPaint with a default rect */
5478 memcpy(&(ps.rcPaint), &(infoPtr->rcBound), sizeof(infoPtr->rcBound));
5480 hdc = wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam;
5482 TRACE("psrect=(%ld,%ld)-(%ld,%ld)\n",
5483 ps.rcPaint.left, ps.rcPaint.top,
5484 ps.rcPaint.right, ps.rcPaint.bottom);
5486 TOOLBAR_Refresh (hwnd, hdc, &ps);
5487 if (!wParam) EndPaint (hwnd, &ps);
5494 TOOLBAR_SetRedraw (HWND hwnd, WPARAM wParam, LPARAM lParam)
5495 /*****************************************************
5498 * Handles the WM_SETREDRAW message.
5501 * According to testing V4.71 of COMCTL32 returns the
5502 * *previous* status of the redraw flag (either 0 or 1)
5503 * instead of the MSDN documented value of 0 if handled.
5504 * (For laughs see the "consistency" with same function
5507 *****************************************************/
5509 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5510 BOOL oldredraw = infoPtr->bDoRedraw;
5512 TRACE("set to %s\n",
5513 (wParam) ? "TRUE" : "FALSE");
5514 infoPtr->bDoRedraw = (BOOL) wParam;
5516 InvalidateRect (infoPtr->hwndSelf, 0, TRUE);
5518 return (oldredraw) ? 1 : 0;
5523 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
5525 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5526 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
5535 /* Resize deadlock check */
5536 if (infoPtr->bAutoSize) {
5537 infoPtr->bAutoSize = FALSE;
5541 /* FIXME: optimize to only update size if the new size doesn't */
5542 /* match the current size */
5544 flags = (INT) wParam;
5546 /* FIXME for flags =
5547 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
5550 TRACE("sizing toolbar!\n");
5552 if (flags == SIZE_RESTORED) {
5553 /* width and height don't apply */
5554 parent = GetParent (hwnd);
5555 GetClientRect(parent, &parent_rect);
5556 x = parent_rect.left;
5557 y = parent_rect.top;
5559 if (dwStyle & CCS_NORESIZE) {
5560 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
5563 * this sets the working width of the toolbar, and
5564 * Calc Toolbar will not adjust it, only the height
5566 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5567 cy = infoPtr->nHeight;
5568 cx = infoPtr->nWidth;
5569 TOOLBAR_CalcToolbar (hwnd);
5570 infoPtr->nWidth = cx;
5571 infoPtr->nHeight = cy;
5574 infoPtr->nWidth = parent_rect.right - parent_rect.left;
5575 TOOLBAR_CalcToolbar (hwnd);
5576 cy = infoPtr->nHeight;
5577 cx = infoPtr->nWidth;
5579 if ((dwStyle & CCS_BOTTOM) == CCS_NOMOVEY) {
5580 GetWindowRect(hwnd, &window_rect);
5581 ScreenToClient(parent, (LPPOINT)&window_rect.left);
5582 y = window_rect.top;
5584 if ((dwStyle & CCS_BOTTOM) == CCS_BOTTOM) {
5585 GetWindowRect(hwnd, &window_rect);
5586 y = parent_rect.bottom -
5587 ( window_rect.bottom - window_rect.top);
5591 if (dwStyle & CCS_NOPARENTALIGN) {
5592 uPosFlags |= SWP_NOMOVE;
5593 cy = infoPtr->nHeight;
5594 cx = infoPtr->nWidth;
5597 if (!(dwStyle & CCS_NODIVIDER))
5598 cy += GetSystemMetrics(SM_CYEDGE);
5600 if (dwStyle & WS_BORDER)
5603 cy += GetSystemMetrics(SM_CYEDGE);
5604 cx += GetSystemMetrics(SM_CYEDGE);
5607 SetWindowPos (hwnd, 0, x, y, cx, cy, uPosFlags | SWP_NOZORDER);
5614 TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle)
5616 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
5618 if (nType == GWL_STYLE) {
5619 if (lpStyle->styleNew & TBSTYLE_LIST) {
5620 infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE;
5623 infoPtr->dwDTFlags = DT_CENTER;
5625 infoPtr->bTransparent = (lpStyle->styleNew & TBSTYLE_TRANSPARENT);
5626 infoPtr->bBtnTranspnt = (lpStyle->styleNew &
5627 (TBSTYLE_FLAT | TBSTYLE_LIST));
5628 TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew);
5631 TOOLBAR_AutoSize (hwnd);
5633 InvalidateRect(hwnd, NULL, FALSE);
5640 TOOLBAR_SysColorChange (HWND hwnd)
5642 COMCTL32_RefreshSysColors();
5649 static LRESULT WINAPI
5650 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
5652 TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n",
5653 hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam);
5655 if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE))
5656 return DefWindowProcA( hwnd, uMsg, wParam, lParam );
5661 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
5663 case TB_ADDBUTTONSA:
5664 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
5666 case TB_ADDBUTTONSW:
5667 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
5670 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
5673 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
5676 return TOOLBAR_AutoSize (hwnd);
5678 case TB_BUTTONCOUNT:
5679 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
5681 case TB_BUTTONSTRUCTSIZE:
5682 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
5684 case TB_CHANGEBITMAP:
5685 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
5687 case TB_CHECKBUTTON:
5688 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
5690 case TB_COMMANDTOINDEX:
5691 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
5694 return TOOLBAR_Customize (hwnd);
5696 case TB_DELETEBUTTON:
5697 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
5699 case TB_ENABLEBUTTON:
5700 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
5702 case TB_GETANCHORHIGHLIGHT:
5703 return TOOLBAR_GetAnchorHighlight (hwnd);
5706 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
5708 case TB_GETBITMAPFLAGS:
5709 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
5712 return TOOLBAR_GetButton (hwnd, wParam, lParam);
5714 case TB_GETBUTTONINFOA:
5715 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
5717 case TB_GETBUTTONINFOW:
5718 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
5720 case TB_GETBUTTONSIZE:
5721 return TOOLBAR_GetButtonSize (hwnd);
5723 case TB_GETBUTTONTEXTA:
5724 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
5726 case TB_GETBUTTONTEXTW:
5727 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
5729 case TB_GETDISABLEDIMAGELIST:
5730 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
5732 case TB_GETEXTENDEDSTYLE:
5733 return TOOLBAR_GetExtendedStyle (hwnd);
5735 case TB_GETHOTIMAGELIST:
5736 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
5739 return TOOLBAR_GetHotItem (hwnd);
5741 case TB_GETIMAGELIST:
5742 return TOOLBAR_GetDefImageList (hwnd, wParam, lParam);
5744 /* case TB_GETINSERTMARK: */ /* 4.71 */
5745 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
5747 case TB_GETITEMRECT:
5748 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
5751 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
5753 /* case TB_GETOBJECT: */ /* 4.71 */
5756 return TOOLBAR_GetPadding (hwnd);
5759 return TOOLBAR_GetRect (hwnd, wParam, lParam);
5762 return TOOLBAR_GetRows (hwnd, wParam, lParam);
5765 return TOOLBAR_GetState (hwnd, wParam, lParam);
5768 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
5770 case TB_GETTEXTROWS:
5771 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
5773 case TB_GETTOOLTIPS:
5774 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
5776 case TB_GETUNICODEFORMAT:
5777 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
5780 return TOOLBAR_HideButton (hwnd, wParam, lParam);
5783 return TOOLBAR_HitTest (hwnd, wParam, lParam);
5785 case TB_INDETERMINATE:
5786 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
5788 case TB_INSERTBUTTONA:
5789 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
5791 case TB_INSERTBUTTONW:
5792 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
5794 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
5796 case TB_ISBUTTONCHECKED:
5797 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
5799 case TB_ISBUTTONENABLED:
5800 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
5802 case TB_ISBUTTONHIDDEN:
5803 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
5805 case TB_ISBUTTONHIGHLIGHTED:
5806 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
5808 case TB_ISBUTTONINDETERMINATE:
5809 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
5811 case TB_ISBUTTONPRESSED:
5812 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
5814 case TB_LOADIMAGES: /* 4.70 */
5815 FIXME("missing standard imagelists\n");
5818 /* case TB_MAPACCELERATORA: */ /* 4.71 */
5819 /* case TB_MAPACCELERATORW: */ /* 4.71 */
5820 /* case TB_MARKBUTTON: */ /* 4.71 */
5821 /* case TB_MOVEBUTTON: */ /* 4.71 */
5823 case TB_PRESSBUTTON:
5824 return TOOLBAR_PressButton (hwnd, wParam, lParam);
5826 case TB_REPLACEBITMAP:
5827 return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam);
5829 case TB_SAVERESTOREA:
5830 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
5832 case TB_SAVERESTOREW:
5833 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
5835 case TB_SETANCHORHIGHLIGHT:
5836 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
5838 case TB_SETBITMAPSIZE:
5839 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
5841 case TB_SETBUTTONINFOA:
5842 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
5844 case TB_SETBUTTONINFOW:
5845 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
5847 case TB_SETBUTTONSIZE:
5848 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
5850 case TB_SETBUTTONWIDTH:
5851 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
5854 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
5856 case TB_SETDISABLEDIMAGELIST:
5857 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
5859 case TB_SETDRAWTEXTFLAGS:
5860 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
5862 case TB_SETEXTENDEDSTYLE:
5863 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
5865 case TB_SETHOTIMAGELIST:
5866 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
5869 return TOOLBAR_SetHotItem (hwnd, wParam);
5871 case TB_SETIMAGELIST:
5872 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
5875 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
5877 /* case TB_SETINSERTMARK: */ /* 4.71 */
5879 case TB_SETINSERTMARKCOLOR:
5880 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
5882 case TB_SETMAXTEXTROWS:
5883 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
5886 return TOOLBAR_SetPadding (hwnd, wParam, lParam);
5889 return TOOLBAR_SetParent (hwnd, wParam, lParam);
5892 return TOOLBAR_SetRows (hwnd, wParam, lParam);
5895 return TOOLBAR_SetState (hwnd, wParam, lParam);
5898 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
5900 case TB_SETTOOLTIPS:
5901 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
5903 case TB_SETUNICODEFORMAT:
5904 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
5907 return TOOLBAR_Unkwn45E (hwnd, wParam, lParam);
5910 return TOOLBAR_Unkwn463 (hwnd, wParam, lParam);
5913 /* Common Control Messages */
5915 /* case TB_GETCOLORSCHEME: */ /* identical to CCM_ */
5916 case CCM_GETCOLORSCHEME:
5917 return TOOLBAR_GetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5919 /* case TB_SETCOLORSCHEME: */ /* identical to CCM_ */
5920 case CCM_SETCOLORSCHEME:
5921 return TOOLBAR_SetColorScheme (hwnd, (LPCOLORSCHEME)lParam);
5923 case CCM_GETVERSION:
5924 return TOOLBAR_GetVersion (hwnd);
5926 case CCM_SETVERSION:
5927 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
5933 return TOOLBAR_Create (hwnd, wParam, lParam);
5936 return TOOLBAR_Destroy (hwnd, wParam, lParam);
5939 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
5942 return TOOLBAR_GetFont (hwnd, wParam, lParam);
5944 /* case WM_KEYDOWN: */
5945 /* case WM_KILLFOCUS: */
5947 case WM_LBUTTONDBLCLK:
5948 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
5950 case WM_LBUTTONDOWN:
5951 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
5954 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
5957 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
5960 return TOOLBAR_MouseLeave (hwnd, wParam, lParam);
5962 case WM_CAPTURECHANGED:
5963 return TOOLBAR_CaptureChanged(hwnd);
5966 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
5969 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
5972 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
5975 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
5978 return TOOLBAR_Notify (hwnd, wParam, lParam);
5980 case WM_NOTIFYFORMAT:
5981 TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam);
5984 return TOOLBAR_Paint (hwnd, wParam);
5987 return TOOLBAR_SetRedraw (hwnd, wParam, lParam);
5990 return TOOLBAR_Size (hwnd, wParam, lParam);
5992 case WM_STYLECHANGED:
5993 return TOOLBAR_StyleChanged (hwnd, (INT)wParam, (LPSTYLESTRUCT)lParam);
5995 case WM_SYSCOLORCHANGE:
5996 return TOOLBAR_SysColorChange (hwnd);
5998 /* case WM_WININICHANGE: */
6003 case WM_MEASUREITEM:
6006 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
6008 return SendMessageA (infoPtr->hwndNotify, uMsg, wParam, lParam);
6010 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
6013 /* We see this in Outlook Express 5.x and just does DefWindowProc */
6014 case PGM_FORWARDMOUSE:
6015 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
6018 if ((uMsg >= WM_USER) && (uMsg < WM_APP))
6019 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
6020 uMsg, wParam, lParam);
6021 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
6028 TOOLBAR_Register (void)
6032 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
6033 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
6034 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
6035 wndClass.cbClsExtra = 0;
6036 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
6037 wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW);
6038 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
6039 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
6041 RegisterClassA (&wndClass);
6046 TOOLBAR_Unregister (void)
6048 UnregisterClassA (TOOLBARCLASSNAMEA, NULL);
6051 static HIMAGELIST TOOLBAR_InsertImageList(PIMLENTRY **pies, INT *cies, HIMAGELIST himl, INT id)
6056 /* Check if the entry already exists */
6057 c = TOOLBAR_GetImageListEntry(*pies, *cies, id);
6059 /* If this is a new entry we must create it and insert into the array */
6064 c = (PIMLENTRY) Alloc(sizeof(IMLENTRY));
6067 pnies = Alloc((*cies + 1) * sizeof(PIMLENTRY));
6068 memcpy(pnies, *pies, ((*cies) * sizeof(PIMLENTRY)));
6083 static VOID TOOLBAR_DeleteImageList(PIMLENTRY **pies, INT *cies)
6087 for (i = 0; i < *cies; i++)
6097 static PIMLENTRY TOOLBAR_GetImageListEntry(PIMLENTRY *pies, INT cies, INT id)
6105 for (i = 0; i < cies; i++)
6107 if (pies[i]->id == id)
6119 static HIMAGELIST TOOLBAR_GetImageList(PIMLENTRY *pies, INT cies, INT id)
6121 HIMAGELIST himlDef = 0;
6122 PIMLENTRY pie = TOOLBAR_GetImageListEntry(pies, cies, id);
6125 himlDef = pie->himl;
6131 static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb)
6133 if (infoPtr->bUnicode)
6134 return TOOLBAR_SendNotify ((NMHDR *) nmtb, infoPtr, TBN_GETBUTTONINFOW);
6141 nmtba.iItem = nmtb->iItem;
6142 nmtba.pszText = Buffer;
6143 nmtba.cchText = 256;
6144 ZeroMemory(nmtba.pszText, nmtba.cchText);
6146 if (TOOLBAR_SendNotify ((NMHDR *) &nmtba, infoPtr, TBN_GETBUTTONINFOA))
6148 int ccht = strlen(nmtba.pszText);
6150 MultiByteToWideChar(CP_ACP, 0, (LPCSTR)nmtba.pszText, -1,
6151 nmtb->pszText, nmtb->cchText);
6153 memcpy(&nmtb->tbButton, &nmtba.tbButton, sizeof(TBBUTTON));
6162 static BOOL TOOLBAR_IsButtonRemovable(TOOLBAR_INFO *infoPtr,
6163 int iItem, PCUSTOMBUTTON btnInfo)
6168 memcpy(&nmtb.tbButton, &btnInfo->btn, sizeof(TBBUTTON));
6170 return TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYDELETE);