4 * Copyright 1998,1999 Eric Kohl
7 * - A little bug in TOOLBAR_DrawMasked()
8 * - Button wrapping (under construction).
12 * - Tooltip support (almost complete).
14 * - Internal COMMCTL32 bitmaps.
15 * - Fix TOOLBAR_SetButtonInfo32A.
16 * - Customize dialog (under construction).
19 * - Run tests using Waite Group Windows95 API Bible Volume 2.
20 * The second cdrom contains executables addstr.exe, btncount.exe,
21 * btnstate.exe, butstrsz.exe, chkbtn.exe, chngbmp.exe, customiz.exe,
22 * enablebtn.exe, getbmp.exe, getbtn.exe, getflags.exe, hidebtn.exe,
23 * indetbtn.exe, insbtn.exe, pressbtn.exe, setbtnsz.exe, setcmdid.exe,
24 * setparnt.exe, setrows.exe, toolwnd.exe.
25 * - Microsofts controlspy examples.
37 #include "debugtools.h"
39 DEFAULT_DEBUG_CHANNEL(toolbar)
41 #define SEPARATOR_WIDTH 8
43 #define BOTTOM_BORDER 2
45 #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
49 TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc)
51 INT x = (lpRect->left + lpRect->right) / 2 - 1;
52 INT yBottom = lpRect->bottom - 3;
53 INT yTop = lpRect->top + 1;
55 SelectObject ( hdc, GetSysColorPen (COLOR_3DSHADOW));
56 MoveToEx (hdc, x, yBottom, NULL);
57 LineTo (hdc, x, yTop);
59 SelectObject ( hdc, GetSysColorPen (COLOR_3DHILIGHT));
60 MoveToEx (hdc, x, yBottom, NULL);
61 LineTo (hdc, x, yTop);
66 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
69 RECT rcText = btnPtr->rect;
75 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
76 InflateRect (&rcText, -3, -3);
77 rcText.top += infoPtr->nBitmapHeight;
78 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
79 OffsetRect (&rcText, 1, 1);
81 hOldFont = SelectObject (hdc, infoPtr->hFont);
82 nOldBkMode = SetBkMode (hdc, TRANSPARENT);
83 if (!(nState & TBSTATE_ENABLED)) {
84 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DHILIGHT));
85 OffsetRect (&rcText, 1, 1);
86 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
87 &rcText, infoPtr->dwDTFlags);
88 SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
89 OffsetRect (&rcText, -1, -1);
90 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
91 &rcText, infoPtr->dwDTFlags);
93 else if (nState & TBSTATE_INDETERMINATE) {
94 clrOld = SetTextColor (hdc, GetSysColor (COLOR_3DSHADOW));
95 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
96 &rcText, infoPtr->dwDTFlags);
99 clrOld = SetTextColor (hdc, GetSysColor (COLOR_BTNTEXT));
100 DrawTextW (hdc, infoPtr->strings[btnPtr->iString], -1,
101 &rcText, infoPtr->dwDTFlags);
104 SetTextColor (hdc, clrOld);
105 SelectObject (hdc, hOldFont);
106 if (nOldBkMode != TRANSPARENT)
107 SetBkMode (hdc, nOldBkMode);
113 TOOLBAR_DrawPattern (HDC hdc, LPRECT lpRect)
115 HBRUSH hbr = SelectObject (hdc, CACHE_GetPattern55AABrush ());
116 INT cx = lpRect->right - lpRect->left;
117 INT cy = lpRect->bottom - lpRect->top;
118 PatBlt (hdc, lpRect->left, lpRect->top, cx, cy, 0x00FA0089);
119 SelectObject (hdc, hbr);
124 TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
125 HDC hdc, INT x, INT y)
127 /* FIXME: this function is a hack since it uses image list
128 internals directly */
130 HDC hdcImageList = CreateCompatibleDC (0);
131 HDC hdcMask = CreateCompatibleDC (0);
132 HIMAGELIST himl = infoPtr->himlStd;
135 /* create new bitmap */
136 hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL);
137 SelectObject (hdcMask, hbmMask);
139 /* copy the mask bitmap */
140 SelectObject (hdcImageList, himl->hbmMask);
141 SetBkColor (hdcImageList, RGB(255, 255, 255));
142 SetTextColor (hdcImageList, RGB(0, 0, 0));
143 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
144 hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
147 /* add white mask from image */
148 SelectObject (hdcImageList, himl->hbmImage);
149 SetBkColor (hdcImageList, RGB(0, 0, 0));
150 BitBlt (hdcMask, 0, 0, himl->cx, himl->cy,
151 hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
154 /* draw the new mask */
155 SelectObject (hdc, GetSysColorBrush (COLOR_3DHILIGHT));
156 BitBlt (hdc, x+1, y+1, himl->cx, himl->cy,
157 hdcMask, 0, 0, 0xB8074A);
159 SelectObject (hdc, GetSysColorBrush (COLOR_3DSHADOW));
160 BitBlt (hdc, x, y, himl->cx, himl->cy,
161 hdcMask, 0, 0, 0xB8074A);
163 DeleteObject (hbmMask);
165 DeleteDC (hdcImageList);
170 TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
172 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
173 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
176 if (btnPtr->fsState & TBSTATE_HIDDEN)
180 if (btnPtr->fsStyle & TBSTYLE_SEP) {
181 if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
182 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
187 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
188 DrawEdge (hdc, &rc, EDGE_RAISED,
189 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
191 if (dwStyle & TBSTYLE_FLAT) {
192 /* if (infoPtr->himlDis) */
193 ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
194 rc.left+1, rc.top+1, ILD_NORMAL);
196 /* TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1); */
199 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
201 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
205 /* pressed TBSTYLE_BUTTON */
206 if (btnPtr->fsState & TBSTATE_PRESSED) {
207 DrawEdge (hdc, &rc, EDGE_SUNKEN, BF_RECT | BF_MIDDLE | BF_ADJUST);
208 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
209 rc.left+2, rc.top+2, ILD_NORMAL);
210 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
214 /* checked TBSTYLE_CHECK*/
215 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
216 (btnPtr->fsState & TBSTATE_CHECKED)) {
217 if (dwStyle & TBSTYLE_FLAT)
218 DrawEdge (hdc, &rc, BDR_SUNKENOUTER,
219 BF_RECT | BF_MIDDLE | BF_ADJUST);
221 DrawEdge (hdc, &rc, EDGE_SUNKEN,
222 BF_RECT | BF_MIDDLE | BF_ADJUST);
224 TOOLBAR_DrawPattern (hdc, &rc);
225 if (dwStyle & TBSTYLE_FLAT)
227 if (infoPtr->himlDef != NULL)
228 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
229 rc.left+2, rc.top+2, ILD_NORMAL);
231 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
232 rc.left+2, rc.top+2, ILD_NORMAL);
235 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
236 rc.left+2, rc.top+2, ILD_NORMAL);
237 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
242 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
243 DrawEdge (hdc, &rc, EDGE_RAISED,
244 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
246 TOOLBAR_DrawPattern (hdc, &rc);
247 TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left+1, rc.top+1);
248 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
252 if (dwStyle & TBSTYLE_FLAT)
255 DrawEdge (hdc, &rc, BDR_RAISEDINNER,
256 BF_RECT | BF_MIDDLE | BF_SOFT);
258 if(infoPtr->himlDef != NULL)
259 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
260 rc.left +2, rc.top +2, ILD_NORMAL);
262 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
263 rc.left +2, rc.top +2, ILD_NORMAL);
267 DrawEdge (hdc, &rc, EDGE_RAISED,
268 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
270 ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
271 rc.left+1, rc.top+1, ILD_NORMAL);
274 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
279 TOOLBAR_Refresh (HWND hwnd, HDC hdc)
281 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
282 TBUTTON_INFO *btnPtr;
286 btnPtr = infoPtr->buttons;
287 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
288 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
293 TOOLBAR_CalcStrings (HWND hwnd, LPSIZE lpSize)
295 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
296 TBUTTON_INFO *btnPtr;
305 hOldFont = SelectObject (hdc, infoPtr->hFont);
307 btnPtr = infoPtr->buttons;
308 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
309 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
310 (btnPtr->iString > -1) &&
311 (btnPtr->iString < infoPtr->nNumStrings)) {
312 LPWSTR lpText = infoPtr->strings[btnPtr->iString];
313 GetTextExtentPoint32W (hdc, lpText, lstrlenW (lpText), &sz);
314 if (sz.cx > lpSize->cx)
316 if (sz.cy > lpSize->cy)
321 SelectObject (hdc, hOldFont);
324 TRACE("string size %d x %d!\n", lpSize->cx, lpSize->cy);
327 /***********************************************************************
328 * TOOLBAR_WrapToolbar
330 * This function walks through the buttons and seperators in the
331 * toolbar, and sets the TBSTATE_WRAP flag only on those items where
332 * wrapping should occur based on the width of the toolbar window.
333 * It does *not* calculate button placement itself. That task
334 * takes place in TOOLBAR_CalcToolbar. If the program wants to manage
335 * the toolbar wrapping on it's own, it can use the TBSTYLE_WRAPPABLE
336 * flag, and set the TBSTATE_WRAP flags manually on the appropriate items.
340 TOOLBAR_WrapToolbar( HWND hwnd )
342 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
343 TBUTTON_INFO *btnPtr;
344 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
347 BOOL bWrap, bButtonWrap;
349 /* When the toolbar window style is not TBSTYLE_WRAPABLE, */
350 /* no layout is necessary. Applications may use this style */
351 /* to perform their own layout on the toolbar. */
352 if( !(dwStyle & TBSTYLE_WRAPABLE) )
355 btnPtr = infoPtr->buttons;
356 x = infoPtr->nIndent;
358 GetClientRect( GetParent(hwnd), &rc );
359 infoPtr->nWidth = rc.right - rc.left;
362 for (i = 0; i < infoPtr->nNumButtons; i++ )
365 btnPtr[i].fsState &= ~TBSTATE_WRAP;
367 if (btnPtr[i].fsState & TBSTATE_HIDDEN)
370 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
371 /* it is the actual width of the separator. This is used for */
372 /* custom controls in toolbars. */
373 if (btnPtr[i].fsStyle & TBSTYLE_SEP)
374 cx = (btnPtr[i].iBitmap > 0) ?
375 btnPtr[i].iBitmap : SEPARATOR_WIDTH;
377 cx = infoPtr->nButtonWidth;
379 /* Two or more adjacent separators form a separator group. */
380 /* The first separator in a group should be wrapped to the */
381 /* next row if the previous wrapping is on a button. */
383 (btnPtr[i].fsStyle & TBSTYLE_SEP) &&
384 (i + 1 < infoPtr->nNumButtons ) &&
385 (btnPtr[i + 1].fsStyle & TBSTYLE_SEP) )
387 btnPtr[i].fsState |= TBSTATE_WRAP;
388 x = infoPtr->nIndent;
394 /* The layout makes sure the bitmap is visible, but not the button. */
395 if ( x + cx - (infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2
400 /* If the current button is a separator and not hidden, */
401 /* go to the next until it reaches a non separator. */
402 /* Wrap the last separator if it is before a button. */
403 while( ( (btnPtr[i].fsStyle & TBSTYLE_SEP) ||
404 (btnPtr[i].fsState & TBSTATE_HIDDEN) ) &&
405 i < infoPtr->nNumButtons )
411 if( bFound && i < infoPtr->nNumButtons )
414 btnPtr[i].fsState |= TBSTATE_WRAP;
415 x = infoPtr->nIndent;
419 else if ( i >= infoPtr->nNumButtons)
422 /* If the current button is not a separator, find the last */
423 /* separator and wrap it. */
424 for ( j = i - 1; j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
426 if ((btnPtr[j].fsStyle & TBSTYLE_SEP) &&
427 !(btnPtr[j].fsState & TBSTATE_HIDDEN))
431 x = infoPtr->nIndent;
432 btnPtr[j].fsState |= TBSTATE_WRAP;
438 /* If no separator available for wrapping, wrap one of */
439 /* non-hidden previous button. */
443 j >= 0 && !(btnPtr[j].fsState & TBSTATE_WRAP); j--)
445 if (btnPtr[j].fsState & TBSTATE_HIDDEN)
450 x = infoPtr->nIndent;
451 btnPtr[j].fsState |= TBSTATE_WRAP;
457 /* If all above failed, wrap the current button. */
460 btnPtr[i].fsState |= TBSTATE_WRAP;
462 x = infoPtr->nIndent;
463 if (btnPtr[i].fsState & TBSTYLE_SEP )
474 /***********************************************************************
475 * TOOLBAR_CalcToolbar
477 * This function calculates button and separator placement. It first
478 * calculates the button sizes, gets the toolbar window width and then
479 * calls TOOLBAR_WrapToolbar to determine which buttons we need to wrap
480 * on. It assigns a new location to each item and sends this location to
481 * the tooltip window if appropriate. Finally, it updates the rcBound
482 * rect and calculates the new required toolbar window height.
486 TOOLBAR_CalcToolbar (HWND hwnd)
488 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
489 TBUTTON_INFO *btnPtr;
490 INT i, nRows, nSepRows;
496 TOOLBAR_CalcStrings (hwnd, &sizeString);
498 if (sizeString.cy > 0)
499 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
500 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
501 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
503 if (sizeString.cx > infoPtr->nBitmapWidth)
504 infoPtr->nButtonWidth = sizeString.cx + 6;
505 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
506 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
508 TOOLBAR_WrapToolbar( hwnd );
510 x = infoPtr->nIndent;
512 cx = infoPtr->nButtonWidth;
513 cy = infoPtr->nButtonHeight;
514 nRows = nSepRows = 0;
516 infoPtr->rcBound.top = y;
517 infoPtr->rcBound.left = x;
518 infoPtr->rcBound.bottom = y + cy;
519 infoPtr->rcBound.right = x;
521 btnPtr = infoPtr->buttons;
522 GetClientRect( GetParent(hwnd), &rc );
523 infoPtr->nWidth = rc.right - rc.left;
525 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++ )
528 if (btnPtr->fsState & TBSTATE_HIDDEN)
530 SetRectEmpty (&btnPtr->rect);
534 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
535 /* it is the actual width of the separator. This is used for */
536 /* custom controls in toolbars. */
537 if (btnPtr->fsStyle & TBSTYLE_SEP)
538 cx = (btnPtr->iBitmap > 0) ?
539 btnPtr->iBitmap : SEPARATOR_WIDTH;
541 cx = infoPtr->nButtonWidth;
543 if (btnPtr->fsState & TBSTATE_WRAP )
546 SetRect (&btnPtr->rect, x, y, x + cx, y + cy);
548 if (infoPtr->rcBound.left > x)
549 infoPtr->rcBound.left = x;
550 if (infoPtr->rcBound.right < x + cx)
551 infoPtr->rcBound.right = x + cx;
552 if (infoPtr->rcBound.bottom < y + cy)
553 infoPtr->rcBound.bottom = y + cy;
555 /* Set the toolTip only for non-hidden, non-separator button */
556 if (infoPtr->hwndToolTip && !(btnPtr->fsStyle & TBSTYLE_SEP ))
560 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
561 ti.cbSize = sizeof(TTTOOLINFOA);
563 ti.uId = btnPtr->idCommand;
564 ti.rect = btnPtr->rect;
565 SendMessageA (infoPtr->hwndToolTip, TTM_NEWTOOLRECTA,
569 /* btnPtr->nRow is zero based. The space between the rows is */
570 /* also considered as a row. */
571 btnPtr->nRow = nRows + nSepRows;
574 if ( !(btnPtr->fsStyle & TBSTYLE_SEP) )
578 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
579 /* it is the actual width of the separator. This is used for */
580 /* custom controls in toolbars. */
581 y += cy + ( (btnPtr->iBitmap > 0 ) ?
582 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 /3;
584 /* nSepRows is used to calculate the extra height follwoing */
588 x = infoPtr->nIndent;
595 /* infoPtr->nRows is the number of rows on the toolbar */
596 infoPtr->nRows = nRows + nSepRows + 1;
598 /* nSepRows * (infoPtr->nBitmapHeight + 1) is the space following */
600 infoPtr->nHeight = TOP_BORDER + (nRows + 1) * infoPtr->nButtonHeight +
601 nSepRows * SEPARATOR_WIDTH * 2 / 3 +
602 nSepRows * (infoPtr->nBitmapHeight + 1) +
604 TRACE("toolbar height %d\n", infoPtr->nHeight);
609 TOOLBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt)
611 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
612 TBUTTON_INFO *btnPtr;
615 btnPtr = infoPtr->buttons;
616 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
617 if (btnPtr->fsState & TBSTATE_HIDDEN)
620 if (btnPtr->fsStyle & TBSTYLE_SEP) {
621 if (PtInRect (&btnPtr->rect, *lpPt)) {
622 TRACE(" ON SEPARATOR %d!\n", i);
627 if (PtInRect (&btnPtr->rect, *lpPt)) {
628 TRACE(" ON BUTTON %d!\n", i);
634 TRACE(" NOWHERE!\n");
640 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT idCommand)
642 TBUTTON_INFO *btnPtr;
645 btnPtr = infoPtr->buttons;
646 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
647 if (btnPtr->idCommand == idCommand) {
648 TRACE("command=%d index=%d\n", idCommand, i);
652 TRACE("no index found for command=%d\n", idCommand);
658 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT nIndex)
660 TBUTTON_INFO *btnPtr;
663 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
666 /* check index button */
667 btnPtr = &infoPtr->buttons[nIndex];
668 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
669 if (btnPtr->fsState & TBSTATE_CHECKED)
673 /* check previous buttons */
674 nRunIndex = nIndex - 1;
675 while (nRunIndex >= 0) {
676 btnPtr = &infoPtr->buttons[nRunIndex];
677 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
678 if (btnPtr->fsState & TBSTATE_CHECKED)
686 /* check next buttons */
687 nRunIndex = nIndex + 1;
688 while (nRunIndex < infoPtr->nNumButtons) {
689 btnPtr = &infoPtr->buttons[nRunIndex];
690 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
691 if (btnPtr->fsState & TBSTATE_CHECKED)
704 TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
705 WPARAM wParam, LPARAM lParam)
713 msg.time = GetMessageTime ();
714 msg.pt.x = LOWORD(GetMessagePos ());
715 msg.pt.y = HIWORD(GetMessagePos ());
717 SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
721 /***********************************************************************
722 * TOOLBAR_CustomizeDialogProc
723 * This function implements the toolbar customization dialog.
726 TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
728 TOOLBAR_INFO *infoPtr = (TOOLBAR_INFO *)GetWindowLongA (hwnd, DWL_USER);
729 static HDSA hDsa = NULL;
734 infoPtr = (TOOLBAR_INFO *)lParam;
735 SetWindowLongA (hwnd, DWL_USER, (DWORD)infoPtr);
737 hDsa = DSA_Create (sizeof(TBUTTON_INFO), 5);
741 TBUTTON_INFO *btnPtr;
744 /* insert 'virtual' separator button into 'available buttons' list */
745 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
747 /* copy all buttons and append them to the right listbox */
748 btnPtr = infoPtr->buttons;
749 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
751 DSA_InsertItem (hDsa, i, btnPtr);
753 if (btnPtr->fsState & TBSTATE_HIDDEN)
755 SendDlgItemMessageA (hwnd, IDC_AVAILBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
759 SendDlgItemMessageA (hwnd, IDC_TOOLBARBTN_LBOX, LB_ADDSTRING, 0, (LPARAM)"");
763 /* append 'virtual' sepatator button to the 'toolbar buttons' list */
769 EndDialog(hwnd, FALSE);
773 switch (LOWORD(wParam))
776 EndDialog(hwnd, FALSE);
787 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
789 LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)lParam;
794 COLORREF oldText = 0;
797 FIXME("action: %x itemState: %x\n",
798 lpdis->itemAction, lpdis->itemState);
800 if (lpdis->itemState & ODS_FOCUS)
802 oldBk = SetBkColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHT));
803 oldText = SetTextColor (lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
806 hOldPen = SelectObject (lpdis->hDC, GetSysColorPen ((lpdis->itemState & ODS_SELECTED)?COLOR_HIGHLIGHT:COLOR_WINDOW));
807 hOldBrush = SelectObject (lpdis->hDC, GetSysColorBrush ((lpdis->itemState & ODS_FOCUS)?COLOR_HIGHLIGHT:COLOR_WINDOW));
809 /* fill background rectangle */
810 Rectangle (lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
811 lpdis->rcItem.right, lpdis->rcItem.bottom);
813 /* calculate button and text rectangles */
814 CopyRect (&rcButton, &lpdis->rcItem);
815 InflateRect (&rcButton, -1, -1);
816 CopyRect (&rcText, &rcButton);
817 rcButton.right = rcButton.left + infoPtr->nBitmapWidth + 6;
818 rcText.left = rcButton.right + 2;
820 /* draw focus rectangle */
821 if (lpdis->itemState & ODS_FOCUS)
822 DrawFocusRect (lpdis->hDC, &lpdis->rcItem);
825 DrawEdge (lpdis->hDC, &rcButton, EDGE_RAISED, BF_RECT|BF_MIDDLE|BF_SOFT);
828 if (wParam == IDC_AVAILBTN_LBOX && lpdis->itemID == 0)
829 DrawTextA (lpdis->hDC, "Separator", -1, &rcText,
830 DT_LEFT | DT_VCENTER | DT_SINGLELINE);
832 if (lpdis->itemState & ODS_FOCUS)
834 SetBkColor (lpdis->hDC, oldBk);
835 SetTextColor (lpdis->hDC, oldText);
838 SelectObject (lpdis->hDC, hOldBrush);
839 SelectObject (lpdis->hDC, hOldPen);
846 if (wParam == IDC_AVAILBTN_LBOX || wParam == IDC_TOOLBARBTN_LBOX)
848 MEASUREITEMSTRUCT *lpmis = (MEASUREITEMSTRUCT*)lParam;
851 lpmis->itemHeight = infoPtr->nBitmapHeight + 8;
853 lpmis->itemHeight = 16 + 8; /* default height */
865 /***********************************************************************
866 * TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
870 TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
872 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
873 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
876 if ((!lpAddBmp) || ((INT)wParam <= 0))
879 TRACE("adding %d bitmaps!\n", wParam);
881 if (!(infoPtr->himlStd)) {
882 /* create new standard image list */
884 TRACE("creating standard image list!\n");
887 /* Windows resize all the buttons to the size of a newly added STandard Image*/
888 /* TODO: The resizing should be done each time a standard image is added*/
889 if (lpAddBmp->hInst == HINST_COMMCTRL)
892 if (lpAddBmp->nID & 1)
894 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
895 MAKELPARAM((WORD)26, (WORD)26));
896 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
897 MAKELPARAM((WORD)33, (WORD)33));
901 SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
902 MAKELPARAM((WORD)16, (WORD)16));
904 SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
905 MAKELPARAM((WORD)22, (WORD)22));
908 TOOLBAR_CalcToolbar (hwnd);
912 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
913 ILC_COLOR | ILC_MASK, (INT)wParam, 2);
916 /* Add bitmaps to the standard image list */
917 if (lpAddBmp->hInst == (HINSTANCE)0) {
919 ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
922 else if (lpAddBmp->hInst == HINST_COMMCTRL) {
923 /* add internal bitmaps */
925 FIXME("internal bitmaps not supported!\n");
926 /* TODO: Resize all the buttons when a new standard image is added */
928 /* Hack to "add" some reserved images within the image list
929 to get the right image indices */
930 nIndex = ImageList_GetImageCount (infoPtr->himlStd);
931 ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
936 LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
937 nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
942 infoPtr->nNumBitmaps += (INT)wParam;
949 TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
951 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
952 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
953 INT nOldButtons, nNewButtons, nAddButtons, nCount;
955 TRACE("adding %d buttons!\n", wParam);
957 nAddButtons = (UINT)wParam;
958 nOldButtons = infoPtr->nNumButtons;
959 nNewButtons = nOldButtons + nAddButtons;
961 if (infoPtr->nNumButtons == 0) {
963 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
966 TBUTTON_INFO *oldButtons = infoPtr->buttons;
968 COMCTL32_Alloc (sizeof(TBUTTON_INFO) * nNewButtons);
969 memcpy (&infoPtr->buttons[0], &oldButtons[0],
970 nOldButtons * sizeof(TBUTTON_INFO));
971 COMCTL32_Free (oldButtons);
974 infoPtr->nNumButtons = nNewButtons;
976 /* insert new button data */
977 for (nCount = 0; nCount < nAddButtons; nCount++) {
978 TBUTTON_INFO *btnPtr = &infoPtr->buttons[nOldButtons+nCount];
979 btnPtr->iBitmap = lpTbb[nCount].iBitmap;
980 btnPtr->idCommand = lpTbb[nCount].idCommand;
981 btnPtr->fsState = lpTbb[nCount].fsState;
982 btnPtr->fsStyle = lpTbb[nCount].fsStyle;
983 btnPtr->dwData = lpTbb[nCount].dwData;
984 btnPtr->iString = lpTbb[nCount].iString;
985 btnPtr->bHot = FALSE;
987 if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
990 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
991 ti.cbSize = sizeof (TTTOOLINFOA);
993 ti.uId = btnPtr->idCommand;
995 ti.lpszText = LPSTR_TEXTCALLBACKA;
997 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1002 TOOLBAR_CalcToolbar (hwnd);
1004 InvalidateRect(hwnd, NULL, FALSE);
1010 /* << TOOLBAR_AddButtons32W >> */
1014 TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1016 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1019 if ((wParam) && (HIWORD(lParam) == 0)) {
1022 TRACE("adding string from resource!\n");
1024 len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam,
1027 TRACE("len=%d \"%s\"\n", len, szString);
1028 nIndex = infoPtr->nNumStrings;
1029 if (infoPtr->nNumStrings == 0) {
1031 COMCTL32_Alloc (sizeof(LPWSTR));
1034 LPWSTR *oldStrings = infoPtr->strings;
1036 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1037 memcpy (&infoPtr->strings[0], &oldStrings[0],
1038 sizeof(LPWSTR) * infoPtr->nNumStrings);
1039 COMCTL32_Free (oldStrings);
1042 infoPtr->strings[infoPtr->nNumStrings] =
1043 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1044 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], szString);
1045 infoPtr->nNumStrings++;
1048 LPSTR p = (LPSTR)lParam;
1053 TRACE("adding string(s) from array!\n");
1054 nIndex = infoPtr->nNumStrings;
1057 TRACE("len=%d \"%s\"\n", len, p);
1059 if (infoPtr->nNumStrings == 0) {
1061 COMCTL32_Alloc (sizeof(LPWSTR));
1064 LPWSTR *oldStrings = infoPtr->strings;
1066 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1067 memcpy (&infoPtr->strings[0], &oldStrings[0],
1068 sizeof(LPWSTR) * infoPtr->nNumStrings);
1069 COMCTL32_Free (oldStrings);
1072 infoPtr->strings[infoPtr->nNumStrings] =
1073 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1074 lstrcpyAtoW (infoPtr->strings[infoPtr->nNumStrings], p);
1075 infoPtr->nNumStrings++;
1086 TOOLBAR_AddStringW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1088 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1091 if ((wParam) && (HIWORD(lParam) == 0)) {
1092 WCHAR szString[256];
1094 TRACE("adding string from resource!\n");
1096 len = LoadStringW ((HINSTANCE)wParam, (UINT)lParam,
1099 TRACE("len=%d \"%s\"\n", len, debugstr_w(szString));
1100 nIndex = infoPtr->nNumStrings;
1101 if (infoPtr->nNumStrings == 0) {
1103 COMCTL32_Alloc (sizeof(LPWSTR));
1106 LPWSTR *oldStrings = infoPtr->strings;
1108 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1109 memcpy (&infoPtr->strings[0], &oldStrings[0],
1110 sizeof(LPWSTR) * infoPtr->nNumStrings);
1111 COMCTL32_Free (oldStrings);
1114 infoPtr->strings[infoPtr->nNumStrings] =
1115 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1116 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], szString);
1117 infoPtr->nNumStrings++;
1120 LPWSTR p = (LPWSTR)lParam;
1125 TRACE("adding string(s) from array!\n");
1126 nIndex = infoPtr->nNumStrings;
1129 TRACE("len=%d \"%s\"\n", len, debugstr_w(p));
1131 if (infoPtr->nNumStrings == 0) {
1133 COMCTL32_Alloc (sizeof(LPWSTR));
1136 LPWSTR *oldStrings = infoPtr->strings;
1138 COMCTL32_Alloc (sizeof(LPWSTR) * (infoPtr->nNumStrings + 1));
1139 memcpy (&infoPtr->strings[0], &oldStrings[0],
1140 sizeof(LPWSTR) * infoPtr->nNumStrings);
1141 COMCTL32_Free (oldStrings);
1144 infoPtr->strings[infoPtr->nNumStrings] =
1145 COMCTL32_Alloc (sizeof(WCHAR)*(len+1));
1146 lstrcpyW (infoPtr->strings[infoPtr->nNumStrings], p);
1147 infoPtr->nNumStrings++;
1158 TOOLBAR_AutoSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1160 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1161 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1168 TRACE("resize forced!\n");
1170 parent = GetParent (hwnd);
1171 GetClientRect(parent, &parent_rect);
1173 if (dwStyle & CCS_NORESIZE) {
1174 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
1179 infoPtr->nWidth = parent_rect.right - parent_rect.left;
1180 TOOLBAR_CalcToolbar (hwnd);
1181 InvalidateRect( hwnd, NULL, TRUE );
1182 cy = infoPtr->nHeight;
1183 cx = infoPtr->nWidth;
1186 if (dwStyle & CCS_NOPARENTALIGN)
1187 uPosFlags |= SWP_NOMOVE;
1189 if (!(dwStyle & CCS_NODIVIDER))
1190 cy += GetSystemMetrics(SM_CYEDGE);
1192 infoPtr->bAutoSize = TRUE;
1193 SetWindowPos (hwnd, HWND_TOP, parent_rect.left, parent_rect.top,
1201 TOOLBAR_ButtonCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
1203 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1205 return infoPtr->nNumButtons;
1210 TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1212 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1214 if (infoPtr == NULL) {
1215 ERR("(0x%x, 0x%x, 0x%lx)\n", hwnd, wParam, lParam);
1216 ERR("infoPtr == NULL!\n");
1220 infoPtr->dwStructSize = (DWORD)wParam;
1227 TOOLBAR_ChangeBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1229 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1230 TBUTTON_INFO *btnPtr;
1234 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1238 btnPtr = &infoPtr->buttons[nIndex];
1239 btnPtr->iBitmap = LOWORD(lParam);
1242 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1243 ReleaseDC (hwnd, hdc);
1250 TOOLBAR_CheckButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1252 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1253 TBUTTON_INFO *btnPtr;
1258 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1262 btnPtr = &infoPtr->buttons[nIndex];
1264 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
1267 if (LOWORD(lParam) == FALSE)
1268 btnPtr->fsState &= ~TBSTATE_CHECKED;
1270 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
1272 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
1273 if (nOldIndex == nIndex)
1275 if (nOldIndex != -1)
1276 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
1278 btnPtr->fsState |= TBSTATE_CHECKED;
1282 if (nOldIndex != -1)
1283 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
1284 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1285 ReleaseDC (hwnd, hdc);
1287 /* FIXME: Send a WM_NOTIFY?? */
1294 TOOLBAR_CommandToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
1296 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1298 return TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1303 TOOLBAR_Customize (HWND hwnd)
1305 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1311 /* send TBN_BEGINADJUST notification */
1312 nmhdr.hwndFrom = hwnd;
1313 nmhdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
1314 nmhdr.code = TBN_BEGINADJUST;
1316 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1317 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1319 if (!(hRes = FindResourceA (COMCTL32_hModule,
1320 MAKEINTRESOURCEA(IDD_TBCUSTOMIZE),
1324 if(!(template = (LPVOID)LoadResource (COMCTL32_hModule, hRes)))
1327 ret = DialogBoxIndirectParamA (GetWindowLongA (hwnd, GWL_HINSTANCE),
1328 (LPDLGTEMPLATEA)template,
1330 (DLGPROC)TOOLBAR_CustomizeDialogProc,
1333 /* send TBN_ENDADJUST notification */
1334 nmhdr.code = TBN_ENDADJUST;
1336 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
1337 (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
1344 TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1346 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1347 INT nIndex = (INT)wParam;
1349 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1352 if ((infoPtr->hwndToolTip) &&
1353 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
1356 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1357 ti.cbSize = sizeof (TTTOOLINFOA);
1359 ti.uId = infoPtr->buttons[nIndex].idCommand;
1361 SendMessageA (infoPtr->hwndToolTip, TTM_DELTOOLA, 0, (LPARAM)&ti);
1364 if (infoPtr->nNumButtons == 1) {
1365 TRACE(" simple delete!\n");
1366 COMCTL32_Free (infoPtr->buttons);
1367 infoPtr->buttons = NULL;
1368 infoPtr->nNumButtons = 0;
1371 TBUTTON_INFO *oldButtons = infoPtr->buttons;
1372 TRACE("complex delete! [nIndex=%d]\n", nIndex);
1374 infoPtr->nNumButtons--;
1375 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1377 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1378 nIndex * sizeof(TBUTTON_INFO));
1381 if (nIndex < infoPtr->nNumButtons) {
1382 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
1383 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
1386 COMCTL32_Free (oldButtons);
1389 TOOLBAR_CalcToolbar (hwnd);
1391 InvalidateRect (hwnd, NULL, TRUE);
1398 TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1400 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1401 TBUTTON_INFO *btnPtr;
1405 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1409 btnPtr = &infoPtr->buttons[nIndex];
1410 if (LOWORD(lParam) == FALSE)
1411 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
1413 btnPtr->fsState |= TBSTATE_ENABLED;
1416 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1417 ReleaseDC (hwnd, hdc);
1423 /* << TOOLBAR_GetAnchorHighlight >> */
1427 TOOLBAR_GetBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
1429 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1432 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1436 return infoPtr->buttons[nIndex].iBitmap;
1440 static inline LRESULT
1441 TOOLBAR_GetBitmapFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
1443 return (GetDeviceCaps (0, LOGPIXELSX) >= 120) ? TBBF_LARGE : 0;
1448 TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1450 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1451 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1452 INT nIndex = (INT)wParam;
1453 TBUTTON_INFO *btnPtr;
1455 if (infoPtr == NULL)
1461 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1464 btnPtr = &infoPtr->buttons[nIndex];
1465 lpTbb->iBitmap = btnPtr->iBitmap;
1466 lpTbb->idCommand = btnPtr->idCommand;
1467 lpTbb->fsState = btnPtr->fsState;
1468 lpTbb->fsStyle = btnPtr->fsStyle;
1469 lpTbb->dwData = btnPtr->dwData;
1470 lpTbb->iString = btnPtr->iString;
1477 TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1479 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1480 LPTBBUTTONINFOA lpTbInfo = (LPTBBUTTONINFOA)lParam;
1481 TBUTTON_INFO *btnPtr;
1484 if (infoPtr == NULL)
1486 if (lpTbInfo == NULL)
1488 if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA))
1491 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1495 btnPtr = &infoPtr->buttons[nIndex];
1497 if (lpTbInfo->dwMask & TBIF_COMMAND)
1498 lpTbInfo->idCommand = btnPtr->idCommand;
1499 if (lpTbInfo->dwMask & TBIF_IMAGE)
1500 lpTbInfo->iImage = btnPtr->iBitmap;
1501 if (lpTbInfo->dwMask & TBIF_LPARAM)
1502 lpTbInfo->lParam = btnPtr->dwData;
1503 if (lpTbInfo->dwMask & TBIF_SIZE)
1504 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
1505 if (lpTbInfo->dwMask & TBIF_STATE)
1506 lpTbInfo->fsState = btnPtr->fsState;
1507 if (lpTbInfo->dwMask & TBIF_STYLE)
1508 lpTbInfo->fsStyle = btnPtr->fsStyle;
1509 if (lpTbInfo->dwMask & TBIF_TEXT) {
1510 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
1511 lstrcpynA (lpTbInfo->pszText,
1512 (LPSTR)infoPtr->strings[btnPtr->iString],
1520 /* << TOOLBAR_GetButtonInfo32W >> */
1524 TOOLBAR_GetButtonSize (HWND hwnd)
1526 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1528 return MAKELONG((WORD)infoPtr->nButtonWidth,
1529 (WORD)infoPtr->nButtonHeight);
1534 TOOLBAR_GetButtonTextA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1536 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1537 INT nIndex, nStringIndex;
1539 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1543 nStringIndex = infoPtr->buttons[nIndex].iString;
1545 TRACE("index=%d stringIndex=%d\n", nIndex, nStringIndex);
1547 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1550 if (lParam == 0) return -1;
1552 lstrcpyA ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
1554 return lstrlenA ((LPSTR)infoPtr->strings[nStringIndex]);
1558 /* << TOOLBAR_GetButtonText32W >> */
1559 /* << TOOLBAR_GetColorScheme >> */
1563 TOOLBAR_GetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1565 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1567 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1568 return (LRESULT)infoPtr->himlDis;
1574 inline static LRESULT
1575 TOOLBAR_GetExtendedStyle (HWND hwnd)
1577 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1579 return infoPtr->dwExStyle;
1584 TOOLBAR_GetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1586 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1588 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1589 return (LRESULT)infoPtr->himlHot;
1595 /* << TOOLBAR_GetHotItem >> */
1599 TOOLBAR_GetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
1601 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1603 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT)
1604 return (LRESULT)infoPtr->himlDef;
1610 /* << TOOLBAR_GetInsertMark >> */
1611 /* << TOOLBAR_GetInsertMarkColor >> */
1615 TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1617 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1618 TBUTTON_INFO *btnPtr;
1622 if (infoPtr == NULL)
1624 nIndex = (INT)wParam;
1625 btnPtr = &infoPtr->buttons[nIndex];
1626 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1628 lpRect = (LPRECT)lParam;
1631 if (btnPtr->fsState & TBSTATE_HIDDEN)
1634 TOOLBAR_CalcToolbar( hwnd );
1636 lpRect->left = btnPtr->rect.left;
1637 lpRect->right = btnPtr->rect.right;
1638 lpRect->bottom = btnPtr->rect.bottom;
1639 lpRect->top = btnPtr->rect.top;
1646 TOOLBAR_GetMaxSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1648 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1649 LPSIZE lpSize = (LPSIZE)lParam;
1654 lpSize->cx = infoPtr->rcBound.right - infoPtr->rcBound.left;
1655 lpSize->cy = infoPtr->rcBound.bottom - infoPtr->rcBound.top;
1657 TRACE("maximum size %d x %d\n",
1658 infoPtr->rcBound.right - infoPtr->rcBound.left,
1659 infoPtr->rcBound.bottom - infoPtr->rcBound.top);
1665 /* << TOOLBAR_GetObject >> */
1666 /* << TOOLBAR_GetPadding >> */
1670 TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1672 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1673 TBUTTON_INFO *btnPtr;
1677 if (infoPtr == NULL)
1679 nIndex = (INT)wParam;
1680 btnPtr = &infoPtr->buttons[nIndex];
1681 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1683 lpRect = (LPRECT)lParam;
1687 lpRect->left = btnPtr->rect.left;
1688 lpRect->right = btnPtr->rect.right;
1689 lpRect->bottom = btnPtr->rect.bottom;
1690 lpRect->top = btnPtr->rect.top;
1697 TOOLBAR_GetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1699 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1701 if (GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_WRAPABLE)
1702 return infoPtr->nRows;
1709 TOOLBAR_GetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
1711 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1714 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1718 return infoPtr->buttons[nIndex].fsState;
1723 TOOLBAR_GetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
1725 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1728 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1732 return infoPtr->buttons[nIndex].fsStyle;
1737 TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
1739 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1741 if (infoPtr == NULL)
1744 return infoPtr->nMaxTextRows;
1749 TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
1751 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1753 if (infoPtr == NULL)
1755 return infoPtr->hwndToolTip;
1760 TOOLBAR_GetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
1762 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1764 TRACE("%s hwnd=0x%x stub!\n",
1765 infoPtr->bUnicode ? "TRUE" : "FALSE", hwnd);
1767 return infoPtr->bUnicode;
1772 TOOLBAR_HideButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1774 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1775 TBUTTON_INFO *btnPtr;
1778 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1782 btnPtr = &infoPtr->buttons[nIndex];
1783 if (LOWORD(lParam) == FALSE)
1784 btnPtr->fsState &= ~TBSTATE_HIDDEN;
1786 btnPtr->fsState |= TBSTATE_HIDDEN;
1788 TOOLBAR_CalcToolbar (hwnd);
1790 InvalidateRect (hwnd, NULL, TRUE);
1796 inline static LRESULT
1797 TOOLBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
1799 return TOOLBAR_InternalHitTest (hwnd, (LPPOINT)lParam);
1804 TOOLBAR_Indeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1806 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1807 TBUTTON_INFO *btnPtr;
1811 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1815 btnPtr = &infoPtr->buttons[nIndex];
1816 if (LOWORD(lParam) == FALSE)
1817 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
1819 btnPtr->fsState |= TBSTATE_INDETERMINATE;
1822 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
1823 ReleaseDC (hwnd, hdc);
1830 TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1832 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1833 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1834 INT nIndex = (INT)wParam;
1835 TBUTTON_INFO *oldButtons;
1842 TRACE("inserting button index=%d\n", nIndex);
1843 if (nIndex > infoPtr->nNumButtons) {
1844 nIndex = infoPtr->nNumButtons;
1845 TRACE("adjust index=%d\n", nIndex);
1848 oldButtons = infoPtr->buttons;
1849 infoPtr->nNumButtons++;
1850 infoPtr->buttons = COMCTL32_Alloc (sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1851 /* pre insert copy */
1853 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1854 nIndex * sizeof(TBUTTON_INFO));
1857 /* insert new button */
1858 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
1859 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
1860 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
1861 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
1862 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
1863 infoPtr->buttons[nIndex].iString = lpTbb->iString;
1865 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
1868 ZeroMemory (&ti, sizeof(TTTOOLINFOA));
1869 ti.cbSize = sizeof (TTTOOLINFOA);
1871 ti.uId = lpTbb->idCommand;
1873 ti.lpszText = LPSTR_TEXTCALLBACKA;
1875 SendMessageA (infoPtr->hwndToolTip, TTM_ADDTOOLA,
1879 /* post insert copy */
1880 if (nIndex < infoPtr->nNumButtons - 1) {
1881 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
1882 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
1885 COMCTL32_Free (oldButtons);
1887 TOOLBAR_CalcToolbar (hwnd);
1889 InvalidateRect (hwnd, NULL, FALSE);
1895 /* << TOOLBAR_InsertButton32W >> */
1896 /* << TOOLBAR_InsertMarkHitTest >> */
1900 TOOLBAR_IsButtonChecked (HWND hwnd, WPARAM wParam, LPARAM lParam)
1902 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1905 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1909 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
1914 TOOLBAR_IsButtonEnabled (HWND hwnd, WPARAM wParam, LPARAM lParam)
1916 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1919 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1923 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
1928 TOOLBAR_IsButtonHidden (HWND hwnd, WPARAM wParam, LPARAM lParam)
1930 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1933 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1937 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
1942 TOOLBAR_IsButtonHighlighted (HWND hwnd, WPARAM wParam, LPARAM lParam)
1944 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1947 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1951 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
1956 TOOLBAR_IsButtonIndeterminate (HWND hwnd, WPARAM wParam, LPARAM lParam)
1958 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1961 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1965 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
1970 TOOLBAR_IsButtonPressed (HWND hwnd, WPARAM wParam, LPARAM lParam)
1972 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1975 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
1979 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
1983 /* << TOOLBAR_LoadImages >> */
1984 /* << TOOLBAR_MapAccelerator >> */
1985 /* << TOOLBAR_MarkButton >> */
1986 /* << TOOLBAR_MoveButton >> */
1990 TOOLBAR_PressButton (HWND hwnd, WPARAM wParam, LPARAM lParam)
1992 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
1993 TBUTTON_INFO *btnPtr;
1997 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2001 btnPtr = &infoPtr->buttons[nIndex];
2002 if (LOWORD(lParam) == FALSE)
2003 btnPtr->fsState &= ~TBSTATE_PRESSED;
2005 btnPtr->fsState |= TBSTATE_PRESSED;
2008 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2009 ReleaseDC (hwnd, hdc);
2015 /* << TOOLBAR_ReplaceBitmap >> */
2019 TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2022 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2023 LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam;
2025 if (lpSave == NULL) return 0;
2028 /* save toolbar information */
2029 FIXME("save to \"%s\" \"%s\"\n",
2030 lpSave->pszSubKey, lpSave->pszValueName);
2035 /* restore toolbar information */
2037 FIXME("restore from \"%s\" \"%s\"\n",
2038 lpSave->pszSubKey, lpSave->pszValueName);
2048 /* << TOOLBAR_SaveRestore32W >> */
2049 /* << TOOLBAR_SetAnchorHighlight >> */
2053 TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2055 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2057 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2060 infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
2061 infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
2068 TOOLBAR_SetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
2070 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2071 LPTBBUTTONINFOA lptbbi = (LPTBBUTTONINFOA)lParam;
2072 TBUTTON_INFO *btnPtr;
2077 if (lptbbi->cbSize < sizeof(TBBUTTONINFOA))
2080 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2084 btnPtr = &infoPtr->buttons[nIndex];
2085 if (lptbbi->dwMask & TBIF_COMMAND)
2086 btnPtr->idCommand = lptbbi->idCommand;
2087 if (lptbbi->dwMask & TBIF_IMAGE)
2088 btnPtr->iBitmap = lptbbi->iImage;
2089 if (lptbbi->dwMask & TBIF_LPARAM)
2090 btnPtr->dwData = lptbbi->lParam;
2091 /* if (lptbbi->dwMask & TBIF_SIZE) */
2092 /* btnPtr->cx = lptbbi->cx; */
2093 if (lptbbi->dwMask & TBIF_STATE)
2094 btnPtr->fsState = lptbbi->fsState;
2095 if (lptbbi->dwMask & TBIF_STYLE)
2096 btnPtr->fsStyle = lptbbi->fsStyle;
2098 if (lptbbi->dwMask & TBIF_TEXT) {
2099 if ((btnPtr->iString >= 0) ||
2100 (btnPtr->iString < infoPtr->nNumStrings)) {
2102 CHAR **lpString = &infoPtr->strings[btnPtr->iString];
2103 INT len = lstrlenA (lptbbi->pszText);
2104 *lpString = COMCTL32_ReAlloc (lpString, sizeof(char)*(len+1));
2107 /* this is the ultimate sollution */
2108 /* Str_SetPtrA (&infoPtr->strings[btnPtr->iString], lptbbi->pszText); */
2116 /* << TOOLBAR_SetButtonInfo32W >> */
2120 TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2122 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2124 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
2127 infoPtr->nButtonWidth = (INT)LOWORD(lParam);
2128 infoPtr->nButtonHeight = (INT)HIWORD(lParam);
2135 TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam)
2137 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2139 if (infoPtr == NULL)
2142 infoPtr->cxMin = (INT)LOWORD(lParam);
2143 infoPtr->cxMax = (INT)HIWORD(lParam);
2150 TOOLBAR_SetCmdId (HWND hwnd, WPARAM wParam, LPARAM lParam)
2152 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2153 INT nIndex = (INT)wParam;
2155 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
2158 infoPtr->buttons[nIndex].idCommand = (INT)lParam;
2160 if (infoPtr->hwndToolTip) {
2162 FIXME("change tool tip!\n");
2170 /* << TOOLBAR_SetColorScheme >> */
2174 TOOLBAR_SetDisabledImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2176 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2177 HIMAGELIST himlTemp;
2179 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2182 himlTemp = infoPtr->himlDis;
2183 infoPtr->himlDis = (HIMAGELIST)lParam;
2185 /* FIXME: redraw ? */
2187 return (LRESULT)himlTemp;
2192 TOOLBAR_SetDrawTextFlags (HWND hwnd, WPARAM wParam, LPARAM lParam)
2194 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2197 dwTemp = infoPtr->dwDTFlags;
2198 infoPtr->dwDTFlags =
2199 (infoPtr->dwDTFlags & (DWORD)wParam) | (DWORD)lParam;
2201 return (LRESULT)dwTemp;
2206 TOOLBAR_SetExtendedStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2208 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2211 dwTemp = infoPtr->dwExStyle;
2212 infoPtr->dwExStyle = (DWORD)lParam;
2214 return (LRESULT)dwTemp;
2219 TOOLBAR_SetHotImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2221 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd);
2222 HIMAGELIST himlTemp;
2224 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2227 himlTemp = infoPtr->himlHot;
2228 infoPtr->himlHot = (HIMAGELIST)lParam;
2230 /* FIXME: redraw ? */
2232 return (LRESULT)himlTemp;
2236 /* << TOOLBAR_SetHotItem >> */
2240 TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam)
2242 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2243 HIMAGELIST himlTemp;
2245 if (!(GetWindowLongA (hwnd, GWL_STYLE) & TBSTYLE_FLAT))
2248 himlTemp = infoPtr->himlDef;
2249 infoPtr->himlDef = (HIMAGELIST)lParam;
2251 /* FIXME: redraw ? */
2253 return (LRESULT)himlTemp;
2258 TOOLBAR_SetIndent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2260 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2262 infoPtr->nIndent = (INT)wParam;
2264 TOOLBAR_CalcToolbar (hwnd);
2266 InvalidateRect(hwnd, NULL, FALSE);
2272 /* << TOOLBAR_SetInsertMark >> */
2276 TOOLBAR_SetInsertMarkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
2278 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2280 infoPtr->clrInsertMark = (COLORREF)lParam;
2282 /* FIXME : redraw ??*/
2289 TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2291 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2293 if (infoPtr == NULL)
2296 infoPtr->nMaxTextRows = (INT)wParam;
2302 /* << TOOLBAR_SetPadding >> */
2306 TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
2308 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2311 if (infoPtr == NULL)
2313 hwndOldNotify = infoPtr->hwndNotify;
2314 infoPtr->hwndNotify = (HWND)wParam;
2316 return hwndOldNotify;
2321 TOOLBAR_SetRows (HWND hwnd, WPARAM wParam, LPARAM lParam)
2323 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2324 LPRECT lprc = (LPRECT)lParam;
2326 if (LOWORD(wParam) > 1) {
2328 FIXME("multiple rows not supported!\n");
2332 /* recalculate toolbar */
2333 TOOLBAR_CalcToolbar (hwnd);
2335 /* return bounding rectangle */
2337 lprc->left = infoPtr->rcBound.left;
2338 lprc->right = infoPtr->rcBound.right;
2339 lprc->top = infoPtr->rcBound.top;
2340 lprc->bottom = infoPtr->rcBound.bottom;
2343 /* repaint toolbar */
2344 InvalidateRect(hwnd, NULL, FALSE);
2351 TOOLBAR_SetState (HWND hwnd, WPARAM wParam, LPARAM lParam)
2353 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2354 TBUTTON_INFO *btnPtr;
2358 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2362 btnPtr = &infoPtr->buttons[nIndex];
2363 btnPtr->fsState = LOWORD(lParam);
2366 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2367 ReleaseDC (hwnd, hdc);
2374 TOOLBAR_SetStyle (HWND hwnd, WPARAM wParam, LPARAM lParam)
2376 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2377 TBUTTON_INFO *btnPtr;
2381 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam);
2385 btnPtr = &infoPtr->buttons[nIndex];
2386 btnPtr->fsStyle = LOWORD(lParam);
2389 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2390 ReleaseDC (hwnd, hdc);
2392 if (infoPtr->hwndToolTip) {
2394 FIXME("change tool tip!\n");
2402 inline static LRESULT
2403 TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam)
2405 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2407 if (infoPtr == NULL)
2409 infoPtr->hwndToolTip = (HWND)wParam;
2415 TOOLBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam, LPARAM lParam)
2417 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2420 TRACE("%s hwnd=0x%04x stub!\n",
2421 ((BOOL)wParam) ? "TRUE" : "FALSE", hwnd);
2423 bTemp = infoPtr->bUnicode;
2424 infoPtr->bUnicode = (BOOL)wParam;
2431 TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
2433 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2434 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2437 /* initialize info structure */
2438 infoPtr->nButtonHeight = 22;
2439 infoPtr->nButtonWidth = 23;
2440 infoPtr->nBitmapHeight = 15;
2441 infoPtr->nBitmapWidth = 16;
2443 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
2445 infoPtr->nMaxTextRows = 1;
2446 infoPtr->cxMin = -1;
2447 infoPtr->cxMax = -1;
2449 infoPtr->bCaptured = FALSE;
2450 infoPtr->bUnicode = IsWindowUnicode (hwnd);
2451 infoPtr->nButtonDown = -1;
2452 infoPtr->nOldHit = -1;
2453 infoPtr->nHotItem = -2; /* It has to be initially different from nOldHit */
2454 infoPtr->hwndNotify = GetParent (hwnd);
2455 infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
2456 infoPtr->dwDTFlags = DT_CENTER;
2458 SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
2459 infoPtr->hFont = CreateFontIndirectA (&logFont);
2461 if (dwStyle & TBSTYLE_TOOLTIPS) {
2462 /* Create tooltip control */
2463 infoPtr->hwndToolTip =
2464 CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0,
2465 CW_USEDEFAULT, CW_USEDEFAULT,
2466 CW_USEDEFAULT, CW_USEDEFAULT,
2469 /* Send NM_TOOLTIPSCREATED notification */
2470 if (infoPtr->hwndToolTip) {
2471 NMTOOLTIPSCREATED nmttc;
2473 nmttc.hdr.hwndFrom = hwnd;
2474 nmttc.hdr.idFrom = GetWindowLongA (hwnd, GWL_ID);
2475 nmttc.hdr.code = NM_TOOLTIPSCREATED;
2476 nmttc.hwndToolTips = infoPtr->hwndToolTip;
2478 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY,
2479 (WPARAM)nmttc.hdr.idFrom, (LPARAM)&nmttc);
2488 TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
2490 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2492 /* delete tooltip control */
2493 if (infoPtr->hwndToolTip)
2494 DestroyWindow (infoPtr->hwndToolTip);
2496 /* delete button data */
2497 if (infoPtr->buttons)
2498 COMCTL32_Free (infoPtr->buttons);
2500 /* delete strings */
2501 if (infoPtr->strings) {
2503 for (i = 0; i < infoPtr->nNumStrings; i++)
2504 if (infoPtr->strings[i])
2505 COMCTL32_Free (infoPtr->strings[i]);
2507 COMCTL32_Free (infoPtr->strings);
2510 /* destroy default image list */
2511 if (infoPtr->himlDef)
2512 ImageList_Destroy (infoPtr->himlDef);
2514 /* destroy disabled image list */
2515 if (infoPtr->himlDis)
2516 ImageList_Destroy (infoPtr->himlDis);
2518 /* destroy hot image list */
2519 if (infoPtr->himlHot)
2520 ImageList_Destroy (infoPtr->himlHot);
2522 /* delete default font */
2524 DeleteObject (infoPtr->hFont);
2526 /* free toolbar info data */
2527 COMCTL32_Free (infoPtr);
2534 TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam)
2536 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2538 if (infoPtr->bTransparent)
2539 return SendMessageA (GetParent (hwnd), WM_ERASEBKGND, wParam, lParam);
2541 return DefWindowProcA (hwnd, WM_ERASEBKGND, wParam, lParam);
2546 TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam)
2548 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2549 TBUTTON_INFO *btnPtr;
2554 pt.x = (INT)LOWORD(lParam);
2555 pt.y = (INT)HIWORD(lParam);
2556 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2559 btnPtr = &infoPtr->buttons[nHit];
2560 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2563 infoPtr->bCaptured = TRUE;
2564 infoPtr->nButtonDown = nHit;
2566 btnPtr->fsState |= TBSTATE_PRESSED;
2569 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2570 ReleaseDC (hwnd, hdc);
2572 else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE)
2573 TOOLBAR_Customize (hwnd);
2580 TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
2582 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2583 TBUTTON_INFO *btnPtr;
2588 if (infoPtr->hwndToolTip)
2589 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2590 WM_LBUTTONDOWN, wParam, lParam);
2592 pt.x = (INT)LOWORD(lParam);
2593 pt.y = (INT)HIWORD(lParam);
2594 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2597 btnPtr = &infoPtr->buttons[nHit];
2598 if (!(btnPtr->fsState & TBSTATE_ENABLED))
2602 infoPtr->bCaptured = TRUE;
2603 infoPtr->nButtonDown = nHit;
2604 infoPtr->nOldHit = nHit;
2606 btnPtr->fsState |= TBSTATE_PRESSED;
2609 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2610 ReleaseDC (hwnd, hdc);
2618 TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
2620 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2621 TBUTTON_INFO *btnPtr;
2626 BOOL bSendMessage = TRUE;
2628 if (infoPtr->hwndToolTip)
2629 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2630 WM_LBUTTONUP, wParam, lParam);
2632 pt.x = (INT)LOWORD(lParam);
2633 pt.y = (INT)HIWORD(lParam);
2634 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2636 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
2637 infoPtr->bCaptured = FALSE;
2639 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2640 btnPtr->fsState &= ~TBSTATE_PRESSED;
2642 if (nHit == infoPtr->nButtonDown) {
2643 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
2644 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2645 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
2646 infoPtr->nButtonDown);
2647 if (nOldIndex == infoPtr->nButtonDown)
2648 bSendMessage = FALSE;
2649 if ((nOldIndex != infoPtr->nButtonDown) &&
2651 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2652 btnPtr->fsState |= TBSTATE_CHECKED;
2655 if (btnPtr->fsState & TBSTATE_CHECKED)
2656 btnPtr->fsState &= ~TBSTATE_CHECKED;
2658 btnPtr->fsState |= TBSTATE_CHECKED;
2663 bSendMessage = FALSE;
2666 if (nOldIndex != -1)
2667 TOOLBAR_DrawButton (hwnd, &infoPtr->buttons[nOldIndex], hdc);
2668 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2669 ReleaseDC (hwnd, hdc);
2672 SendMessageA (infoPtr->hwndNotify, WM_COMMAND,
2673 MAKEWPARAM(btnPtr->idCommand, 0), (LPARAM)hwnd);
2675 infoPtr->nButtonDown = -1;
2676 infoPtr->nOldHit = -1;
2684 TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
2686 TBUTTON_INFO *btnPtr, *oldBtnPtr;
2687 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2692 if (infoPtr->hwndToolTip)
2693 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, hwnd,
2694 WM_MOUSEMOVE, wParam, lParam);
2696 pt.x = (INT)LOWORD(lParam);
2697 pt.y = (INT)HIWORD(lParam);
2699 nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
2701 if (infoPtr->nOldHit != nHit)
2703 /* Remove the effect of an old hot button */
2704 if(infoPtr->nOldHit == infoPtr->nHotItem)
2706 oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
2707 oldBtnPtr->bHot = FALSE;
2709 InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
2712 /* It's not a separator or in nowhere. It's a hot button. */
2715 btnPtr = &infoPtr->buttons[nHit];
2716 btnPtr->bHot = TRUE;
2719 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2720 ReleaseDC (hwnd, hdc);
2722 infoPtr->nHotItem = nHit;
2725 if (infoPtr->bCaptured) {
2726 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2727 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
2728 btnPtr->fsState &= ~TBSTATE_PRESSED;
2730 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2731 ReleaseDC (hwnd, hdc);
2733 else if (nHit == infoPtr->nButtonDown) {
2734 btnPtr->fsState |= TBSTATE_PRESSED;
2736 TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
2737 ReleaseDC (hwnd, hdc);
2740 infoPtr->nOldHit = nHit;
2746 inline static LRESULT
2747 TOOLBAR_NCActivate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2749 /* if (wndPtr->dwStyle & CCS_NODIVIDER) */
2750 return DefWindowProcA (hwnd, WM_NCACTIVATE, wParam, lParam);
2752 /* return TOOLBAR_NCPaint (wndPtr, wParam, lParam); */
2756 inline static LRESULT
2757 TOOLBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
2759 if (!(GetWindowLongA (hwnd, GWL_STYLE) & CCS_NODIVIDER))
2760 ((LPRECT)lParam)->top += GetSystemMetrics(SM_CYEDGE);
2762 return DefWindowProcA (hwnd, WM_NCCALCSIZE, wParam, lParam);
2767 TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam)
2769 TOOLBAR_INFO *infoPtr;
2771 /* allocate memory for info structure */
2772 infoPtr = (TOOLBAR_INFO *)COMCTL32_Alloc (sizeof(TOOLBAR_INFO));
2773 SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
2776 infoPtr->dwStructSize = sizeof(TBBUTTON);
2778 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
2779 if (!GetWindowLongA (hwnd, GWL_HINSTANCE)) {
2780 HINSTANCE hInst = (HINSTANCE)GetWindowLongA (GetParent (hwnd), GWL_HINSTANCE);
2781 SetWindowLongA (hwnd, GWL_HINSTANCE, (DWORD)hInst);
2784 return DefWindowProcA (hwnd, WM_NCCREATE, wParam, lParam);
2789 TOOLBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
2791 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2795 if (dwStyle & WS_MINIMIZE)
2796 return 0; /* Nothing to do */
2798 DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
2800 if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW)))
2803 if (!(dwStyle & CCS_NODIVIDER))
2805 GetWindowRect (hwnd, &rcWindow);
2806 OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
2807 DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_TOP);
2810 ReleaseDC( hwnd, hdc );
2816 inline static LRESULT
2817 TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
2819 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2820 LPNMHDR lpnmh = (LPNMHDR)lParam;
2822 TRACE("passing WM_NOTIFY!\n");
2824 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
2825 SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
2828 if (lpnmh->code == TTN_GETDISPINFOA) {
2829 LPNMTTDISPINFOA lpdi = (LPNMTTDISPINFOA)lParam;
2831 FIXME("retrieving ASCII string\n");
2834 else if (lpnmh->code == TTN_GETDISPINFOW) {
2835 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
2837 FIXME("retrieving UNICODE string\n");
2848 TOOLBAR_Paint (HWND hwnd, WPARAM wParam)
2853 TOOLBAR_CalcToolbar( hwnd );
2854 hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
2855 TOOLBAR_Refresh (hwnd, hdc);
2857 EndPaint (hwnd, &ps);
2863 TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
2865 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
2866 DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
2874 /* Resize deadlock check */
2875 if (infoPtr->bAutoSize) {
2876 infoPtr->bAutoSize = FALSE;
2880 flags = (INT) wParam;
2882 /* FIXME for flags =
2883 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
2886 TRACE("sizing toolbar!\n");
2888 if (flags == SIZE_RESTORED) {
2889 /* width and height don't apply */
2890 parent = GetParent (hwnd);
2891 GetClientRect(parent, &parent_rect);
2893 if (dwStyle & CCS_NORESIZE) {
2894 uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
2897 /* infoPtr->nWidth = parent_rect.right - parent_rect.left; */
2898 cy = infoPtr->nHeight;
2899 cx = infoPtr->nWidth;
2900 TOOLBAR_CalcToolbar (hwnd);
2901 infoPtr->nWidth = cx;
2902 infoPtr->nHeight = cy;
2905 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2906 TOOLBAR_CalcToolbar (hwnd);
2907 cy = infoPtr->nHeight;
2908 cx = infoPtr->nWidth;
2911 if (dwStyle & CCS_NOPARENTALIGN) {
2912 uPosFlags |= SWP_NOMOVE;
2913 cy = infoPtr->nHeight;
2914 cx = infoPtr->nWidth;
2917 if (!(dwStyle & CCS_NODIVIDER))
2918 cy += GetSystemMetrics(SM_CYEDGE);
2920 SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top,
2921 cx, cy, uPosFlags | SWP_NOZORDER);
2928 TOOLBAR_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
2930 TOOLBAR_AutoSize (hwnd, wParam, lParam);
2932 InvalidateRect(hwnd, NULL, FALSE);
2940 ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
2945 return TOOLBAR_AddBitmap (hwnd, wParam, lParam);
2947 case TB_ADDBUTTONSA:
2948 return TOOLBAR_AddButtonsA (hwnd, wParam, lParam);
2950 /* case TB_ADDBUTTONSW: */
2953 return TOOLBAR_AddStringA (hwnd, wParam, lParam);
2956 return TOOLBAR_AddStringW (hwnd, wParam, lParam);
2959 return TOOLBAR_AutoSize (hwnd, wParam, lParam);
2961 case TB_BUTTONCOUNT:
2962 return TOOLBAR_ButtonCount (hwnd, wParam, lParam);
2964 case TB_BUTTONSTRUCTSIZE:
2965 return TOOLBAR_ButtonStructSize (hwnd, wParam, lParam);
2967 case TB_CHANGEBITMAP:
2968 return TOOLBAR_ChangeBitmap (hwnd, wParam, lParam);
2970 case TB_CHECKBUTTON:
2971 return TOOLBAR_CheckButton (hwnd, wParam, lParam);
2973 case TB_COMMANDTOINDEX:
2974 return TOOLBAR_CommandToIndex (hwnd, wParam, lParam);
2977 return TOOLBAR_Customize (hwnd);
2979 case TB_DELETEBUTTON:
2980 return TOOLBAR_DeleteButton (hwnd, wParam, lParam);
2982 case TB_ENABLEBUTTON:
2983 return TOOLBAR_EnableButton (hwnd, wParam, lParam);
2985 /* case TB_GETANCHORHIGHLIGHT: */ /* 4.71 */
2988 return TOOLBAR_GetBitmap (hwnd, wParam, lParam);
2990 case TB_GETBITMAPFLAGS:
2991 return TOOLBAR_GetBitmapFlags (hwnd, wParam, lParam);
2994 return TOOLBAR_GetButton (hwnd, wParam, lParam);
2996 case TB_GETBUTTONINFOA:
2997 return TOOLBAR_GetButtonInfoA (hwnd, wParam, lParam);
2999 /* case TB_GETBUTTONINFOW: */ /* 4.71 */
3001 case TB_GETBUTTONSIZE:
3002 return TOOLBAR_GetButtonSize (hwnd);
3004 case TB_GETBUTTONTEXTA:
3005 return TOOLBAR_GetButtonTextA (hwnd, wParam, lParam);
3007 /* case TB_GETBUTTONTEXTW: */
3008 /* case TB_GETCOLORSCHEME: */ /* 4.71 */
3010 case TB_GETDISABLEDIMAGELIST:
3011 return TOOLBAR_GetDisabledImageList (hwnd, wParam, lParam);
3013 case TB_GETEXTENDEDSTYLE:
3014 return TOOLBAR_GetExtendedStyle (hwnd);
3016 case TB_GETHOTIMAGELIST:
3017 return TOOLBAR_GetHotImageList (hwnd, wParam, lParam);
3019 /* case TB_GETHOTITEM: */ /* 4.71 */
3021 case TB_GETIMAGELIST:
3022 return TOOLBAR_GetImageList (hwnd, wParam, lParam);
3024 /* case TB_GETINSERTMARK: */ /* 4.71 */
3025 /* case TB_GETINSERTMARKCOLOR: */ /* 4.71 */
3027 case TB_GETITEMRECT:
3028 return TOOLBAR_GetItemRect (hwnd, wParam, lParam);
3031 return TOOLBAR_GetMaxSize (hwnd, wParam, lParam);
3033 /* case TB_GETOBJECT: */ /* 4.71 */
3034 /* case TB_GETPADDING: */ /* 4.71 */
3037 return TOOLBAR_GetRect (hwnd, wParam, lParam);
3040 return TOOLBAR_GetRows (hwnd, wParam, lParam);
3043 return TOOLBAR_GetState (hwnd, wParam, lParam);
3046 return TOOLBAR_GetStyle (hwnd, wParam, lParam);
3048 case TB_GETTEXTROWS:
3049 return TOOLBAR_GetTextRows (hwnd, wParam, lParam);
3051 case TB_GETTOOLTIPS:
3052 return TOOLBAR_GetToolTips (hwnd, wParam, lParam);
3054 case TB_GETUNICODEFORMAT:
3055 return TOOLBAR_GetUnicodeFormat (hwnd, wParam, lParam);
3058 return TOOLBAR_HideButton (hwnd, wParam, lParam);
3061 return TOOLBAR_HitTest (hwnd, wParam, lParam);
3063 case TB_INDETERMINATE:
3064 return TOOLBAR_Indeterminate (hwnd, wParam, lParam);
3066 case TB_INSERTBUTTONA:
3067 return TOOLBAR_InsertButtonA (hwnd, wParam, lParam);
3069 /* case TB_INSERTBUTTONW: */
3070 /* case TB_INSERTMARKHITTEST: */ /* 4.71 */
3072 case TB_ISBUTTONCHECKED:
3073 return TOOLBAR_IsButtonChecked (hwnd, wParam, lParam);
3075 case TB_ISBUTTONENABLED:
3076 return TOOLBAR_IsButtonEnabled (hwnd, wParam, lParam);
3078 case TB_ISBUTTONHIDDEN:
3079 return TOOLBAR_IsButtonHidden (hwnd, wParam, lParam);
3081 case TB_ISBUTTONHIGHLIGHTED:
3082 return TOOLBAR_IsButtonHighlighted (hwnd, wParam, lParam);
3084 case TB_ISBUTTONINDETERMINATE:
3085 return TOOLBAR_IsButtonIndeterminate (hwnd, wParam, lParam);
3087 case TB_ISBUTTONPRESSED:
3088 return TOOLBAR_IsButtonPressed (hwnd, wParam, lParam);
3090 /* case TB_LOADIMAGES: */ /* 4.70 */
3091 /* case TB_MAPACCELERATORA: */ /* 4.71 */
3092 /* case TB_MAPACCELERATORW: */ /* 4.71 */
3093 /* case TB_MARKBUTTON: */ /* 4.71 */
3094 /* case TB_MOVEBUTTON: */ /* 4.71 */
3096 case TB_PRESSBUTTON:
3097 return TOOLBAR_PressButton (hwnd, wParam, lParam);
3099 /* case TB_REPLACEBITMAP: */
3101 case TB_SAVERESTOREA:
3102 return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam);
3104 /* case TB_SAVERESTOREW: */
3105 /* case TB_SETANCHORHIGHLIGHT: */ /* 4.71 */
3107 case TB_SETBITMAPSIZE:
3108 return TOOLBAR_SetBitmapSize (hwnd, wParam, lParam);
3110 case TB_SETBUTTONINFOA:
3111 return TOOLBAR_SetButtonInfoA (hwnd, wParam, lParam);
3113 /* case TB_SETBUTTONINFOW: */ /* 4.71 */
3115 case TB_SETBUTTONSIZE:
3116 return TOOLBAR_SetButtonSize (hwnd, wParam, lParam);
3118 case TB_SETBUTTONWIDTH:
3119 return TOOLBAR_SetButtonWidth (hwnd, wParam, lParam);
3122 return TOOLBAR_SetCmdId (hwnd, wParam, lParam);
3124 /* case TB_SETCOLORSCHEME: */ /* 4.71 */
3126 case TB_SETDISABLEDIMAGELIST:
3127 return TOOLBAR_SetDisabledImageList (hwnd, wParam, lParam);
3129 case TB_SETDRAWTEXTFLAGS:
3130 return TOOLBAR_SetDrawTextFlags (hwnd, wParam, lParam);
3132 case TB_SETEXTENDEDSTYLE:
3133 return TOOLBAR_SetExtendedStyle (hwnd, wParam, lParam);
3135 case TB_SETHOTIMAGELIST:
3136 return TOOLBAR_SetHotImageList (hwnd, wParam, lParam);
3138 /* case TB_SETHOTITEM: */ /* 4.71 */
3140 case TB_SETIMAGELIST:
3141 return TOOLBAR_SetImageList (hwnd, wParam, lParam);
3144 return TOOLBAR_SetIndent (hwnd, wParam, lParam);
3146 /* case TB_SETINSERTMARK: */ /* 4.71 */
3148 case TB_SETINSERTMARKCOLOR:
3149 return TOOLBAR_SetInsertMarkColor (hwnd, wParam, lParam);
3151 case TB_SETMAXTEXTROWS:
3152 return TOOLBAR_SetMaxTextRows (hwnd, wParam, lParam);
3154 /* case TB_SETPADDING: */ /* 4.71 */
3157 return TOOLBAR_SetParent (hwnd, wParam, lParam);
3160 return TOOLBAR_SetRows (hwnd, wParam, lParam);
3163 return TOOLBAR_SetState (hwnd, wParam, lParam);
3166 return TOOLBAR_SetStyle (hwnd, wParam, lParam);
3168 case TB_SETTOOLTIPS:
3169 return TOOLBAR_SetToolTips (hwnd, wParam, lParam);
3171 case TB_SETUNICODEFORMAT:
3172 return TOOLBAR_SetUnicodeFormat (hwnd, wParam, lParam);
3178 return TOOLBAR_Create (hwnd, wParam, lParam);
3181 return TOOLBAR_Destroy (hwnd, wParam, lParam);
3184 return TOOLBAR_EraseBackground (hwnd, wParam, lParam);
3186 /* case WM_GETFONT: */
3187 /* case WM_KEYDOWN: */
3188 /* case WM_KILLFOCUS: */
3190 case WM_LBUTTONDBLCLK:
3191 return TOOLBAR_LButtonDblClk (hwnd, wParam, lParam);
3193 case WM_LBUTTONDOWN:
3194 return TOOLBAR_LButtonDown (hwnd, wParam, lParam);
3197 return TOOLBAR_LButtonUp (hwnd, wParam, lParam);
3200 return TOOLBAR_MouseMove (hwnd, wParam, lParam);
3203 return TOOLBAR_NCActivate (hwnd, wParam, lParam);
3206 return TOOLBAR_NCCalcSize (hwnd, wParam, lParam);
3209 return TOOLBAR_NCCreate (hwnd, wParam, lParam);
3212 return TOOLBAR_NCPaint (hwnd, wParam, lParam);
3215 return TOOLBAR_Notify (hwnd, wParam, lParam);
3217 /* case WM_NOTIFYFORMAT: */
3220 return TOOLBAR_Paint (hwnd, wParam);
3223 return TOOLBAR_Size (hwnd, wParam, lParam);
3225 case WM_STYLECHANGED:
3226 return TOOLBAR_StyleChanged (hwnd, wParam, lParam);
3228 /* case WM_SYSCOLORCHANGE: */
3230 /* case WM_WININICHANGE: */
3235 case WM_MEASUREITEM:
3237 return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
3240 if (uMsg >= WM_USER)
3241 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
3242 uMsg, wParam, lParam);
3243 return DefWindowProcA (hwnd, uMsg, wParam, lParam);
3250 TOOLBAR_Register (VOID)
3254 if (GlobalFindAtomA (TOOLBARCLASSNAMEA)) return;
3256 ZeroMemory (&wndClass, sizeof(WNDCLASSA));
3257 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
3258 wndClass.lpfnWndProc = (WNDPROC)ToolbarWindowProc;
3259 wndClass.cbClsExtra = 0;
3260 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
3261 wndClass.hCursor = LoadCursorA (0, IDC_ARROWA);
3262 wndClass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
3263 wndClass.lpszClassName = TOOLBARCLASSNAMEA;
3265 RegisterClassA (&wndClass);
3270 TOOLBAR_Unregister (VOID)
3272 if (GlobalFindAtomA (TOOLBARCLASSNAMEA))
3273 UnregisterClassA (TOOLBARCLASSNAMEA, (HINSTANCE)NULL);