Converted to the new debugging interface (done with the help of the
[wine] / dlls / comctl32 / rebar.c
1 /*
2  * Rebar control
3  *
4  * Copyright 1998, 1999 Eric Kohl
5  *
6  * NOTES
7  *   An author is needed! Any volunteers?
8  *   I will only improve this control once in a while.
9  *     Eric <ekohl@abo.rhein-zeitung.de>
10  *
11  * TODO:
12  *   - vertical placement
13  *   - ComboBox and ComboBoxEx placement
14  *   - center image 
15  *   - Layout code.
16  *   - Display code.
17  *   - Some messages.
18  *   - All notifications.
19  */
20
21 #include <string.h>
22
23 #include "winbase.h"
24 #include "commctrl.h"
25 #include "rebar.h"
26 #include "sysmetrics.h"
27 #include "debug.h"
28
29 DEFAULT_DEBUG_CHANNEL(rebar)
30
31
32 /* fDraw flags */
33 #define DRAW_GRIPPER    1
34 #define DRAW_IMAGE      2
35 #define DRAW_TEXT       4
36 #define DRAW_CHILD      8
37
38 #define GRIPPER_WIDTH   13
39
40
41 #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongA (hwnd, 0))
42
43
44 static VOID
45 REBAR_DrawBand (HDC hdc, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
46 {
47
48     DrawEdge (hdc, &lpBand->rcBand, BDR_RAISEDINNER, BF_MIDDLE);
49
50     /* draw background */
51
52     /* draw gripper */
53     if (lpBand->fDraw & DRAW_GRIPPER)
54         DrawEdge (hdc, &lpBand->rcGripper, BDR_RAISEDINNER, BF_RECT | BF_MIDDLE);
55
56     /* draw caption image */
57     if (lpBand->fDraw & DRAW_IMAGE) {
58         /* FIXME: center image */
59         POINT pt;
60
61         pt.y = (lpBand->rcCapImage.bottom + lpBand->rcCapImage.top - infoPtr->imageSize.cy)/2;
62         pt.x = (lpBand->rcCapImage.right + lpBand->rcCapImage.left - infoPtr->imageSize.cx)/2;
63
64         ImageList_Draw (infoPtr->himl, lpBand->iImage, hdc,
65 /*                      lpBand->rcCapImage.left, lpBand->rcCapImage.top, */
66                         pt.x, pt.y,
67                         ILD_TRANSPARENT);
68     }
69
70     /* draw caption text */
71     if (lpBand->fDraw & DRAW_TEXT) {
72         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
73         INT oldBkMode = SetBkMode (hdc, TRANSPARENT);
74         DrawTextW (hdc, lpBand->lpText, -1, &lpBand->rcCapText,
75                      DT_CENTER | DT_VCENTER | DT_SINGLELINE);
76         if (oldBkMode != TRANSPARENT)
77             SetBkMode (hdc, oldBkMode);
78         SelectObject (hdc, hOldFont);
79     }
80 }
81
82
83 static VOID
84 REBAR_Refresh (HWND hwnd, HDC hdc)
85 {
86     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
87     REBAR_BAND *lpBand;
88     UINT i;
89
90     for (i = 0; i < infoPtr->uNumBands; i++) {
91         lpBand = &infoPtr->bands[i];
92
93         if ((lpBand->fStyle & RBBS_HIDDEN) || 
94             ((GetWindowLongA (hwnd, GWL_STYLE) & CCS_VERT) &&
95              (lpBand->fStyle & RBBS_NOVERT)))
96             continue;
97
98         REBAR_DrawBand (hdc, infoPtr, lpBand);
99
100     }
101 }
102
103
104 static VOID
105 REBAR_CalcHorzBand (REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
106 {
107     lpBand->fDraw = 0;
108
109     /* set initial caption image rectangle */
110     SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
111
112     /* image is visible */
113     if ((lpBand->iImage > -1) && (infoPtr->himl)) {
114         lpBand->fDraw |= DRAW_IMAGE;
115
116         lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
117         lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
118
119         /* update band height */
120         if (lpBand->uMinHeight < infoPtr->imageSize.cy + 2) {
121             lpBand->uMinHeight = infoPtr->imageSize.cy + 2;
122             lpBand->rcBand.bottom = lpBand->rcBand.top + lpBand->uMinHeight;
123         }
124     }
125
126     /* set initial caption text rectangle */
127     lpBand->rcCapText.left   = lpBand->rcCapImage.right;
128     lpBand->rcCapText.top    = lpBand->rcBand.top + 1;
129     lpBand->rcCapText.right  = lpBand->rcCapText.left;
130     lpBand->rcCapText.bottom = lpBand->rcBand.bottom - 1;
131
132     /* text is visible */
133     if (lpBand->lpText) {
134         HDC hdc = GetDC (0);
135         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
136         SIZE size;
137
138         lpBand->fDraw |= DRAW_TEXT;
139         GetTextExtentPoint32W (hdc, lpBand->lpText,
140                                lstrlenW (lpBand->lpText), &size);
141         lpBand->rcCapText.right += size.cx;
142
143         SelectObject (hdc, hOldFont);
144         ReleaseDC (0, hdc);
145     }
146
147     /* set initial child window rectangle */
148     if (lpBand->fStyle & RBBS_FIXEDSIZE) {
149         lpBand->rcChild.left   = lpBand->rcCapText.right;
150         lpBand->rcChild.top    = lpBand->rcBand.top;
151         lpBand->rcChild.right  = lpBand->rcBand.right;
152         lpBand->rcChild.bottom = lpBand->rcBand.bottom;
153     }
154     else {
155         lpBand->rcChild.left   = lpBand->rcCapText.right + 4;
156         lpBand->rcChild.top    = lpBand->rcBand.top + 2;
157         lpBand->rcChild.right  = lpBand->rcBand.right - 4;
158         lpBand->rcChild.bottom = lpBand->rcBand.bottom - 2;
159     }
160
161     /* calculate gripper rectangle */
162     if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
163         (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
164         ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || 
165          (infoPtr->uNumBands > 1))) {
166         lpBand->fDraw |= DRAW_GRIPPER;
167         lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
168         lpBand->rcGripper.right  = lpBand->rcGripper.left + 3;
169         lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
170         lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
171
172         /* move caption rectangles */
173         OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
174         OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
175
176         /* adjust child rectangle */
177         lpBand->rcChild.left += GRIPPER_WIDTH;
178     }
179
180
181 }
182
183
184 static VOID
185 REBAR_CalcVertBand (HWND hwnd, REBAR_INFO *infoPtr, REBAR_BAND *lpBand)
186 {
187     lpBand->fDraw = 0;
188
189     /* set initial caption image rectangle */
190     SetRect (&lpBand->rcCapImage, 0, 0, 0, 0);
191
192     /* image is visible */
193     if ((lpBand->iImage > -1) && (infoPtr->himl)) {
194         lpBand->fDraw |= DRAW_IMAGE;
195
196         lpBand->rcCapImage.right  = lpBand->rcCapImage.left + infoPtr->imageSize.cx;
197         lpBand->rcCapImage.bottom = lpBand->rcCapImage.top + infoPtr->imageSize.cy;
198
199         /* update band width */
200         if (lpBand->uMinHeight < infoPtr->imageSize.cx + 2) {
201             lpBand->uMinHeight = infoPtr->imageSize.cx + 2;
202             lpBand->rcBand.right = lpBand->rcBand.left + lpBand->uMinHeight;
203         }
204     }
205
206     /* set initial caption text rectangle */
207     lpBand->rcCapText.left   = lpBand->rcBand.left + 1;
208     lpBand->rcCapText.top    = lpBand->rcCapImage.bottom;
209     lpBand->rcCapText.right  = lpBand->rcBand.right - 1;
210     lpBand->rcCapText.bottom = lpBand->rcCapText.top;
211
212     /* text is visible */
213     if (lpBand->lpText) {
214         HDC hdc = GetDC (0);
215         HFONT hOldFont = SelectObject (hdc, infoPtr->hFont);
216         SIZE size;
217
218         lpBand->fDraw |= DRAW_TEXT;
219         GetTextExtentPoint32W (hdc, lpBand->lpText,
220                                lstrlenW (lpBand->lpText), &size);
221 /*      lpBand->rcCapText.right += size.cx; */
222         lpBand->rcCapText.bottom += size.cy;
223
224         SelectObject (hdc, hOldFont);
225         ReleaseDC (0, hdc);
226     }
227
228     /* set initial child window rectangle */
229     if (lpBand->fStyle & RBBS_FIXEDSIZE) {
230         lpBand->rcChild.left   = lpBand->rcBand.left;
231         lpBand->rcChild.top    = lpBand->rcCapText.bottom;
232         lpBand->rcChild.right  = lpBand->rcBand.right;
233         lpBand->rcChild.bottom = lpBand->rcBand.bottom;
234     }
235     else {
236         lpBand->rcChild.left   = lpBand->rcBand.left + 2;
237         lpBand->rcChild.top    = lpBand->rcCapText.bottom + 4;
238         lpBand->rcChild.right  = lpBand->rcBand.right - 2;
239         lpBand->rcChild.bottom = lpBand->rcBand.bottom - 4;
240     }
241
242     /* calculate gripper rectangle */
243     if ((!(lpBand->fStyle & RBBS_NOGRIPPER)) &&
244         (!(lpBand->fStyle & RBBS_FIXEDSIZE)) &&
245         ((lpBand->fStyle & RBBS_GRIPPERALWAYS) || 
246          (infoPtr->uNumBands > 1))) {
247         lpBand->fDraw |= DRAW_GRIPPER;
248
249         if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_VERTICALGRIPPER) {
250             /* adjust band width */
251             lpBand->rcBand.right += GRIPPER_WIDTH;
252             lpBand->uMinHeight += GRIPPER_WIDTH;
253
254             lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
255             lpBand->rcGripper.right  = lpBand->rcGripper.left + 3;
256             lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
257             lpBand->rcGripper.bottom = lpBand->rcBand.bottom - 3;
258
259             /* move caption rectangles */
260             OffsetRect (&lpBand->rcCapImage, GRIPPER_WIDTH, 0);
261             OffsetRect (&lpBand->rcCapText, GRIPPER_WIDTH, 0);
262  
263             /* adjust child rectangle */
264             lpBand->rcChild.left += GRIPPER_WIDTH;
265         }
266         else {
267             lpBand->rcGripper.left   = lpBand->rcBand.left + 3;
268             lpBand->rcGripper.right  = lpBand->rcBand.right - 3;
269             lpBand->rcGripper.top    = lpBand->rcBand.top + 3;
270             lpBand->rcGripper.bottom = lpBand->rcGripper.top + 3;
271
272             /* move caption rectangles */
273             OffsetRect (&lpBand->rcCapImage, 0, GRIPPER_WIDTH);
274             OffsetRect (&lpBand->rcCapText, 0, GRIPPER_WIDTH);
275  
276             /* adjust child rectangle */
277             lpBand->rcChild.top += GRIPPER_WIDTH;
278         }
279     }
280 }
281
282
283 static VOID
284 REBAR_Layout (HWND hwnd, LPRECT lpRect)
285 {
286     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
287     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
288     REBAR_BAND *lpBand;
289     RECT rcClient;
290     INT x, y, cx, cy;
291     UINT i;
292
293     if (lpRect)
294         rcClient = *lpRect;
295     else
296         GetClientRect (hwnd, &rcClient);
297
298     x = 0;
299     y = 0;
300
301     if (dwStyle & CCS_VERT) {
302         cx = 20;    /* FIXME: fixed height */
303         cy = rcClient.bottom - rcClient.top;
304     }
305     else {
306         cx = rcClient.right - rcClient.left;
307         cy = 20;    /* FIXME: fixed height */
308     }
309
310     for (i = 0; i < infoPtr->uNumBands; i++) {
311         lpBand = &infoPtr->bands[i];
312
313         if ((lpBand->fStyle & RBBS_HIDDEN) || 
314             ((dwStyle & CCS_VERT) && (lpBand->fStyle & RBBS_NOVERT)))
315             continue;
316
317
318         if (dwStyle & CCS_VERT) {
319             if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
320                 cx = lpBand->cyMaxChild;
321             else if (lpBand->fStyle & RBBIM_CHILDSIZE)
322                 cx = lpBand->cyMinChild;
323             else
324                 cx = 20; /* FIXME */
325
326             lpBand->rcBand.left   = x;
327             lpBand->rcBand.right  = x + cx;
328             lpBand->rcBand.top    = y;
329             lpBand->rcBand.bottom = y + cy;
330             lpBand->uMinHeight = cx;
331         }
332         else {
333             if (lpBand->fStyle & RBBS_VARIABLEHEIGHT)
334                 cy = lpBand->cyMaxChild;
335             else if (lpBand->fStyle & RBBIM_CHILDSIZE)
336                 cy = lpBand->cyMinChild;
337             else
338                 cy = 20; /* FIXME */
339
340             lpBand->rcBand.left   = x;
341             lpBand->rcBand.right  = x + cx;
342             lpBand->rcBand.top    = y;
343             lpBand->rcBand.bottom = y + cy;
344             lpBand->uMinHeight = cy;
345         }
346
347         if (dwStyle & CCS_VERT) {
348             REBAR_CalcVertBand (hwnd, infoPtr, lpBand);
349             x += lpBand->uMinHeight;
350         }
351         else {
352             REBAR_CalcHorzBand (infoPtr, lpBand);
353             y += lpBand->uMinHeight;
354         }
355     }
356
357     if (dwStyle & CCS_VERT) {
358         infoPtr->calcSize.cx = x;
359         infoPtr->calcSize.cy = rcClient.bottom - rcClient.top;
360     }
361     else {
362         infoPtr->calcSize.cx = rcClient.right - rcClient.left;
363         infoPtr->calcSize.cy = y;
364     }
365 }
366
367
368 static VOID
369 REBAR_ForceResize (HWND hwnd)
370 {
371     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
372     RECT rc;
373
374     TRACE (rebar, " to [%d x %d]!\n",
375            infoPtr->calcSize.cx, infoPtr->calcSize.cy);
376
377     infoPtr->bAutoResize = TRUE;
378
379     rc.left = 0;
380     rc.top = 0;
381     rc.right  = infoPtr->calcSize.cx;
382     rc.bottom = infoPtr->calcSize.cy;
383
384     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
385         InflateRect (&rc, sysMetrics[SM_CXEDGE], sysMetrics[SM_CYEDGE]);
386     }
387
388     SetWindowPos (hwnd, 0, 0, 0,
389                     rc.right - rc.left, rc.bottom - rc.top,
390                     SWP_NOMOVE | SWP_NOZORDER | SWP_SHOWWINDOW);
391 }
392
393
394 static VOID
395 REBAR_MoveChildWindows (HWND hwnd)
396 {
397     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
398     REBAR_BAND *lpBand;
399     CHAR szClassName[40];
400     UINT i;
401
402     for (i = 0; i < infoPtr->uNumBands; i++) {
403         lpBand = &infoPtr->bands[i];
404
405         if (lpBand->fStyle & RBBS_HIDDEN)
406             continue;
407         if (lpBand->hwndChild) {
408             TRACE (rebar, "hwndChild = %x\n", lpBand->hwndChild);
409
410             GetClassNameA (lpBand->hwndChild, szClassName, 40);
411             if (!lstrcmpA (szClassName, "ComboBox")) {
412                 INT nEditHeight, yPos;
413                 RECT rc;
414
415                 /* special placement code for combo box */
416
417
418                 /* get size of edit line */
419                 GetWindowRect (lpBand->hwndChild, &rc);
420                 nEditHeight = rc.bottom - rc.top;
421                 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
422
423                 /* center combo box inside child area */
424                 SetWindowPos (lpBand->hwndChild, HWND_TOP,
425                             lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
426                             lpBand->rcChild.right - lpBand->rcChild.left,
427                             nEditHeight,
428                             SWP_SHOWWINDOW);
429             }
430 #if 0
431             else if (!lstrcmpA (szClassName, WC_COMBOBOXEXA)) {
432                 /* special placement code for extended combo box */
433
434
435             }
436 #endif
437             else {
438                 SetWindowPos (lpBand->hwndChild, HWND_TOP,
439                             lpBand->rcChild.left, lpBand->rcChild.top,
440                             lpBand->rcChild.right - lpBand->rcChild.left,
441                             lpBand->rcChild.bottom - lpBand->rcChild.top,
442                             SWP_SHOWWINDOW);
443             }
444         }
445     }
446 }
447
448
449 static void
450 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
451 {
452     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
453     REBAR_BAND *lpBand;
454     RECT rect;
455     INT  iCount;
456
457     GetClientRect (hwnd, &rect);
458
459     *pFlags = RBHT_NOWHERE;
460     if (PtInRect (&rect, *lpPt))
461     {
462         if (infoPtr->uNumBands == 0) {
463             *pFlags = RBHT_NOWHERE;
464             if (pBand)
465                 *pBand = -1;
466             TRACE (rebar, "NOWHERE\n");
467             return;
468         }
469         else {
470             /* somewhere inside */
471             for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
472                 lpBand = &infoPtr->bands[iCount];
473                 if (PtInRect (&lpBand->rcBand, *lpPt)) {
474                     if (pBand)
475                         *pBand = iCount;
476                     if (PtInRect (&lpBand->rcGripper, *lpPt)) {
477                         *pFlags = RBHT_GRABBER;
478                         TRACE (rebar, "ON GRABBER %d\n", iCount);
479                         return;
480                     }
481                     else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
482                         *pFlags = RBHT_CAPTION;
483                         TRACE (rebar, "ON CAPTION %d\n", iCount);
484                         return;
485                     }
486                     else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
487                         *pFlags = RBHT_CAPTION;
488                         TRACE (rebar, "ON CAPTION %d\n", iCount);
489                         return;
490                     }
491                     else if (PtInRect (&lpBand->rcChild, *lpPt)) {
492                         *pFlags = RBHT_CLIENT;
493                         TRACE (rebar, "ON CLIENT %d\n", iCount);
494                         return;
495                     }
496                     else {
497                         *pFlags = RBHT_NOWHERE;
498                         TRACE (rebar, "NOWHERE %d\n", iCount);
499                         return;
500                     }
501                 }
502             }
503
504             *pFlags = RBHT_NOWHERE;
505             if (pBand)
506                 *pBand = -1;
507
508             TRACE (rebar, "NOWHERE\n");
509             return;
510         }
511     }
512     else {
513         *pFlags = RBHT_NOWHERE;
514         if (pBand)
515             *pBand = -1;
516         TRACE (rebar, "NOWHERE\n");
517         return;
518     }
519
520     TRACE (rebar, "flags=0x%X\n", *pFlags);
521     return;
522 }
523
524
525
526 /* << REBAR_BeginDrag >> */
527
528
529 static LRESULT
530 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
531 {
532     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
533     UINT uBand = (UINT)wParam;
534
535     if (uBand >= infoPtr->uNumBands)
536         return FALSE;
537
538     TRACE (rebar, "deleting band %u!\n", uBand);
539
540     if (infoPtr->uNumBands == 1) {
541         TRACE (rebar, " simple delete!\n");
542         COMCTL32_Free (infoPtr->bands);
543         infoPtr->bands = NULL;
544         infoPtr->uNumBands = 0;
545     }
546     else {
547         REBAR_BAND *oldBands = infoPtr->bands;
548         TRACE(rebar, "complex delete! [uBand=%u]\n", uBand);
549
550         infoPtr->uNumBands--;
551         infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
552         if (uBand > 0) {
553             memcpy (&infoPtr->bands[0], &oldBands[0],
554                     uBand * sizeof(REBAR_BAND));
555         }
556
557         if (uBand < infoPtr->uNumBands) {
558             memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
559                     (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
560         }
561
562         COMCTL32_Free (oldBands);
563     }
564
565     REBAR_Layout (hwnd, NULL);
566     REBAR_ForceResize (hwnd);
567     REBAR_MoveChildWindows (hwnd);
568
569     return TRUE;
570 }
571
572
573 /* << REBAR_DragMove >> */
574 /* << REBAR_EndDrag >> */
575
576
577 static LRESULT
578 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
579 {
580     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
581     /* LPRECT32 lpRect = (LPRECT32)lParam; */
582     REBAR_BAND *lpBand;
583
584     if (!lParam)
585         return 0;
586     if ((UINT)wParam >= infoPtr->uNumBands)
587         return 0;
588
589     lpBand = &infoPtr->bands[(UINT)wParam];
590     if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
591
592     }
593     else {
594
595     }
596
597     return 0;
598 }
599
600
601 __inline__ static LRESULT
602 REBAR_GetBandCount (HWND hwnd)
603 {
604     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
605
606     TRACE (rebar, "band count %u!\n", infoPtr->uNumBands);
607
608     return infoPtr->uNumBands;
609 }
610
611
612 static LRESULT
613 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
614 {
615     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
616     LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
617     REBAR_BAND *lpBand;
618
619     if (lprbbi == NULL)
620         return FALSE;
621     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
622         return FALSE;
623     if ((UINT)wParam >= infoPtr->uNumBands)
624         return FALSE;
625
626     TRACE (rebar, "index %u\n", (UINT)wParam);
627
628     /* copy band information */
629     lpBand = &infoPtr->bands[(UINT)wParam];
630
631     if (lprbbi->fMask & RBBIM_STYLE)
632         lprbbi->fStyle = lpBand->fStyle;
633
634     if (lprbbi->fMask & RBBIM_COLORS) {
635         lprbbi->clrFore = lpBand->clrFore;
636         lprbbi->clrBack = lpBand->clrBack;
637     }
638
639     if ((lprbbi->fMask & RBBIM_TEXT) && 
640         (lprbbi->lpText) && (lpBand->lpText)) {
641             lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
642     }
643
644     if (lprbbi->fMask & RBBIM_IMAGE)
645         lprbbi->iImage = lpBand->iImage;
646
647     if (lprbbi->fMask & RBBIM_CHILD)
648         lprbbi->hwndChild = lpBand->hwndChild;
649
650     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
651         lprbbi->cxMinChild = lpBand->cxMinChild;
652         lprbbi->cyMinChild = lpBand->cyMinChild;
653         lprbbi->cyMaxChild = lpBand->cyMaxChild;
654         lprbbi->cyChild    = lpBand->cyChild;
655         lprbbi->cyIntegral = lpBand->cyIntegral;
656     }
657
658     if (lprbbi->fMask & RBBIM_SIZE)
659         lprbbi->cx = lpBand->cx;
660
661     if (lprbbi->fMask & RBBIM_BACKGROUND)
662         lprbbi->hbmBack = lpBand->hbmBack;
663
664     if (lprbbi->fMask & RBBIM_ID)
665         lprbbi->wID = lpBand->wID;
666
667     /* check for additional data */
668     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
669         if (lprbbi->fMask & RBBIM_IDEALSIZE)
670             lprbbi->cxIdeal = lpBand->cxIdeal;
671
672         if (lprbbi->fMask & RBBIM_LPARAM)
673             lprbbi->lParam = lpBand->lParam;
674
675         if (lprbbi->fMask & RBBIM_HEADERSIZE)
676             lprbbi->cxHeader = lpBand->cxHeader;
677     }
678
679     return TRUE;
680 }
681
682
683 static LRESULT
684 REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
685 {
686     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
687     LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
688     REBAR_BAND *lpBand;
689
690     if (lprbbi == NULL)
691         return FALSE;
692     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
693         return FALSE;
694     if ((UINT)wParam >= infoPtr->uNumBands)
695         return FALSE;
696
697     TRACE (rebar, "index %u\n", (UINT)wParam);
698
699     /* copy band information */
700     lpBand = &infoPtr->bands[(UINT)wParam];
701
702     if (lprbbi->fMask & RBBIM_STYLE)
703         lprbbi->fStyle = lpBand->fStyle;
704
705     if (lprbbi->fMask & RBBIM_COLORS) {
706         lprbbi->clrFore = lpBand->clrFore;
707         lprbbi->clrBack = lpBand->clrBack;
708     }
709
710     if ((lprbbi->fMask & RBBIM_TEXT) && 
711         (lprbbi->lpText) && (lpBand->lpText)) {
712             lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
713     }
714
715     if (lprbbi->fMask & RBBIM_IMAGE)
716         lprbbi->iImage = lpBand->iImage;
717
718     if (lprbbi->fMask & RBBIM_CHILD)
719         lprbbi->hwndChild = lpBand->hwndChild;
720
721     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
722         lprbbi->cxMinChild = lpBand->cxMinChild;
723         lprbbi->cyMinChild = lpBand->cyMinChild;
724         lprbbi->cyMaxChild = lpBand->cyMaxChild;
725         lprbbi->cyChild    = lpBand->cyChild;
726         lprbbi->cyIntegral = lpBand->cyIntegral;
727     }
728
729     if (lprbbi->fMask & RBBIM_SIZE)
730         lprbbi->cx = lpBand->cx;
731
732     if (lprbbi->fMask & RBBIM_BACKGROUND)
733         lprbbi->hbmBack = lpBand->hbmBack;
734
735     if (lprbbi->fMask & RBBIM_ID)
736         lprbbi->wID = lpBand->wID;
737
738     /* check for additional data */
739     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
740         if (lprbbi->fMask & RBBIM_IDEALSIZE)
741             lprbbi->cxIdeal = lpBand->cxIdeal;
742
743         if (lprbbi->fMask & RBBIM_LPARAM)
744             lprbbi->lParam = lpBand->lParam;
745
746         if (lprbbi->fMask & RBBIM_HEADERSIZE)
747             lprbbi->cxHeader = lpBand->cxHeader;
748     }
749
750     return TRUE;
751 }
752
753
754 static LRESULT
755 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
756 {
757     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
758     INT nHeight;
759
760     REBAR_Layout (hwnd, NULL);
761     nHeight = infoPtr->calcSize.cy;
762
763     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
764         nHeight += (2 * sysMetrics[SM_CYEDGE]);
765
766     FIXME (rebar, "height = %d\n", nHeight);
767
768     return nHeight;
769 }
770
771
772 static LRESULT
773 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
774 {
775     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
776     LPREBARINFO lpInfo = (LPREBARINFO)lParam;
777
778     if (lpInfo == NULL)
779         return FALSE;
780
781     if (lpInfo->cbSize < sizeof (REBARINFO))
782         return FALSE;
783
784     TRACE (rebar, "getting bar info!\n");
785
786     if (infoPtr->himl) {
787         lpInfo->himl = infoPtr->himl;
788         lpInfo->fMask |= RBIM_IMAGELIST;
789     }
790
791     return TRUE;
792 }
793
794
795 __inline__ static LRESULT
796 REBAR_GetBkColor (HWND hwnd)
797 {
798     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
799
800     TRACE (rebar, "background color 0x%06lx!\n", infoPtr->clrBk);
801
802     return infoPtr->clrBk;
803 }
804
805
806 /* << REBAR_GetColorScheme >> */
807 /* << REBAR_GetDropTarget >> */
808
809
810 static LRESULT
811 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
812 {
813     FIXME (rebar, "empty stub!\n");
814
815     return 0;
816 }
817
818
819 static LRESULT
820 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
821 {
822     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
823     INT iBand = (INT)wParam;
824     LPRECT lprc = (LPRECT)lParam;
825     REBAR_BAND *lpBand;
826
827     if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
828         return FALSE;
829     if (!lprc)
830         return FALSE;
831
832     TRACE (rebar, "band %d\n", iBand);
833
834     lpBand = &infoPtr->bands[iBand];
835     CopyRect (lprc, &lpBand->rcBand);
836 /*
837     lprc->left   = lpBand->rcBand.left;
838     lprc->top    = lpBand->rcBand.top;
839     lprc->right  = lpBand->rcBand.right;
840     lprc->bottom = lpBand->rcBand.bottom;
841 */
842
843     return TRUE;
844 }
845
846
847 __inline__ static LRESULT
848 REBAR_GetRowCount (HWND hwnd)
849 {
850     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
851
852     FIXME (rebar, "%u : semi stub!\n", infoPtr->uNumBands);
853
854     return infoPtr->uNumBands;
855 }
856
857
858 static LRESULT
859 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
860 {
861 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
862
863     FIXME (rebar, "-- height = 20: semi stub!\n");
864
865     return 20;
866 }
867
868
869 __inline__ static LRESULT
870 REBAR_GetTextColor (HWND hwnd)
871 {
872     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
873
874     TRACE (rebar, "text color 0x%06lx!\n", infoPtr->clrText);
875
876     return infoPtr->clrText;
877 }
878
879
880 __inline__ static LRESULT
881 REBAR_GetToolTips (HWND hwnd)
882 {
883     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
884     return infoPtr->hwndToolTip;
885 }
886
887
888 __inline__ static LRESULT
889 REBAR_GetUnicodeFormat (HWND hwnd)
890 {
891     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
892     return infoPtr->bUnicode;
893 }
894
895
896 static LRESULT
897 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
898 {
899     /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
900     LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 
901
902     if (!lprbht)
903         return -1;
904
905     REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
906
907     return lprbht->iBand;
908 }
909
910
911 static LRESULT
912 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
913 {
914     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
915     UINT i;
916
917     if (infoPtr == NULL)
918         return -1;
919
920     if (infoPtr->uNumBands < 1)
921         return -1;
922
923     TRACE (rebar, "id %u\n", (UINT)wParam);
924
925     for (i = 0; i < infoPtr->uNumBands; i++) {
926         if (infoPtr->bands[i].wID == (UINT)wParam) {
927             TRACE (rebar, "band %u found!\n", i);
928             return i;
929         }
930     }
931
932     TRACE (rebar, "no band found!\n");
933     return -1;
934 }
935
936
937 static LRESULT
938 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
939 {
940     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
941     LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
942     UINT uIndex = (UINT)wParam;
943     REBAR_BAND *lpBand;
944
945     if (infoPtr == NULL)
946         return FALSE;
947     if (lprbbi == NULL)
948         return FALSE;
949     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
950         return FALSE;
951
952     TRACE (rebar, "insert band at %u!\n", uIndex);
953
954     if (infoPtr->uNumBands == 0) {
955         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
956         uIndex = 0;
957     }
958     else {
959         REBAR_BAND *oldBands = infoPtr->bands;
960         infoPtr->bands =
961             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
962         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
963             uIndex = infoPtr->uNumBands;
964
965         /* pre insert copy */
966         if (uIndex > 0) {
967             memcpy (&infoPtr->bands[0], &oldBands[0],
968                     uIndex * sizeof(REBAR_BAND));
969         }
970
971         /* post copy */
972         if (uIndex < infoPtr->uNumBands - 1) {
973             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
974                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
975         }
976
977         COMCTL32_Free (oldBands);
978     }
979
980     infoPtr->uNumBands++;
981
982     TRACE (rebar, "index %u!\n", uIndex);
983
984     /* initialize band (infoPtr->bands[uIndex])*/
985     lpBand = &infoPtr->bands[uIndex];
986
987     if (lprbbi->fMask & RBBIM_STYLE)
988         lpBand->fStyle = lprbbi->fStyle;
989
990     if (lprbbi->fMask & RBBIM_COLORS) {
991         lpBand->clrFore = lprbbi->clrFore;
992         lpBand->clrBack = lprbbi->clrBack;
993     }
994     else {
995         lpBand->clrFore = CLR_NONE;
996         lpBand->clrBack = CLR_NONE;
997     }
998
999     if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1000         INT len = lstrlenA (lprbbi->lpText);
1001         if (len > 0) {
1002             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1003             lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1004         }
1005     }
1006
1007     if (lprbbi->fMask & RBBIM_IMAGE)
1008         lpBand->iImage = lprbbi->iImage;
1009     else
1010         lpBand->iImage = -1;
1011
1012     if (lprbbi->fMask & RBBIM_CHILD) {
1013         TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
1014         lpBand->hwndChild = lprbbi->hwndChild;
1015         lpBand->hwndPrevParent =
1016             SetParent (lpBand->hwndChild, hwnd);
1017     }
1018
1019     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1020         lpBand->cxMinChild = lprbbi->cxMinChild;
1021         lpBand->cyMinChild = lprbbi->cyMinChild;
1022         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1023         lpBand->cyChild    = lprbbi->cyChild;
1024         lpBand->cyIntegral = lprbbi->cyIntegral;
1025     }
1026     else {
1027         lpBand->cxMinChild = -1;
1028         lpBand->cyMinChild = -1;
1029         lpBand->cyMaxChild = -1;
1030         lpBand->cyChild    = -1;
1031         lpBand->cyIntegral = -1;
1032     }
1033
1034     if (lprbbi->fMask & RBBIM_SIZE)
1035         lpBand->cx = lprbbi->cx;
1036     else
1037         lpBand->cx = -1;
1038
1039     if (lprbbi->fMask & RBBIM_BACKGROUND)
1040         lpBand->hbmBack = lprbbi->hbmBack;
1041
1042     if (lprbbi->fMask & RBBIM_ID)
1043         lpBand->wID = lprbbi->wID;
1044
1045     /* check for additional data */
1046     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1047         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1048             lpBand->cxIdeal = lprbbi->cxIdeal;
1049
1050         if (lprbbi->fMask & RBBIM_LPARAM)
1051             lpBand->lParam = lprbbi->lParam;
1052
1053         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1054             lpBand->cxHeader = lprbbi->cxHeader;
1055     }
1056
1057
1058     REBAR_Layout (hwnd, NULL);
1059     REBAR_ForceResize (hwnd);
1060     REBAR_MoveChildWindows (hwnd);
1061
1062     return TRUE;
1063 }
1064
1065
1066 static LRESULT
1067 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1068 {
1069     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1070     LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1071     UINT uIndex = (UINT)wParam;
1072     REBAR_BAND *lpBand;
1073
1074     if (infoPtr == NULL)
1075         return FALSE;
1076     if (lprbbi == NULL)
1077         return FALSE;
1078     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1079         return FALSE;
1080
1081     TRACE (rebar, "insert band at %u!\n", uIndex);
1082
1083     if (infoPtr->uNumBands == 0) {
1084         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1085         uIndex = 0;
1086     }
1087     else {
1088         REBAR_BAND *oldBands = infoPtr->bands;
1089         infoPtr->bands =
1090             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1091         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1092             uIndex = infoPtr->uNumBands;
1093
1094         /* pre insert copy */
1095         if (uIndex > 0) {
1096             memcpy (&infoPtr->bands[0], &oldBands[0],
1097                     uIndex * sizeof(REBAR_BAND));
1098         }
1099
1100         /* post copy */
1101         if (uIndex < infoPtr->uNumBands - 1) {
1102             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1103                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1104         }
1105
1106         COMCTL32_Free (oldBands);
1107     }
1108
1109     infoPtr->uNumBands++;
1110
1111     TRACE (rebar, "index %u!\n", uIndex);
1112
1113     /* initialize band (infoPtr->bands[uIndex])*/
1114     lpBand = &infoPtr->bands[uIndex];
1115
1116     if (lprbbi->fMask & RBBIM_STYLE)
1117         lpBand->fStyle = lprbbi->fStyle;
1118
1119     if (lprbbi->fMask & RBBIM_COLORS) {
1120         lpBand->clrFore = lprbbi->clrFore;
1121         lpBand->clrBack = lprbbi->clrBack;
1122     }
1123     else {
1124         lpBand->clrFore = CLR_NONE;
1125         lpBand->clrBack = CLR_NONE;
1126     }
1127
1128     if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1129         INT len = lstrlenW (lprbbi->lpText);
1130         if (len > 0) {
1131             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1132             lstrcpyW (lpBand->lpText, lprbbi->lpText);
1133         }
1134     }
1135
1136     if (lprbbi->fMask & RBBIM_IMAGE)
1137         lpBand->iImage = lprbbi->iImage;
1138     else
1139         lpBand->iImage = -1;
1140
1141     if (lprbbi->fMask & RBBIM_CHILD) {
1142         TRACE (rebar, "hwndChild = %x\n", lprbbi->hwndChild);
1143         lpBand->hwndChild = lprbbi->hwndChild;
1144         lpBand->hwndPrevParent =
1145             SetParent (lpBand->hwndChild, hwnd);
1146     }
1147
1148     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1149         lpBand->cxMinChild = lprbbi->cxMinChild;
1150         lpBand->cyMinChild = lprbbi->cyMinChild;
1151         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1152         lpBand->cyChild    = lprbbi->cyChild;
1153         lpBand->cyIntegral = lprbbi->cyIntegral;
1154     }
1155     else {
1156         lpBand->cxMinChild = -1;
1157         lpBand->cyMinChild = -1;
1158         lpBand->cyMaxChild = -1;
1159         lpBand->cyChild    = -1;
1160         lpBand->cyIntegral = -1;
1161     }
1162
1163     if (lprbbi->fMask & RBBIM_SIZE)
1164         lpBand->cx = lprbbi->cx;
1165     else
1166         lpBand->cx = -1;
1167
1168     if (lprbbi->fMask & RBBIM_BACKGROUND)
1169         lpBand->hbmBack = lprbbi->hbmBack;
1170
1171     if (lprbbi->fMask & RBBIM_ID)
1172         lpBand->wID = lprbbi->wID;
1173
1174     /* check for additional data */
1175     if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1176         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1177             lpBand->cxIdeal = lprbbi->cxIdeal;
1178
1179         if (lprbbi->fMask & RBBIM_LPARAM)
1180             lpBand->lParam = lprbbi->lParam;
1181
1182         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1183             lpBand->cxHeader = lprbbi->cxHeader;
1184     }
1185
1186
1187     REBAR_Layout (hwnd, NULL);
1188     REBAR_ForceResize (hwnd);
1189     REBAR_MoveChildWindows (hwnd);
1190
1191     return TRUE;
1192 }
1193
1194
1195 static LRESULT
1196 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1197 {
1198 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1199
1200     FIXME (rebar, "(uBand = %u fIdeal = %s)\n",
1201            (UINT)wParam, lParam ? "TRUE" : "FALSE");
1202
1203  
1204     return 0;
1205 }
1206
1207
1208 static LRESULT
1209 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1210 {
1211 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1212
1213     FIXME (rebar, "(uBand = %u)\n", (UINT)wParam);
1214
1215  
1216     return 0;
1217 }
1218
1219
1220 static LRESULT
1221 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1222 {
1223 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1224
1225     FIXME (rebar, "(iFrom = %u iTof = %u)\n",
1226            (UINT)wParam, (UINT)lParam);
1227
1228  
1229     return FALSE;
1230 }
1231
1232
1233 static LRESULT
1234 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1235 {
1236     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1237     LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1238     REBAR_BAND *lpBand;
1239
1240     if (lprbbi == NULL)
1241         return FALSE;
1242     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1243         return FALSE;
1244     if ((UINT)wParam >= infoPtr->uNumBands)
1245         return FALSE;
1246
1247     TRACE (rebar, "index %u\n", (UINT)wParam);
1248
1249     /* set band information */
1250     lpBand = &infoPtr->bands[(UINT)wParam];
1251
1252     if (lprbbi->fMask & RBBIM_STYLE)
1253         lpBand->fStyle = lprbbi->fStyle;
1254
1255     if (lprbbi->fMask & RBBIM_COLORS) {
1256         lpBand->clrFore = lprbbi->clrFore;
1257         lpBand->clrBack = lprbbi->clrBack;
1258     }
1259
1260     if (lprbbi->fMask & RBBIM_TEXT) {
1261         if (lpBand->lpText) {
1262             COMCTL32_Free (lpBand->lpText);
1263             lpBand->lpText = NULL;
1264         }
1265         if (lprbbi->lpText) {
1266             INT len = lstrlenA (lprbbi->lpText);
1267             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1268             lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1269         }
1270     }
1271
1272     if (lprbbi->fMask & RBBIM_IMAGE)
1273         lpBand->iImage = lprbbi->iImage;
1274
1275     if (lprbbi->fMask & RBBIM_CHILD) {
1276         if (lprbbi->hwndChild) {
1277             lpBand->hwndChild = lprbbi->hwndChild;
1278             lpBand->hwndPrevParent =
1279                 SetParent (lpBand->hwndChild, hwnd);
1280         }
1281         else {
1282             TRACE (rebar, "child: 0x%x  prev parent: 0x%x\n",
1283                    lpBand->hwndChild, lpBand->hwndPrevParent);
1284             lpBand->hwndChild = 0;
1285             lpBand->hwndPrevParent = 0;
1286         }
1287     }
1288
1289     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1290         lpBand->cxMinChild = lprbbi->cxMinChild;
1291         lpBand->cyMinChild = lprbbi->cyMinChild;
1292         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1293         lpBand->cyChild    = lprbbi->cyChild;
1294         lpBand->cyIntegral = lprbbi->cyIntegral;
1295     }
1296
1297     if (lprbbi->fMask & RBBIM_SIZE)
1298         lpBand->cx = lprbbi->cx;
1299
1300     if (lprbbi->fMask & RBBIM_BACKGROUND)
1301         lpBand->hbmBack = lprbbi->hbmBack;
1302
1303     if (lprbbi->fMask & RBBIM_ID)
1304         lpBand->wID = lprbbi->wID;
1305
1306     /* check for additional data */
1307     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1308         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1309             lpBand->cxIdeal = lprbbi->cxIdeal;
1310
1311         if (lprbbi->fMask & RBBIM_LPARAM)
1312             lpBand->lParam = lprbbi->lParam;
1313
1314         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1315             lpBand->cxHeader = lprbbi->cxHeader;
1316     }
1317
1318     REBAR_Layout (hwnd, NULL);
1319     REBAR_ForceResize (hwnd);
1320     REBAR_MoveChildWindows (hwnd);
1321
1322     return TRUE;
1323 }
1324
1325
1326 static LRESULT
1327 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1328 {
1329     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1330     LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1331     REBAR_BAND *lpBand;
1332
1333     if (lprbbi == NULL)
1334         return FALSE;
1335     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1336         return FALSE;
1337     if ((UINT)wParam >= infoPtr->uNumBands)
1338         return FALSE;
1339
1340     TRACE (rebar, "index %u\n", (UINT)wParam);
1341
1342     /* set band information */
1343     lpBand = &infoPtr->bands[(UINT)wParam];
1344
1345     if (lprbbi->fMask & RBBIM_STYLE)
1346         lpBand->fStyle = lprbbi->fStyle;
1347
1348     if (lprbbi->fMask & RBBIM_COLORS) {
1349         lpBand->clrFore = lprbbi->clrFore;
1350         lpBand->clrBack = lprbbi->clrBack;
1351     }
1352
1353     if (lprbbi->fMask & RBBIM_TEXT) {
1354         if (lpBand->lpText) {
1355             COMCTL32_Free (lpBand->lpText);
1356             lpBand->lpText = NULL;
1357         }
1358         if (lprbbi->lpText) {
1359             INT len = lstrlenW (lprbbi->lpText);
1360             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1361             lstrcpyW (lpBand->lpText, lprbbi->lpText);
1362         }
1363     }
1364
1365     if (lprbbi->fMask & RBBIM_IMAGE)
1366         lpBand->iImage = lprbbi->iImage;
1367
1368     if (lprbbi->fMask & RBBIM_CHILD) {
1369         if (lprbbi->hwndChild) {
1370             lpBand->hwndChild = lprbbi->hwndChild;
1371             lpBand->hwndPrevParent =
1372                 SetParent (lpBand->hwndChild, hwnd);
1373         }
1374         else {
1375             TRACE (rebar, "child: 0x%x  prev parent: 0x%x\n",
1376                    lpBand->hwndChild, lpBand->hwndPrevParent);
1377             lpBand->hwndChild = 0;
1378             lpBand->hwndPrevParent = 0;
1379         }
1380     }
1381
1382     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1383         lpBand->cxMinChild = lprbbi->cxMinChild;
1384         lpBand->cyMinChild = lprbbi->cyMinChild;
1385         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1386         lpBand->cyChild    = lprbbi->cyChild;
1387         lpBand->cyIntegral = lprbbi->cyIntegral;
1388     }
1389
1390     if (lprbbi->fMask & RBBIM_SIZE)
1391         lpBand->cx = lprbbi->cx;
1392
1393     if (lprbbi->fMask & RBBIM_BACKGROUND)
1394         lpBand->hbmBack = lprbbi->hbmBack;
1395
1396     if (lprbbi->fMask & RBBIM_ID)
1397         lpBand->wID = lprbbi->wID;
1398
1399     /* check for additional data */
1400     if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1401         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1402             lpBand->cxIdeal = lprbbi->cxIdeal;
1403
1404         if (lprbbi->fMask & RBBIM_LPARAM)
1405             lpBand->lParam = lprbbi->lParam;
1406
1407         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1408             lpBand->cxHeader = lprbbi->cxHeader;
1409     }
1410
1411     REBAR_Layout (hwnd, NULL);
1412     REBAR_ForceResize (hwnd);
1413     REBAR_MoveChildWindows (hwnd);
1414
1415     return TRUE;
1416 }
1417
1418
1419 static LRESULT
1420 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
1421 {
1422     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1423     LPREBARINFO lpInfo = (LPREBARINFO)lParam;
1424
1425     if (lpInfo == NULL)
1426         return FALSE;
1427
1428     if (lpInfo->cbSize < sizeof (REBARINFO))
1429         return FALSE;
1430
1431     TRACE (rebar, "setting bar info!\n");
1432
1433     if (lpInfo->fMask & RBIM_IMAGELIST) {
1434         infoPtr->himl = lpInfo->himl;
1435         if (infoPtr->himl) {
1436             ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
1437                                    &infoPtr->imageSize.cy);
1438         }
1439         else {
1440             infoPtr->imageSize.cx = 0;
1441             infoPtr->imageSize.cy = 0;
1442         }
1443     }
1444
1445     return TRUE;
1446 }
1447
1448
1449 static LRESULT
1450 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1451 {
1452     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1453     COLORREF clrTemp;
1454
1455     clrTemp = infoPtr->clrBk;
1456     infoPtr->clrBk = (COLORREF)lParam;
1457
1458     TRACE (rebar, "background color 0x%06lx!\n", infoPtr->clrBk);
1459
1460     return clrTemp;
1461 }
1462
1463
1464 /* << REBAR_SetColorScheme >> */
1465 /* << REBAR_SetPalette >> */
1466
1467
1468 static LRESULT
1469 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1470 {
1471     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1472     HWND hwndTemp = infoPtr->hwndNotify;
1473
1474     infoPtr->hwndNotify = (HWND)wParam;
1475
1476     return (LRESULT)hwndTemp;
1477 }
1478
1479
1480 static LRESULT
1481 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1482 {
1483     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1484     COLORREF clrTemp;
1485
1486     clrTemp = infoPtr->clrText;
1487     infoPtr->clrText = (COLORREF)lParam;
1488
1489     TRACE (rebar, "text color 0x%06lx!\n", infoPtr->clrText);
1490
1491     return clrTemp;
1492 }
1493
1494
1495 /* << REBAR_SetTooltips >> */
1496
1497
1498 __inline__ static LRESULT
1499 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
1500 {
1501     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1502     BOOL bTemp = infoPtr->bUnicode;
1503     infoPtr->bUnicode = (BOOL)wParam;
1504     return bTemp;
1505 }
1506
1507
1508 static LRESULT
1509 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1510 {
1511     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1512     REBAR_BAND *lpBand;
1513
1514     if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
1515         return FALSE;
1516
1517     lpBand = &infoPtr->bands[(INT)wParam];
1518
1519     if ((BOOL)lParam) {
1520         TRACE (rebar, "show band %d\n", (INT)wParam);
1521         lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
1522         if (IsWindow (lpBand->hwndChild))
1523             ShowWindow (lpBand->hwndChild, SW_SHOW);
1524     }
1525     else {
1526         TRACE (rebar, "hide band %d\n", (INT)wParam);
1527         lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
1528         if (IsWindow (lpBand->hwndChild))
1529             ShowWindow (lpBand->hwndChild, SW_SHOW);
1530     }
1531
1532     REBAR_Layout (hwnd, NULL);
1533     REBAR_ForceResize (hwnd);
1534     REBAR_MoveChildWindows (hwnd);
1535
1536     return TRUE;
1537 }
1538
1539
1540 static LRESULT
1541 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1542 {
1543     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1544     LPRECT lpRect = (LPRECT)lParam;
1545
1546     if (lpRect == NULL)
1547         return FALSE;
1548
1549     FIXME (rebar, "layout change not implemented!\n");
1550     FIXME (rebar, "[%d %d %d %d]\n",
1551            lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1552
1553 #if 0
1554     SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
1555                     lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
1556                     SWP_NOZORDER);
1557 #endif
1558
1559     infoPtr->calcSize.cx = lpRect->right - lpRect->left;
1560     infoPtr->calcSize.cy = lpRect->bottom - lpRect->top;
1561
1562     REBAR_ForceResize (hwnd);
1563     return TRUE;
1564 }
1565
1566
1567
1568 static LRESULT
1569 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1570 {
1571     REBAR_INFO *infoPtr;
1572
1573     /* allocate memory for info structure */
1574     infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
1575     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1576
1577     /* initialize info structure */
1578     infoPtr->clrBk = CLR_NONE;
1579     infoPtr->clrText = RGB(0, 0, 0);
1580
1581     infoPtr->bAutoResize = FALSE;
1582     infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
1583     infoPtr->hcurHorz  = LoadCursorA (0, IDC_SIZEWEA);
1584     infoPtr->hcurVert  = LoadCursorA (0, IDC_SIZENSA);
1585     infoPtr->hcurDrag  = LoadCursorA (0, IDC_SIZEA);
1586
1587     infoPtr->bUnicode = IsWindowUnicode (hwnd);
1588
1589     if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
1590         FIXME (rebar, "style RBS_AUTOSIZE set!\n");
1591
1592 #if 0
1593     SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1594 #endif
1595
1596     TRACE (rebar, "created!\n");
1597     return 0;
1598 }
1599
1600
1601 static LRESULT
1602 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1603 {
1604     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1605     REBAR_BAND *lpBand;
1606     INT i;
1607
1608
1609     /* free rebar bands */
1610     if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
1611         /* clean up each band */
1612         for (i = 0; i < infoPtr->uNumBands; i++) {
1613             lpBand = &infoPtr->bands[i];
1614
1615             /* delete text strings */
1616             if (lpBand->lpText) {
1617                 COMCTL32_Free (lpBand->lpText);
1618                 lpBand->lpText = NULL;
1619             }
1620             /* destroy child window */
1621             DestroyWindow (lpBand->hwndChild);
1622         }
1623
1624         /* free band array */
1625         COMCTL32_Free (infoPtr->bands);
1626         infoPtr->bands = NULL;
1627     }
1628
1629
1630
1631
1632     DeleteObject (infoPtr->hcurArrow);
1633     DeleteObject (infoPtr->hcurHorz);
1634     DeleteObject (infoPtr->hcurVert);
1635     DeleteObject (infoPtr->hcurDrag);
1636
1637
1638
1639
1640     /* free rebar info data */
1641     COMCTL32_Free (infoPtr);
1642
1643     TRACE (rebar, "destroyed!\n");
1644     return 0;
1645 }
1646
1647
1648 static LRESULT
1649 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1650 {
1651     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1652
1653     return (LRESULT)infoPtr->hFont;
1654 }
1655
1656
1657 #if 0
1658 static LRESULT
1659 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1660 {
1661     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1662
1663     return 0;
1664 }
1665 #endif
1666
1667
1668 __inline__ static LRESULT
1669 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1670 {
1671     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
1672         ((LPRECT)lParam)->left   += sysMetrics[SM_CXEDGE];
1673         ((LPRECT)lParam)->top    += sysMetrics[SM_CYEDGE];
1674         ((LPRECT)lParam)->right  -= sysMetrics[SM_CXEDGE];
1675         ((LPRECT)lParam)->bottom -= sysMetrics[SM_CYEDGE];
1676     }
1677
1678     return 0;
1679 }
1680
1681
1682 static LRESULT
1683 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1684 {
1685     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1686     RECT rcWindow;
1687     HDC hdc;
1688
1689     if (dwStyle & WS_MINIMIZE)
1690         return 0; /* Nothing to do */
1691
1692     DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
1693
1694     if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
1695         return 0;
1696
1697     if (dwStyle & WS_BORDER) {
1698         GetWindowRect (hwnd, &rcWindow);
1699         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
1700         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
1701     }
1702
1703     ReleaseDC( hwnd, hdc );
1704
1705     return 0;
1706 }
1707
1708
1709 static LRESULT
1710 REBAR_Paint (HWND hwnd, WPARAM wParam)
1711 {
1712     HDC hdc;
1713     PAINTSTRUCT ps;
1714
1715     hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1716     REBAR_Refresh (hwnd, hdc);
1717     if (!wParam)
1718         EndPaint (hwnd, &ps);
1719     return 0;
1720 }
1721
1722
1723 static LRESULT
1724 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1725 {
1726     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1727     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1728     POINT pt;
1729     UINT  flags;
1730
1731     TRACE (rebar, "code=0x%X  id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
1732
1733     GetCursorPos (&pt);
1734     ScreenToClient (hwnd, &pt);
1735
1736     REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
1737
1738     if (flags == RBHT_GRABBER) {
1739         if ((dwStyle & CCS_VERT) &&
1740             !(dwStyle & RBS_VERTICALGRIPPER))
1741             SetCursor (infoPtr->hcurVert);
1742         else
1743             SetCursor (infoPtr->hcurHorz);
1744     }
1745     else if (flags != RBHT_CLIENT)
1746         SetCursor (infoPtr->hcurArrow);
1747
1748     return 0;
1749 }
1750
1751
1752 static LRESULT
1753 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1754 {
1755     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1756     
1757     /* TEXTMETRIC32A tm; */
1758     HFONT hFont /*, hOldFont */;
1759     /* HDC32 hdc; */
1760
1761     infoPtr->hFont = (HFONT)wParam;
1762
1763     hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
1764 /*
1765     hdc = GetDC32 (0);
1766     hOldFont = SelectObject32 (hdc, hFont);
1767     GetTextMetrics32A (hdc, &tm);
1768     infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
1769     SelectObject32 (hdc, hOldFont);
1770     ReleaseDC32 (0, hdc);
1771 */
1772     if (lParam) {
1773 /*
1774         REBAR_Layout (hwnd);
1775         hdc = GetDC32 (hwnd);
1776         REBAR_Refresh (hwnd, hdc);
1777         ReleaseDC32 (hwnd, hdc);
1778 */
1779     }
1780
1781     return 0;
1782 }
1783
1784 static LRESULT
1785 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1786 {
1787     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1788     /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */
1789     RECT rcParent;
1790     /* INT32 x, y, cx, cy; */
1791
1792     /* auto resize deadlock check */
1793     if (infoPtr->bAutoResize) {
1794         infoPtr->bAutoResize = FALSE;
1795         return 0;
1796     }
1797
1798     TRACE (rebar, "sizing rebar!\n");
1799
1800     /* get parent rectangle */
1801     GetClientRect (GetParent (hwnd), &rcParent);
1802 /*
1803     REBAR_Layout (hwnd, &rcParent);
1804
1805     if (dwStyle & CCS_VERT) {
1806         if (dwStyle & CCS_LEFT == CCS_LEFT) {
1807             x = rcParent.left;
1808             y = rcParent.top;
1809             cx = infoPtr->calcSize.cx;
1810             cy = infoPtr->calcSize.cy;
1811         }
1812         else {
1813             x = rcParent.right - infoPtr->calcSize.cx;
1814             y = rcParent.top;
1815             cx = infoPtr->calcSize.cx;
1816             cy = infoPtr->calcSize.cy;
1817         }
1818     }
1819     else {
1820         if (dwStyle & CCS_TOP) {
1821             x = rcParent.left;
1822             y = rcParent.top;
1823             cx = infoPtr->calcSize.cx;
1824             cy = infoPtr->calcSize.cy;
1825         }
1826         else {
1827             x = rcParent.left;
1828             y = rcParent.bottom - infoPtr->calcSize.cy;
1829             cx = infoPtr->calcSize.cx;
1830             cy = infoPtr->calcSize.cy;
1831         }
1832     }
1833
1834     SetWindowPos32 (hwnd, 0, x, y, cx, cy,
1835                     SWP_NOZORDER | SWP_SHOWWINDOW);
1836 */
1837     REBAR_Layout (hwnd, NULL);
1838     REBAR_ForceResize (hwnd);
1839     REBAR_MoveChildWindows (hwnd);
1840
1841     return 0;
1842 }
1843
1844
1845 LRESULT WINAPI
1846 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1847 {
1848     switch (uMsg)
1849     {
1850 /*      case RB_BEGINDRAG: */
1851
1852         case RB_DELETEBAND:
1853             return REBAR_DeleteBand (hwnd, wParam, lParam);
1854
1855 /*      case RB_DRAGMOVE: */
1856 /*      case RB_ENDDRAG: */
1857
1858         case RB_GETBANDBORDERS:
1859             return REBAR_GetBandBorders (hwnd, wParam, lParam);
1860
1861         case RB_GETBANDCOUNT:
1862             return REBAR_GetBandCount (hwnd);
1863
1864 /*      case RB_GETBANDINFO32:  */ /* outdated, just for compatibility */
1865
1866         case RB_GETBANDINFOA:
1867             return REBAR_GetBandInfoA (hwnd, wParam, lParam);
1868
1869         case RB_GETBANDINFOW:
1870             return REBAR_GetBandInfoW (hwnd, wParam, lParam);
1871
1872         case RB_GETBARHEIGHT:
1873             return REBAR_GetBarHeight (hwnd, wParam, lParam);
1874
1875         case RB_GETBARINFO:
1876             return REBAR_GetBarInfo (hwnd, wParam, lParam);
1877
1878         case RB_GETBKCOLOR:
1879             return REBAR_GetBkColor (hwnd);
1880
1881 /*      case RB_GETCOLORSCHEME: */
1882 /*      case RB_GETDROPTARGET: */
1883
1884         case RB_GETPALETTE:
1885             return REBAR_GetPalette (hwnd, wParam, lParam);
1886
1887         case RB_GETRECT:
1888             return REBAR_GetRect (hwnd, wParam, lParam);
1889
1890         case RB_GETROWCOUNT:
1891             return REBAR_GetRowCount (hwnd);
1892
1893         case RB_GETROWHEIGHT:
1894             return REBAR_GetRowHeight (hwnd, wParam, lParam);
1895
1896         case RB_GETTEXTCOLOR:
1897             return REBAR_GetTextColor (hwnd);
1898
1899         case RB_GETTOOLTIPS:
1900             return REBAR_GetToolTips (hwnd);
1901
1902         case RB_GETUNICODEFORMAT:
1903             return REBAR_GetUnicodeFormat (hwnd);
1904
1905         case RB_HITTEST:
1906             return REBAR_HitTest (hwnd, wParam, lParam);
1907
1908         case RB_IDTOINDEX:
1909             return REBAR_IdToIndex (hwnd, wParam, lParam);
1910
1911         case RB_INSERTBANDA:
1912             return REBAR_InsertBandA (hwnd, wParam, lParam);
1913
1914         case RB_INSERTBANDW:
1915             return REBAR_InsertBandW (hwnd, wParam, lParam);
1916
1917         case RB_MAXIMIZEBAND:
1918             return REBAR_MaximizeBand (hwnd, wParam, lParam);
1919
1920         case RB_MINIMIZEBAND:
1921             return REBAR_MinimizeBand (hwnd, wParam, lParam);
1922
1923         case RB_MOVEBAND:
1924             return REBAR_MoveBand (hwnd, wParam, lParam);
1925
1926         case RB_SETBANDINFOA:
1927             return REBAR_SetBandInfoA (hwnd, wParam, lParam);
1928
1929         case RB_SETBANDINFOW:
1930             return REBAR_SetBandInfoW (hwnd, wParam, lParam);
1931
1932         case RB_SETBARINFO:
1933             return REBAR_SetBarInfo (hwnd, wParam, lParam);
1934
1935         case RB_SETBKCOLOR:
1936             return REBAR_SetBkColor (hwnd, wParam, lParam);
1937
1938 /*      case RB_SETCOLORSCHEME: */
1939 /*      case RB_SETPALETTE: */
1940 /*          return REBAR_GetPalette (hwnd, wParam, lParam); */
1941
1942         case RB_SETPARENT:
1943             return REBAR_SetParent (hwnd, wParam, lParam);
1944
1945         case RB_SETTEXTCOLOR:
1946             return REBAR_SetTextColor (hwnd, wParam, lParam);
1947
1948 /*      case RB_SETTOOLTIPS: */
1949
1950         case RB_SETUNICODEFORMAT:
1951             return REBAR_SetUnicodeFormat (hwnd, wParam);
1952
1953         case RB_SHOWBAND:
1954             return REBAR_ShowBand (hwnd, wParam, lParam);
1955
1956         case RB_SIZETORECT:
1957             return REBAR_SizeToRect (hwnd, wParam, lParam);
1958
1959
1960         case WM_COMMAND:
1961             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
1962
1963         case WM_CREATE:
1964             return REBAR_Create (hwnd, wParam, lParam);
1965
1966         case WM_DESTROY:
1967             return REBAR_Destroy (hwnd, wParam, lParam);
1968
1969         case WM_GETFONT:
1970             return REBAR_GetFont (hwnd, wParam, lParam);
1971
1972 /*      case WM_MOUSEMOVE: */
1973 /*          return REBAR_MouseMove (hwnd, wParam, lParam); */
1974
1975         case WM_NCCALCSIZE:
1976             return REBAR_NCCalcSize (hwnd, wParam, lParam);
1977
1978         case WM_NCPAINT:
1979             return REBAR_NCPaint (hwnd, wParam, lParam);
1980
1981         case WM_NOTIFY:
1982             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
1983
1984         case WM_PAINT:
1985             return REBAR_Paint (hwnd, wParam);
1986
1987         case WM_SETCURSOR:
1988             return REBAR_SetCursor (hwnd, wParam, lParam);
1989
1990         case WM_SETFONT:
1991             return REBAR_SetFont (hwnd, wParam, lParam);
1992
1993         case WM_SIZE:
1994             return REBAR_Size (hwnd, wParam, lParam);
1995
1996 /*      case WM_TIMER: */
1997
1998 /*      case WM_WININICHANGE: */
1999
2000         default:
2001             if (uMsg >= WM_USER)
2002                 ERR (rebar, "unknown msg %04x wp=%08x lp=%08lx\n",
2003                      uMsg, wParam, lParam);
2004             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2005     }
2006     return 0;
2007 }
2008
2009
2010 VOID
2011 REBAR_Register (VOID)
2012 {
2013     WNDCLASSA wndClass;
2014
2015     if (GlobalFindAtomA (REBARCLASSNAMEA)) return;
2016
2017     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2018     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS;
2019     wndClass.lpfnWndProc   = (WNDPROC)REBAR_WindowProc;
2020     wndClass.cbClsExtra    = 0;
2021     wndClass.cbWndExtra    = sizeof(REBAR_INFO *);
2022     wndClass.hCursor       = 0;
2023     wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2024     wndClass.lpszClassName = REBARCLASSNAMEA;
2025  
2026     RegisterClassA (&wndClass);
2027 }
2028
2029
2030 VOID
2031 REBAR_Unregister (VOID)
2032 {
2033     if (GlobalFindAtomA (REBARCLASSNAMEA))
2034         UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);
2035 }
2036