4 * Copyright 1998,1999 Eric Kohl
7 * - A little bug in TOOLBAR_DrawMasked()
8 * - Button wrapping (under construction).
12 * - Tooltip support (almost complete).
14 * - Fix TOOLBAR_SetButtonInfo32A.
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;
792 COLORREF oldText = 0;
795 FIXME("action: %x itemState: %x\n",
796 lpdis->itemAction, lpdis->itemState);
798 if (lpdis->itemState & ODS_FOCUS)
800 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
801 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
804 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
805 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
807 /* fill background rectangle */
808 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
809 lpdis->rcItem.right, lpdis->rcItem.bottom);
811 /* calculate button and text rectangles */
812 CopyRect (&rcButton, &lpdis->rcItem);
813 InflateRect (&rcButton, -1, -1);
814 CopyRect (&rcText, &rcButton);
815 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
816 rcText.left = rcButton.right + 2;
818 /* draw focus rectangle */
819 if (lpdis->itemState & ODS_FOCUS)
820 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
823 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
825 /* FIXME: draw bitmap */
827 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
828 rcButton.left+1, rcButton.top+1, ILD_NORMAL);
831 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
833 /* virtual separator in the 'available' list */
834 DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
835 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
842 if (lpdis->itemState & ODS_FOCUS)
844 SetBkColor (lpdis->hDC, oldBk);
845 SetTextColor (lpdis->hDC, oldText);
848 SelectObject (lpdis->hDC, hOldBrush);
849 SelectObject (lpdis->hDC, hOldPen);
856 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
858 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
861 lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
863 lpmis->itemHeight = 16 + 8; /* default height */
875 /***********************************************************************
876 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
880 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
882 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
883 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
884 INT nIndex = 0, nButtons;
890 if (lpAddBmp->hInst == HINST_COMMCTRL)
892 if ((lpAddBmp->nID & ~1) == IDB_STD_SMALL_COLOR)
894 else if ((lpAddBmp->nID & ~1) == IDB_VIEW_SMALL_COLOR)
896 else if ((lpAddBmp->nID & ~1) == IDB_HIST_SMALL_COLOR)
901 TRACE ("adding %d internal bitmaps!\n", nButtons);
903 /* Windows resize all the buttons to the size of a newly added standard image */
904 if (lpAddBmp->nID & 1)
907 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
908 MAKELPARAM((WORD)26, (WORD)26));
909 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
910 MAKELPARAM((WORD)33, (WORD)33));
915 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
916 MAKELPARAM((WORD)16, (WORD)16));
917 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
918 MAKELPARAM((WORD)22, (WORD)22));
921 TOOLBAR_CalcToolbar (hwnd);
925 nButtons = (INT)wParam;
929 TRACE ("adding %d bitmaps!\n", nButtons);
932 if (!(infoPtr->himlDef)) {
933 /* create new default image list */
934 TRACE ("creating default image list!\n");
937 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
938 ILC_COLOR | ILC_MASK, nButtons, 2);
939 infoPtr->himlInt = infoPtr->himlDef;
942 /* Add bitmaps to the default image list */
943 if (lpAddBmp->hInst == (HINSTANCE)0)
946 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP)lpAddBmp->nID,
949 else if (lpAddBmp->hInst == HINST_COMMCTRL)
951 /* Add system bitmaps */
952 switch (lpAddBmp->nID)
954 case IDB_STD_SMALL_COLOR:
955 hbmLoad = LoadBitmapA (COMCTL32_hModule,
956 MAKEINTRESOURCEA(IDB_STD_SMALL));
957 nIndex = ImageList_AddMasked (infoPtr->himlDef,
958 hbmLoad, CLR_DEFAULT);
959 DeleteObject (hbmLoad);
962 case IDB_STD_LARGE_COLOR:
963 hbmLoad = LoadBitmapA (COMCTL32_hModule,
964 MAKEINTRESOURCEA(IDB_STD_LARGE));
965 nIndex = ImageList_AddMasked (infoPtr->himlDef,
966 hbmLoad, CLR_DEFAULT);
967 DeleteObject (hbmLoad);
970 case IDB_VIEW_SMALL_COLOR:
971 hbmLoad = LoadBitmapA (COMCTL32_hModule,
972 MAKEINTRESOURCEA(IDB_VIEW_SMALL));
973 nIndex = ImageList_AddMasked (infoPtr->himlDef,
974 hbmLoad, CLR_DEFAULT);
975 DeleteObject (hbmLoad);
978 case IDB_VIEW_LARGE_COLOR:
979 hbmLoad = LoadBitmapA (COMCTL32_hModule,
980 MAKEINTRESOURCEA(IDB_VIEW_LARGE));
981 nIndex = ImageList_AddMasked (infoPtr->himlDef,
982 hbmLoad, CLR_DEFAULT);
983 DeleteObject (hbmLoad);
986 case IDB_HIST_SMALL_COLOR:
987 hbmLoad = LoadBitmapA (COMCTL32_hModule,
988 MAKEINTRESOURCEA(IDB_HIST_SMALL));
989 nIndex = ImageList_AddMasked (infoPtr->himlDef,
990 hbmLoad, CLR_DEFAULT);
991 DeleteObject (hbmLoad);
994 case IDB_HIST_LARGE_COLOR:
995 hbmLoad = LoadBitmapA (COMCTL32_hModule,
996 MAKEINTRESOURCEA(IDB_HIST_LARGE));
997 nIndex = ImageList_AddMasked (infoPtr->himlDef,
998 hbmLoad, CLR_DEFAULT);
999 DeleteObject (hbmLoad);
1003 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
1004 ERR ("invalid imagelist!\n");
1010 hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
1011 nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
1012 DeleteObject (hbmLoad);
1015 infoPtr->nNumBitmaps += nButtons;
1022 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1024 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1025 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1026 INT nOldButtons, nNewButtons, nAddButtons, nCount;
1028 TRACE("adding %d buttons!\n", wParam);
1030 nAddButtons = (UINT)wParam;
1031 nOldButtons = infoPtr->nNumButtons;
1032 nNewButtons = nOldButtons + nAddButtons;
1034 if (infoPtr->nNumButtons == 0) {
1036 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1039 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1041 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
1042 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1043 nOldButtons * sizeof(TBUTTON_INFO));
1044 COMCTL32_Free (oldButtons);
1047 infoPtr->nNumButtons = nNewButtons;
1049 /* insert new button data */
1050 for (nCount = 0; nCount < nAddButtons; nCount++) {
1051 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
1052 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
1053 btnPtr->idCommand = lpTbb[nCount].idCommand;
1054 btnPtr->fsState = lpTbb[nCount].fsState;
1055 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
1056 btnPtr->dwData = lpTbb[nCount].dwData;
1057 btnPtr->iString = lpTbb[nCount].iString;
1058 btnPtr->bHot = FALSE;
1060 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
1063 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1064 ti.cbSize = sizeof (TTTOOLINFOA);
1066 ti.uId = btnPtr->idCommand;
1068 ti.lpszText = LPSTR_TEXTCALLBACKA;
1070 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1075 TOOLBAR_CalcToolbar (hwnd);
1077 InvalidateRect(hwnd, NULL, FALSE);
1083 /* << TOOLBAR_AddButtons32W >> */
1087 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1089 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1092 if ((wParam) && (HIWORD(lParam) == 0)) {
1095 TRACE("adding string from resource!\n");
1097 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
1100 TRACE("len=%d \"%s\"\n", len, szString);
1101 nIndex = infoPtr->nNumStrings;
1102 if (infoPtr->nNumStrings == 0) {
1104 COMCTL32_Alloc (sizeof(LPWSTR));
1107 LPWSTR *oldStrings = infoPtr->strings;
1109 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1110 memcpy (&infoPtr->strings[0], &oldStrings[0],
1111 sizeof(LPWSTR) * infoPtr->nNumStrings);
1112 COMCTL32_Free (oldStrings);
1115 infoPtr->strings[infoPtr->nNumStrings] =
1116 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1117 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
1118 infoPtr->nNumStrings++;
1121 LPSTR p = (LPSTR)lParam;
1126 TRACE("adding string(s) from array!\n");
1127 nIndex = infoPtr->nNumStrings;
1130 TRACE("len=%d \"%s\"\n", len, p);
1132 if (infoPtr->nNumStrings == 0) {
1134 COMCTL32_Alloc (sizeof(LPWSTR));
1137 LPWSTR *oldStrings = infoPtr->strings;
1139 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1140 memcpy (&infoPtr->strings[0], &oldStrings[0],
1141 sizeof(LPWSTR) * infoPtr->nNumStrings);
1142 COMCTL32_Free (oldStrings);
1145 infoPtr->strings[infoPtr->nNumStrings] =
1146 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1147 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
1148 infoPtr->nNumStrings++;
1159 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1161 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1164 if ((wParam) && (HIWORD(lParam) == 0)) {
1165 WCHAR szString[256];
1167 TRACE("adding string from resource!\n");
1169 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
1172 TRACE("len=%d \"%s\"\n", len, debugstr_w(szString));
1173 nIndex = infoPtr->nNumStrings;
1174 if (infoPtr->nNumStrings == 0) {
1176 COMCTL32_Alloc (sizeof(LPWSTR));
1179 LPWSTR *oldStrings = infoPtr->strings;
1181 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1182 memcpy (&infoPtr->strings[0], &oldStrings[0],
1183 sizeof(LPWSTR) * infoPtr->nNumStrings);
1184 COMCTL32_Free (oldStrings);
1187 infoPtr->strings[infoPtr->nNumStrings] =
1188 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1189 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
1190 infoPtr->nNumStrings++;
1193 LPWSTR p = (LPWSTR)lParam;
1198 TRACE("adding string(s) from array!\n");
1199 nIndex = infoPtr->nNumStrings;
1202 TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
1204 if (infoPtr->nNumStrings == 0) {
1206 COMCTL32_Alloc (sizeof(LPWSTR));
1209 LPWSTR *oldStrings = infoPtr->strings;
1211 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1212 memcpy (&infoPtr->strings[0], &oldStrings[0],
1213 sizeof(LPWSTR) * infoPtr->nNumStrings);
1214 COMCTL32_Free (oldStrings);
1217 infoPtr->strings[infoPtr->nNumStrings] =
1218 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1219 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1220 infoPtr->nNumStrings++;
1231 TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1233 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1234 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1241 TRACE("resize forced!\n");
1243 parent = GetParent (hwnd);
1244 GetClientRect(parent, &parent_rect);
1246 if (dwStyle & CCS_NORESIZE) {
1247 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1252 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1253 TOOLBAR_CalcToolbar (hwnd);
1254 InvalidateRect( hwnd, NULL, TRUE );
1255 cy = infoPtr->nHeight;
1256 cx = infoPtr->nWidth;
1259 if (dwStyle & CCS_NOPARENTALIGN)
1260 uPosFlags |= SWP_NOMOVE;
1262 if (!(dwStyle & CCS_NODIVIDER))
1263 cy += GetSystemMetrics(SM_CYEDGE);
1265 infoPtr->bAutoSize = TRUE;
1266 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
1274 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1276 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1278 return infoPtr->nNumButtons;
1283 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1285 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1287 if (infoPtr == NULL) {
1288 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1289 ERR("infoPtr == NULL!\n");
1293 infoPtr->dwStructSize = (DWORD)wParam;
1300 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1302 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1303 TBUTTON_INFO *btnPtr;
1307 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1311 btnPtr = &infoPtr->buttons[nIndex];
1312 btnPtr->iBitmap = LOWORD(lParam);
1315 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1316 ReleaseDC (hwnd, hdc);
1323 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1325 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1326 TBUTTON_INFO *btnPtr;
1331 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1335 btnPtr = &infoPtr->buttons[nIndex];
1337 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1340 if (LOWORD(lParam) == FALSE)
1341 btnPtr->fsState &= ~TBSTATE_CHECKED;
1343 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1345 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1346 if (nOldIndex == nIndex)
1348 if (nOldIndex != -1)
1349 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1351 btnPtr->fsState |= TBSTATE_CHECKED;
1355 if (nOldIndex != -1)
1356 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1357 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1358 ReleaseDC (hwnd, hdc);
1360 /* FIXME: Send a WM_NOTIFY?? */
1367 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1369 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1371 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1376 TOOLBAR_Customize (HWND hwnd)
1378 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1384 /* send TBN_BEGINADJUST notification */
1385 nmhdr.hwndFrom = hwnd;
1386 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1387 nmhdr.code = TBN_BEGINADJUST;
1389 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1390 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1392 if (!(hRes = FindResourceA (COMCTL32_hModule,
1393 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1397 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1400 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1401 (LPDLGTEMPLATEA)template,
1403 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1406 /* send TBN_ENDADJUST notification */
1407 nmhdr.code = TBN_ENDADJUST;
1409 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1410 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1417 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1419 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1420 INT nIndex = (INT)wParam;
1422 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1425 if ((infoPtr->hwndToolTip) &&
1426 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1429 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1430 ti.cbSize = sizeof (TTTOOLINFOA);
1432 ti.uId = infoPtr->buttons[nIndex].idCommand;
1434 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1437 if (infoPtr->nNumButtons == 1) {
1438 TRACE(" simple delete!\n");
1439 COMCTL32_Free (infoPtr->buttons);
1440 infoPtr->buttons = NULL;
1441 infoPtr->nNumButtons = 0;
1444 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1445 TRACE("complex delete! [nIndex=%d]\n", nIndex);
1447 infoPtr->nNumButtons--;
1448 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1450 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1451 nIndex * sizeof(TBUTTON_INFO));
1454 if (nIndex < infoPtr->nNumButtons) {
1455 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1456 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1459 COMCTL32_Free (oldButtons);
1462 TOOLBAR_CalcToolbar (hwnd);
1464 InvalidateRect (hwnd, NULL, TRUE);
1471 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1473 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1474 TBUTTON_INFO *btnPtr;
1478 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1482 btnPtr = &infoPtr->buttons[nIndex];
1483 if (LOWORD(lParam) == FALSE)
1484 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1486 btnPtr->fsState |= TBSTATE_ENABLED;
1489 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1490 ReleaseDC (hwnd, hdc);
1496 /* << TOOLBAR_GetAnchorHighlight >> */
1500 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1502 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1505 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1509 return infoPtr->buttons[nIndex].iBitmap;
1513 static inline LRESULT
1514 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1516 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1521 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1523 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1524 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1525 INT nIndex = (INT)wParam;
1526 TBUTTON_INFO *btnPtr;
1528 if (infoPtr == NULL)
1534 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1537 btnPtr = &infoPtr->buttons[nIndex];
1538 lpTbb->iBitmap = btnPtr->iBitmap;
1539 lpTbb->idCommand = btnPtr->idCommand;
1540 lpTbb->fsState = btnPtr->fsState;
1541 lpTbb->fsStyle = btnPtr->fsStyle;
1542 lpTbb->dwData = btnPtr->dwData;
1543 lpTbb->iString = btnPtr->iString;
1550 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1552 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1553 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1554 TBUTTON_INFO *btnPtr;
1557 if (infoPtr == NULL)
1559 if (lpTbInfo == NULL)
1561 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1564 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1568 btnPtr = &infoPtr->buttons[nIndex];
1570 if (lpTbInfo->dwMask & TBIF_COMMAND)
1571 lpTbInfo->idCommand = btnPtr->idCommand;
1572 if (lpTbInfo->dwMask & TBIF_IMAGE)
1573 lpTbInfo->iImage = btnPtr->iBitmap;
1574 if (lpTbInfo->dwMask & TBIF_LPARAM)
1575 lpTbInfo->lParam = btnPtr->dwData;
1576 if (lpTbInfo->dwMask & TBIF_SIZE)
1577 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1578 if (lpTbInfo->dwMask & TBIF_STATE)
1579 lpTbInfo->fsState = btnPtr->fsState;
1580 if (lpTbInfo->dwMask & TBIF_STYLE)
1581 lpTbInfo->fsStyle = btnPtr->fsStyle;
1582 if (lpTbInfo->dwMask & TBIF_TEXT) {
1583 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1584 lstrcpynA (lpTbInfo->pszText,
1585 (LPSTR)infoPtr->strings[btnPtr->iString],
1593 /* << TOOLBAR_GetButtonInfo32W >> */
1597 TOOLBAR_GetButtonSize (HWND hwnd)
1599 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1601 return MAKELONG((WORD)infoPtr->nButtonWidth,
1602 (WORD)infoPtr->nButtonHeight);
1607 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1609 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1610 INT nIndex, nStringIndex;
1612 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1616 nStringIndex = infoPtr->buttons[nIndex].iString;
1618 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1620 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1623 if (lParam == 0) return -1;
1625 lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
1627 return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]);
1631 /* << TOOLBAR_GetButtonText32W >> */
1632 /* << TOOLBAR_GetColorScheme >> */
1636 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1638 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1640 return (LRESULT)infoPtr->himlDis;
1644 inline static LRESULT
1645 TOOLBAR_GetExtendedStyle (HWND hwnd)
1647 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1649 return infoPtr->dwExStyle;
1654 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1656 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1658 return (LRESULT)infoPtr->himlHot;
1662 /* << TOOLBAR_GetHotItem >> */
1666 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1668 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1670 return (LRESULT)infoPtr->himlDef;
1674 /* << TOOLBAR_GetInsertMark >> */
1675 /* << TOOLBAR_GetInsertMarkColor >> */
1679 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1681 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1682 TBUTTON_INFO *btnPtr;
1686 if (infoPtr == NULL)
1688 nIndex = (INT)wParam;
1689 btnPtr = &infoPtr->buttons[nIndex];
1690 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1692 lpRect = (LPRECT)lParam;
1695 if (btnPtr->fsState & TBSTATE_HIDDEN)
1698 TOOLBAR_CalcToolbar( hwnd );
1700 lpRect->left = btnPtr->rect.left;
1701 lpRect->right = btnPtr->rect.right;
1702 lpRect->bottom = btnPtr->rect.bottom;
1703 lpRect->top = btnPtr->rect.top;
1710 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1712 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1713 LPSIZE lpSize = (LPSIZE)lParam;
1718 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1719 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1721 TRACE("maximum size %d x %d\n",
1722 infoPtr->rcBound.right - infoPtr->rcBound.left,
1723 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1729 /* << TOOLBAR_GetObject >> */
1730 /* << TOOLBAR_GetPadding >> */
1734 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1736 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1737 TBUTTON_INFO *btnPtr;
1741 if (infoPtr == NULL)
1743 nIndex = (INT)wParam;
1744 btnPtr = &infoPtr->buttons[nIndex];
1745 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1747 lpRect = (LPRECT)lParam;
1751 lpRect->left = btnPtr->rect.left;
1752 lpRect->right = btnPtr->rect.right;
1753 lpRect->bottom = btnPtr->rect.bottom;
1754 lpRect->top = btnPtr->rect.top;
1761 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1763 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1765 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1766 return infoPtr->nRows;
1773 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1775 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1778 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1782 return infoPtr->buttons[nIndex].fsState;
1787 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1789 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1792 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1796 return infoPtr->buttons[nIndex].fsStyle;
1801 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1803 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1805 if (infoPtr == NULL)
1808 return infoPtr->nMaxTextRows;
1813 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1815 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1817 if (infoPtr == NULL)
1819 return infoPtr->hwndToolTip;
1824 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1826 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1828 TRACE("%s hwnd=0x%x stub!\n",
1829 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
1831 return infoPtr->bUnicode;
1836 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1838 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1839 TBUTTON_INFO *btnPtr;
1842 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1846 btnPtr = &infoPtr->buttons[nIndex];
1847 if (LOWORD(lParam) == FALSE)
1848 btnPtr->fsState &= ~TBSTATE_HIDDEN;
1850 btnPtr->fsState |= TBSTATE_HIDDEN;
1852 TOOLBAR_CalcToolbar (hwnd);
1854 InvalidateRect (hwnd, NULL, TRUE);
1860 inline static LRESULT
1861 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
1863 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
1868 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1870 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1871 TBUTTON_INFO *btnPtr;
1875 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1879 btnPtr = &infoPtr->buttons[nIndex];
1880 if (LOWORD(lParam) == FALSE)
1881 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
1883 btnPtr->fsState |= TBSTATE_INDETERMINATE;
1886 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1887 ReleaseDC (hwnd, hdc);
1894 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1896 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1897 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1898 INT nIndex = (INT)wParam;
1899 TBUTTON_INFO *oldButtons;
1906 TRACE("inserting button index=%d\n", nIndex);
1907 if (nIndex > infoPtr->nNumButtons) {
1908 nIndex = infoPtr->nNumButtons;
1909 TRACE("adjust index=%d\n", nIndex);
1912 oldButtons = infoPtr->buttons;
1913 infoPtr->nNumButtons++;
1914 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1915 /* pre insert copy */
1917 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1918 nIndex * sizeof(TBUTTON_INFO));
1921 /* insert new button */
1922 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
1923 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
1924 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
1925 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
1926 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
1927 infoPtr->buttons[nIndex].iString = lpTbb->iString;
1929 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
1932 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1933 ti.cbSize = sizeof (TTTOOLINFOA);
1935 ti.uId = lpTbb->idCommand;
1937 ti.lpszText = LPSTR_TEXTCALLBACKA;
1939 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1943 /* post insert copy */
1944 if (nIndex < infoPtr->nNumButtons - 1) {
1945 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
1946 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
1949 COMCTL32_Free (oldButtons);
1951 TOOLBAR_CalcToolbar (hwnd);
1953 InvalidateRect (hwnd, NULL, FALSE);
1959 /* << TOOLBAR_InsertButton32W >> */
1960 /* << TOOLBAR_InsertMarkHitTest >> */
1964 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
1966 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1969 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1973 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
1978 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
1980 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1983 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1987 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
1992 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
1994 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1997 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2001 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
2006 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
2008 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2011 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2015 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
2020 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2022 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2025 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2029 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
2034 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
2036 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2039 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2043 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
2047 /* << TOOLBAR_LoadImages >> */
2048 /* << TOOLBAR_MapAccelerator >> */
2049 /* << TOOLBAR_MarkButton >> */
2050 /* << TOOLBAR_MoveButton >> */
2054 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
2056 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2057 TBUTTON_INFO *btnPtr;
2061 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2065 btnPtr = &infoPtr->buttons[nIndex];
2066 if (LOWORD(lParam) == FALSE)
2067 btnPtr->fsState &= ~TBSTATE_PRESSED;
2069 btnPtr->fsState |= TBSTATE_PRESSED;
2072 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2073 ReleaseDC (hwnd, hdc);
2079 /* << TOOLBAR_ReplaceBitmap >> */
2083 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2086 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2087 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2089 if (lpSave == NULL) return 0;
2092 /* save toolbar information */
2093 FIXME("save to \"%s\" \"%s\"\n",
2094 lpSave->pszSubKey, lpSave->pszValueName);
2099 /* restore toolbar information */
2101 FIXME("restore from \"%s\" \"%s\"\n",
2102 lpSave->pszSubKey, lpSave->pszValueName);
2112 /* << TOOLBAR_SaveRestore32W >> */
2113 /* << TOOLBAR_SetAnchorHighlight >> */
2117 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2119 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2121 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2124 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2125 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2132 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2134 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2135 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2136 TBUTTON_INFO *btnPtr;
2141 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2144 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2148 btnPtr = &infoPtr->buttons[nIndex];
2149 if (lptbbi->dwMask & TBIF_COMMAND)
2150 btnPtr->idCommand = lptbbi->idCommand;
2151 if (lptbbi->dwMask & TBIF_IMAGE)
2152 btnPtr->iBitmap = lptbbi->iImage;
2153 if (lptbbi->dwMask & TBIF_LPARAM)
2154 btnPtr->dwData = lptbbi->lParam;
2155 /* if (lptbbi->dwMask & TBIF_SIZE) */
2156 /* btnPtr->cx = lptbbi->cx; */
2157 if (lptbbi->dwMask & TBIF_STATE)
2158 btnPtr->fsState = lptbbi->fsState;
2159 if (lptbbi->dwMask & TBIF_STYLE)
2160 btnPtr->fsStyle = lptbbi->fsStyle;
2162 if (lptbbi->dwMask & TBIF_TEXT) {
2163 if ((btnPtr->iString >= 0) ||
2164 (btnPtr->iString < infoPtr->nNumStrings)) {
2166 CHAR **lpString = &infoPtr->strings[btnPtr->iString];
2167 INT len = lstrlenA (lptbbi->pszText);
2168 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
2171 /* this is the ultimate sollution */
2172 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2180 /* << TOOLBAR_SetButtonInfo32W >> */
2184 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2186 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2188 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2191 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2192 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2199 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2201 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2203 if (infoPtr == NULL)
2206 infoPtr->cxMin = (INT)LOWORD(lParam);
2207 infoPtr->cxMax = (INT)HIWORD(lParam);
2214 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2216 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2217 INT nIndex = (INT)wParam;
2219 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2222 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2224 if (infoPtr->hwndToolTip) {
2226 FIXME("change tool tip!\n");
2234 /* << TOOLBAR_SetColorScheme >> */
2238 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2240 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2241 HIMAGELIST himlTemp;
2243 himlTemp = infoPtr->himlDis;
2244 infoPtr->himlDis = (HIMAGELIST)lParam;
2246 /* FIXME: redraw ? */
2248 return (LRESULT)himlTemp;
2253 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2255 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2258 dwTemp = infoPtr->dwDTFlags;
2259 infoPtr->dwDTFlags =
2260 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2262 return (LRESULT)dwTemp;
2267 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2269 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2272 dwTemp = infoPtr->dwExStyle;
2273 infoPtr->dwExStyle = (DWORD)lParam;
2275 return (LRESULT)dwTemp;
2280 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2282 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2283 HIMAGELIST himlTemp;
2285 himlTemp = infoPtr->himlHot;
2286 infoPtr->himlHot = (HIMAGELIST)lParam;
2288 /* FIXME: redraw ? */
2290 return (LRESULT)himlTemp;
2294 /* << TOOLBAR_SetHotItem >> */
2298 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2300 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2301 HIMAGELIST himlTemp;
2303 himlTemp = infoPtr->himlDef;
2304 infoPtr->himlDef = (HIMAGELIST)lParam;
2306 /* FIXME: redraw ? */
2308 return (LRESULT)himlTemp;
2313 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2315 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2317 infoPtr->nIndent = (INT)wParam;
2319 TOOLBAR_CalcToolbar (hwnd);
2321 InvalidateRect(hwnd, NULL, FALSE);
2327 /* << TOOLBAR_SetInsertMark >> */
2331 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2333 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2335 infoPtr->clrInsertMark = (COLORREF)lParam;
2337 /* FIXME : redraw ??*/
2344 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2346 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2348 if (infoPtr == NULL)
2351 infoPtr->nMaxTextRows = (INT)wParam;
2357 /* << TOOLBAR_SetPadding >> */
2361 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2363 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2366 if (infoPtr == NULL)
2368 hwndOldNotify = infoPtr->hwndNotify;
2369 infoPtr->hwndNotify = (HWND)wParam;
2371 return hwndOldNotify;
2376 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2378 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2379 LPRECT lprc = (LPRECT)lParam;
2381 if (LOWORD(wParam) > 1) {
2383 FIXME("multiple rows not supported!\n");
2387 /* recalculate toolbar */
2388 TOOLBAR_CalcToolbar (hwnd);
2390 /* return bounding rectangle */
2392 lprc->left = infoPtr->rcBound.left;
2393 lprc->right = infoPtr->rcBound.right;
2394 lprc->top = infoPtr->rcBound.top;
2395 lprc->bottom = infoPtr->rcBound.bottom;
2398 /* repaint toolbar */
2399 InvalidateRect(hwnd, NULL, FALSE);
2406 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2408 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2409 TBUTTON_INFO *btnPtr;
2413 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2417 btnPtr = &infoPtr->buttons[nIndex];
2418 btnPtr->fsState = LOWORD(lParam);
2421 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2422 ReleaseDC (hwnd, hdc);
2429 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2431 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2432 TBUTTON_INFO *btnPtr;
2436 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2440 btnPtr = &infoPtr->buttons[nIndex];
2441 btnPtr->fsStyle = LOWORD(lParam);
2444 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2445 ReleaseDC (hwnd, hdc);
2447 if (infoPtr->hwndToolTip) {
2449 FIXME("change tool tip!\n");
2457 inline static LRESULT
2458 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2460 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2462 if (infoPtr == NULL)
2464 infoPtr->hwndToolTip = (HWND)wParam;
2470 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2472 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2475 TRACE("%s hwnd=0x%04x stub!\n",
2476 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2478 bTemp = infoPtr->bUnicode;
2479 infoPtr->bUnicode = (BOOL)wParam;
2486 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2488 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2489 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2492 /* initialize info structure */
2493 infoPtr->nButtonHeight = 22;
2494 infoPtr->nButtonWidth = 23;
2495 infoPtr->nBitmapHeight = 15;
2496 infoPtr->nBitmapWidth = 16;
2498 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2500 infoPtr->nMaxTextRows = 1;
2501 infoPtr->cxMin = -1;
2502 infoPtr->cxMax = -1;
2504 infoPtr->bCaptured = FALSE;
2505 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2506 infoPtr->nButtonDown = -1;
2507 infoPtr->nOldHit = -1;
2508 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2509 infoPtr->hwndNotify = GetParent (hwnd);
2510 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2511 infoPtr->dwDTFlags = DT_CENTER;
2513 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2514 infoPtr->hFont = CreateFontIndirectA (&logFont);
2516 if (dwStyle & TBSTYLE_TOOLTIPS) {
2517 /* Create tooltip control */
2518 infoPtr->hwndToolTip =
2519 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2520 CW_USEDEFAULT, CW_USEDEFAULT,
2521 CW_USEDEFAULT, CW_USEDEFAULT,
2524 /* Send NM_TOOLTIPSCREATED notification */
2525 if (infoPtr->hwndToolTip) {
2526 NMTOOLTIPSCREATED nmttc;
2528 nmttc.hdr.hwndFrom = hwnd;
2529 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2530 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2531 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2533 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2534 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2543 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2545 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2547 /* delete tooltip control */
2548 if (infoPtr->hwndToolTip)
2549 DestroyWindow (infoPtr->hwndToolTip);
2551 /* delete button data */
2552 if (infoPtr->buttons)
2553 COMCTL32_Free (infoPtr->buttons);
2555 /* delete strings */
2556 if (infoPtr->strings) {
2558 for (i = 0; i < infoPtr->nNumStrings; i++)
2559 if (infoPtr->strings[i])
2560 COMCTL32_Free (infoPtr->strings[i]);
2562 COMCTL32_Free (infoPtr->strings);
2565 /* destroy internal image list */
2566 if (infoPtr->himlInt)
2567 ImageList_Destroy (infoPtr->himlInt);
2569 /* delete default font */
2571 DeleteObject (infoPtr->hFont);
2573 /* free toolbar info data */
2574 COMCTL32_Free (infoPtr);
2581 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2583 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2585 if (infoPtr->bTransparent)
2586 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2588 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2593 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
2595 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2596 TBUTTON_INFO *btnPtr;
2601 pt.x = (INT)LOWORD(lParam);
2602 pt.y = (INT)HIWORD(lParam);
2603 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2606 btnPtr = &infoPtr->buttons[nHit];
2607 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2610 infoPtr->bCaptured = TRUE;
2611 infoPtr->nButtonDown = nHit;
2613 btnPtr->fsState |= TBSTATE_PRESSED;
2616 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2617 ReleaseDC (hwnd, hdc);
2619 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
2620 TOOLBAR_Customize (hwnd);
2627 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
2629 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2630 TBUTTON_INFO *btnPtr;
2635 if (infoPtr->hwndToolTip)
2636 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2637 WM_LBUTTONDOWN, wParam, lParam);
2639 pt.x = (INT)LOWORD(lParam);
2640 pt.y = (INT)HIWORD(lParam);
2641 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2644 btnPtr = &infoPtr->buttons[nHit];
2645 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2649 infoPtr->bCaptured = TRUE;
2650 infoPtr->nButtonDown = nHit;
2651 infoPtr->nOldHit = nHit;
2653 btnPtr->fsState |= TBSTATE_PRESSED;
2656 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2657 ReleaseDC (hwnd, hdc);
2665 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
2667 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2668 TBUTTON_INFO *btnPtr;
2673 BOOL bSendMessage = TRUE;
2675 if (infoPtr->hwndToolTip)
2676 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2677 WM_LBUTTONUP, wParam, lParam);
2679 pt.x = (INT)LOWORD(lParam);
2680 pt.y = (INT)HIWORD(lParam);
2681 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2683 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
2684 infoPtr->bCaptured = FALSE;
2686 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2687 btnPtr->fsState &= ~TBSTATE_PRESSED;
2689 if (nHit == infoPtr->nButtonDown) {
2690 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
2691 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2692 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
2693 infoPtr->nButtonDown);
2694 if (nOldIndex == infoPtr->nButtonDown)
2695 bSendMessage = FALSE;
2696 if ((nOldIndex != infoPtr->nButtonDown) &&
2698 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2699 btnPtr->fsState |= TBSTATE_CHECKED;
2702 if (btnPtr->fsState & TBSTATE_CHECKED)
2703 btnPtr->fsState &= ~TBSTATE_CHECKED;
2705 btnPtr->fsState |= TBSTATE_CHECKED;
2710 bSendMessage = FALSE;
2713 if (nOldIndex != -1)
2714 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
2715 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2716 ReleaseDC (hwnd, hdc);
2719 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
2720 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
2722 infoPtr->nButtonDown = -1;
2723 infoPtr->nOldHit = -1;
2731 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
2733 TBUTTON_INFO *btnPtr, *oldBtnPtr;
2734 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2739 if (infoPtr->hwndToolTip)
2740 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2741 WM_MOUSEMOVE, wParam, lParam);
2743 pt.x = (INT)LOWORD(lParam);
2744 pt.y = (INT)HIWORD(lParam);
2746 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2748 if (infoPtr->nOldHit != nHit)
2750 /* Remove the effect of an old hot button */
2751 if(infoPtr->nOldHit == infoPtr->nHotItem)
2753 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
2754 oldBtnPtr->bHot = FALSE;
2756 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
2759 /* It's not a separator or in nowhere. It's a hot button. */
2762 btnPtr = &infoPtr->buttons[nHit];
2763 btnPtr->bHot = TRUE;
2766 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2767 ReleaseDC (hwnd, hdc);
2769 infoPtr->nHotItem = nHit;
2772 if (infoPtr->bCaptured) {
2773 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2774 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
2775 btnPtr->fsState &= ~TBSTATE_PRESSED;
2777 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2778 ReleaseDC (hwnd, hdc);
2780 else if (nHit == infoPtr->nButtonDown) {
2781 btnPtr->fsState |= TBSTATE_PRESSED;
2783 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2784 ReleaseDC (hwnd, hdc);
2787 infoPtr->nOldHit = nHit;
2793 inline static LRESULT
2794 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2796 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
2797 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
2799 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
2803 inline static LRESULT
2804 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2806 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
2807 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
2809 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
2814 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2816 TOOLBAR_INFO *infoPtr;
2818 /* allocate memory for info structure */
2819 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
2820 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
2823 infoPtr->dwStructSize = sizeof(TBBUTTON);
2825 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
2826 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
2827 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
2828 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
2831 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
2836 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2838 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2842 if (dwStyle & WS_MINIMIZE)
2843 return 0; /* Nothing to do */
2845 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
2847 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
2850 if (!(dwStyle & CCS_NODIVIDER))
2852 GetWindowRect (hwnd, &rcWindow);
2853 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
2854 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
2857 ReleaseDC( hwnd, hdc );
2863 inline static LRESULT
2864 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
2866 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2867 LPNMHDR lpnmh = (LPNMHDR)lParam;
2869 TRACE("passing WM_NOTIFY!\n");
2871 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
2872 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
2875 if (lpnmh->code == TTN_GETDISPINFOA) {
2876 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
2878 FIXME("retrieving ASCII string\n");
2881 else if (lpnmh->code == TTN_GETDISPINFOW) {
2882 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
2884 FIXME("retrieving UNICODE string\n");
2895 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
2900 TOOLBAR_CalcToolbar( hwnd );
2901 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2902 TOOLBAR_Refresh (hwnd, hdc);
2904 EndPaint (hwnd, &ps);
2910 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
2912 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2913 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2921 /* Resize deadlock check */
2922 if (infoPtr->bAutoSize) {
2923 infoPtr->bAutoSize = FALSE;
2927 flags = (INT) wParam;
2929 /* FIXME for flags =
2930 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
2933 TRACE("sizing toolbar!\n");
2935 if (flags == SIZE_RESTORED) {
2936 /* width and height don't apply */
2937 parent = GetParent (hwnd);
2938 GetClientRect(parent, &parent_rect);
2940 if (dwStyle & CCS_NORESIZE) {
2941 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2944 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
2945 cy = infoPtr->nHeight;
2946 cx = infoPtr->nWidth;
2947 TOOLBAR_CalcToolbar (hwnd);
2948 infoPtr->nWidth = cx;
2949 infoPtr->nHeight = cy;
2952 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2953 TOOLBAR_CalcToolbar (hwnd);
2954 cy = infoPtr->nHeight;
2955 cx = infoPtr->nWidth;
2958 if (dwStyle & CCS_NOPARENTALIGN) {
2959 uPosFlags |= SWP_NOMOVE;
2960 cy = infoPtr->nHeight;
2961 cx = infoPtr->nWidth;
2964 if (!(dwStyle & CCS_NODIVIDER))
2965 cy += GetSystemMetrics(SM_CYEDGE);
2967 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
2968 cx, cy, uPosFlags | SWP_NOZORDER);
2975 TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
2977 TOOLBAR_AutoSize (hwnd, wParam, lParam);
2979 InvalidateRect(hwnd, NULL, FALSE);
2986 static LRESULT WINAPI
2987 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2992 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
2994 case TB_ADDBUTTONSA:
2995 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
2997 /* case TB_ADDBUTTONSW: */
3000 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
3003 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
3006 return TOOLBAR_AutoSize (hwnd, wParam, lParam);
3008 case TB_BUTTONCOUNT:
3009 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
3011 case TB_BUTTONSTRUCTSIZE:
3012 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
3014 case TB_CHANGEBITMAP:
3015 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
3017 case TB_CHECKBUTTON:
3018 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
3020 case TB_COMMANDTOINDEX:
3021 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
3024 return TOOLBAR_Customize (hwnd);
3026 case TB_DELETEBUTTON:
3027 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
3029 case TB_ENABLEBUTTON:
3030 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
3032 /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
3035 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
3037 case TB_GETBITMAPFLAGS:
3038 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
3041 return TOOLBAR_GetButton (hwnd, wParam, lParam);
3043 case TB_GETBUTTONINFOA:
3044 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
3046 /* case TB_GETBUTTONINFOW: */ /* 4.71 */
3048 case TB_GETBUTTONSIZE:
3049 return TOOLBAR_GetButtonSize (hwnd);
3051 case TB_GETBUTTONTEXTA:
3052 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3054 /* case TB_GETBUTTONTEXTW: */
3055 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
3057 case TB_GETDISABLEDIMAGELIST:
3058 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3060 case TB_GETEXTENDEDSTYLE:
3061 return TOOLBAR_GetExtendedStyle (hwnd);
3063 case TB_GETHOTIMAGELIST:
3064 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3066 /* case TB_GETHOTITEM: */ /* 4.71 */
3068 case TB_GETIMAGELIST:
3069 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3071 /* case TB_GETINSERTMARK: */ /* 4.71 */
3072 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3074 case TB_GETITEMRECT:
3075 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3078 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3080 /* case TB_GETOBJECT: */ /* 4.71 */
3081 /* case TB_GETPADDING: */ /* 4.71 */
3084 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3087 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3090 return TOOLBAR_GetState (hwnd, wParam, lParam);
3093 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3095 case TB_GETTEXTROWS:
3096 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3098 case TB_GETTOOLTIPS:
3099 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3101 case TB_GETUNICODEFORMAT:
3102 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3105 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3108 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3110 case TB_INDETERMINATE:
3111 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3113 case TB_INSERTBUTTONA:
3114 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3116 /* case TB_INSERTBUTTONW: */
3117 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3119 case TB_ISBUTTONCHECKED:
3120 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3122 case TB_ISBUTTONENABLED:
3123 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3125 case TB_ISBUTTONHIDDEN:
3126 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3128 case TB_ISBUTTONHIGHLIGHTED:
3129 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3131 case TB_ISBUTTONINDETERMINATE:
3132 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3134 case TB_ISBUTTONPRESSED:
3135 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3137 /* case TB_LOADIMAGES: */ /* 4.70 */
3138 /* case TB_MAPACCELERATORA: */ /* 4.71 */
3139 /* case TB_MAPACCELERATORW: */ /* 4.71 */
3140 /* case TB_MARKBUTTON: */ /* 4.71 */
3141 /* case TB_MOVEBUTTON: */ /* 4.71 */
3143 case TB_PRESSBUTTON:
3144 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3146 /* case TB_REPLACEBITMAP: */
3148 case TB_SAVERESTOREA:
3149 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3151 /* case TB_SAVERESTOREW: */
3152 /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
3154 case TB_SETBITMAPSIZE:
3155 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3157 case TB_SETBUTTONINFOA:
3158 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3160 /* case TB_SETBUTTONINFOW: */ /* 4.71 */
3162 case TB_SETBUTTONSIZE:
3163 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3165 case TB_SETBUTTONWIDTH:
3166 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3169 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3171 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
3173 case TB_SETDISABLEDIMAGELIST:
3174 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3176 case TB_SETDRAWTEXTFLAGS:
3177 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3179 case TB_SETEXTENDEDSTYLE:
3180 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3182 case TB_SETHOTIMAGELIST:
3183 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3185 /* case TB_SETHOTITEM: */ /* 4.71 */
3187 case TB_SETIMAGELIST:
3188 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3191 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3193 /* case TB_SETINSERTMARK: */ /* 4.71 */
3195 case TB_SETINSERTMARKCOLOR:
3196 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3198 case TB_SETMAXTEXTROWS:
3199 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3201 /* case TB_SETPADDING: */ /* 4.71 */
3204 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3207 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3210 return TOOLBAR_SetState (hwnd, wParam, lParam);
3213 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3215 case TB_SETTOOLTIPS:
3216 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3218 case TB_SETUNICODEFORMAT:
3219 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3225 return TOOLBAR_Create (hwnd, wParam, lParam);
3228 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3231 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3233 /* case WM_GETFONT: */
3234 /* case WM_KEYDOWN: */
3235 /* case WM_KILLFOCUS: */
3237 case WM_LBUTTONDBLCLK:
3238 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3240 case WM_LBUTTONDOWN:
3241 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3244 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3247 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3250 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3253 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3256 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3259 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3262 return TOOLBAR_Notify (hwnd, wParam, lParam);
3264 /* case WM_NOTIFYFORMAT: */
3267 return TOOLBAR_Paint (hwnd, wParam);
3270 return TOOLBAR_Size (hwnd, wParam, lParam);
3272 case WM_STYLECHANGED:
3273 return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
3275 /* case WM_SYSCOLORCHANGE: */
3277 /* case WM_WININICHANGE: */
3282 case WM_MEASUREITEM:
3284 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3287 if (uMsg >= WM_USER)
3288 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
3289 uMsg, wParam, lParam);
3290 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3297 TOOLBAR_Register (void)
3301 if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
3303 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3304 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3305 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3306 wndClass.cbClsExtra = 0;
3307 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3308 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3309 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3310 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3312 RegisterClassA (&wndClass);
3317 TOOLBAR_Unregister (void)
3319 if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
3320 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);