Release 980822
[wine/multimedia.git] / controls / toolbar.c
blob142ffb6ee1a4b3d26f7b666cec639f72bdf92834
1 /*
2 * Toolbar control
4 * Copyright 1998 Eric Kohl
6 * TODO:
7 * - Bitmap drawing.
8 * - Button wrapping.
9 * - Messages.
10 * - Notifications.
11 * - Fix TB_GETBITMAPFLAGS.
12 * - Fix TB_GETROWS and TB_SETROWS.
13 * - Tooltip support (almost complete).
14 * - Unicode suppport.
15 * - Internal COMMCTL32 bitmaps.
16 * - Fix TOOLBAR_Customize. (Customize dialog.)
18 * Testing:
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.
28 #include "windows.h"
29 #include "commctrl.h"
30 #include "cache.h"
31 #include "toolbar.h"
32 #include "heap.h"
33 #include "win.h"
34 #include "debug.h"
37 #define SEPARATOR_WIDTH 8
38 #define SEPARATOR_HEIGHT 5
39 #define TOP_BORDER 2
40 #define BOTTOM_BORDER 2
44 #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)wndPtr->wExtra[0])
47 static void
48 TOOLBAR_DrawFlatSeparator (LPRECT32 lpRect, HDC32 hdc)
50 INT32 x = (lpRect->left + lpRect->right) / 2 - 1;
51 INT32 yBottom = lpRect->bottom - 3;
52 INT32 yTop = lpRect->top + 1;
54 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DSHADOW));
55 MoveToEx32 (hdc, x, yBottom, NULL);
56 LineTo32 (hdc, x, yTop);
57 x++;
58 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DHILIGHT));
59 MoveToEx32 (hdc, x, yBottom, NULL);
60 LineTo32 (hdc, x, yTop);
64 static void
65 TOOLBAR_DrawString (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
66 HDC32 hdc, INT32 nState)
68 RECT32 rcText = btnPtr->rect;
69 HFONT32 hOldFont;
70 INT32 nOldBkMode;
72 /* draw text */
73 if ((btnPtr->iString > -1) && (btnPtr->iString < infoPtr->nNumStrings)) {
75 InflateRect32 (&rcText, -3, -3);
76 rcText.top += infoPtr->nBitmapHeight;
77 if (nState & (TBSTATE_PRESSED | TBSTATE_CHECKED))
78 OffsetRect32 (&rcText, 1, 1);
80 hOldFont = SelectObject32 (hdc, infoPtr->hFont);
81 nOldBkMode = SetBkMode32 (hdc, TRANSPARENT);
82 if (!(nState & TBSTATE_ENABLED)) {
83 COLORREF clrOld =
84 SetTextColor32 (hdc, GetSysColor32 (COLOR_3DHILIGHT));
85 OffsetRect32 (&rcText, 1, 1);
86 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
87 DT_CENTER);
88 SetTextColor32 (hdc, GetSysColor32 (COLOR_3DSHADOW));
89 OffsetRect32 (&rcText, -1, -1);
90 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
91 DT_CENTER);
92 SetTextColor32 (hdc, clrOld);
94 else if (nState & TBSTATE_INDETERMINATE) {
95 COLORREF clrOld =
96 SetTextColor32 (hdc, GetSysColor32 (COLOR_3DSHADOW));
97 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
98 DT_CENTER);
99 SetTextColor32 (hdc, clrOld);
101 else
102 DrawText32A (hdc, infoPtr->strings[btnPtr->iString], -1, &rcText,
103 DT_CENTER);
105 SelectObject32 (hdc, hOldFont);
106 if (nOldBkMode != TRANSPARENT)
107 SetBkMode32 (hdc, nOldBkMode);
112 static void
113 TOOLBAR_DrawButton (WND *wndPtr, TBUTTON_INFO *btnPtr, HDC32 hdc)
115 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
116 BOOL32 bFlat = (wndPtr->dwStyle & TBSTYLE_FLAT);
117 RECT32 rc;
119 if (btnPtr->fsState & TBSTATE_HIDDEN) return;
121 rc = btnPtr->rect;
122 if (btnPtr->fsStyle & TBSTYLE_SEP) {
123 if ((bFlat) && (btnPtr->idCommand == 0))
124 TOOLBAR_DrawFlatSeparator (&btnPtr->rect, hdc);
125 return;
128 /* disabled */
129 if (!(btnPtr->fsState & TBSTATE_ENABLED)) {
130 HICON32 hIcon;
131 DrawEdge32 (hdc, &rc, EDGE_RAISED,
132 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
134 // ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
135 // rc.left+1, rc.top+1, ILD_NORMAL);
136 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
137 return;
140 /* pressed TBSTYLE_BUTTON */
141 if (btnPtr->fsState & TBSTATE_PRESSED) {
142 DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
143 BF_RECT | BF_MIDDLE | BF_ADJUST);
144 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
145 rc.left+2, rc.top+2, ILD_NORMAL);
146 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
147 return;
150 /* checked TBSTYLE_CHECK*/
151 if ((btnPtr->fsStyle & TBSTYLE_CHECK) &&
152 (btnPtr->fsState & TBSTATE_CHECKED)) {
153 HBRUSH32 hbr;
154 DrawEdge32 (hdc, &rc, EDGE_SUNKEN,
155 BF_RECT | BF_MIDDLE | BF_ADJUST);
157 hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
158 PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
159 rc.bottom - rc.top, 0x00FA0089);
160 SelectObject32 (hdc, hbr);
161 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
162 rc.left+2, rc.top+2, ILD_NORMAL);
163 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
164 return;
167 /* indeterminate */
168 if (btnPtr->fsState & TBSTATE_INDETERMINATE) {
169 HBRUSH32 hbr;
170 DrawEdge32 (hdc, &rc, EDGE_RAISED,
171 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
173 hbr = SelectObject32 (hdc, CACHE_GetPattern55AABrush ());
174 PatBlt32 (hdc, rc.left, rc.top, rc.right - rc.left,
175 rc.bottom - rc.top, 0x00FA0089);
176 SelectObject32 (hdc, hbr);
177 // ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
178 // rc.left+1, rc.top+1, ILD_NORMAL);
179 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
180 return;
183 /* normal state */
184 DrawEdge32 (hdc, &rc, EDGE_RAISED,
185 BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
186 ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
187 rc.left+1, rc.top+1, ILD_NORMAL);
188 TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
192 static void
193 TOOLBAR_Refresh (WND *wndPtr, HDC32 hdc)
195 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
196 TBUTTON_INFO *btnPtr;
197 INT32 i;
199 /* draw buttons */
200 btnPtr = infoPtr->buttons;
201 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++)
202 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
206 static void
207 TOOLBAR_CalcStrings (WND *wndPtr, LPSIZE32 lpSize)
209 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
210 TBUTTON_INFO *btnPtr;
211 INT32 i;
212 HDC32 hdc;
213 HFONT32 hOldFont;
214 SIZE32 sz;
216 lpSize->cx = 0;
217 lpSize->cy = 0;
218 hdc = GetDC32 (0);
219 hOldFont = SelectObject32 (hdc, infoPtr->hFont);
221 btnPtr = infoPtr->buttons;
222 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
223 if (!(btnPtr->fsState & TBSTATE_HIDDEN) &&
224 (btnPtr->iString > -1) &&
225 (btnPtr->iString < infoPtr->nNumStrings)) {
226 LPSTR lpText = infoPtr->strings[btnPtr->iString];
227 GetTextExtentPoint32A (hdc, lpText, lstrlen32A(lpText), &sz);
228 if (sz.cx > lpSize->cx)
229 lpSize->cx = sz.cx;
230 if (sz.cy > lpSize->cy)
231 lpSize->cy = sz.cy;
235 SelectObject32 (hdc, hOldFont);
236 ReleaseDC32 (0, hdc);
238 TRACE (toolbar, "string size %d x %d!\n", lpSize->cx, lpSize->cy);
242 static void
243 TOOLBAR_CalcToolbar (WND *wndPtr)
245 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
246 TBUTTON_INFO *btnPtr;
247 INT32 i, j, nRows;
248 INT32 x, y, cx, cy;
249 BOOL32 bVertical;
250 SIZE32 sizeString;
251 RECT32 rect = {0, 0, 0, 0};
253 TOOLBAR_CalcStrings (wndPtr, &sizeString);
255 if (sizeString.cy > 0)
256 infoPtr->nButtonHeight = sizeString.cy + infoPtr->nBitmapHeight + 6;
257 else if (infoPtr->nButtonHeight < infoPtr->nBitmapHeight + 6)
258 infoPtr->nButtonHeight = infoPtr->nBitmapHeight + 6;
260 if (sizeString.cx > infoPtr->nBitmapWidth)
261 infoPtr->nButtonWidth = sizeString.cx + 6;
262 else if (infoPtr->nButtonWidth < infoPtr->nBitmapWidth + 6)
263 infoPtr->nButtonWidth = infoPtr->nBitmapWidth + 6;
265 x = infoPtr->nIndent;
266 y = TOP_BORDER;
267 cx = infoPtr->nButtonWidth;
268 cy = infoPtr->nButtonHeight;
269 nRows = 1;
270 rect.top = y;
271 rect.left = x;
272 rect.bottom = y + cy;
273 rect.right = x;
275 btnPtr = infoPtr->buttons;
276 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
277 bVertical = FALSE;
279 if (btnPtr->fsState & TBSTATE_HIDDEN)
280 continue;
282 if (btnPtr->fsStyle & TBSTYLE_SEP) {
283 /* UNDOCUMENTED: If a separator has a non zero bitmap index, */
284 /* it is the actual width of the separator. This is used for */
285 /* custom controls in toolbars. */
286 if ((wndPtr->dwStyle & TBSTYLE_WRAPABLE) &&
287 (btnPtr->fsState & TBSTATE_WRAP)) {
288 x = 0;
289 y += cy;
290 cx = infoPtr->nWidth;
291 cy = ((btnPtr->iBitmap > 0) ?
292 btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 / 3;
293 nRows++;
294 bVertical = TRUE;
296 else
297 cx = (btnPtr->iBitmap > 0) ?
298 btnPtr->iBitmap : SEPARATOR_WIDTH;
300 else {
301 /* this must be a button */
302 cx = infoPtr->nButtonWidth;
306 btnPtr->rect.left = x;
307 btnPtr->rect.top = y;
308 btnPtr->rect.right = x + cx;
309 btnPtr->rect.bottom = y + cy;
311 if (rect.left > x)
312 rect.left = x;
313 if (rect.right < x + cx)
314 rect.right = x + cx;
315 if (rect.bottom < y + cy)
316 rect.bottom = y + cy;
318 if (infoPtr->hwndToolTip) {
319 TTTOOLINFO32A ti;
321 ZeroMemory (&ti, sizeof(TTTOOLINFO32A));
322 ti.cbSize = sizeof(TTTOOLINFO32A);
323 ti.hwnd = wndPtr->hwndSelf;
324 ti.uId = btnPtr->idCommand;
325 ti.rect = btnPtr->rect;
326 SendMessage32A (infoPtr->hwndToolTip, TTM_NEWTOOLRECT32A,
327 0, (LPARAM)&ti);
330 if (bVertical) {
331 x = 0;
332 y += cy;
333 if (i < infoPtr->nNumButtons)
334 nRows++;
336 else
337 x += cx;
340 infoPtr->nHeight = y + cy + BOTTOM_BORDER;
341 infoPtr->maxSize.cx = rect.right - rect.left;
342 infoPtr->maxSize.cy = rect.bottom - rect.top;
343 TRACE (toolbar, "toolbar height %d\n", infoPtr->nHeight);
347 static INT32
348 TOOLBAR_InternalHitTest (WND *wndPtr, LPPOINT32 lpPt)
350 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
351 TBUTTON_INFO *btnPtr;
352 INT32 i;
354 btnPtr = infoPtr->buttons;
355 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
356 if (btnPtr->fsState & TBSTATE_HIDDEN)
357 continue;
359 if (btnPtr->fsStyle & TBSTYLE_SEP) {
360 if (PtInRect32 (&btnPtr->rect, *lpPt)) {
361 TRACE (toolbar, " ON SEPARATOR %d!\n", i);
362 return -i;
365 else {
366 if (PtInRect32 (&btnPtr->rect, *lpPt)) {
367 TRACE (toolbar, " ON BUTTON %d!\n", i);
368 return i;
373 TRACE (toolbar, " NOWHERE!\n");
374 return -1;
378 static INT32
379 TOOLBAR_GetButtonIndex (TOOLBAR_INFO *infoPtr, INT32 idCommand)
381 TBUTTON_INFO *btnPtr;
382 INT32 i;
384 btnPtr = infoPtr->buttons;
385 for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
386 if (btnPtr->idCommand == idCommand) {
387 TRACE (toolbar, "command=%d index=%d\n", idCommand, i);
388 return i;
391 TRACE (toolbar, "no index found for command=%d\n", idCommand);
392 return -1;
396 static INT32
397 TOOLBAR_GetCheckedGroupButtonIndex (TOOLBAR_INFO *infoPtr, INT32 nIndex)
399 TBUTTON_INFO *btnPtr;
400 INT32 nRunIndex;
402 if ((nIndex < 0) || (nIndex > infoPtr->nNumButtons))
403 return -1;
405 /* check index button */
406 btnPtr = &infoPtr->buttons[nIndex];
407 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
408 if (btnPtr->fsState & TBSTATE_CHECKED)
409 return nIndex;
412 /* check previous buttons */
413 nRunIndex = nIndex - 1;
414 while (nRunIndex >= 0) {
415 btnPtr = &infoPtr->buttons[nRunIndex];
416 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
417 if (btnPtr->fsState & TBSTATE_CHECKED)
418 return nRunIndex;
420 else
421 break;
422 nRunIndex--;
425 /* check next buttons */
426 nRunIndex = nIndex + 1;
427 while (nRunIndex < infoPtr->nNumButtons) {
428 btnPtr = &infoPtr->buttons[nRunIndex];
429 if ((btnPtr->fsStyle & TBSTYLE_CHECKGROUP) == TBSTYLE_CHECKGROUP) {
430 if (btnPtr->fsState & TBSTATE_CHECKED)
431 return nRunIndex;
433 else
434 break;
435 nRunIndex++;
438 return -1;
442 static VOID
443 TOOLBAR_RelayEvent (HWND32 hwndTip, HWND32 hwndMsg, UINT32 uMsg,
444 WPARAM32 wParam, LPARAM lParam)
446 MSG32 msg;
448 msg.hwnd = hwndMsg;
449 msg.message = uMsg;
450 msg.wParam = wParam;
451 msg.lParam = lParam;
452 msg.time = GetMessageTime ();
453 msg.pt.x = LOWORD(GetMessagePos ());
454 msg.pt.y = HIWORD(GetMessagePos ());
456 SendMessage32A (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
460 static LRESULT
461 TOOLBAR_AddBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
463 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
464 LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
465 INT32 nIndex = 0;
467 if ((!lpAddBmp) || ((INT32)wParam <= 0))
468 return -1;
470 TRACE (toolbar, "adding %d bitmaps!\n", wParam);
472 if (!(infoPtr->himlDef)) {
473 /* create new default image list */
474 TRACE (toolbar, "creating default image list!\n");
475 infoPtr->himlDef =
476 ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
477 ILC_COLOR | ILC_MASK, (INT32)wParam, 2);
480 #if 0
481 if (!(infoPtr->himlDis)) {
482 /* create new disabled image list */
483 TRACE (toolbar, "creating disabled image list!\n");
484 infoPtr->himlDis =
485 ImageList_Create (infoPtr->nBitmapWidth,
486 infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
487 (INT32)wParam, 2);
489 #endif
491 /* Add bitmaps to the default image list */
492 if (lpAddBmp->hInst == (HINSTANCE32)0) {
493 nIndex =
494 ImageList_AddMasked (infoPtr->himlDef, (HBITMAP32)lpAddBmp->nID,
495 GetSysColor32 (COLOR_3DFACE));
497 else if (lpAddBmp->hInst == HINST_COMMCTRL) {
498 /* add internal bitmaps */
499 FIXME (toolbar, "internal bitmaps not supported!\n");
501 /* Hack to "add" some reserved images within the image list
502 to get the right image indices */
503 nIndex = ImageList_GetImageCount (infoPtr->himlDef);
504 ImageList_SetImageCount (infoPtr->himlDef, nIndex + (INT32)wParam);
506 else {
507 HBITMAP32 hBmp =
508 LoadBitmap32A (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
510 nIndex = ImageList_Add (infoPtr->himlDef, hBmp, (HBITMAP32)0);
512 DeleteObject32 (hBmp);
516 infoPtr->nNumBitmaps += (INT32)wParam;
518 return nIndex;
522 static LRESULT
523 TOOLBAR_AddButtons32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
525 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
526 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
527 INT32 nOldButtons, nNewButtons, nAddButtons, nCount;
528 HDC32 hdc;
530 TRACE (toolbar, "adding %d buttons!\n", wParam);
532 nAddButtons = (UINT32)wParam;
533 nOldButtons = infoPtr->nNumButtons;
534 nNewButtons = nOldButtons + nAddButtons;
536 if (infoPtr->nNumButtons == 0) {
537 infoPtr->buttons =
538 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
539 sizeof (TBUTTON_INFO) * nNewButtons);
541 else {
542 TBUTTON_INFO *oldButtons = infoPtr->buttons;
543 infoPtr->buttons =
544 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
545 sizeof (TBUTTON_INFO) * nNewButtons);
546 memcpy (&infoPtr->buttons[0], &oldButtons[0],
547 nOldButtons * sizeof(TBUTTON_INFO));
548 HeapFree (GetProcessHeap (), 0, oldButtons);
551 infoPtr->nNumButtons = nNewButtons;
553 /* insert new button data (bad implementation)*/
554 for (nCount = 0; nCount < nAddButtons; nCount++) {
555 infoPtr->buttons[nOldButtons+nCount].iBitmap = lpTbb[nCount].iBitmap;
556 infoPtr->buttons[nOldButtons+nCount].idCommand = lpTbb[nCount].idCommand;
557 infoPtr->buttons[nOldButtons+nCount].fsState = lpTbb[nCount].fsState;
558 infoPtr->buttons[nOldButtons+nCount].fsStyle = lpTbb[nCount].fsStyle;
559 infoPtr->buttons[nOldButtons+nCount].dwData = lpTbb[nCount].dwData;
560 infoPtr->buttons[nOldButtons+nCount].iString = lpTbb[nCount].iString;
562 if ((infoPtr->hwndToolTip) && !(lpTbb[nCount].fsStyle & TBSTYLE_SEP)) {
563 TTTOOLINFO32A ti;
565 ZeroMemory (&ti, sizeof(TTTOOLINFO32A));
566 ti.cbSize = sizeof (TTTOOLINFO32A);
567 ti.hwnd = wndPtr->hwndSelf;
568 ti.uId = lpTbb[nCount].idCommand;
569 ti.hinst = 0;
570 ti.lpszText = LPSTR_TEXTCALLBACK32A;
572 SendMessage32A (infoPtr->hwndToolTip, TTM_ADDTOOL32A,
573 0, (LPARAM)&ti);
577 TOOLBAR_CalcToolbar (wndPtr);
579 hdc = GetDC32 (wndPtr->hwndSelf);
580 TOOLBAR_Refresh (wndPtr, hdc);
581 ReleaseDC32 (wndPtr->hwndSelf, hdc);
583 return TRUE;
587 // << TOOLBAR_AddButtons32W >>
590 static LRESULT
591 TOOLBAR_AddString32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
593 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
594 INT32 nIndex;
596 if (wParam) {
597 char szString[256];
598 INT32 len;
599 TRACE (toolbar, "adding string from resource!\n");
601 len = LoadString32A ((HINSTANCE32)wParam, (UINT32)lParam,
602 szString, 256);
604 TRACE (toolbar, "len=%d \"%s\"\n", len, szString);
605 nIndex = infoPtr->nNumStrings;
606 if (infoPtr->nNumStrings == 0) {
607 infoPtr->strings =
608 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char *));
610 else {
611 char **oldStrings = infoPtr->strings;
612 infoPtr->strings =
613 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
614 sizeof(char *) * (infoPtr->nNumStrings + 1));
615 memcpy (&infoPtr->strings[0], &oldStrings[0],
616 sizeof(char *) * infoPtr->nNumStrings);
617 HeapFree (GetProcessHeap (), 0, oldStrings);
620 infoPtr->strings[infoPtr->nNumStrings] =
621 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
622 lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], szString);
623 infoPtr->nNumStrings++;
625 else {
626 char *p = (char*)lParam;
627 INT32 len;
629 if (p == NULL) return -1;
630 TRACE (toolbar, "adding string(s) from array!\n");
631 nIndex = infoPtr->nNumStrings;
632 while (*p) {
633 len = lstrlen32A (p);
634 TRACE (toolbar, "len=%d \"%s\"\n", len, p);
636 if (infoPtr->nNumStrings == 0) {
637 infoPtr->strings =
638 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char *));
640 else {
641 char **oldStrings = infoPtr->strings;
642 infoPtr->strings =
643 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
644 sizeof(char *) * (infoPtr->nNumStrings + 1));
645 memcpy (&infoPtr->strings[0], &oldStrings[0],
646 sizeof(char *) * infoPtr->nNumStrings);
647 HeapFree (GetProcessHeap (), 0, oldStrings);
650 infoPtr->strings[infoPtr->nNumStrings] =
651 HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, sizeof(char)*(len+1));
652 lstrcpy32A (infoPtr->strings[infoPtr->nNumStrings], p);
653 infoPtr->nNumStrings++;
655 p += (len+1);
659 return nIndex;
663 // << TOOLBAR_AddString32W >>
666 static LRESULT
667 TOOLBAR_AutoSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
669 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
670 RECT32 parent_rect;
671 HWND32 parent;
672 INT32 x, y, cx, cy;
673 UINT32 uPosFlags = 0;
675 TRACE (toolbar, "resizing!\n");
677 parent = GetParent32 (wndPtr->hwndSelf);
678 GetClientRect32(parent, &parent_rect);
680 if (wndPtr->dwStyle & CCS_NORESIZE) {
681 uPosFlags |= SWP_NOSIZE;
682 cx = 0;
683 cy = 0;
685 else {
686 infoPtr->nWidth = parent_rect.right - parent_rect.left;
687 TOOLBAR_CalcToolbar (wndPtr);
688 cy = infoPtr->nHeight;
689 cx = infoPtr->nWidth;
692 if (wndPtr->dwStyle & CCS_NOPARENTALIGN)
693 uPosFlags |= SWP_NOMOVE;
695 if (!(wndPtr->dwStyle & CCS_NODIVIDER))
696 cy += 2;
698 infoPtr->bAutoSize = TRUE;
699 SetWindowPos32 (wndPtr->hwndSelf, HWND_TOP, parent_rect.left, parent_rect.top,
700 cx, cy, uPosFlags);
702 return 0;
706 static LRESULT
707 TOOLBAR_ButtonCount (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
709 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
711 return infoPtr->nNumButtons;
715 static LRESULT
716 TOOLBAR_ButtonStructSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
718 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
720 if (infoPtr == NULL) {
721 ERR (toolbar, "(0x%08lx, 0x%08x, 0x%08lx)\n", (DWORD)wndPtr, wParam, lParam);
722 ERR (toolbar, "infoPtr == NULL!\n");
723 return 0;
726 infoPtr->dwStructSize = (DWORD)wParam;
728 return 0;
732 static LRESULT
733 TOOLBAR_ChangeBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
735 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
736 TBUTTON_INFO *btnPtr;
737 HDC32 hdc;
738 INT32 nIndex;
740 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
741 if (nIndex == -1)
742 return FALSE;
744 btnPtr = &infoPtr->buttons[nIndex];
745 btnPtr->iBitmap = LOWORD(lParam);
747 hdc = GetDC32 (wndPtr->hwndSelf);
748 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
749 ReleaseDC32 (wndPtr->hwndSelf, hdc);
751 return TRUE;
755 static LRESULT
756 TOOLBAR_CheckButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
758 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
759 TBUTTON_INFO *btnPtr;
760 HDC32 hdc;
761 INT32 nIndex;
762 INT32 nOldIndex = -1;
764 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
765 if (nIndex == -1)
766 return FALSE;
768 btnPtr = &infoPtr->buttons[nIndex];
770 if (!(btnPtr->fsStyle & TBSTYLE_CHECK))
771 return FALSE;
773 if (LOWORD(lParam) == FALSE)
774 btnPtr->fsState &= ~TBSTATE_CHECKED;
775 else {
776 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
777 nOldIndex =
778 TOOLBAR_GetCheckedGroupButtonIndex (infoPtr, nIndex);
779 if (nOldIndex == nIndex)
780 return 0;
781 if (nOldIndex != -1)
782 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
784 btnPtr->fsState |= TBSTATE_CHECKED;
787 hdc = GetDC32 (wndPtr->hwndSelf);
788 if (nOldIndex != -1)
789 TOOLBAR_DrawButton (wndPtr, &infoPtr->buttons[nOldIndex], hdc);
790 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
791 ReleaseDC32 (wndPtr->hwndSelf, hdc);
793 /* FIXME: Send a WM_NOTIFY?? */
795 return TRUE;
799 static LRESULT
800 TOOLBAR_CommandToIndex (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
802 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
804 return TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
808 static LRESULT
809 TOOLBAR_Customize (WND *wndPtr)
811 FIXME (toolbar, "customization not implemented!\n");
813 return 0;
817 static LRESULT
818 TOOLBAR_DeleteButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
820 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
821 INT32 nIndex = (INT32)wParam;
823 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
824 return FALSE;
826 if ((infoPtr->hwndToolTip) &&
827 !(infoPtr->buttons[nIndex].fsStyle & TBSTYLE_SEP)) {
828 TTTOOLINFO32A ti;
830 ZeroMemory (&ti, sizeof(TTTOOLINFO32A));
831 ti.cbSize = sizeof (TTTOOLINFO32A);
832 ti.hwnd = wndPtr->hwndSelf;
833 ti.uId = infoPtr->buttons[nIndex].idCommand;
835 SendMessage32A (infoPtr->hwndToolTip, TTM_DELTOOL32A, 0, (LPARAM)&ti);
838 if (infoPtr->nNumButtons == 1) {
839 TRACE (toolbar, " simple delete!\n");
840 HeapFree (GetProcessHeap (), 0, infoPtr->buttons);
841 infoPtr->buttons = NULL;
842 infoPtr->nNumButtons = 0;
844 else {
845 TBUTTON_INFO *oldButtons = infoPtr->buttons;
846 TRACE(toolbar, "complex delete! [nIndex=%d]\n", nIndex);
848 infoPtr->nNumButtons--;
849 infoPtr->buttons = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
850 sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
851 if (nIndex > 0) {
852 memcpy (&infoPtr->buttons[0], &oldButtons[0],
853 nIndex * sizeof(TBUTTON_INFO));
856 if (nIndex < infoPtr->nNumButtons) {
857 memcpy (&infoPtr->buttons[nIndex], &oldButtons[nIndex+1],
858 (infoPtr->nNumButtons - nIndex) * sizeof(TBUTTON_INFO));
861 HeapFree (GetProcessHeap (), 0, oldButtons);
864 TOOLBAR_CalcToolbar (wndPtr);
866 InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
867 UpdateWindow32 (wndPtr->hwndSelf);
869 return TRUE;
873 static LRESULT
874 TOOLBAR_EnableButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
876 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
877 TBUTTON_INFO *btnPtr;
878 HDC32 hdc;
879 INT32 nIndex;
881 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
882 if (nIndex == -1)
883 return FALSE;
885 btnPtr = &infoPtr->buttons[nIndex];
886 if (LOWORD(lParam) == FALSE)
887 btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED);
888 else
889 btnPtr->fsState |= TBSTATE_ENABLED;
891 hdc = GetDC32 (wndPtr->hwndSelf);
892 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
893 ReleaseDC32 (wndPtr->hwndSelf, hdc);
895 return TRUE;
899 // << TOOLBAR_GetAnchorHighlight >>
902 static LRESULT
903 TOOLBAR_GetBitmap (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
905 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
906 INT32 nIndex;
908 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
909 if (nIndex == -1)
910 return 0;
912 return infoPtr->buttons[nIndex].iBitmap;
916 static LRESULT
917 TOOLBAR_GetBitmapFlags (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
919 FIXME (toolbar, "stub!\n");
920 return 0;
924 static LRESULT
925 TOOLBAR_GetButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
927 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
928 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
929 INT32 nIndex = (INT32)wParam;
930 TBUTTON_INFO *btnPtr;
932 if (infoPtr == NULL) return FALSE;
933 if (lpTbb == NULL) return FALSE;
935 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
936 return FALSE;
938 btnPtr = &infoPtr->buttons[nIndex];
939 lpTbb->iBitmap = btnPtr->iBitmap;
940 lpTbb->idCommand = btnPtr->idCommand;
941 lpTbb->fsState = btnPtr->fsState;
942 lpTbb->fsStyle = btnPtr->fsStyle;
943 lpTbb->dwData = btnPtr->dwData;
944 lpTbb->iString = btnPtr->iString;
946 return TRUE;
950 static LRESULT
951 TOOLBAR_GetButtonInfo32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
953 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
954 LPTBBUTTONINFO32A lpTbInfo = (LPTBBUTTONINFO32A)lParam;
955 TBUTTON_INFO *btnPtr;
956 INT32 nIndex;
958 if (infoPtr == NULL) return -1;
959 if (lpTbInfo == NULL) return -1;
960 if (lpTbInfo->cbSize < sizeof(LPTBBUTTONINFO32A)) return -1;
962 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
964 if (nIndex == -1)
965 return -1;
967 btnPtr = &infoPtr->buttons[nIndex];
969 if (lpTbInfo->dwMask & TBIF_COMMAND)
970 lpTbInfo->idCommand = btnPtr->idCommand;
972 if (lpTbInfo->dwMask & TBIF_IMAGE)
973 lpTbInfo->iImage = btnPtr->iBitmap;
975 if (lpTbInfo->dwMask & TBIF_LPARAM)
976 lpTbInfo->lParam = btnPtr->dwData;
978 if (lpTbInfo->dwMask & TBIF_SIZE)
979 lpTbInfo->cx = (WORD)(btnPtr->rect.right - btnPtr->rect.left);
981 if (lpTbInfo->dwMask & TBIF_STATE)
982 lpTbInfo->fsState = btnPtr->fsState;
984 if (lpTbInfo->dwMask & TBIF_STYLE)
985 lpTbInfo->fsStyle = btnPtr->fsStyle;
987 if (lpTbInfo->dwMask & TBIF_TEXT) {
988 if ((btnPtr->iString >= 0) || (btnPtr->iString < infoPtr->nNumStrings))
989 lstrcpyn32A (lpTbInfo->pszText,
990 (LPSTR)infoPtr->strings[btnPtr->iString],
991 lpTbInfo->cchText);
994 return nIndex;
998 // << TOOLBAR_GetButtonInfo32W >>
1001 static LRESULT
1002 TOOLBAR_GetButtonSize (WND *wndPtr)
1004 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1006 return MAKELONG((WORD)infoPtr->nButtonWidth,
1007 (WORD)infoPtr->nButtonHeight);
1011 static LRESULT
1012 TOOLBAR_GetButtonText32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1014 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1015 INT32 nIndex, nStringIndex;
1017 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1018 if (nIndex == -1)
1019 return -1;
1021 nStringIndex = infoPtr->buttons[nIndex].iString;
1023 TRACE (toolbar, "index=%d stringIndex=%d\n", nIndex, nStringIndex);
1025 if ((nStringIndex < 0) || (nStringIndex >= infoPtr->nNumStrings))
1026 return -1;
1028 if (lParam == 0) return -1;
1030 lstrcpy32A ((LPSTR)lParam, (LPSTR)infoPtr->strings[nStringIndex]);
1032 return lstrlen32A ((LPSTR)infoPtr->strings[nStringIndex]);
1036 // << TOOLBAR_GetButtonText32W >>
1037 // << TOOLBAR_GetColorScheme >>
1040 static LRESULT
1041 TOOLBAR_GetDisabledImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1043 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1045 if (wndPtr->dwStyle & TBSTYLE_FLAT)
1046 return (LRESULT)infoPtr->himlDis;
1047 else
1048 return 0;
1052 __inline__ static LRESULT
1053 TOOLBAR_GetExtendedStyle (WND *wndPtr)
1055 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1057 return infoPtr->dwExStyle;
1061 static LRESULT
1062 TOOLBAR_GetHotImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1064 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1066 if (wndPtr->dwStyle & TBSTYLE_FLAT)
1067 return (LRESULT)infoPtr->himlHot;
1068 else
1069 return 0;
1073 // << TOOLBAR_GetHotItem >>
1076 static LRESULT
1077 TOOLBAR_GetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1079 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1081 if (wndPtr->dwStyle & TBSTYLE_FLAT)
1082 return (LRESULT)infoPtr->himlDef;
1083 else
1084 return 0;
1088 // << TOOLBAR_GetInsertMark >>
1089 // << TOOLBAR_GetInsertMarkColor >>
1092 static LRESULT
1093 TOOLBAR_GetItemRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1095 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1096 TBUTTON_INFO *btnPtr;
1097 LPRECT32 lpRect;
1098 INT32 nIndex;
1100 if (infoPtr == NULL) return FALSE;
1101 nIndex = (INT32)wParam;
1102 btnPtr = &infoPtr->buttons[nIndex];
1103 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1104 return FALSE;
1105 lpRect = (LPRECT32)lParam;
1106 if (lpRect == NULL) return FALSE;
1107 if (btnPtr->fsState & TBSTATE_HIDDEN) return FALSE;
1109 lpRect->left = btnPtr->rect.left;
1110 lpRect->right = btnPtr->rect.right;
1111 lpRect->bottom = btnPtr->rect.bottom;
1112 lpRect->top = btnPtr->rect.top;
1114 return TRUE;
1118 static LRESULT
1119 TOOLBAR_GetMaxSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1121 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1122 LPSIZE32 lpSize = (LPSIZE32)lParam;
1124 if (lpSize == NULL)
1125 return FALSE;
1127 lpSize->cx = infoPtr->maxSize.cx;
1128 lpSize->cx = infoPtr->maxSize.cy;
1130 TRACE (toolbar, "maximum size %d x %d\n",
1131 infoPtr->maxSize.cx, infoPtr->maxSize.cy);
1133 return TRUE;
1137 // << TOOLBAR_GetObject >>
1138 // << TOOLBAR_GetPadding >>
1141 static LRESULT
1142 TOOLBAR_GetRect (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1144 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1145 TBUTTON_INFO *btnPtr;
1146 LPRECT32 lpRect;
1147 INT32 nIndex;
1149 if (infoPtr == NULL) return FALSE;
1150 nIndex = (INT32)wParam;
1151 btnPtr = &infoPtr->buttons[nIndex];
1152 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1153 return FALSE;
1154 lpRect = (LPRECT32)lParam;
1155 if (lpRect == NULL) return FALSE;
1157 lpRect->left = btnPtr->rect.left;
1158 lpRect->right = btnPtr->rect.right;
1159 lpRect->bottom = btnPtr->rect.bottom;
1160 lpRect->top = btnPtr->rect.top;
1162 return TRUE;
1166 static LRESULT
1167 TOOLBAR_GetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1169 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1171 if (wndPtr->dwStyle & TBSTYLE_WRAPABLE)
1172 return infoPtr->nMaxRows;
1173 else
1174 return 1;
1178 static LRESULT
1179 TOOLBAR_GetState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1181 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1182 INT32 nIndex;
1184 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1185 if (nIndex == -1) return -1;
1187 return infoPtr->buttons[nIndex].fsState;
1191 static LRESULT
1192 TOOLBAR_GetStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1194 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1195 INT32 nIndex;
1197 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1198 if (nIndex == -1) return -1;
1200 return infoPtr->buttons[nIndex].fsStyle;
1204 static LRESULT
1205 TOOLBAR_GetTextRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1207 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1209 if (infoPtr == NULL)
1210 return 0;
1212 return infoPtr->nMaxTextRows;
1216 static LRESULT
1217 TOOLBAR_GetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1219 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1221 if (infoPtr == NULL) return 0;
1222 return infoPtr->hwndToolTip;
1226 static LRESULT
1227 TOOLBAR_GetUnicodeFormat (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1229 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1231 TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
1232 infoPtr->bUnicode ? "TRUE" : "FALSE", wndPtr->hwndSelf);
1234 return infoPtr->bUnicode;
1238 static LRESULT
1239 TOOLBAR_HideButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1241 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1242 TBUTTON_INFO *btnPtr;
1243 INT32 nIndex;
1245 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1246 if (nIndex == -1)
1247 return FALSE;
1249 btnPtr = &infoPtr->buttons[nIndex];
1250 if (LOWORD(lParam) == FALSE)
1251 btnPtr->fsState &= ~TBSTATE_HIDDEN;
1252 else
1253 btnPtr->fsState |= TBSTATE_HIDDEN;
1255 TOOLBAR_CalcToolbar (wndPtr);
1257 InvalidateRect32 (wndPtr->hwndSelf, NULL, TRUE);
1258 UpdateWindow32 (wndPtr->hwndSelf);
1260 return TRUE;
1264 __inline__ static LRESULT
1265 TOOLBAR_HitTest (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1267 return TOOLBAR_InternalHitTest (wndPtr, (LPPOINT32)lParam);
1271 static LRESULT
1272 TOOLBAR_Indeterminate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1274 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1275 TBUTTON_INFO *btnPtr;
1276 HDC32 hdc;
1277 INT32 nIndex;
1279 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1280 if (nIndex == -1)
1281 return FALSE;
1283 btnPtr = &infoPtr->buttons[nIndex];
1284 if (LOWORD(lParam) == FALSE)
1285 btnPtr->fsState &= ~TBSTATE_INDETERMINATE;
1286 else
1287 btnPtr->fsState |= TBSTATE_INDETERMINATE;
1289 hdc = GetDC32 (wndPtr->hwndSelf);
1290 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1291 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1293 return TRUE;
1297 static LRESULT
1298 TOOLBAR_InsertButton32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1300 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1301 LPTBBUTTON lpTbb = (LPTBBUTTON)lParam;
1302 INT32 nIndex = (INT32)wParam;
1303 TBUTTON_INFO *oldButtons;
1304 HDC32 hdc;
1306 if (lpTbb == NULL) return FALSE;
1307 if (nIndex < 0) return FALSE;
1309 TRACE (toolbar, "inserting button index=%d\n", nIndex);
1310 if (nIndex > infoPtr->nNumButtons) {
1311 nIndex = infoPtr->nNumButtons;
1312 TRACE (toolbar, "adjust index=%d\n", nIndex);
1315 oldButtons = infoPtr->buttons;
1316 infoPtr->nNumButtons++;
1317 infoPtr->buttons = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
1318 sizeof (TBUTTON_INFO) * infoPtr->nNumButtons);
1319 /* pre insert copy */
1320 if (nIndex > 0) {
1321 memcpy (&infoPtr->buttons[0], &oldButtons[0],
1322 nIndex * sizeof(TBUTTON_INFO));
1325 /* insert new button */
1326 infoPtr->buttons[nIndex].iBitmap = lpTbb->iBitmap;
1327 infoPtr->buttons[nIndex].idCommand = lpTbb->idCommand;
1328 infoPtr->buttons[nIndex].fsState = lpTbb->fsState;
1329 infoPtr->buttons[nIndex].fsStyle = lpTbb->fsStyle;
1330 infoPtr->buttons[nIndex].dwData = lpTbb->dwData;
1331 infoPtr->buttons[nIndex].iString = lpTbb->iString;
1333 if ((infoPtr->hwndToolTip) && !(lpTbb->fsStyle & TBSTYLE_SEP)) {
1334 TTTOOLINFO32A ti;
1336 ZeroMemory (&ti, sizeof(TTTOOLINFO32A));
1337 ti.cbSize = sizeof (TTTOOLINFO32A);
1338 ti.hwnd = wndPtr->hwndSelf;
1339 ti.uId = lpTbb->idCommand;
1340 ti.hinst = 0;
1341 ti.lpszText = LPSTR_TEXTCALLBACK32A;
1343 SendMessage32A (infoPtr->hwndToolTip, TTM_ADDTOOL32A,
1344 0, (LPARAM)&ti);
1347 /* post insert copy */
1348 if (nIndex < infoPtr->nNumButtons - 1) {
1349 memcpy (&infoPtr->buttons[nIndex+1], &oldButtons[nIndex],
1350 (infoPtr->nNumButtons - nIndex - 1) * sizeof(TBUTTON_INFO));
1353 HeapFree (GetProcessHeap (), 0, oldButtons);
1355 TOOLBAR_CalcToolbar (wndPtr);
1357 hdc = GetDC32 (wndPtr->hwndSelf);
1358 TOOLBAR_Refresh (wndPtr, hdc);
1359 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1361 return TRUE;
1365 // << TOOLBAR_InsertButton32W >>
1366 // << TOOLBAR_InsertMarkHitTest >>
1369 static LRESULT
1370 TOOLBAR_IsButtonChecked (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1372 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1373 INT32 nIndex;
1375 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1376 if (nIndex == -1)
1377 return FALSE;
1379 return (infoPtr->buttons[nIndex].fsState & TBSTATE_CHECKED);
1383 static LRESULT
1384 TOOLBAR_IsButtonEnabled (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1386 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1387 INT32 nIndex;
1389 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1390 if (nIndex == -1)
1391 return FALSE;
1393 return (infoPtr->buttons[nIndex].fsState & TBSTATE_ENABLED);
1397 static LRESULT
1398 TOOLBAR_IsButtonHidden (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1400 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1401 INT32 nIndex;
1403 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1404 if (nIndex == -1)
1405 return FALSE;
1407 return (infoPtr->buttons[nIndex].fsState & TBSTATE_HIDDEN);
1411 static LRESULT
1412 TOOLBAR_IsButtonHighlighted (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1414 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1415 INT32 nIndex;
1417 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1418 if (nIndex == -1)
1419 return FALSE;
1421 return (infoPtr->buttons[nIndex].fsState & TBSTATE_MARKED);
1425 static LRESULT
1426 TOOLBAR_IsButtonIndeterminate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1428 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1429 INT32 nIndex;
1431 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1432 if (nIndex == -1)
1433 return FALSE;
1435 return (infoPtr->buttons[nIndex].fsState & TBSTATE_INDETERMINATE);
1439 static LRESULT
1440 TOOLBAR_IsButtonPressed (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1442 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1443 INT32 nIndex;
1445 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1446 if (nIndex == -1)
1447 return FALSE;
1449 return (infoPtr->buttons[nIndex].fsState & TBSTATE_PRESSED);
1453 // << TOOLBAR_LoadImages >>
1454 // << TOOLBAR_MapAccelerator >>
1455 // << TOOLBAR_MarkButton >>
1456 // << TOOLBAR_MoveButton >>
1459 static LRESULT
1460 TOOLBAR_PressButton (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1462 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1463 TBUTTON_INFO *btnPtr;
1464 HDC32 hdc;
1465 INT32 nIndex;
1467 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1468 if (nIndex == -1)
1469 return FALSE;
1471 btnPtr = &infoPtr->buttons[nIndex];
1472 if (LOWORD(lParam) == FALSE)
1473 btnPtr->fsState &= ~TBSTATE_PRESSED;
1474 else
1475 btnPtr->fsState |= TBSTATE_PRESSED;
1477 hdc = GetDC32 (wndPtr->hwndSelf);
1478 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1479 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1481 return TRUE;
1485 // << TOOLBAR_ReplaceBitmap >>
1488 static LRESULT
1489 TOOLBAR_SaveRestore32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1491 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1492 LPTBSAVEPARAMS32A lpSave = (LPTBSAVEPARAMS32A)lParam;
1494 if (lpSave == NULL) return 0;
1496 if ((BOOL32)wParam) {
1497 /* save toolbar information */
1498 FIXME (toolbar, "save to \"%s\" \"%s\"\n",
1499 lpSave->pszSubKey, lpSave->pszValueName);
1503 else {
1504 /* restore toolbar information */
1506 FIXME (toolbar, "restore from \"%s\" \"%s\"\n",
1507 lpSave->pszSubKey, lpSave->pszValueName);
1512 return 0;
1516 // << TOOLBAR_SaveRestore32W >>
1517 // << TOOLBAR_SetAnchorHighlight >>
1520 static LRESULT
1521 TOOLBAR_SetBitmapSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1523 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1525 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
1526 return FALSE;
1528 infoPtr->nBitmapWidth = (INT32)LOWORD(lParam);
1529 infoPtr->nBitmapHeight = (INT32)HIWORD(lParam);
1531 return TRUE;
1535 // << TOOLBAR_SetButtonInfo >>
1538 static LRESULT
1539 TOOLBAR_SetButtonSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1541 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1543 if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
1544 return FALSE;
1546 infoPtr->nButtonWidth = (INT32)LOWORD(lParam);
1547 infoPtr->nButtonHeight = (INT32)HIWORD(lParam);
1549 return TRUE;
1553 static LRESULT
1554 TOOLBAR_SetButtonWidth (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1556 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1558 if (infoPtr == NULL)
1559 return FALSE;
1561 infoPtr->cxMin = (INT32)LOWORD(lParam);
1562 infoPtr->cxMax = (INT32)HIWORD(lParam);
1564 return TRUE;
1568 static LRESULT
1569 TOOLBAR_SetCmdId (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1571 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1572 INT32 nIndex = (INT32)wParam;
1574 if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons))
1575 return FALSE;
1577 infoPtr->buttons[nIndex].idCommand = (INT32)lParam;
1579 if (infoPtr->hwndToolTip) {
1581 FIXME (toolbar, "change tool tip!\n");
1585 return TRUE;
1589 // << TOOLBAR_SetColorScheme >>
1592 static LRESULT
1593 TOOLBAR_SetDisabledImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1595 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1596 HIMAGELIST himlTemp;
1598 if (!(wndPtr->dwStyle & TBSTYLE_FLAT))
1599 return 0;
1601 himlTemp = infoPtr->himlDis;
1602 infoPtr->himlDis = (HIMAGELIST)lParam;
1604 /* FIXME: redraw ? */
1606 return (LRESULT)himlTemp;
1610 // << TOOLBAR_SetDrawTextFlags >>
1613 static LRESULT
1614 TOOLBAR_SetExtendedStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1616 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1617 DWORD dwTemp;
1619 dwTemp = infoPtr->dwExStyle;
1620 infoPtr->dwExStyle = (DWORD)lParam;
1622 return (LRESULT)dwTemp;
1626 static LRESULT
1627 TOOLBAR_SetHotImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1629 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1630 HIMAGELIST himlTemp;
1632 if (!(wndPtr->dwStyle & TBSTYLE_FLAT))
1633 return 0;
1635 himlTemp = infoPtr->himlHot;
1636 infoPtr->himlHot = (HIMAGELIST)lParam;
1638 /* FIXME: redraw ? */
1640 return (LRESULT)himlTemp;
1644 // << TOOLBAR_SetHotItem >>
1647 static LRESULT
1648 TOOLBAR_SetImageList (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1650 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1651 HIMAGELIST himlTemp;
1653 if (!(wndPtr->dwStyle & TBSTYLE_FLAT))
1654 return 0;
1656 himlTemp = infoPtr->himlDef;
1657 infoPtr->himlDef = (HIMAGELIST)lParam;
1659 /* FIXME: redraw ? */
1661 return (LRESULT)himlTemp;
1665 static LRESULT
1666 TOOLBAR_SetIndent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1668 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1669 HDC32 hdc;
1671 infoPtr->nIndent = (INT32)wParam;
1672 TOOLBAR_CalcToolbar (wndPtr);
1673 hdc = GetDC32 (wndPtr->hwndSelf);
1674 TOOLBAR_Refresh (wndPtr, hdc);
1675 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1677 return TRUE;
1681 // << TOOLBAR_SetInsertMark >>
1684 static LRESULT
1685 TOOLBAR_SetInsertMarkColor (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1687 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1689 infoPtr->clrInsertMark = (COLORREF)lParam;
1691 /* FIXME : redraw ??*/
1693 return 0;
1697 static LRESULT
1698 TOOLBAR_SetMaxTextRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1700 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1702 if (infoPtr == NULL)
1703 return FALSE;
1705 infoPtr->nMaxTextRows = (INT32)wParam;
1707 return TRUE;
1711 // << TOOLBAR_SetPadding >>
1714 static LRESULT
1715 TOOLBAR_SetParent (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1717 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1718 HWND32 hwndOldNotify;
1720 if (infoPtr == NULL) return 0;
1721 hwndOldNotify = infoPtr->hwndNotify;
1722 infoPtr->hwndNotify = (HWND32)wParam;
1724 return hwndOldNotify;
1728 static LRESULT
1729 TOOLBAR_SetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1731 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1733 FIXME (toolbar, "support multiple rows!\n");
1735 return 0;
1739 static LRESULT
1740 TOOLBAR_SetState (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1742 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1743 TBUTTON_INFO *btnPtr;
1744 HDC32 hdc;
1745 INT32 nIndex;
1747 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1748 if (nIndex == -1)
1749 return FALSE;
1751 btnPtr = &infoPtr->buttons[nIndex];
1752 btnPtr->fsState = LOWORD(lParam);
1754 hdc = GetDC32 (wndPtr->hwndSelf);
1755 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1756 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1758 return TRUE;
1762 static LRESULT
1763 TOOLBAR_SetStyle (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1765 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1766 TBUTTON_INFO *btnPtr;
1767 HDC32 hdc;
1768 INT32 nIndex;
1770 nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT32)wParam);
1771 if (nIndex == -1)
1772 return FALSE;
1774 btnPtr = &infoPtr->buttons[nIndex];
1775 btnPtr->fsStyle = LOWORD(lParam);
1777 hdc = GetDC32 (wndPtr->hwndSelf);
1778 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1779 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1781 if (infoPtr->hwndToolTip) {
1783 FIXME (toolbar, "change tool tip!\n");
1787 return TRUE;
1791 static LRESULT
1792 TOOLBAR_SetToolTips (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1794 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1796 if (infoPtr == NULL) return 0;
1797 infoPtr->hwndToolTip = (HWND32)wParam;
1798 return 0;
1802 static LRESULT
1803 TOOLBAR_SetUnicodeFormat (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1805 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1806 BOOL32 bTemp;
1808 TRACE (toolbar, "%s hwnd=0x%04x stub!\n",
1809 ((BOOL32)wParam) ? "TRUE" : "FALSE", wndPtr->hwndSelf);
1811 bTemp = infoPtr->bUnicode;
1812 infoPtr->bUnicode = (BOOL32)wParam;
1814 return bTemp;
1818 static LRESULT
1819 TOOLBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1821 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1822 LOGFONT32A logFont;
1824 /* initialize info structure */
1825 infoPtr->nButtonHeight = 22;
1826 infoPtr->nButtonWidth = 23;
1827 infoPtr->nBitmapHeight = 15;
1828 infoPtr->nBitmapWidth = 16;
1830 infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
1831 infoPtr->nMaxRows = 1;
1832 infoPtr->nMaxTextRows = 1;
1833 infoPtr->cxMin = -1;
1834 infoPtr->cxMax = -1;
1836 infoPtr->bCaptured = FALSE;
1837 infoPtr->bUnicode = FALSE;
1838 infoPtr->nButtonDown = -1;
1839 infoPtr->nOldHit = -1;
1841 infoPtr->hwndNotify = GetParent32 (wndPtr->hwndSelf);
1842 infoPtr->bTransparent = (wndPtr->dwStyle & TBSTYLE_FLAT);
1843 infoPtr->nHotItem = -1;
1845 SystemParametersInfo32A (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
1846 infoPtr->hFont = CreateFontIndirect32A (&logFont);
1848 if (wndPtr->dwStyle & TBSTYLE_TOOLTIPS) {
1849 /* Create tooltip control */
1850 infoPtr->hwndToolTip =
1851 CreateWindowEx32A (0, TOOLTIPS_CLASS32A, NULL, TTS_ALWAYSTIP,
1852 CW_USEDEFAULT32, CW_USEDEFAULT32,
1853 CW_USEDEFAULT32, CW_USEDEFAULT32,
1854 wndPtr->hwndSelf, 0, 0, 0);
1856 /* Send NM_TOOLTIPSCREATED notification */
1857 if (infoPtr->hwndToolTip) {
1858 NMTOOLTIPSCREATED nmttc;
1860 nmttc.hdr.hwndFrom = wndPtr->hwndSelf;
1861 nmttc.hdr.idFrom = wndPtr->wIDmenu;
1862 nmttc.hdr.code = NM_TOOLTIPSCREATED;
1863 nmttc.hwndToolTips = infoPtr->hwndToolTip;
1865 SendMessage32A (infoPtr->hwndNotify, WM_NOTIFY,
1866 (WPARAM32)wndPtr->wIDmenu, (LPARAM)&nmttc);
1870 return 0;
1874 static LRESULT
1875 TOOLBAR_Destroy (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1877 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1879 /* delete tooltip control */
1880 if (infoPtr->hwndToolTip)
1881 DestroyWindow32 (infoPtr->hwndToolTip);
1883 /* delete button data */
1884 if (infoPtr->buttons)
1885 HeapFree (GetProcessHeap (), 0, infoPtr->buttons);
1887 /* delete strings */
1888 if (infoPtr->strings) {
1889 INT32 i;
1890 for (i = 0; i < infoPtr->nNumStrings; i++)
1891 if (infoPtr->strings[i])
1892 HeapFree (GetProcessHeap (), 0, infoPtr->strings[i]);
1894 HeapFree (GetProcessHeap (), 0, infoPtr->strings);
1897 /* destroy default image list */
1898 if (infoPtr->himlDef)
1899 ImageList_Destroy (infoPtr->himlDef);
1901 /* destroy disabled image list */
1902 if (infoPtr->himlDis)
1903 ImageList_Destroy (infoPtr->himlDis);
1905 /* destroy hot image list */
1906 if (infoPtr->himlHot)
1907 ImageList_Destroy (infoPtr->himlHot);
1909 /* delete default font */
1910 if (infoPtr->hFont)
1911 DeleteObject32 (infoPtr->hFont);
1913 /* free toolbar info data */
1914 HeapFree (GetProcessHeap (), 0, infoPtr);
1916 return 0;
1920 static LRESULT
1921 TOOLBAR_EraseBackground (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1923 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1925 if (infoPtr->bTransparent)
1926 return SendMessage32A (GetParent32 (wndPtr->hwndSelf), WM_ERASEBKGND,
1927 wParam, lParam);
1929 return DefWindowProc32A (wndPtr->hwndSelf, WM_ERASEBKGND, wParam, lParam);
1933 static LRESULT
1934 TOOLBAR_LButtonDblClk (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1936 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1937 TBUTTON_INFO *btnPtr;
1938 POINT32 pt;
1939 INT32 nHit;
1940 HDC32 hdc;
1942 pt.x = (INT32)LOWORD(lParam);
1943 pt.y = (INT32)HIWORD(lParam);
1944 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
1946 if (nHit >= 0) {
1947 btnPtr = &infoPtr->buttons[nHit];
1948 if (!(btnPtr->fsState & TBSTATE_ENABLED))
1949 return 0;
1950 SetCapture32 (wndPtr->hwndSelf);
1951 infoPtr->bCaptured = TRUE;
1952 infoPtr->nButtonDown = nHit;
1954 btnPtr->fsState |= TBSTATE_PRESSED;
1956 hdc = GetDC32 (wndPtr->hwndSelf);
1957 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1958 ReleaseDC32 (wndPtr->hwndSelf, hdc);
1960 else if (wndPtr->dwStyle & CCS_ADJUSTABLE)
1961 TOOLBAR_Customize (wndPtr);
1963 return 0;
1967 static LRESULT
1968 TOOLBAR_LButtonDown (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
1970 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
1971 TBUTTON_INFO *btnPtr;
1972 POINT32 pt;
1973 INT32 nHit;
1974 HDC32 hdc;
1976 if (infoPtr->hwndToolTip)
1977 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, wndPtr->hwndSelf,
1978 WM_LBUTTONDOWN, wParam, lParam);
1980 pt.x = (INT32)LOWORD(lParam);
1981 pt.y = (INT32)HIWORD(lParam);
1982 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
1984 if (nHit >= 0) {
1985 btnPtr = &infoPtr->buttons[nHit];
1986 if (!(btnPtr->fsState & TBSTATE_ENABLED))
1987 return 0;
1989 SetCapture32 (wndPtr->hwndSelf);
1990 infoPtr->bCaptured = TRUE;
1991 infoPtr->nButtonDown = nHit;
1992 infoPtr->nOldHit = nHit;
1994 btnPtr->fsState |= TBSTATE_PRESSED;
1996 hdc = GetDC32 (wndPtr->hwndSelf);
1997 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
1998 ReleaseDC32 (wndPtr->hwndSelf, hdc);
2002 return 0;
2006 static LRESULT
2007 TOOLBAR_LButtonUp (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2009 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
2010 TBUTTON_INFO *btnPtr;
2011 POINT32 pt;
2012 INT32 nHit;
2013 INT32 nOldIndex = -1;
2014 HDC32 hdc;
2015 BOOL32 bSendMessage = TRUE;
2017 if (infoPtr->hwndToolTip)
2018 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, wndPtr->hwndSelf,
2019 WM_LBUTTONUP, wParam, lParam);
2021 pt.x = (INT32)LOWORD(lParam);
2022 pt.y = (INT32)HIWORD(lParam);
2023 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
2025 if ((infoPtr->bCaptured) && (infoPtr->nButtonDown >= 0)) {
2026 infoPtr->bCaptured = FALSE;
2027 ReleaseCapture ();
2028 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2029 btnPtr->fsState &= ~TBSTATE_PRESSED;
2031 if (nHit == infoPtr->nButtonDown) {
2032 if (btnPtr->fsStyle & TBSTYLE_CHECK) {
2033 if (btnPtr->fsStyle & TBSTYLE_GROUP) {
2034 nOldIndex = TOOLBAR_GetCheckedGroupButtonIndex (infoPtr,
2035 infoPtr->nButtonDown);
2036 if (nOldIndex == infoPtr->nButtonDown)
2037 bSendMessage = FALSE;
2038 if ((nOldIndex != infoPtr->nButtonDown) &&
2039 (nOldIndex != -1))
2040 infoPtr->buttons[nOldIndex].fsState &= ~TBSTATE_CHECKED;
2041 btnPtr->fsState |= TBSTATE_CHECKED;
2043 else {
2044 if (btnPtr->fsState & TBSTATE_CHECKED)
2045 btnPtr->fsState &= ~TBSTATE_CHECKED;
2046 else
2047 btnPtr->fsState |= TBSTATE_CHECKED;
2051 else
2052 bSendMessage = FALSE;
2054 hdc = GetDC32 (wndPtr->hwndSelf);
2055 if (nOldIndex != -1)
2056 TOOLBAR_DrawButton (wndPtr, &infoPtr->buttons[nOldIndex], hdc);
2057 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
2058 ReleaseDC32 (wndPtr->hwndSelf, hdc);
2060 if (bSendMessage)
2061 SendMessage32A (infoPtr->hwndNotify, WM_COMMAND,
2062 MAKEWPARAM(btnPtr->idCommand, 0),
2063 (LPARAM)wndPtr->hwndSelf);
2065 infoPtr->nButtonDown = -1;
2066 infoPtr->nOldHit = -1;
2069 return 0;
2073 static LRESULT
2074 TOOLBAR_MouseMove (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2076 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
2077 TBUTTON_INFO *btnPtr;
2078 POINT32 pt;
2079 INT32 nHit;
2080 HDC32 hdc;
2082 if (infoPtr->hwndToolTip)
2083 TOOLBAR_RelayEvent (infoPtr->hwndToolTip, wndPtr->hwndSelf,
2084 WM_MOUSEMOVE, wParam, lParam);
2086 pt.x = (INT32)LOWORD(lParam);
2087 pt.y = (INT32)HIWORD(lParam);
2088 nHit = TOOLBAR_InternalHitTest (wndPtr, &pt);
2090 if (infoPtr->bCaptured) {
2091 if (infoPtr->nOldHit != nHit) {
2092 btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
2093 if (infoPtr->nOldHit == infoPtr->nButtonDown) {
2094 btnPtr->fsState &= ~TBSTATE_PRESSED;
2095 hdc = GetDC32 (wndPtr->hwndSelf);
2096 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
2097 ReleaseDC32 (wndPtr->hwndSelf, hdc);
2099 else if (nHit == infoPtr->nButtonDown) {
2100 btnPtr->fsState |= TBSTATE_PRESSED;
2101 hdc = GetDC32 (wndPtr->hwndSelf);
2102 TOOLBAR_DrawButton (wndPtr, btnPtr, hdc);
2103 ReleaseDC32 (wndPtr->hwndSelf, hdc);
2106 infoPtr->nOldHit = nHit;
2109 return 0;
2113 // << TOOLBAR_NCActivate >>
2116 static LRESULT
2117 TOOLBAR_NCCalcSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2119 if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
2120 LPRECT32 winRect = (LPRECT32)lParam;
2121 winRect->top += 2;
2124 return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCALCSIZE, wParam, lParam);
2128 static LRESULT
2129 TOOLBAR_NCCreate (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2131 TOOLBAR_INFO *infoPtr;
2133 /* allocate memory for info structure */
2134 infoPtr = (TOOLBAR_INFO *)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
2135 sizeof(TOOLBAR_INFO));
2136 wndPtr->wExtra[0] = (DWORD)infoPtr;
2138 if (infoPtr == NULL) {
2139 ERR (toolbar, "could not allocate info memory!\n");
2140 return 0;
2143 if ((TOOLBAR_INFO*)wndPtr->wExtra[0] != infoPtr) {
2144 ERR (toolbar, "pointer assignment error!\n");
2145 return 0;
2148 /* paranoid!! */
2149 infoPtr->dwStructSize = sizeof(TBBUTTON);
2151 /* fix instance handle, if the toolbar was created by CreateToolbarEx() */
2152 if (!wndPtr->hInstance)
2153 wndPtr->hInstance = wndPtr->parent->hInstance;
2155 return DefWindowProc32A (wndPtr->hwndSelf, WM_NCCREATE, wParam, lParam);
2159 static LRESULT
2160 TOOLBAR_NCPaint (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2162 HDC32 hdc;
2163 RECT32 rect;
2164 HWND32 hwnd = wndPtr->hwndSelf;
2166 if ( wndPtr->dwStyle & WS_MINIMIZE ||
2167 !WIN_IsWindowDrawable( wndPtr, 0 )) return 0; /* Nothing to do */
2169 DefWindowProc32A (hwnd, WM_NCPAINT, wParam, lParam);
2171 if (!(hdc = GetDCEx32( hwnd, 0, DCX_USESTYLE | DCX_WINDOW ))) return 0;
2173 if (ExcludeVisRect( hdc, wndPtr->rectClient.left-wndPtr->rectWindow.left,
2174 wndPtr->rectClient.top-wndPtr->rectWindow.top,
2175 wndPtr->rectClient.right-wndPtr->rectWindow.left,
2176 wndPtr->rectClient.bottom-wndPtr->rectWindow.top )
2177 == NULLREGION){
2178 ReleaseDC32( hwnd, hdc );
2179 return 0;
2182 if (!(wndPtr->flags & WIN_MANAGED)) {
2183 if (!(wndPtr->dwStyle & CCS_NODIVIDER)) {
2184 rect.left = wndPtr->rectClient.left;
2185 rect.top = wndPtr->rectClient.top - 2;
2186 rect.right = wndPtr->rectClient.right;
2188 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DSHADOW));
2189 MoveToEx32 (hdc, rect.left, rect.top, NULL);
2190 LineTo32 (hdc, rect.right, rect.top);
2191 rect.top++;
2192 SelectObject32 ( hdc, GetSysColorPen32 (COLOR_3DHILIGHT));
2193 MoveToEx32 (hdc, rect.left, rect.top, NULL);
2194 LineTo32 (hdc, rect.right, rect.top);
2199 ReleaseDC32( hwnd, hdc );
2201 return 0;
2205 __inline__ static LRESULT
2206 TOOLBAR_Notify (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2208 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
2209 LPNMHDR lpnmh = (LPNMHDR)lParam;
2211 TRACE (toolbar, "passing WM_NOTIFY!\n");
2213 if ((infoPtr->hwndToolTip) && (lpnmh->hwndFrom == infoPtr->hwndToolTip)) {
2214 SendMessage32A (infoPtr->hwndNotify, WM_NOTIFY, wParam, lParam);
2216 #if 0
2217 if (lpnmh->code == TTN_GETDISPINFO32A) {
2218 LPNMTTDISPINFO32A lpdi = (LPNMTTDISPINFO32A)lParam;
2220 FIXME (toolbar, "retrieving ASCII string\n");
2223 else if (lpnmh->code == TTN_GETDISPINFO32W) {
2224 LPNMTTDISPINFO32W lpdi = (LPNMTTDISPINFO32W)lParam;
2226 FIXME (toolbar, "retrieving UNICODE string\n");
2229 #endif
2232 return 0;
2236 static LRESULT
2237 TOOLBAR_Paint (WND *wndPtr, WPARAM32 wParam)
2239 HDC32 hdc;
2240 PAINTSTRUCT32 ps;
2242 hdc = wParam==0 ? BeginPaint32 (wndPtr->hwndSelf, &ps) : (HDC32)wParam;
2243 TOOLBAR_Refresh (wndPtr, hdc);
2244 if (!wParam)
2245 EndPaint32 (wndPtr->hwndSelf, &ps);
2246 return 0;
2250 static LRESULT
2251 TOOLBAR_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
2253 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
2254 RECT32 parent_rect;
2255 HWND32 parent;
2256 INT32 x, y, cx, cy;
2257 INT32 flags;
2258 UINT32 uPosFlags = 0;
2260 /* Resize deadlock check */
2261 if (infoPtr->bAutoSize) {
2262 infoPtr->bAutoSize = FALSE;
2263 return 0;
2266 flags = (INT32) wParam;
2268 /* FIXME for flags =
2269 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED
2272 TRACE (toolbar, "sizing toolbar!\n");
2274 if (flags == SIZE_RESTORED) {
2275 /* width and height don't apply */
2276 parent = GetParent32 (wndPtr->hwndSelf);
2277 GetClientRect32(parent, &parent_rect);
2279 if (wndPtr->dwStyle & CCS_NORESIZE) {
2280 uPosFlags |= SWP_NOSIZE;
2282 /* FIXME */
2283 // infoPtr->nWidth = parent_rect.right - parent_rect.left;
2284 cy = infoPtr->nHeight;
2285 cx = infoPtr->nWidth;
2286 TOOLBAR_CalcToolbar (wndPtr);
2287 infoPtr->nWidth = cx;
2288 infoPtr->nHeight = cy;
2290 else {
2291 infoPtr->nWidth = parent_rect.right - parent_rect.left;
2292 TOOLBAR_CalcToolbar (wndPtr);
2293 cy = infoPtr->nHeight;
2294 cx = infoPtr->nWidth;
2297 if (wndPtr->dwStyle & CCS_NOPARENTALIGN) {
2298 uPosFlags |= SWP_NOMOVE;
2299 cy = infoPtr->nHeight;
2300 cx = infoPtr->nWidth;
2303 if (!(wndPtr->dwStyle & CCS_NODIVIDER))
2304 cy += 2;
2306 SetWindowPos32 (wndPtr->hwndSelf, 0, parent_rect.left, parent_rect.top,
2307 cx, cy, uPosFlags | SWP_NOZORDER);
2309 return 0;
2318 LRESULT WINAPI
2319 ToolbarWindowProc (HWND32 hwnd, UINT32 uMsg, WPARAM32 wParam, LPARAM lParam)
2321 WND *wndPtr = WIN_FindWndPtr(hwnd);
2323 switch (uMsg)
2325 case TB_ADDBITMAP:
2326 return TOOLBAR_AddBitmap (wndPtr, wParam, lParam);
2328 case TB_ADDBUTTONS32A:
2329 return TOOLBAR_AddButtons32A (wndPtr, wParam, lParam);
2331 // case TB_ADDBUTTONS32W:
2333 case TB_ADDSTRING32A:
2334 return TOOLBAR_AddString32A (wndPtr, wParam, lParam);
2336 // case TB_ADDSTRING32W:
2338 case TB_AUTOSIZE:
2339 return TOOLBAR_AutoSize (wndPtr, wParam, lParam);
2341 case TB_BUTTONCOUNT:
2342 return TOOLBAR_ButtonCount (wndPtr, wParam, lParam);
2344 case TB_BUTTONSTRUCTSIZE:
2345 return TOOLBAR_ButtonStructSize (wndPtr, wParam, lParam);
2347 case TB_CHANGEBITMAP:
2348 return TOOLBAR_ChangeBitmap (wndPtr, wParam, lParam);
2350 case TB_CHECKBUTTON:
2351 return TOOLBAR_CheckButton (wndPtr, wParam, lParam);
2353 case TB_COMMANDTOINDEX:
2354 return TOOLBAR_CommandToIndex (wndPtr, wParam, lParam);
2356 case TB_CUSTOMIZE:
2357 return TOOLBAR_Customize (wndPtr);
2359 case TB_DELETEBUTTON:
2360 return TOOLBAR_DeleteButton (wndPtr, wParam, lParam);
2362 case TB_ENABLEBUTTON:
2363 return TOOLBAR_EnableButton (wndPtr, wParam, lParam);
2365 // case TB_GETANCHORHIGHLIGHT: /* 4.71 */
2367 case TB_GETBITMAP:
2368 return TOOLBAR_GetBitmap (wndPtr, wParam, lParam);
2370 case TB_GETBITMAPFLAGS:
2371 return TOOLBAR_GetBitmapFlags (wndPtr, wParam, lParam);
2373 case TB_GETBUTTON:
2374 return TOOLBAR_GetButton (wndPtr, wParam, lParam);
2376 case TB_GETBUTTONINFO32A:
2377 return TOOLBAR_GetButtonInfo32A (wndPtr, wParam, lParam);
2379 // case TB_GETBUTTONINFO32W: /* 4.71 */
2381 case TB_GETBUTTONSIZE:
2382 return TOOLBAR_GetButtonSize (wndPtr);
2384 case TB_GETBUTTONTEXT32A:
2385 return TOOLBAR_GetButtonText32A (wndPtr, wParam, lParam);
2387 // case TB_GETBUTTONTEXT32W:
2388 // case TB_GETCOLORSCHEME: /* 4.71 */
2390 case TB_GETDISABLEDIMAGELIST:
2391 return TOOLBAR_GetDisabledImageList (wndPtr, wParam, lParam);
2393 case TB_GETEXTENDEDSTYLE:
2394 return TOOLBAR_GetExtendedStyle (wndPtr);
2396 case TB_GETHOTIMAGELIST:
2397 return TOOLBAR_GetHotImageList (wndPtr, wParam, lParam);
2399 // case TB_GETHOTITEM: /* 4.71 */
2401 case TB_GETIMAGELIST:
2402 return TOOLBAR_GetImageList (wndPtr, wParam, lParam);
2404 // case TB_GETINSERTMARK: /* 4.71 */
2405 // case TB_GETINSERTMARKCOLOR: /* 4.71 */
2407 case TB_GETITEMRECT:
2408 return TOOLBAR_GetItemRect (wndPtr, wParam, lParam);
2410 case TB_GETMAXSIZE:
2411 return TOOLBAR_GetMaxSize (wndPtr, wParam, lParam);
2413 // case TB_GETOBJECT: /* 4.71 */
2414 // case TB_GETPADDING: /* 4.71 */
2416 case TB_GETRECT:
2417 return TOOLBAR_GetRect (wndPtr, wParam, lParam);
2419 case TB_GETROWS:
2420 return TOOLBAR_GetRows (wndPtr, wParam, lParam);
2422 case TB_GETSTATE:
2423 return TOOLBAR_GetState (wndPtr, wParam, lParam);
2425 case TB_GETSTYLE:
2426 return TOOLBAR_GetStyle (wndPtr, wParam, lParam);
2428 case TB_GETTEXTROWS:
2429 return TOOLBAR_GetTextRows (wndPtr, wParam, lParam);
2431 case TB_GETTOOLTIPS:
2432 return TOOLBAR_GetToolTips (wndPtr, wParam, lParam);
2434 case TB_GETUNICODEFORMAT:
2435 return TOOLBAR_GetUnicodeFormat (wndPtr, wParam, lParam);
2437 case TB_HIDEBUTTON:
2438 return TOOLBAR_HideButton (wndPtr, wParam, lParam);
2440 case TB_HITTEST:
2441 return TOOLBAR_HitTest (wndPtr, wParam, lParam);
2443 case TB_INDETERMINATE:
2444 return TOOLBAR_Indeterminate (wndPtr, wParam, lParam);
2446 case TB_INSERTBUTTON32A:
2447 return TOOLBAR_InsertButton32A (wndPtr, wParam, lParam);
2449 // case TB_INSERTBUTTON32W:
2450 // case TB_INSERTMARKHITTEST: /* 4.71 */
2452 case TB_ISBUTTONCHECKED:
2453 return TOOLBAR_IsButtonChecked (wndPtr, wParam, lParam);
2455 case TB_ISBUTTONENABLED:
2456 return TOOLBAR_IsButtonEnabled (wndPtr, wParam, lParam);
2458 case TB_ISBUTTONHIDDEN:
2459 return TOOLBAR_IsButtonHidden (wndPtr, wParam, lParam);
2461 case TB_ISBUTTONHIGHLIGHTED:
2462 return TOOLBAR_IsButtonHighlighted (wndPtr, wParam, lParam);
2464 case TB_ISBUTTONINDETERMINATE:
2465 return TOOLBAR_IsButtonIndeterminate (wndPtr, wParam, lParam);
2467 case TB_ISBUTTONPRESSED:
2468 return TOOLBAR_IsButtonPressed (wndPtr, wParam, lParam);
2470 // case TB_LOADIMAGES: /* 4.70 */
2471 // case TB_MAPACCELERATOR32A: /* 4.71 */
2472 // case TB_MAPACCELERATOR32W: /* 4.71 */
2473 // case TB_MARKBUTTON: /* 4.71 */
2474 // case TB_MOVEBUTTON: /* 4.71 */
2476 case TB_PRESSBUTTON:
2477 return TOOLBAR_PressButton (wndPtr, wParam, lParam);
2479 // case TB_REPLACEBITMAP:
2481 case TB_SAVERESTORE32A:
2482 return TOOLBAR_SaveRestore32A (wndPtr, wParam, lParam);
2484 // case TB_SAVERESTORE32W:
2485 // case TB_SETANCHORHIGHLIGHT: /* 4.71 */
2487 case TB_SETBITMAPSIZE:
2488 return TOOLBAR_SetBitmapSize (wndPtr, wParam, lParam);
2490 // case TB_SETBUTTONINFO32A: /* 4.71 */
2491 // case TB_SETBUTTONINFO32W: /* 4.71 */
2493 case TB_SETBUTTONSIZE:
2494 return TOOLBAR_SetButtonSize (wndPtr, wParam, lParam);
2496 case TB_SETBUTTONWIDTH:
2497 return TOOLBAR_SetButtonWidth (wndPtr, wParam, lParam);
2499 case TB_SETCMDID:
2500 return TOOLBAR_SetCmdId (wndPtr, wParam, lParam);
2502 // case TB_SETCOLORSCHEME: /* 4.71 */
2504 case TB_SETDISABLEDIMAGELIST:
2505 return TOOLBAR_SetDisabledImageList (wndPtr, wParam, lParam);
2507 // case TB_SETDRAWTEXTFLAGS: /* 4.71 */
2509 case TB_SETEXTENDEDSTYLE:
2510 return TOOLBAR_SetExtendedStyle (wndPtr, wParam, lParam);
2512 case TB_SETHOTIMAGELIST:
2513 return TOOLBAR_SetHotImageList (wndPtr, wParam, lParam);
2515 // case TB_SETHOTITEM: /* 4.71 */
2517 case TB_SETIMAGELIST:
2518 return TOOLBAR_SetImageList (wndPtr, wParam, lParam);
2520 case TB_SETINDENT:
2521 return TOOLBAR_SetIndent (wndPtr, wParam, lParam);
2523 // case TB_SETINSERTMARK: /* 4.71 */
2525 case TB_SETINSERTMARKCOLOR:
2526 return TOOLBAR_SetInsertMarkColor (wndPtr, wParam, lParam);
2528 case TB_SETMAXTEXTROWS:
2529 return TOOLBAR_SetMaxTextRows (wndPtr, wParam, lParam);
2531 // case TB_SETPADDING: /* 4.71 */
2533 case TB_SETPARENT:
2534 return TOOLBAR_SetParent (wndPtr, wParam, lParam);
2536 case TB_SETROWS:
2537 return TOOLBAR_SetRows (wndPtr, wParam, lParam);
2539 case TB_SETSTATE:
2540 return TOOLBAR_SetState (wndPtr, wParam, lParam);
2542 case TB_SETSTYLE:
2543 return TOOLBAR_SetStyle (wndPtr, wParam, lParam);
2545 case TB_SETTOOLTIPS:
2546 return TOOLBAR_SetToolTips (wndPtr, wParam, lParam);
2548 case TB_SETUNICODEFORMAT:
2549 return TOOLBAR_SetUnicodeFormat (wndPtr, wParam, lParam);
2552 // case WM_CHAR:
2554 case WM_CREATE:
2555 return TOOLBAR_Create (wndPtr, wParam, lParam);
2557 // case WM_COMMAND:
2559 case WM_DESTROY:
2560 return TOOLBAR_Destroy (wndPtr, wParam, lParam);
2562 case WM_ERASEBKGND:
2563 return TOOLBAR_EraseBackground (wndPtr, wParam, lParam);
2565 // case WM_GETFONT:
2566 // case WM_KEYDOWN:
2567 // case WM_KILLFOCUS:
2569 case WM_LBUTTONDBLCLK:
2570 return TOOLBAR_LButtonDblClk (wndPtr, wParam, lParam);
2572 case WM_LBUTTONDOWN:
2573 return TOOLBAR_LButtonDown (wndPtr, wParam, lParam);
2575 case WM_LBUTTONUP:
2576 return TOOLBAR_LButtonUp (wndPtr, wParam, lParam);
2578 case WM_MOUSEMOVE:
2579 return TOOLBAR_MouseMove (wndPtr, wParam, lParam);
2581 // case WM_NCACTIVATE:
2582 // return TOOLBAR_NCActivate (wndPtr, wParam, lParam);
2584 case WM_NCCALCSIZE:
2585 return TOOLBAR_NCCalcSize (wndPtr, wParam, lParam);
2587 case WM_NCCREATE:
2588 return TOOLBAR_NCCreate (wndPtr, wParam, lParam);
2590 case WM_NCPAINT:
2591 return TOOLBAR_NCPaint (wndPtr, wParam, lParam);
2593 case WM_NOTIFY:
2594 return TOOLBAR_Notify (wndPtr, wParam, lParam);
2596 // case WM_NOTIFYFORMAT:
2598 case WM_PAINT:
2599 return TOOLBAR_Paint (wndPtr, wParam);
2601 case WM_SIZE:
2602 return TOOLBAR_Size (wndPtr, wParam, lParam);
2604 // case WM_SYSCOLORCHANGE:
2606 // case WM_WININICHANGE:
2608 case WM_CHARTOITEM:
2609 case WM_COMMAND:
2610 case WM_DRAWITEM:
2611 case WM_MEASUREITEM:
2612 case WM_VKEYTOITEM:
2613 return SendMessage32A (GetParent32 (hwnd), uMsg, wParam, lParam);
2615 default:
2616 if (uMsg >= WM_USER)
2617 ERR (toolbar, "unknown msg %04x wp=%08x lp=%08lx\n",
2618 uMsg, wParam, lParam);
2619 return DefWindowProc32A (hwnd, uMsg, wParam, lParam);
2621 return 0;
2625 void TOOLBAR_Register (void)
2627 WNDCLASS32A wndClass;
2629 if (GlobalFindAtom32A (TOOLBARCLASSNAME32A)) return;
2631 ZeroMemory (&wndClass, sizeof(WNDCLASS32A));
2632 wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS;
2633 wndClass.lpfnWndProc = (WNDPROC32)ToolbarWindowProc;
2634 wndClass.cbClsExtra = 0;
2635 wndClass.cbWndExtra = sizeof(TOOLBAR_INFO *);
2636 wndClass.hCursor = LoadCursor32A (0, IDC_ARROW32A);
2637 wndClass.hbrBackground = (HBRUSH32)(COLOR_3DFACE + 1);
2638 wndClass.lpszClassName = TOOLBARCLASSNAME32A;
2640 RegisterClass32A (&wndClass);