4 * Copyright 1998,1999 Eric Kohl
7 * - A little bug in TOOLBAR_DrawMasked()
8 * - Button wrapping (under construction).
10 * - Notifications (under construction).
12 * - Tooltip support (almost complete).
13 * - Unicode suppport (under construction).
14 * - Fix TOOLBAR_SetButtonInfo32A/W.
15 * - Customize dialog (under construction).
18 * - Run tests using Waite Group Windows95 API Bible Volume 2.
19 * The second cdrom contains executables addstr.exe, btncount.exe,
20 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
21 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
22 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
23 * setparnt.exe, setrows.exe, toolwnd.exe.
24 * - Microsofts controlspy examples.
36 #include "debugtools.h"
38 DEFAULT_DEBUG_CHANNEL(toolbar)
40 #define SEPARATOR_WIDTH 8
42 #define BOTTOM_BORDER 2
44 #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
48 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
50 INT x = (lpRect->left + lpRect->right) / 2 - 1;
51 INT yBottom = lpRect->bottom - 3;
52 INT yTop = lpRect->top + 1;
54 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
55 MoveToEx (hdc, x, yBottom, NULL);
56 LineTo (hdc, x, yTop);
58 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
59 MoveToEx (hdc, x, yBottom, NULL);
60 LineTo (hdc, x, yTop);
65 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
68 RECT rcText = btnPtr->rect;
74 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
75 InflateRect (&rcText, -3, -3);
76 rcText.top += infoPtr->nBitmapHeight;
77 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
78 OffsetRect (&rcText, 1, 1);
80 hOldFont = SelectObject (hdc, infoPtr->hFont);
81 nOldBkMode = SetBkMode (hdc, TRANSPARENT);
82 if (!(nState & TBSTATE_ENABLED)) {
83 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
84 OffsetRect (&rcText, 1, 1);
85 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
86 &rcText, infoPtr->dwDTFlags);
87 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
88 OffsetRect (&rcText, -1, -1);
89 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
90 &rcText, infoPtr->dwDTFlags);
92 else if (nState & TBSTATE_INDETERMINATE) {
93 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
94 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
95 &rcText, infoPtr->dwDTFlags);
98 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
99 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
100 &rcText, infoPtr->dwDTFlags);
103 SetTextColor (hdc, clrOld);
104 SelectObject (hdc, hOldFont);
105 if (nOldBkMode != TRANSPARENT)
106 SetBkMode (hdc, nOldBkMode);
112 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
114 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
115 INT cx = lpRect->right - lpRect->left;
116 INT cy = lpRect->bottom - lpRect->top;
117 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
118 SelectObject (hdc, hbr);
123 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
124 HDC hdc, INT x, INT y)
126 /* FIXME: this function is a hack since it uses image list
127 internals directly */
129 HIMAGELIST himl = infoPtr->himlDef;
137 /* create new dc's */
138 hdcImageList = CreateCompatibleDC (0);
139 hdcMask = CreateCompatibleDC (0);
141 /* create new bitmap */
142 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
143 SelectObject (hdcMask, hbmMask);
145 /* copy the mask bitmap */
146 SelectObject (hdcImageList, himl->hbmMask);
147 SetBkColor (hdcImageList, RGB(255, 255, 255));
148 SetTextColor (hdcImageList, RGB(0, 0, 0));
149 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
150 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
153 /* add white mask from image */
154 SelectObject (hdcImageList, himl->hbmImage);
155 SetBkColor (hdcImageList, RGB(0, 0, 0));
156 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
157 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
160 /* draw the new mask */
161 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
162 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
163 hdcMask, 0, 0, 0xB8074A);
165 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
166 BitBlt (hdc, x, y, himl->cx, himl->cy,
167 hdcMask, 0, 0, 0xB8074A);
169 DeleteObject (hbmMask);
171 DeleteDC (hdcImageList);
176 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
178 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
179 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
182 if (btnPtr->fsState & TBSTATE_HIDDEN)
188 if (btnPtr->fsStyle & TBSTYLE_SEP) {
189 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0))
190 TOOLBAR_DrawFlatSeparator (&rc, hdc);
195 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
196 if (!(dwStyle & TBSTYLE_FLAT))
197 DrawEdge (hdc, &rc, EDGE_RAISED,
198 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
200 if (infoPtr->himlDis)
201 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
202 rc.left+1, rc.top+1, ILD_NORMAL);
204 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
206 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
210 /* pressed TBSTYLE_BUTTON */
211 if (btnPtr->fsState & TBSTATE_PRESSED) {
212 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
213 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
214 rc.left+2, rc.top+2, ILD_NORMAL);
215 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
219 /* checked TBSTYLE_CHECK */
220 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
221 (btnPtr->fsState & TBSTATE_CHECKED)) {
222 if (dwStyle & TBSTYLE_FLAT)
223 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
224 BF_RECT | BF_MIDDLE | BF_ADJUST);
226 DrawEdge (hdc, &rc, EDGE_SUNKEN,
227 BF_RECT | BF_MIDDLE | BF_ADJUST);
229 TOOLBAR_DrawPattern (hdc, &rc);
231 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
232 rc.left+2, rc.top+2, ILD_NORMAL);
234 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
239 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
240 DrawEdge (hdc, &rc, EDGE_RAISED,
241 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
243 TOOLBAR_DrawPattern (hdc, &rc);
244 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
245 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
250 if (dwStyle & TBSTYLE_FLAT)
253 DrawEdge (hdc, &rc, BDR_RAISEDINNER,
254 BF_RECT | BF_MIDDLE | BF_SOFT);
255 if (btnPtr->bHot && infoPtr->himlHot)
256 ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
257 rc.left +2, rc.top +2, ILD_NORMAL);
259 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
260 rc.left +2, rc.top +2, ILD_NORMAL);
264 DrawEdge (hdc, &rc, EDGE_RAISED,
265 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
267 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
268 rc.left+1, rc.top+1, ILD_NORMAL);
271 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
276 TOOLBAR_Refresh (HWND hwnd, HDC hdc)
278 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
279 TBUTTON_INFO *btnPtr;
283 btnPtr = infoPtr->buttons;
284 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
285 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
290 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
292 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
293 TBUTTON_INFO *btnPtr;
302 hOldFont = SelectObject (hdc, infoPtr->hFont);
304 btnPtr = infoPtr->buttons;
305 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
306 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
307 (btnPtr->iString > -1) &&
308 (btnPtr->iString < infoPtr->nNumStrings)) {
309 LPWSTR lpText = infoPtr->strings[btnPtr->iString];
310 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
311 if (sz.cx > lpSize->cx)
313 if (sz.cy > lpSize->cy)
318 SelectObject (hdc, hOldFont);
321 TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy);
324 /***********************************************************************
325 * TOOLBAR_WrapToolbar
327 * This function walks through the buttons and seperators in the
328 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
329 * wrapping should occur based on the width of the toolbar window.
330 * It does *not* calculate button placement itself. That task
331 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
332 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
333 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
337 TOOLBAR_WrapToolbar( HWND hwnd )
339 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
340 TBUTTON_INFO *btnPtr;
341 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
344 BOOL bWrap, bButtonWrap;
346 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
347 /* no layout is necessary. Applications may use this style */
348 /* to perform their own layout on the toolbar. */
349 if( !(dwStyle & TBSTYLE_WRAPABLE) )
352 btnPtr = infoPtr->buttons;
353 x = infoPtr->nIndent;
355 GetClientRect( GetParent(hwnd), &rc );
356 infoPtr->nWidth = rc.right - rc.left;
359 for (i = 0; i < infoPtr->nNumButtons; i++ )
362 btnPtr[i].fsState &= ~TBSTATE_WRAP;
364 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
367 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
368 /* it is the actual width of the separator. This is used for */
369 /* custom controls in toolbars. */
370 if (btnPtr[i].fsStyle & TBSTYLE_SEP)
371 cx = (btnPtr[i].iBitmap > 0) ?
372 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
374 cx = infoPtr->nButtonWidth;
376 /* Two or more adjacent separators form a separator group. */
377 /* The first separator in a group should be wrapped to the */
378 /* next row if the previous wrapping is on a button. */
380 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
381 (i + 1 < infoPtr->nNumButtons ) &&
382 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
384 btnPtr[i].fsState |= TBSTATE_WRAP;
385 x = infoPtr->nIndent;
391 /* The layout makes sure the bitmap is visible, but not the button. */
392 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
397 /* If the current button is a separator and not hidden, */
398 /* go to the next until it reaches a non separator. */
399 /* Wrap the last separator if it is before a button. */
400 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
401 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
402 i < infoPtr->nNumButtons )
408 if( bFound && i < infoPtr->nNumButtons )
411 btnPtr[i].fsState |= TBSTATE_WRAP;
412 x = infoPtr->nIndent;
416 else if ( i >= infoPtr->nNumButtons)
419 /* If the current button is not a separator, find the last */
420 /* separator and wrap it. */
421 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
423 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
424 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
428 x = infoPtr->nIndent;
429 btnPtr[j].fsState |= TBSTATE_WRAP;
435 /* If no separator available for wrapping, wrap one of */
436 /* non-hidden previous button. */
440 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
442 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
447 x = infoPtr->nIndent;
448 btnPtr[j].fsState |= TBSTATE_WRAP;
454 /* If all above failed, wrap the current button. */
457 btnPtr[i].fsState |= TBSTATE_WRAP;
459 x = infoPtr->nIndent;
460 if (btnPtr[i].fsState & TBSTYLE_SEP )
471 /***********************************************************************
472 * TOOLBAR_CalcToolbar
474 * This function calculates button and separator placement. It first
475 * calculates the button sizes, gets the toolbar window width and then
476 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
477 * on. It assigns a new location to each item and sends this location to
478 * the tooltip window if appropriate. Finally, it updates the rcBound
479 * rect and calculates the new required toolbar window height.
483 TOOLBAR_CalcToolbar (HWND hwnd)
485 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
486 TBUTTON_INFO *btnPtr;
487 INT i, nRows, nSepRows;
493 TOOLBAR_CalcStrings (hwnd, &sizeString);
495 if (sizeString.cy > 0)
496 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
497 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
498 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
500 if (sizeString.cx > infoPtr->nBitmapWidth)
501 infoPtr->nButtonWidth = sizeString.cx + 6;
502 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
503 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
505 TOOLBAR_WrapToolbar( hwnd );
507 x = infoPtr->nIndent;
509 cx = infoPtr->nButtonWidth;
510 cy = infoPtr->nButtonHeight;
511 nRows = nSepRows = 0;
513 infoPtr->rcBound.top = y;
514 infoPtr->rcBound.left = x;
515 infoPtr->rcBound.bottom = y + cy;
516 infoPtr->rcBound.right = x;
518 btnPtr = infoPtr->buttons;
519 GetClientRect( GetParent(hwnd), &rc );
520 infoPtr->nWidth = rc.right - rc.left;
522 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
525 if (btnPtr->fsState & TBSTATE_HIDDEN)
527 SetRectEmpty (&btnPtr->rect);
531 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
532 /* it is the actual width of the separator. This is used for */
533 /* custom controls in toolbars. */
534 if (btnPtr->fsStyle & TBSTYLE_SEP)
535 cx = (btnPtr->iBitmap > 0) ?
536 btnPtr->iBitmap : SEPARATOR_WIDTH;
538 cx = infoPtr->nButtonWidth;
540 if (btnPtr->fsState & TBSTATE_WRAP )
543 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
545 if (infoPtr->rcBound.left > x)
546 infoPtr->rcBound.left = x;
547 if (infoPtr->rcBound.right < x + cx)
548 infoPtr->rcBound.right = x + cx;
549 if (infoPtr->rcBound.bottom < y + cy)
550 infoPtr->rcBound.bottom = y + cy;
552 /* Set the toolTip only for non-hidden, non-separator button */
553 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
557 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
558 ti.cbSize = sizeof(TTTOOLINFOA);
560 ti.uId = btnPtr->idCommand;
561 ti.rect = btnPtr->rect;
562 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
566 /* btnPtr->nRow is zero based. The space between the rows is */
567 /* also considered as a row. */
568 btnPtr->nRow = nRows + nSepRows;
571 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
575 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
576 /* it is the actual width of the separator. This is used for */
577 /* custom controls in toolbars. */
578 y += cy + ( (btnPtr->iBitmap > 0 ) ?
579 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
581 /* nSepRows is used to calculate the extra height follwoing */
585 x = infoPtr->nIndent;
592 /* infoPtr->nRows is the number of rows on the toolbar */
593 infoPtr->nRows = nRows + nSepRows + 1;
595 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
597 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
598 nSepRows * SEPARATOR_WIDTH * 2 / 3 +
599 nSepRows * (infoPtr->nBitmapHeight + 1) +
601 TRACE("toolbar height %d\n", infoPtr->nHeight);
606 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
608 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
609 TBUTTON_INFO *btnPtr;
612 btnPtr = infoPtr->buttons;
613 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
614 if (btnPtr->fsState & TBSTATE_HIDDEN)
617 if (btnPtr->fsStyle & TBSTYLE_SEP) {
618 if (PtInRect (&btnPtr->rect, *lpPt)) {
619 TRACE(" ON SEPARATOR %d!\n", i);
624 if (PtInRect (&btnPtr->rect, *lpPt)) {
625 TRACE(" ON BUTTON %d!\n", i);
631 TRACE(" NOWHERE!\n");
637 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
639 TBUTTON_INFO *btnPtr;
642 btnPtr = infoPtr->buttons;
643 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
644 if (btnPtr->idCommand == idCommand) {
645 TRACE("command=%d index=%d\n", idCommand, i);
649 TRACE("no index found for command=%d\n", idCommand);
655 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
657 TBUTTON_INFO *btnPtr;
660 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
663 /* check index button */
664 btnPtr = &infoPtr->buttons[nIndex];
665 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
666 if (btnPtr->fsState & TBSTATE_CHECKED)
670 /* check previous buttons */
671 nRunIndex = nIndex - 1;
672 while (nRunIndex >= 0) {
673 btnPtr = &infoPtr->buttons[nRunIndex];
674 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
675 if (btnPtr->fsState & TBSTATE_CHECKED)
683 /* check next buttons */
684 nRunIndex = nIndex + 1;
685 while (nRunIndex < infoPtr->nNumButtons) {
686 btnPtr = &infoPtr->buttons[nRunIndex];
687 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
688 if (btnPtr->fsState & TBSTATE_CHECKED)
701 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
702 WPARAM wParam, LPARAM lParam)
710 msg.time = GetMessageTime ();
711 msg.pt.x = LOWORD(GetMessagePos ());
712 msg.pt.y = HIWORD(GetMessagePos ());
714 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
718 /***********************************************************************
719 * TOOLBAR_CustomizeDialogProc
720 * This function implements the toolbar customization dialog.
723 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
725 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
726 static HDSA hDsa = NULL;
731 infoPtr = (TOOLBAR_INFO *)lParam;
732 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
734 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
738 TBUTTON_INFO *btnPtr;
741 /* insert 'virtual' separator button into 'available buttons' list */
742 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
744 /* copy all buttons and append them to the right listbox */
745 btnPtr = infoPtr->buttons;
746 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
748 DSA_InsertItem (hDsa, i, btnPtr);
750 /* FIXME: hidden buttons appear in the 'toolbar buttons' list too */
751 if (btnPtr->fsState & TBSTATE_HIDDEN)
753 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
757 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
761 /* append 'virtual' separator button to the 'toolbar buttons' list */
767 EndDialog(hwnd, FALSE);
771 switch (LOWORD(wParam))
774 EndDialog(hwnd, FALSE);
785 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
787 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
793 COLORREF oldText = 0;
796 FIXME("action: %x itemState: %x\n",
797 lpdis->itemAction, lpdis->itemState);
799 DSA_GetItem (hDsa, 0 /*lpdis->itemID*/, &btnPtr);
801 if (lpdis->itemState & ODS_FOCUS)
803 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
804 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
807 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
808 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
810 /* fill background rectangle */
811 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
812 lpdis->rcItem.right, lpdis->rcItem.bottom);
814 /* calculate button and text rectangles */
815 CopyRect (&rcButton, &lpdis->rcItem);
816 InflateRect (&rcButton, -1, -1);
817 CopyRect (&rcText, &rcButton);
818 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
819 rcText.left = rcButton.right + 2;
821 /* draw focus rectangle */
822 if (lpdis->itemState & ODS_FOCUS)
823 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
826 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
828 /* draw image and text */
829 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
831 /* virtual separator in the 'available' list */
832 DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
833 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
839 ImageList_Draw (infoPtr->himlDef, btnPtr.iBitmap, lpdis->hDC,
840 rcButton.left+1, rcButton.top+1, ILD_NORMAL);
842 DrawTextW (lpdis->hDC, infoPtr->strings[btnPtr.iString], -1, &rcText,
843 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
847 if (lpdis->itemState & ODS_FOCUS)
849 SetBkColor (lpdis->hDC, oldBk);
850 SetTextColor (lpdis->hDC, oldText);
853 SelectObject (lpdis->hDC, hOldBrush);
854 SelectObject (lpdis->hDC, hOldPen);
861 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
863 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
866 lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
868 lpmis->itemHeight = 16 + 8; /* default height */
880 /***********************************************************************
881 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
885 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
887 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
888 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
889 INT nIndex = 0, nButtons;
895 if (lpAddBmp->hInst == HINST_COMMCTRL)
897 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
899 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
901 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
906 TRACE ("adding %d internal bitmaps!\n", nButtons);
908 /* Windows resize all the buttons to the size of a newly added standard image */
909 if (lpAddBmp->nID & 1)
912 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
913 MAKELPARAM((WORD)26, (WORD)26));
914 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
915 MAKELPARAM((WORD)33, (WORD)33));
920 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
921 MAKELPARAM((WORD)16, (WORD)16));
922 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
923 MAKELPARAM((WORD)22, (WORD)22));
926 TOOLBAR_CalcToolbar (hwnd);
930 nButtons = (INT)wParam;
934 TRACE ("adding %d bitmaps!\n", nButtons);
937 if (!(infoPtr->himlDef)) {
938 /* create new default image list */
939 TRACE ("creating default image list!\n");
942 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
943 ILC_COLOR | ILC_MASK, nButtons, 2);
944 infoPtr->himlInt = infoPtr->himlDef;
947 /* Add bitmaps to the default image list */
948 if (lpAddBmp->hInst == (HINSTANCE)0)
951 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
954 else if (lpAddBmp->hInst == HINST_COMMCTRL)
956 /* Add system bitmaps */
957 switch (lpAddBmp->nID)
959 case IDB_STD_SMALL_COLOR:
960 hbmLoad = LoadBitmapA (COMCTL32_hModule,
961 MAKEINTRESOURCEA(IDB_STD_SMALL));
962 nIndex = ImageList_AddMasked (infoPtr->himlDef,
963 hbmLoad, CLR_DEFAULT);
964 DeleteObject (hbmLoad);
967 case IDB_STD_LARGE_COLOR:
968 hbmLoad = LoadBitmapA (COMCTL32_hModule,
969 MAKEINTRESOURCEA(IDB_STD_LARGE));
970 nIndex = ImageList_AddMasked (infoPtr->himlDef,
971 hbmLoad, CLR_DEFAULT);
972 DeleteObject (hbmLoad);
975 case IDB_VIEW_SMALL_COLOR:
976 hbmLoad = LoadBitmapA (COMCTL32_hModule,
977 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
978 nIndex = ImageList_AddMasked (infoPtr->himlDef,
979 hbmLoad, CLR_DEFAULT);
980 DeleteObject (hbmLoad);
983 case IDB_VIEW_LARGE_COLOR:
984 hbmLoad = LoadBitmapA (COMCTL32_hModule,
985 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
986 nIndex = ImageList_AddMasked (infoPtr->himlDef,
987 hbmLoad, CLR_DEFAULT);
988 DeleteObject (hbmLoad);
991 case IDB_HIST_SMALL_COLOR:
992 hbmLoad = LoadBitmapA (COMCTL32_hModule,
993 MAKEINTRESOURCEA(IDB_HIST_SMALL));
994 nIndex = ImageList_AddMasked (infoPtr->himlDef,
995 hbmLoad, CLR_DEFAULT);
996 DeleteObject (hbmLoad);
999 case IDB_HIST_LARGE_COLOR:
1000 hbmLoad = LoadBitmapA (COMCTL32_hModule,
1001 MAKEINTRESOURCEA(IDB_HIST_LARGE));
1002 nIndex = ImageList_AddMasked (infoPtr->himlDef,
1003 hbmLoad, CLR_DEFAULT);
1004 DeleteObject (hbmLoad);
1008 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
1009 ERR ("invalid imagelist!\n");
1015 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
1016 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
1017 DeleteObject (hbmLoad);
1020 infoPtr->nNumBitmaps += nButtons;
1027 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1029 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1030 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1031 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1033 TRACE("adding %d buttons!\n", wParam);
1035 nAddButtons = (UINT)wParam;
1036 nOldButtons = infoPtr->nNumButtons;
1037 nNewButtons = nOldButtons + nAddButtons;
1039 if (infoPtr->nNumButtons == 0) {
1041 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1044 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1046 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1047 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1048 nOldButtons * sizeof(TBUTTON_INFO));
1049 COMCTL32_Free (oldButtons);
1052 infoPtr->nNumButtons = nNewButtons;
1054 /* insert new button data */
1055 for (nCount = 0; nCount < nAddButtons; nCount++) {
1056 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1057 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1058 btnPtr->idCommand = lpTbb[nCount].idCommand;
1059 btnPtr->fsState = lpTbb[nCount].fsState;
1060 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1061 btnPtr->dwData = lpTbb[nCount].dwData;
1062 btnPtr->iString = lpTbb[nCount].iString;
1063 btnPtr->bHot = FALSE;
1065 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1068 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1069 ti.cbSize = sizeof (TTTOOLINFOA);
1071 ti.uId = btnPtr->idCommand;
1073 ti.lpszText = LPSTR_TEXTCALLBACKA;
1075 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1080 TOOLBAR_CalcToolbar (hwnd);
1082 InvalidateRect(hwnd, NULL, FALSE);
1089 TOOLBAR_AddButtonsW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1091 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1092 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1093 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1095 TRACE("adding %d buttons!\n", wParam);
1097 nAddButtons = (UINT)wParam;
1098 nOldButtons = infoPtr->nNumButtons;
1099 nNewButtons = nOldButtons + nAddButtons;
1101 if (infoPtr->nNumButtons == 0) {
1103 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1106 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1108 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1109 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1110 nOldButtons * sizeof(TBUTTON_INFO));
1111 COMCTL32_Free (oldButtons);
1114 infoPtr->nNumButtons = nNewButtons;
1116 /* insert new button data */
1117 for (nCount = 0; nCount < nAddButtons; nCount++) {
1118 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1119 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1120 btnPtr->idCommand = lpTbb[nCount].idCommand;
1121 btnPtr->fsState = lpTbb[nCount].fsState;
1122 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1123 btnPtr->dwData = lpTbb[nCount].dwData;
1124 btnPtr->iString = lpTbb[nCount].iString;
1125 btnPtr->bHot = FALSE;
1127 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1130 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
1131 ti.cbSize = sizeof (TTTOOLINFOW);
1133 ti.uId = btnPtr->idCommand;
1135 ti.lpszText = LPSTR_TEXTCALLBACKW;
1137 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
1142 TOOLBAR_CalcToolbar (hwnd);
1144 InvalidateRect(hwnd, NULL, FALSE);
1151 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1153 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1156 if ((wParam) && (HIWORD(lParam) == 0)) {
1159 TRACE("adding string from resource!\n");
1161 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
1164 TRACE("len=%d \"%s\"\n", len, szString);
1165 nIndex = infoPtr->nNumStrings;
1166 if (infoPtr->nNumStrings == 0) {
1168 COMCTL32_Alloc (sizeof(LPWSTR));
1171 LPWSTR *oldStrings = infoPtr->strings;
1173 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1174 memcpy (&infoPtr->strings[0], &oldStrings[0],
1175 sizeof(LPWSTR) * infoPtr->nNumStrings);
1176 COMCTL32_Free (oldStrings);
1179 infoPtr->strings[infoPtr->nNumStrings] =
1180 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1181 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
1182 infoPtr->nNumStrings++;
1185 LPSTR p = (LPSTR)lParam;
1190 TRACE("adding string(s) from array!\n");
1191 nIndex = infoPtr->nNumStrings;
1194 TRACE("len=%d \"%s\"\n", len, p);
1196 if (infoPtr->nNumStrings == 0) {
1198 COMCTL32_Alloc (sizeof(LPWSTR));
1201 LPWSTR *oldStrings = infoPtr->strings;
1203 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1204 memcpy (&infoPtr->strings[0], &oldStrings[0],
1205 sizeof(LPWSTR) * infoPtr->nNumStrings);
1206 COMCTL32_Free (oldStrings);
1209 infoPtr->strings[infoPtr->nNumStrings] =
1210 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1211 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
1212 infoPtr->nNumStrings++;
1223 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1225 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1228 if ((wParam) && (HIWORD(lParam) == 0)) {
1229 WCHAR szString[256];
1231 TRACE("adding string from resource!\n");
1233 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
1236 TRACE("len=%d \"%s\"\n", len, debugstr_w(szString));
1237 nIndex = infoPtr->nNumStrings;
1238 if (infoPtr->nNumStrings == 0) {
1240 COMCTL32_Alloc (sizeof(LPWSTR));
1243 LPWSTR *oldStrings = infoPtr->strings;
1245 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1246 memcpy (&infoPtr->strings[0], &oldStrings[0],
1247 sizeof(LPWSTR) * infoPtr->nNumStrings);
1248 COMCTL32_Free (oldStrings);
1251 infoPtr->strings[infoPtr->nNumStrings] =
1252 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1253 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
1254 infoPtr->nNumStrings++;
1257 LPWSTR p = (LPWSTR)lParam;
1262 TRACE("adding string(s) from array!\n");
1263 nIndex = infoPtr->nNumStrings;
1266 TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
1268 if (infoPtr->nNumStrings == 0) {
1270 COMCTL32_Alloc (sizeof(LPWSTR));
1273 LPWSTR *oldStrings = infoPtr->strings;
1275 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1276 memcpy (&infoPtr->strings[0], &oldStrings[0],
1277 sizeof(LPWSTR) * infoPtr->nNumStrings);
1278 COMCTL32_Free (oldStrings);
1281 infoPtr->strings[infoPtr->nNumStrings] =
1282 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1283 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1284 infoPtr->nNumStrings++;
1295 TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1297 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1298 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1305 TRACE("resize forced!\n");
1307 parent = GetParent (hwnd);
1308 GetClientRect(parent, &parent_rect);
1310 if (dwStyle & CCS_NORESIZE) {
1311 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1316 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1317 TOOLBAR_CalcToolbar (hwnd);
1318 InvalidateRect( hwnd, NULL, TRUE );
1319 cy = infoPtr->nHeight;
1320 cx = infoPtr->nWidth;
1323 if (dwStyle & CCS_NOPARENTALIGN)
1324 uPosFlags |= SWP_NOMOVE;
1326 if (!(dwStyle & CCS_NODIVIDER))
1327 cy += GetSystemMetrics(SM_CYEDGE);
1329 infoPtr->bAutoSize = TRUE;
1330 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
1338 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1340 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1342 return infoPtr->nNumButtons;
1347 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1349 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1351 if (infoPtr == NULL) {
1352 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1353 ERR("infoPtr == NULL!\n");
1357 infoPtr->dwStructSize = (DWORD)wParam;
1364 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1366 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1367 TBUTTON_INFO *btnPtr;
1371 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1375 btnPtr = &infoPtr->buttons[nIndex];
1376 btnPtr->iBitmap = LOWORD(lParam);
1379 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1380 ReleaseDC (hwnd, hdc);
1387 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1389 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1390 TBUTTON_INFO *btnPtr;
1395 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1399 btnPtr = &infoPtr->buttons[nIndex];
1401 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1404 if (LOWORD(lParam) == FALSE)
1405 btnPtr->fsState &= ~TBSTATE_CHECKED;
1407 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1409 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1410 if (nOldIndex == nIndex)
1412 if (nOldIndex != -1)
1413 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1415 btnPtr->fsState |= TBSTATE_CHECKED;
1419 if (nOldIndex != -1)
1420 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1421 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1422 ReleaseDC (hwnd, hdc);
1424 /* FIXME: Send a WM_NOTIFY?? */
1431 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1433 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1435 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1440 TOOLBAR_Customize (HWND hwnd)
1442 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1448 /* send TBN_BEGINADJUST notification */
1449 nmhdr.hwndFrom = hwnd;
1450 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1451 nmhdr.code = TBN_BEGINADJUST;
1453 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1454 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1456 if (!(hRes = FindResourceA (COMCTL32_hModule,
1457 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1461 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1464 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1465 (LPDLGTEMPLATEA)template,
1467 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1470 /* send TBN_ENDADJUST notification */
1471 nmhdr.code = TBN_ENDADJUST;
1473 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1474 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1481 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1483 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1484 INT nIndex = (INT)wParam;
1486 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1489 if ((infoPtr->hwndToolTip) &&
1490 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1493 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1494 ti.cbSize = sizeof (TTTOOLINFOA);
1496 ti.uId = infoPtr->buttons[nIndex].idCommand;
1498 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1501 if (infoPtr->nNumButtons == 1) {
1502 TRACE(" simple delete!\n");
1503 COMCTL32_Free (infoPtr->buttons);
1504 infoPtr->buttons = NULL;
1505 infoPtr->nNumButtons = 0;
1508 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1509 TRACE("complex delete! [nIndex=%d]\n", nIndex);
1511 infoPtr->nNumButtons--;
1512 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1514 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1515 nIndex * sizeof(TBUTTON_INFO));
1518 if (nIndex < infoPtr->nNumButtons) {
1519 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1520 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1523 COMCTL32_Free (oldButtons);
1526 TOOLBAR_CalcToolbar (hwnd);
1528 InvalidateRect (hwnd, NULL, TRUE);
1535 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1537 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1538 TBUTTON_INFO *btnPtr;
1542 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1546 btnPtr = &infoPtr->buttons[nIndex];
1547 if (LOWORD(lParam) == FALSE)
1548 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1550 btnPtr->fsState |= TBSTATE_ENABLED;
1553 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1554 ReleaseDC (hwnd, hdc);
1560 static inline LRESULT
1561 TOOLBAR_GetAnchorHighlight (HWND hwnd)
1563 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1565 return infoPtr->bAnchor;
1570 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1572 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1575 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1579 return infoPtr->buttons[nIndex].iBitmap;
1583 static inline LRESULT
1584 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1586 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1591 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1593 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1594 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1595 INT nIndex = (INT)wParam;
1596 TBUTTON_INFO *btnPtr;
1598 if (infoPtr == NULL)
1604 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1607 btnPtr = &infoPtr->buttons[nIndex];
1608 lpTbb->iBitmap = btnPtr->iBitmap;
1609 lpTbb->idCommand = btnPtr->idCommand;
1610 lpTbb->fsState = btnPtr->fsState;
1611 lpTbb->fsStyle = btnPtr->fsStyle;
1612 lpTbb->dwData = btnPtr->dwData;
1613 lpTbb->iString = btnPtr->iString;
1620 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1622 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1623 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1624 TBUTTON_INFO *btnPtr;
1627 if (infoPtr == NULL)
1629 if (lpTbInfo == NULL)
1631 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1634 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1638 btnPtr = &infoPtr->buttons[nIndex];
1640 if (lpTbInfo->dwMask & TBIF_COMMAND)
1641 lpTbInfo->idCommand = btnPtr->idCommand;
1642 if (lpTbInfo->dwMask & TBIF_IMAGE)
1643 lpTbInfo->iImage = btnPtr->iBitmap;
1644 if (lpTbInfo->dwMask & TBIF_LPARAM)
1645 lpTbInfo->lParam = btnPtr->dwData;
1646 if (lpTbInfo->dwMask & TBIF_SIZE)
1647 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1648 if (lpTbInfo->dwMask & TBIF_STATE)
1649 lpTbInfo->fsState = btnPtr->fsState;
1650 if (lpTbInfo->dwMask & TBIF_STYLE)
1651 lpTbInfo->fsStyle = btnPtr->fsStyle;
1652 if (lpTbInfo->dwMask & TBIF_TEXT) {
1653 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1654 lstrcpynWtoA (lpTbInfo->pszText,
1655 (LPWSTR)infoPtr->strings[btnPtr->iString],
1664 TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1666 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1667 LPTBBUTTONINFOW lpTbInfo = (LPTBBUTTONINFOW)lParam;
1668 TBUTTON_INFO *btnPtr;
1671 if (infoPtr == NULL)
1673 if (lpTbInfo == NULL)
1675 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW))
1678 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1682 btnPtr = &infoPtr->buttons[nIndex];
1684 if (lpTbInfo->dwMask & TBIF_COMMAND)
1685 lpTbInfo->idCommand = btnPtr->idCommand;
1686 if (lpTbInfo->dwMask & TBIF_IMAGE)
1687 lpTbInfo->iImage = btnPtr->iBitmap;
1688 if (lpTbInfo->dwMask & TBIF_LPARAM)
1689 lpTbInfo->lParam = btnPtr->dwData;
1690 if (lpTbInfo->dwMask & TBIF_SIZE)
1691 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1692 if (lpTbInfo->dwMask & TBIF_STATE)
1693 lpTbInfo->fsState = btnPtr->fsState;
1694 if (lpTbInfo->dwMask & TBIF_STYLE)
1695 lpTbInfo->fsStyle = btnPtr->fsStyle;
1696 if (lpTbInfo->dwMask & TBIF_TEXT) {
1697 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1698 lstrcpynW (lpTbInfo->pszText,
1699 (LPWSTR)infoPtr->strings[btnPtr->iString],
1708 TOOLBAR_GetButtonSize (HWND hwnd)
1710 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1712 return MAKELONG((WORD)infoPtr->nButtonWidth,
1713 (WORD)infoPtr->nButtonHeight);
1718 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1720 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1721 INT nIndex, nStringIndex;
1723 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1727 nStringIndex = infoPtr->buttons[nIndex].iString;
1729 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1731 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1737 lstrcpyWtoA ((LPSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1739 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1744 TOOLBAR_GetButtonTextW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1746 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1747 INT nIndex, nStringIndex;
1749 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1753 nStringIndex = infoPtr->buttons[nIndex].iString;
1755 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1757 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1763 lstrcpyW ((LPWSTR)lParam, (LPWSTR)infoPtr->strings[nStringIndex]);
1765 return lstrlenW ((LPWSTR)infoPtr->strings[nStringIndex]);
1769 /* << TOOLBAR_GetColorScheme >> */
1773 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1775 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1777 return (LRESULT)infoPtr->himlDis;
1781 inline static LRESULT
1782 TOOLBAR_GetExtendedStyle (HWND hwnd)
1784 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1786 return infoPtr->dwExStyle;
1791 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1793 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1795 return (LRESULT)infoPtr->himlHot;
1800 TOOLBAR_GetHotItem (HWND hwnd)
1802 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1804 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
1807 if (infoPtr->nHotItem < 0)
1810 return (LRESULT)infoPtr->nHotItem;
1815 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1817 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1819 return (LRESULT)infoPtr->himlDef;
1823 /* << TOOLBAR_GetInsertMark >> */
1824 /* << TOOLBAR_GetInsertMarkColor >> */
1828 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1830 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1831 TBUTTON_INFO *btnPtr;
1835 if (infoPtr == NULL)
1837 nIndex = (INT)wParam;
1838 btnPtr = &infoPtr->buttons[nIndex];
1839 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1841 lpRect = (LPRECT)lParam;
1844 if (btnPtr->fsState & TBSTATE_HIDDEN)
1847 TOOLBAR_CalcToolbar( hwnd );
1849 lpRect->left = btnPtr->rect.left;
1850 lpRect->right = btnPtr->rect.right;
1851 lpRect->bottom = btnPtr->rect.bottom;
1852 lpRect->top = btnPtr->rect.top;
1859 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1861 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1862 LPSIZE lpSize = (LPSIZE)lParam;
1867 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1868 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1870 TRACE("maximum size %d x %d\n",
1871 infoPtr->rcBound.right - infoPtr->rcBound.left,
1872 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1878 /* << TOOLBAR_GetObject >> */
1879 /* << TOOLBAR_GetPadding >> */
1883 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1885 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1886 TBUTTON_INFO *btnPtr;
1890 if (infoPtr == NULL)
1892 nIndex = (INT)wParam;
1893 btnPtr = &infoPtr->buttons[nIndex];
1894 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1896 lpRect = (LPRECT)lParam;
1900 lpRect->left = btnPtr->rect.left;
1901 lpRect->right = btnPtr->rect.right;
1902 lpRect->bottom = btnPtr->rect.bottom;
1903 lpRect->top = btnPtr->rect.top;
1910 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1912 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1914 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1915 return infoPtr->nRows;
1922 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1924 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1927 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1931 return infoPtr->buttons[nIndex].fsState;
1936 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1938 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1941 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1945 return infoPtr->buttons[nIndex].fsStyle;
1950 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1952 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1954 if (infoPtr == NULL)
1957 return infoPtr->nMaxTextRows;
1962 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1964 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1966 if (infoPtr == NULL)
1968 return infoPtr->hwndToolTip;
1973 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1975 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1977 TRACE("%s hwnd=0x%x stub!\n",
1978 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
1980 return infoPtr->bUnicode;
1984 inline static LRESULT
1985 TOOLBAR_GetVersion (HWND hwnd)
1987 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1988 return infoPtr->iVersion;
1993 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1995 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1996 TBUTTON_INFO *btnPtr;
1999 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2003 btnPtr = &infoPtr->buttons[nIndex];
2004 if (LOWORD(lParam) == FALSE)
2005 btnPtr->fsState &= ~TBSTATE_HIDDEN;
2007 btnPtr->fsState |= TBSTATE_HIDDEN;
2009 TOOLBAR_CalcToolbar (hwnd);
2011 InvalidateRect (hwnd, NULL, TRUE);
2017 inline static LRESULT
2018 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
2020 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
2025 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2027 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2028 TBUTTON_INFO *btnPtr;
2032 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2036 btnPtr = &infoPtr->buttons[nIndex];
2037 if (LOWORD(lParam) == FALSE)
2038 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
2040 btnPtr->fsState |= TBSTATE_INDETERMINATE;
2043 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2044 ReleaseDC (hwnd, hdc);
2051 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2053 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2054 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2055 INT nIndex = (INT)wParam;
2056 TBUTTON_INFO *oldButtons;
2062 /* EPP: this seems to be an undocumented call (from my IE4)
2063 * I assume in that case that:
2064 * - lpTbb->iString is a string pointer (not a string index in strings[] table
2065 * - index of insertion is at the end of existing buttons
2066 * I only see this happen with nIndex == -1, but it could have a special
2067 * meaning (like -nIndex (or ~nIndex) to get the real position of insertion).
2069 int len = lstrlenA((char*)lpTbb->iString) + 2;
2070 LPSTR ptr = COMCTL32_Alloc(len);
2072 nIndex = infoPtr->nNumButtons;
2073 strcpy(ptr, (char*)lpTbb->iString);
2074 ptr[len - 1] = 0; /* ended by two '\0' */
2075 lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr);
2078 } else if (nIndex < 0)
2081 TRACE("inserting button index=%d\n", nIndex);
2082 if (nIndex > infoPtr->nNumButtons) {
2083 nIndex = infoPtr->nNumButtons;
2084 TRACE("adjust index=%d\n", nIndex);
2087 oldButtons = infoPtr->buttons;
2088 infoPtr->nNumButtons++;
2089 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2090 /* pre insert copy */
2092 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2093 nIndex * sizeof(TBUTTON_INFO));
2096 /* insert new button */
2097 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2098 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2099 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2100 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2101 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2102 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2104 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2107 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
2108 ti.cbSize = sizeof (TTTOOLINFOA);
2110 ti.uId = lpTbb->idCommand;
2112 ti.lpszText = LPSTR_TEXTCALLBACKA;
2114 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
2118 /* post insert copy */
2119 if (nIndex < infoPtr->nNumButtons - 1) {
2120 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2121 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2124 COMCTL32_Free (oldButtons);
2126 TOOLBAR_CalcToolbar (hwnd);
2128 InvalidateRect (hwnd, NULL, FALSE);
2135 TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2137 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2138 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
2139 INT nIndex = (INT)wParam;
2140 TBUTTON_INFO *oldButtons;
2147 TRACE("inserting button index=%d\n", nIndex);
2148 if (nIndex > infoPtr->nNumButtons) {
2149 nIndex = infoPtr->nNumButtons;
2150 TRACE("adjust index=%d\n", nIndex);
2153 oldButtons = infoPtr->buttons;
2154 infoPtr->nNumButtons++;
2155 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
2156 /* pre insert copy */
2158 memcpy (&infoPtr->buttons[0], &oldButtons[0],
2159 nIndex * sizeof(TBUTTON_INFO));
2162 /* insert new button */
2163 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
2164 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
2165 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
2166 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
2167 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
2168 infoPtr->buttons[nIndex].iString = lpTbb->iString;
2170 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
2173 ZeroMemory (&ti, sizeof(TTTOOLINFOW));
2174 ti.cbSize = sizeof (TTTOOLINFOW);
2176 ti.uId = lpTbb->idCommand;
2178 ti.lpszText = LPSTR_TEXTCALLBACKW;
2180 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
2184 /* post insert copy */
2185 if (nIndex < infoPtr->nNumButtons - 1) {
2186 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
2187 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
2190 COMCTL32_Free (oldButtons);
2192 TOOLBAR_CalcToolbar (hwnd);
2194 InvalidateRect (hwnd, NULL, FALSE);
2200 /* << TOOLBAR_InsertMarkHitTest >> */
2204 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
2206 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2209 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2213 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
2218 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
2220 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2223 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2227 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
2232 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
2234 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2237 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2241 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
2246 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
2248 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2251 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2255 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
2260 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2262 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2265 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2269 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
2274 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
2276 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2279 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2283 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
2287 /* << TOOLBAR_LoadImages >> */
2288 /* << TOOLBAR_MapAccelerator >> */
2289 /* << TOOLBAR_MarkButton >> */
2290 /* << TOOLBAR_MoveButton >> */
2294 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2296 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2297 TBUTTON_INFO *btnPtr;
2301 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2305 btnPtr = &infoPtr->buttons[nIndex];
2306 if (LOWORD(lParam) == FALSE)
2307 btnPtr->fsState &= ~TBSTATE_PRESSED;
2309 btnPtr->fsState |= TBSTATE_PRESSED;
2312 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2313 ReleaseDC (hwnd, hdc);
2319 /* << TOOLBAR_ReplaceBitmap >> */
2323 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2326 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2327 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2329 if (lpSave == NULL) return 0;
2332 /* save toolbar information */
2333 FIXME("save to \"%s\" \"%s\"\n",
2334 lpSave->pszSubKey, lpSave->pszValueName);
2339 /* restore toolbar information */
2341 FIXME("restore from \"%s\" \"%s\"\n",
2342 lpSave->pszSubKey, lpSave->pszValueName);
2353 TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2356 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2357 LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam;
2363 /* save toolbar information */
2364 FIXME("save to \"%s\" \"%s\"\n",
2365 lpSave->pszSubKey, lpSave->pszValueName);
2370 /* restore toolbar information */
2372 FIXME("restore from \"%s\" \"%s\"\n",
2373 lpSave->pszSubKey, lpSave->pszValueName);
2384 TOOLBAR_SetAnchorHighlight (HWND hwnd, WPARAM wParam)
2386 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2387 BOOL bOldAnchor = infoPtr->bAnchor;
2389 infoPtr->bAnchor = (BOOL)wParam;
2391 return (LRESULT)bOldAnchor;
2396 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2398 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2400 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2403 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2404 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2411 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2413 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2414 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2415 TBUTTON_INFO *btnPtr;
2420 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2423 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2427 btnPtr = &infoPtr->buttons[nIndex];
2428 if (lptbbi->dwMask & TBIF_COMMAND)
2429 btnPtr->idCommand = lptbbi->idCommand;
2430 if (lptbbi->dwMask & TBIF_IMAGE)
2431 btnPtr->iBitmap = lptbbi->iImage;
2432 if (lptbbi->dwMask & TBIF_LPARAM)
2433 btnPtr->dwData = lptbbi->lParam;
2434 /* if (lptbbi->dwMask & TBIF_SIZE) */
2435 /* btnPtr->cx = lptbbi->cx; */
2436 if (lptbbi->dwMask & TBIF_STATE)
2437 btnPtr->fsState = lptbbi->fsState;
2438 if (lptbbi->dwMask & TBIF_STYLE)
2439 btnPtr->fsStyle = lptbbi->fsStyle;
2441 if (lptbbi->dwMask & TBIF_TEXT) {
2442 if ((btnPtr->iString >= 0) ||
2443 (btnPtr->iString < infoPtr->nNumStrings)) {
2444 TRACE("Ooooooch\n");
2446 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2447 INT len = lstrlenA (lptbbi->pszText);
2448 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2451 /* this is the ultimate sollution */
2452 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2461 TOOLBAR_SetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
2463 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2464 LPTBBUTTONINFOW lptbbi = (LPTBBUTTONINFOW)lParam;
2465 TBUTTON_INFO *btnPtr;
2470 if (lptbbi->cbSize < sizeof(TBBUTTONINFOW))
2473 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2477 btnPtr = &infoPtr->buttons[nIndex];
2478 if (lptbbi->dwMask & TBIF_COMMAND)
2479 btnPtr->idCommand = lptbbi->idCommand;
2480 if (lptbbi->dwMask & TBIF_IMAGE)
2481 btnPtr->iBitmap = lptbbi->iImage;
2482 if (lptbbi->dwMask & TBIF_LPARAM)
2483 btnPtr->dwData = lptbbi->lParam;
2484 /* if (lptbbi->dwMask & TBIF_SIZE) */
2485 /* btnPtr->cx = lptbbi->cx; */
2486 if (lptbbi->dwMask & TBIF_STATE)
2487 btnPtr->fsState = lptbbi->fsState;
2488 if (lptbbi->dwMask & TBIF_STYLE)
2489 btnPtr->fsStyle = lptbbi->fsStyle;
2491 if (lptbbi->dwMask & TBIF_TEXT) {
2492 if ((btnPtr->iString >= 0) ||
2493 (btnPtr->iString < infoPtr->nNumStrings)) {
2495 WCHAR **lpString = &infoPtr->strings[btnPtr->iString];
2496 INT len = lstrlenW (lptbbi->pszText);
2497 *lpString = COMCTL32_ReAlloc (lpString, sizeof(WCHAR)*(len+1));
2500 /* this is the ultimate sollution */
2501 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2510 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2512 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2514 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2517 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2518 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2525 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2527 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2529 if (infoPtr == NULL)
2532 infoPtr->cxMin = (INT)LOWORD(lParam);
2533 infoPtr->cxMax = (INT)HIWORD(lParam);
2540 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2542 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2543 INT nIndex = (INT)wParam;
2545 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2548 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2550 if (infoPtr->hwndToolTip) {
2552 FIXME("change tool tip!\n");
2560 /* << TOOLBAR_SetColorScheme >> */
2564 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2566 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2567 HIMAGELIST himlTemp;
2569 himlTemp = infoPtr->himlDis;
2570 infoPtr->himlDis = (HIMAGELIST)lParam;
2572 /* FIXME: redraw ? */
2574 return (LRESULT)himlTemp;
2579 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2581 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2584 dwTemp = infoPtr->dwDTFlags;
2585 infoPtr->dwDTFlags =
2586 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2588 return (LRESULT)dwTemp;
2593 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2595 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2598 dwTemp = infoPtr->dwExStyle;
2599 infoPtr->dwExStyle = (DWORD)lParam;
2601 return (LRESULT)dwTemp;
2606 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2608 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2609 HIMAGELIST himlTemp;
2611 himlTemp = infoPtr->himlHot;
2612 infoPtr->himlHot = (HIMAGELIST)lParam;
2614 /* FIXME: redraw ? */
2616 return (LRESULT)himlTemp;
2621 TOOLBAR_SetHotItem (HWND hwnd, WPARAM wParam)
2623 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2624 INT nOldHotItem = infoPtr->nHotItem;
2626 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
2628 infoPtr->nHotItem = (INT)wParam;
2630 /* FIXME: What else must be done ??? */
2634 if (nOldHotItem < 0)
2637 return (LRESULT)nOldHotItem;
2642 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2644 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2645 HIMAGELIST himlTemp;
2647 himlTemp = infoPtr->himlDef;
2648 infoPtr->himlDef = (HIMAGELIST)lParam;
2650 /* FIXME: redraw ? */
2652 return (LRESULT)himlTemp;
2657 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2659 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2661 infoPtr->nIndent = (INT)wParam;
2663 TOOLBAR_CalcToolbar (hwnd);
2665 InvalidateRect(hwnd, NULL, FALSE);
2671 /* << TOOLBAR_SetInsertMark >> */
2675 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2677 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2679 infoPtr->clrInsertMark = (COLORREF)lParam;
2681 /* FIXME : redraw ??*/
2688 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2690 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2692 if (infoPtr == NULL)
2695 infoPtr->nMaxTextRows = (INT)wParam;
2701 /* << TOOLBAR_SetPadding >> */
2705 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2707 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2710 if (infoPtr == NULL)
2712 hwndOldNotify = infoPtr->hwndNotify;
2713 infoPtr->hwndNotify = (HWND)wParam;
2715 return hwndOldNotify;
2720 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2722 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2723 LPRECT lprc = (LPRECT)lParam;
2725 if (LOWORD(wParam) > 1) {
2727 FIXME("multiple rows not supported!\n");
2731 /* recalculate toolbar */
2732 TOOLBAR_CalcToolbar (hwnd);
2734 /* return bounding rectangle */
2736 lprc->left = infoPtr->rcBound.left;
2737 lprc->right = infoPtr->rcBound.right;
2738 lprc->top = infoPtr->rcBound.top;
2739 lprc->bottom = infoPtr->rcBound.bottom;
2742 /* repaint toolbar */
2743 InvalidateRect(hwnd, NULL, FALSE);
2750 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2752 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2753 TBUTTON_INFO *btnPtr;
2757 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2761 btnPtr = &infoPtr->buttons[nIndex];
2762 btnPtr->fsState = LOWORD(lParam);
2765 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2766 ReleaseDC (hwnd, hdc);
2773 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2775 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2776 TBUTTON_INFO *btnPtr;
2780 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2784 btnPtr = &infoPtr->buttons[nIndex];
2785 btnPtr->fsStyle = LOWORD(lParam);
2788 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2789 ReleaseDC (hwnd, hdc);
2791 if (infoPtr->hwndToolTip) {
2793 FIXME("change tool tip!\n");
2801 inline static LRESULT
2802 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2804 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2806 if (infoPtr == NULL)
2808 infoPtr->hwndToolTip = (HWND)wParam;
2814 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2816 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2819 TRACE("%s hwnd=0x%04x stub!\n",
2820 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2822 bTemp = infoPtr->bUnicode;
2823 infoPtr->bUnicode = (BOOL)wParam;
2830 TOOLBAR_SetVersion (HWND hwnd, INT iVersion)
2832 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2833 INT iOldVersion = infoPtr->iVersion;
2835 infoPtr->iVersion = iVersion;
2842 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2844 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2845 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2848 /* initialize info structure */
2849 infoPtr->nButtonHeight = 22;
2850 infoPtr->nButtonWidth = 23;
2851 infoPtr->nBitmapHeight = 15;
2852 infoPtr->nBitmapWidth = 16;
2854 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2856 infoPtr->nMaxTextRows = 1;
2857 infoPtr->cxMin = -1;
2858 infoPtr->cxMax = -1;
2860 infoPtr->bCaptured = FALSE;
2861 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2862 infoPtr->nButtonDown = -1;
2863 infoPtr->nOldHit = -1;
2864 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2865 infoPtr->hwndNotify = GetParent (hwnd);
2866 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2867 infoPtr->dwDTFlags = DT_CENTER;
2868 infoPtr->bAnchor = FALSE; /* no anchor highlighting */
2869 infoPtr->iVersion = 0;
2871 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2872 infoPtr->hFont = CreateFontIndirectA (&logFont);
2874 if (dwStyle & TBSTYLE_TOOLTIPS) {
2875 /* Create tooltip control */
2876 infoPtr->hwndToolTip =
2877 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2878 CW_USEDEFAULT, CW_USEDEFAULT,
2879 CW_USEDEFAULT, CW_USEDEFAULT,
2882 /* Send NM_TOOLTIPSCREATED notification */
2883 if (infoPtr->hwndToolTip) {
2884 NMTOOLTIPSCREATED nmttc;
2886 nmttc.hdr.hwndFrom = hwnd;
2887 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2888 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2889 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2891 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2892 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2901 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2903 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2905 /* delete tooltip control */
2906 if (infoPtr->hwndToolTip)
2907 DestroyWindow (infoPtr->hwndToolTip);
2909 /* delete button data */
2910 if (infoPtr->buttons)
2911 COMCTL32_Free (infoPtr->buttons);
2913 /* delete strings */
2914 if (infoPtr->strings) {
2916 for (i = 0; i < infoPtr->nNumStrings; i++)
2917 if (infoPtr->strings[i])
2918 COMCTL32_Free (infoPtr->strings[i]);
2920 COMCTL32_Free (infoPtr->strings);
2923 /* destroy internal image list */
2924 if (infoPtr->himlInt)
2925 ImageList_Destroy (infoPtr->himlInt);
2927 /* delete default font */
2929 DeleteObject (infoPtr->hFont);
2931 /* free toolbar info data */
2932 COMCTL32_Free (infoPtr);
2939 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2941 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2943 if (infoPtr->bTransparent)
2944 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2946 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2951 TOOLBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
2953 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2955 return infoPtr->hFont;
2960 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
2962 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2963 TBUTTON_INFO *btnPtr;
2968 pt.x = (INT)LOWORD(lParam);
2969 pt.y = (INT)HIWORD(lParam);
2970 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2973 btnPtr = &infoPtr->buttons[nHit];
2974 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2977 infoPtr->bCaptured = TRUE;
2978 infoPtr->nButtonDown = nHit;
2980 btnPtr->fsState |= TBSTATE_PRESSED;
2983 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2984 ReleaseDC (hwnd, hdc);
2986 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
2987 TOOLBAR_Customize (hwnd);
2994 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
2996 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2997 TBUTTON_INFO *btnPtr;
3002 if (infoPtr->hwndToolTip)
3003 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3004 WM_LBUTTONDOWN, wParam, lParam);
3006 pt.x = (INT)LOWORD(lParam);
3007 pt.y = (INT)HIWORD(lParam);
3008 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3011 btnPtr = &infoPtr->buttons[nHit];
3012 if (!(btnPtr->fsState & TBSTATE_ENABLED))
3015 if (btnPtr->fsStyle & TBSTYLE_DROPDOWN)
3019 nmtb.hdr.hwndFrom = hwnd;
3020 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3021 nmtb.hdr.code = TBN_DROPDOWN;
3022 nmtb.iItem = btnPtr->idCommand;
3024 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
3025 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3029 infoPtr->bCaptured = TRUE;
3030 infoPtr->nButtonDown = nHit;
3031 infoPtr->nOldHit = nHit;
3033 btnPtr->fsState |= TBSTATE_PRESSED;
3036 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3037 ReleaseDC (hwnd, hdc);
3044 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
3046 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3047 TBUTTON_INFO *btnPtr;
3052 BOOL bSendMessage = TRUE;
3054 if (infoPtr->hwndToolTip)
3055 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3056 WM_LBUTTONUP, wParam, lParam);
3058 pt.x = (INT)LOWORD(lParam);
3059 pt.y = (INT)HIWORD(lParam);
3060 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3062 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
3063 infoPtr->bCaptured = FALSE;
3065 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3066 btnPtr->fsState &= ~TBSTATE_PRESSED;
3068 if (nHit == infoPtr->nButtonDown) {
3069 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
3070 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
3071 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
3072 infoPtr->nButtonDown);
3073 if (nOldIndex == infoPtr->nButtonDown)
3074 bSendMessage = FALSE;
3075 if ((nOldIndex != infoPtr->nButtonDown) &&
3077 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
3078 btnPtr->fsState |= TBSTATE_CHECKED;
3081 if (btnPtr->fsState & TBSTATE_CHECKED)
3082 btnPtr->fsState &= ~TBSTATE_CHECKED;
3084 btnPtr->fsState |= TBSTATE_CHECKED;
3089 bSendMessage = FALSE;
3092 if (nOldIndex != -1)
3093 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
3094 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3095 ReleaseDC (hwnd, hdc);
3098 SendMessageA (GetParent(hwnd), WM_COMMAND,
3099 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
3101 if ((GetWindowLongA(hwnd, GWL_STYLE) & TBSTYLE_DROPDOWN) ||
3102 (btnPtr->fsStyle & 0x08/* BTNS_DROPDOWN */)) {
3105 nmtb.hdr.hwndFrom = hwnd;
3106 nmtb.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
3107 nmtb.hdr.code = TBN_DROPDOWN;
3109 /* nmtb.tbButton not used with TBN_DROPDOWN */
3110 if ((btnPtr->iString >= 0) && (btnPtr->iString < infoPtr->nNumStrings)) {
3111 nmtb.pszText = infoPtr->strings[btnPtr->iString];
3112 nmtb.cchText = lstrlenW(nmtb.pszText);
3114 nmtb.pszText = NULL;
3117 nmtb.rcButton = btnPtr->rect;
3119 SendMessageW(infoPtr->hwndNotify, WM_NOTIFY,
3120 (WPARAM)nmtb.hdr.idFrom, (LPARAM)&nmtb);
3123 infoPtr->nButtonDown = -1;
3124 infoPtr->nOldHit = -1;
3132 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
3134 TBUTTON_INFO *btnPtr, *oldBtnPtr;
3135 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3140 if (infoPtr->hwndToolTip)
3141 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
3142 WM_MOUSEMOVE, wParam, lParam);
3144 pt.x = (INT)LOWORD(lParam);
3145 pt.y = (INT)HIWORD(lParam);
3147 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
3149 if (infoPtr->nOldHit != nHit)
3151 /* Remove the effect of an old hot button */
3152 if(infoPtr->nOldHit == infoPtr->nHotItem)
3154 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
3155 oldBtnPtr->bHot = FALSE;
3157 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
3160 /* It's not a separator or in nowhere. It's a hot button. */
3163 btnPtr = &infoPtr->buttons[nHit];
3164 btnPtr->bHot = TRUE;
3167 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3168 ReleaseDC (hwnd, hdc);
3170 infoPtr->nHotItem = nHit;
3173 if (infoPtr->bCaptured) {
3174 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
3175 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
3176 btnPtr->fsState &= ~TBSTATE_PRESSED;
3178 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3179 ReleaseDC (hwnd, hdc);
3181 else if (nHit == infoPtr->nButtonDown) {
3182 btnPtr->fsState |= TBSTATE_PRESSED;
3184 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
3185 ReleaseDC (hwnd, hdc);
3188 infoPtr->nOldHit = nHit;
3194 inline static LRESULT
3195 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3197 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
3198 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
3200 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
3204 inline static LRESULT
3205 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
3207 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
3208 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
3210 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
3215 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
3217 TOOLBAR_INFO *infoPtr;
3219 /* allocate memory for info structure */
3220 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
3221 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
3224 infoPtr->dwStructSize = sizeof(TBBUTTON);
3226 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
3227 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
3228 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
3229 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
3232 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
3237 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
3239 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3243 if (dwStyle & WS_MINIMIZE)
3244 return 0; /* Nothing to do */
3246 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
3248 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
3251 if (!(dwStyle & CCS_NODIVIDER))
3253 GetWindowRect (hwnd, &rcWindow);
3254 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
3255 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
3258 ReleaseDC( hwnd, hdc );
3264 inline static LRESULT
3265 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
3267 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3268 LPNMHDR lpnmh = (LPNMHDR)lParam;
3270 TRACE("passing WM_NOTIFY!\n");
3272 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
3273 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
3276 if (lpnmh->code == TTN_GETDISPINFOA) {
3277 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
3279 FIXME("retrieving ASCII string\n");
3282 else if (lpnmh->code == TTN_GETDISPINFOW) {
3283 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
3285 FIXME("retrieving UNICODE string\n");
3296 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
3301 TOOLBAR_CalcToolbar( hwnd );
3302 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
3303 TOOLBAR_Refresh (hwnd, hdc);
3305 EndPaint (hwnd, &ps);
3311 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
3313 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
3314 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
3322 /* Resize deadlock check */
3323 if (infoPtr->bAutoSize) {
3324 infoPtr->bAutoSize = FALSE;
3328 flags = (INT) wParam;
3330 /* FIXME for flags =
3331 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
3334 TRACE("sizing toolbar!\n");
3336 if (flags == SIZE_RESTORED) {
3337 /* width and height don't apply */
3338 parent = GetParent (hwnd);
3339 GetClientRect(parent, &parent_rect);
3341 if (dwStyle & CCS_NORESIZE) {
3342 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
3345 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
3346 cy = infoPtr->nHeight;
3347 cx = infoPtr->nWidth;
3348 TOOLBAR_CalcToolbar (hwnd);
3349 infoPtr->nWidth = cx;
3350 infoPtr->nHeight = cy;
3353 infoPtr->nWidth = parent_rect.right - parent_rect.left;
3354 TOOLBAR_CalcToolbar (hwnd);
3355 cy = infoPtr->nHeight;
3356 cx = infoPtr->nWidth;
3359 if (dwStyle & CCS_NOPARENTALIGN) {
3360 uPosFlags |= SWP_NOMOVE;
3361 cy = infoPtr->nHeight;
3362 cx = infoPtr->nWidth;
3365 if (!(dwStyle & CCS_NODIVIDER))
3366 cy += GetSystemMetrics(SM_CYEDGE);
3368 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
3369 cx, cy, uPosFlags | SWP_NOZORDER);
3376 TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
3378 TOOLBAR_AutoSize (hwnd, wParam, lParam);
3380 InvalidateRect(hwnd, NULL, FALSE);
3387 static LRESULT WINAPI
3388 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
3393 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
3395 case TB_ADDBUTTONSA:
3396 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
3398 case TB_ADDBUTTONSW:
3399 return TOOLBAR_AddButtonsW (hwnd, wParam, lParam);
3402 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
3405 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
3408 return TOOLBAR_AutoSize (hwnd, wParam, lParam);
3410 case TB_BUTTONCOUNT:
3411 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
3413 case TB_BUTTONSTRUCTSIZE:
3414 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
3416 case TB_CHANGEBITMAP:
3417 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
3419 case TB_CHECKBUTTON:
3420 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
3422 case TB_COMMANDTOINDEX:
3423 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
3426 return TOOLBAR_Customize (hwnd);
3428 case TB_DELETEBUTTON:
3429 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
3431 case TB_ENABLEBUTTON:
3432 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
3434 case TB_GETANCHORHIGHLIGHT:
3435 return TOOLBAR_GetAnchorHighlight (hwnd);
3438 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
3440 case TB_GETBITMAPFLAGS:
3441 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
3444 return TOOLBAR_GetButton (hwnd, wParam, lParam);
3446 case TB_GETBUTTONINFOA:
3447 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
3449 case TB_GETBUTTONINFOW:
3450 return TOOLBAR_GetButtonInfoW (hwnd, wParam, lParam);
3452 case TB_GETBUTTONSIZE:
3453 return TOOLBAR_GetButtonSize (hwnd);
3455 case TB_GETBUTTONTEXTA:
3456 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3458 case TB_GETBUTTONTEXTW:
3459 return TOOLBAR_GetButtonTextW (hwnd, wParam, lParam);
3461 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
3463 case TB_GETDISABLEDIMAGELIST:
3464 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3466 case TB_GETEXTENDEDSTYLE:
3467 return TOOLBAR_GetExtendedStyle (hwnd);
3469 case TB_GETHOTIMAGELIST:
3470 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3473 return TOOLBAR_GetHotItem (hwnd);
3475 case TB_GETIMAGELIST:
3476 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3478 /* case TB_GETINSERTMARK: */ /* 4.71 */
3479 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3481 case TB_GETITEMRECT:
3482 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3485 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3487 /* case TB_GETOBJECT: */ /* 4.71 */
3488 /* case TB_GETPADDING: */ /* 4.71 */
3491 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3494 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3497 return TOOLBAR_GetState (hwnd, wParam, lParam);
3500 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3502 case TB_GETTEXTROWS:
3503 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3505 case TB_GETTOOLTIPS:
3506 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3508 case TB_GETUNICODEFORMAT:
3509 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3511 case CCM_GETVERSION:
3512 return TOOLBAR_GetVersion (hwnd);
3515 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3518 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3520 case TB_INDETERMINATE:
3521 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3523 case TB_INSERTBUTTONA:
3524 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3526 case TB_INSERTBUTTONW:
3527 return TOOLBAR_InsertButtonW (hwnd, wParam, lParam);
3529 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3531 case TB_ISBUTTONCHECKED:
3532 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3534 case TB_ISBUTTONENABLED:
3535 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3537 case TB_ISBUTTONHIDDEN:
3538 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3540 case TB_ISBUTTONHIGHLIGHTED:
3541 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3543 case TB_ISBUTTONINDETERMINATE:
3544 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3546 case TB_ISBUTTONPRESSED:
3547 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3549 case TB_LOADIMAGES: /* 4.70 */
3550 FIXME("missing standard imagelists\n");
3553 /* case TB_MAPACCELERATORA: */ /* 4.71 */
3554 /* case TB_MAPACCELERATORW: */ /* 4.71 */
3555 /* case TB_MARKBUTTON: */ /* 4.71 */
3556 /* case TB_MOVEBUTTON: */ /* 4.71 */
3558 case TB_PRESSBUTTON:
3559 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3561 /* case TB_REPLACEBITMAP: */
3563 case TB_SAVERESTOREA:
3564 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3566 case TB_SAVERESTOREW:
3567 return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam);
3569 case TB_SETANCHORHIGHLIGHT:
3570 return TOOLBAR_SetAnchorHighlight (hwnd, wParam);
3572 case TB_SETBITMAPSIZE:
3573 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3575 case TB_SETBUTTONINFOA:
3576 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3578 case TB_SETBUTTONINFOW:
3579 return TOOLBAR_SetButtonInfoW (hwnd, wParam, lParam);
3581 case TB_SETBUTTONSIZE:
3582 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3584 case TB_SETBUTTONWIDTH:
3585 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3588 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3590 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
3592 case TB_SETDISABLEDIMAGELIST:
3593 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3595 case TB_SETDRAWTEXTFLAGS:
3596 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3598 case TB_SETEXTENDEDSTYLE:
3599 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3601 case TB_SETHOTIMAGELIST:
3602 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3605 return TOOLBAR_SetHotItem (hwnd, wParam);
3607 case TB_SETIMAGELIST:
3608 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3611 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3613 /* case TB_SETINSERTMARK: */ /* 4.71 */
3615 case TB_SETINSERTMARKCOLOR:
3616 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3618 case TB_SETMAXTEXTROWS:
3619 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3621 /* case TB_SETPADDING: */ /* 4.71 */
3624 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3627 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3630 return TOOLBAR_SetState (hwnd, wParam, lParam);
3633 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3635 case TB_SETTOOLTIPS:
3636 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3638 case TB_SETUNICODEFORMAT:
3639 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3641 case CCM_SETVERSION:
3642 return TOOLBAR_SetVersion (hwnd, (INT)wParam);
3648 return TOOLBAR_Create (hwnd, wParam, lParam);
3651 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3654 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3657 return TOOLBAR_GetFont (hwnd, wParam, lParam);
3659 /* case WM_KEYDOWN: */
3660 /* case WM_KILLFOCUS: */
3662 case WM_LBUTTONDBLCLK:
3663 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3665 case WM_LBUTTONDOWN:
3666 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3669 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3672 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3675 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3678 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3681 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3684 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3687 return TOOLBAR_Notify (hwnd, wParam, lParam);
3689 /* case WM_NOTIFYFORMAT: */
3692 return TOOLBAR_Paint (hwnd, wParam);
3695 return TOOLBAR_Size (hwnd, wParam, lParam);
3697 case WM_STYLECHANGED:
3698 return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
3700 /* case WM_SYSCOLORCHANGE: */
3702 /* case WM_WININICHANGE: */
3707 case WM_MEASUREITEM:
3709 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3712 if (uMsg >= WM_USER)
3713 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
3714 uMsg, wParam, lParam);
3715 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3722 TOOLBAR_Register (void)
3726 if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
3728 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3729 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3730 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3731 wndClass.cbClsExtra = 0;
3732 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3733 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3734 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3735 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3737 RegisterClassA (&wndClass);
3742 TOOLBAR_Unregister (void)
3744 if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
3745 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);