Mouse position is signed.
[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 "wingdi.h"
25 #include "commctrl.h"
26 #include "rebar.h"
27 #include "debugtools.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(" 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, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(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("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                 INT nEditHeight, yPos;
433                 RECT rc;
434                 HWND hwndEdit;
435
436                 /* special placement code for extended combo box */
437
438                 /* get size of edit line */
439                 hwndEdit = SendMessageA (lpBand->hwndChild, CBEM_GETEDITCONTROL, 0, 0);
440                 GetWindowRect (hwndEdit, &rc);
441                 nEditHeight = rc.bottom - rc.top;
442                 yPos = (lpBand->rcChild.bottom + lpBand->rcChild.top - nEditHeight)/2;
443
444                 /* center combo box inside child area */
445                 SetWindowPos (lpBand->hwndChild, HWND_TOP,
446                             lpBand->rcChild.left, /*lpBand->rcChild.top*/ yPos,
447                             lpBand->rcChild.right - lpBand->rcChild.left,
448                             nEditHeight,
449                             SWP_SHOWWINDOW);
450
451             }
452 #endif
453             else {
454                 SetWindowPos (lpBand->hwndChild, HWND_TOP,
455                             lpBand->rcChild.left, lpBand->rcChild.top,
456                             lpBand->rcChild.right - lpBand->rcChild.left,
457                             lpBand->rcChild.bottom - lpBand->rcChild.top,
458                             SWP_SHOWWINDOW);
459             }
460         }
461     }
462 }
463
464
465 static void
466 REBAR_InternalHitTest (HWND hwnd, LPPOINT lpPt, UINT *pFlags, INT *pBand)
467 {
468     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
469     REBAR_BAND *lpBand;
470     RECT rect;
471     INT  iCount;
472
473     GetClientRect (hwnd, &rect);
474
475     *pFlags = RBHT_NOWHERE;
476     if (PtInRect (&rect, *lpPt))
477     {
478         if (infoPtr->uNumBands == 0) {
479             *pFlags = RBHT_NOWHERE;
480             if (pBand)
481                 *pBand = -1;
482             TRACE("NOWHERE\n");
483             return;
484         }
485         else {
486             /* somewhere inside */
487             for (iCount = 0; iCount < infoPtr->uNumBands; iCount++) {
488                 lpBand = &infoPtr->bands[iCount];
489                 if (PtInRect (&lpBand->rcBand, *lpPt)) {
490                     if (pBand)
491                         *pBand = iCount;
492                     if (PtInRect (&lpBand->rcGripper, *lpPt)) {
493                         *pFlags = RBHT_GRABBER;
494                         TRACE("ON GRABBER %d\n", iCount);
495                         return;
496                     }
497                     else if (PtInRect (&lpBand->rcCapImage, *lpPt)) {
498                         *pFlags = RBHT_CAPTION;
499                         TRACE("ON CAPTION %d\n", iCount);
500                         return;
501                     }
502                     else if (PtInRect (&lpBand->rcCapText, *lpPt)) {
503                         *pFlags = RBHT_CAPTION;
504                         TRACE("ON CAPTION %d\n", iCount);
505                         return;
506                     }
507                     else if (PtInRect (&lpBand->rcChild, *lpPt)) {
508                         *pFlags = RBHT_CLIENT;
509                         TRACE("ON CLIENT %d\n", iCount);
510                         return;
511                     }
512                     else {
513                         *pFlags = RBHT_NOWHERE;
514                         TRACE("NOWHERE %d\n", iCount);
515                         return;
516                     }
517                 }
518             }
519
520             *pFlags = RBHT_NOWHERE;
521             if (pBand)
522                 *pBand = -1;
523
524             TRACE("NOWHERE\n");
525             return;
526         }
527     }
528     else {
529         *pFlags = RBHT_NOWHERE;
530         if (pBand)
531             *pBand = -1;
532         TRACE("NOWHERE\n");
533         return;
534     }
535
536     TRACE("flags=0x%X\n", *pFlags);
537     return;
538 }
539
540
541
542 /* << REBAR_BeginDrag >> */
543
544
545 static LRESULT
546 REBAR_DeleteBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
547 {
548     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
549     UINT uBand = (UINT)wParam;
550
551     if (uBand >= infoPtr->uNumBands)
552         return FALSE;
553
554     TRACE("deleting band %u!\n", uBand);
555
556     if (infoPtr->uNumBands == 1) {
557         TRACE(" simple delete!\n");
558         COMCTL32_Free (infoPtr->bands);
559         infoPtr->bands = NULL;
560         infoPtr->uNumBands = 0;
561     }
562     else {
563         REBAR_BAND *oldBands = infoPtr->bands;
564         TRACE("complex delete! [uBand=%u]\n", uBand);
565
566         infoPtr->uNumBands--;
567         infoPtr->bands = COMCTL32_Alloc (sizeof (REBAR_BAND) * infoPtr->uNumBands);
568         if (uBand > 0) {
569             memcpy (&infoPtr->bands[0], &oldBands[0],
570                     uBand * sizeof(REBAR_BAND));
571         }
572
573         if (uBand < infoPtr->uNumBands) {
574             memcpy (&infoPtr->bands[uBand], &oldBands[uBand+1],
575                     (infoPtr->uNumBands - uBand) * sizeof(REBAR_BAND));
576         }
577
578         COMCTL32_Free (oldBands);
579     }
580
581     REBAR_Layout (hwnd, NULL);
582     REBAR_ForceResize (hwnd);
583     REBAR_MoveChildWindows (hwnd);
584
585     return TRUE;
586 }
587
588
589 /* << REBAR_DragMove >> */
590 /* << REBAR_EndDrag >> */
591
592
593 static LRESULT
594 REBAR_GetBandBorders (HWND hwnd, WPARAM wParam, LPARAM lParam)
595 {
596     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
597     /* LPRECT32 lpRect = (LPRECT32)lParam; */
598     REBAR_BAND *lpBand;
599
600     if (!lParam)
601         return 0;
602     if ((UINT)wParam >= infoPtr->uNumBands)
603         return 0;
604
605     lpBand = &infoPtr->bands[(UINT)wParam];
606     if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_BANDBORDERS) {
607
608     }
609     else {
610
611     }
612
613     return 0;
614 }
615
616
617 inline static LRESULT
618 REBAR_GetBandCount (HWND hwnd)
619 {
620     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
621
622     TRACE("band count %u!\n", infoPtr->uNumBands);
623
624     return infoPtr->uNumBands;
625 }
626
627
628 static LRESULT
629 REBAR_GetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
630 {
631     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
632     LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
633     REBAR_BAND *lpBand;
634
635     if (lprbbi == NULL)
636         return FALSE;
637     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
638         return FALSE;
639     if ((UINT)wParam >= infoPtr->uNumBands)
640         return FALSE;
641
642     TRACE("index %u\n", (UINT)wParam);
643
644     /* copy band information */
645     lpBand = &infoPtr->bands[(UINT)wParam];
646
647     if (lprbbi->fMask & RBBIM_STYLE)
648         lprbbi->fStyle = lpBand->fStyle;
649
650     if (lprbbi->fMask & RBBIM_COLORS) {
651         lprbbi->clrFore = lpBand->clrFore;
652         lprbbi->clrBack = lpBand->clrBack;
653     }
654
655     if ((lprbbi->fMask & RBBIM_TEXT) && 
656         (lprbbi->lpText) && (lpBand->lpText)) {
657             lstrcpynWtoA (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
658     }
659
660     if (lprbbi->fMask & RBBIM_IMAGE)
661         lprbbi->iImage = lpBand->iImage;
662
663     if (lprbbi->fMask & RBBIM_CHILD)
664         lprbbi->hwndChild = lpBand->hwndChild;
665
666     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
667         lprbbi->cxMinChild = lpBand->cxMinChild;
668         lprbbi->cyMinChild = lpBand->cyMinChild;
669         lprbbi->cyMaxChild = lpBand->cyMaxChild;
670         lprbbi->cyChild    = lpBand->cyChild;
671         lprbbi->cyIntegral = lpBand->cyIntegral;
672     }
673
674     if (lprbbi->fMask & RBBIM_SIZE)
675         lprbbi->cx = lpBand->cx;
676
677     if (lprbbi->fMask & RBBIM_BACKGROUND)
678         lprbbi->hbmBack = lpBand->hbmBack;
679
680     if (lprbbi->fMask & RBBIM_ID)
681         lprbbi->wID = lpBand->wID;
682
683     /* check for additional data */
684     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
685         if (lprbbi->fMask & RBBIM_IDEALSIZE)
686             lprbbi->cxIdeal = lpBand->cxIdeal;
687
688         if (lprbbi->fMask & RBBIM_LPARAM)
689             lprbbi->lParam = lpBand->lParam;
690
691         if (lprbbi->fMask & RBBIM_HEADERSIZE)
692             lprbbi->cxHeader = lpBand->cxHeader;
693     }
694
695     return TRUE;
696 }
697
698
699 static LRESULT
700 REBAR_GetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
701 {
702     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
703     LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
704     REBAR_BAND *lpBand;
705
706     if (lprbbi == NULL)
707         return FALSE;
708     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
709         return FALSE;
710     if ((UINT)wParam >= infoPtr->uNumBands)
711         return FALSE;
712
713     TRACE("index %u\n", (UINT)wParam);
714
715     /* copy band information */
716     lpBand = &infoPtr->bands[(UINT)wParam];
717
718     if (lprbbi->fMask & RBBIM_STYLE)
719         lprbbi->fStyle = lpBand->fStyle;
720
721     if (lprbbi->fMask & RBBIM_COLORS) {
722         lprbbi->clrFore = lpBand->clrFore;
723         lprbbi->clrBack = lpBand->clrBack;
724     }
725
726     if ((lprbbi->fMask & RBBIM_TEXT) && 
727         (lprbbi->lpText) && (lpBand->lpText)) {
728             lstrcpynW (lprbbi->lpText, lpBand->lpText, lprbbi->cch);
729     }
730
731     if (lprbbi->fMask & RBBIM_IMAGE)
732         lprbbi->iImage = lpBand->iImage;
733
734     if (lprbbi->fMask & RBBIM_CHILD)
735         lprbbi->hwndChild = lpBand->hwndChild;
736
737     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
738         lprbbi->cxMinChild = lpBand->cxMinChild;
739         lprbbi->cyMinChild = lpBand->cyMinChild;
740         lprbbi->cyMaxChild = lpBand->cyMaxChild;
741         lprbbi->cyChild    = lpBand->cyChild;
742         lprbbi->cyIntegral = lpBand->cyIntegral;
743     }
744
745     if (lprbbi->fMask & RBBIM_SIZE)
746         lprbbi->cx = lpBand->cx;
747
748     if (lprbbi->fMask & RBBIM_BACKGROUND)
749         lprbbi->hbmBack = lpBand->hbmBack;
750
751     if (lprbbi->fMask & RBBIM_ID)
752         lprbbi->wID = lpBand->wID;
753
754     /* check for additional data */
755     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
756         if (lprbbi->fMask & RBBIM_IDEALSIZE)
757             lprbbi->cxIdeal = lpBand->cxIdeal;
758
759         if (lprbbi->fMask & RBBIM_LPARAM)
760             lprbbi->lParam = lpBand->lParam;
761
762         if (lprbbi->fMask & RBBIM_HEADERSIZE)
763             lprbbi->cxHeader = lpBand->cxHeader;
764     }
765
766     return TRUE;
767 }
768
769
770 static LRESULT
771 REBAR_GetBarHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
772 {
773     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
774     INT nHeight;
775
776     REBAR_Layout (hwnd, NULL);
777     nHeight = infoPtr->calcSize.cy;
778
779     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER)
780         nHeight += (2 * GetSystemMetrics(SM_CYEDGE));
781
782
783     FIXME("height = %d\n", nHeight);
784
785     return nHeight;
786 }
787
788
789 static LRESULT
790 REBAR_GetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
791 {
792     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
793     LPREBARINFO lpInfo = (LPREBARINFO)lParam;
794
795     if (lpInfo == NULL)
796         return FALSE;
797
798     if (lpInfo->cbSize < sizeof (REBARINFO))
799         return FALSE;
800
801     TRACE("getting bar info!\n");
802
803     if (infoPtr->himl) {
804         lpInfo->himl = infoPtr->himl;
805         lpInfo->fMask |= RBIM_IMAGELIST;
806     }
807
808     return TRUE;
809 }
810
811
812 inline static LRESULT
813 REBAR_GetBkColor (HWND hwnd)
814 {
815     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
816
817     TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
818
819     return infoPtr->clrBk;
820 }
821
822
823 /* << REBAR_GetColorScheme >> */
824 /* << REBAR_GetDropTarget >> */
825
826
827 static LRESULT
828 REBAR_GetPalette (HWND hwnd, WPARAM wParam, LPARAM lParam)
829 {
830     FIXME("empty stub!\n");
831
832     return 0;
833 }
834
835
836 static LRESULT
837 REBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
838 {
839     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
840     INT iBand = (INT)wParam;
841     LPRECT lprc = (LPRECT)lParam;
842     REBAR_BAND *lpBand;
843
844     if ((iBand < 0) && ((UINT)iBand >= infoPtr->uNumBands))
845         return FALSE;
846     if (!lprc)
847         return FALSE;
848
849     TRACE("band %d\n", iBand);
850
851     lpBand = &infoPtr->bands[iBand];
852     CopyRect (lprc, &lpBand->rcBand);
853 /*
854     lprc->left   = lpBand->rcBand.left;
855     lprc->top    = lpBand->rcBand.top;
856     lprc->right  = lpBand->rcBand.right;
857     lprc->bottom = lpBand->rcBand.bottom;
858 */
859
860     return TRUE;
861 }
862
863
864 inline static LRESULT
865 REBAR_GetRowCount (HWND hwnd)
866 {
867     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
868
869     FIXME("%u : semi stub!\n", infoPtr->uNumBands);
870
871     return infoPtr->uNumBands;
872 }
873
874
875 static LRESULT
876 REBAR_GetRowHeight (HWND hwnd, WPARAM wParam, LPARAM lParam)
877 {
878 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
879
880     FIXME("-- height = 20: semi stub!\n");
881
882     return 20;
883 }
884
885
886 inline static LRESULT
887 REBAR_GetTextColor (HWND hwnd)
888 {
889     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
890
891     TRACE("text color 0x%06lx!\n", infoPtr->clrText);
892
893     return infoPtr->clrText;
894 }
895
896
897 inline static LRESULT
898 REBAR_GetToolTips (HWND hwnd)
899 {
900     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
901     return infoPtr->hwndToolTip;
902 }
903
904
905 inline static LRESULT
906 REBAR_GetUnicodeFormat (HWND hwnd)
907 {
908     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
909     return infoPtr->bUnicode;
910 }
911
912
913 static LRESULT
914 REBAR_HitTest (HWND hwnd, WPARAM wParam, LPARAM lParam)
915 {
916     /* REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
917     LPRBHITTESTINFO lprbht = (LPRBHITTESTINFO)lParam; 
918
919     if (!lprbht)
920         return -1;
921
922     REBAR_InternalHitTest (hwnd, &lprbht->pt, &lprbht->flags, &lprbht->iBand);
923
924     return lprbht->iBand;
925 }
926
927
928 static LRESULT
929 REBAR_IdToIndex (HWND hwnd, WPARAM wParam, LPARAM lParam)
930 {
931     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
932     UINT i;
933
934     if (infoPtr == NULL)
935         return -1;
936
937     if (infoPtr->uNumBands < 1)
938         return -1;
939
940     TRACE("id %u\n", (UINT)wParam);
941
942     for (i = 0; i < infoPtr->uNumBands; i++) {
943         if (infoPtr->bands[i].wID == (UINT)wParam) {
944             TRACE("band %u found!\n", i);
945             return i;
946         }
947     }
948
949     TRACE("no band found!\n");
950     return -1;
951 }
952
953
954 static LRESULT
955 REBAR_InsertBandA (HWND hwnd, WPARAM wParam, LPARAM lParam)
956 {
957     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
958     LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
959     UINT uIndex = (UINT)wParam;
960     REBAR_BAND *lpBand;
961
962     if (infoPtr == NULL)
963         return FALSE;
964     if (lprbbi == NULL)
965         return FALSE;
966     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
967         return FALSE;
968
969     TRACE("insert band at %u!\n", uIndex);
970
971     if (infoPtr->uNumBands == 0) {
972         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
973         uIndex = 0;
974     }
975     else {
976         REBAR_BAND *oldBands = infoPtr->bands;
977         infoPtr->bands =
978             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
979         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
980             uIndex = infoPtr->uNumBands;
981
982         /* pre insert copy */
983         if (uIndex > 0) {
984             memcpy (&infoPtr->bands[0], &oldBands[0],
985                     uIndex * sizeof(REBAR_BAND));
986         }
987
988         /* post copy */
989         if (uIndex < infoPtr->uNumBands - 1) {
990             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
991                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
992         }
993
994         COMCTL32_Free (oldBands);
995     }
996
997     infoPtr->uNumBands++;
998
999     TRACE("index %u!\n", uIndex);
1000
1001     /* initialize band (infoPtr->bands[uIndex])*/
1002     lpBand = &infoPtr->bands[uIndex];
1003
1004     if (lprbbi->fMask & RBBIM_STYLE)
1005         lpBand->fStyle = lprbbi->fStyle;
1006
1007     if (lprbbi->fMask & RBBIM_COLORS) {
1008         lpBand->clrFore = lprbbi->clrFore;
1009         lpBand->clrBack = lprbbi->clrBack;
1010     }
1011     else {
1012         lpBand->clrFore = CLR_NONE;
1013         lpBand->clrBack = CLR_NONE;
1014     }
1015
1016     if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1017         INT len = lstrlenA (lprbbi->lpText);
1018         if (len > 0) {
1019             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1020             lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1021         }
1022     }
1023
1024     if (lprbbi->fMask & RBBIM_IMAGE)
1025         lpBand->iImage = lprbbi->iImage;
1026     else
1027         lpBand->iImage = -1;
1028
1029     if (lprbbi->fMask & RBBIM_CHILD) {
1030         TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1031         lpBand->hwndChild = lprbbi->hwndChild;
1032         lpBand->hwndPrevParent =
1033             SetParent (lpBand->hwndChild, hwnd);
1034     }
1035
1036     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1037         lpBand->cxMinChild = lprbbi->cxMinChild;
1038         lpBand->cyMinChild = lprbbi->cyMinChild;
1039         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1040         lpBand->cyChild    = lprbbi->cyChild;
1041         lpBand->cyIntegral = lprbbi->cyIntegral;
1042     }
1043     else {
1044         lpBand->cxMinChild = -1;
1045         lpBand->cyMinChild = -1;
1046         lpBand->cyMaxChild = -1;
1047         lpBand->cyChild    = -1;
1048         lpBand->cyIntegral = -1;
1049     }
1050
1051     if (lprbbi->fMask & RBBIM_SIZE)
1052         lpBand->cx = lprbbi->cx;
1053     else
1054         lpBand->cx = -1;
1055
1056     if (lprbbi->fMask & RBBIM_BACKGROUND)
1057         lpBand->hbmBack = lprbbi->hbmBack;
1058
1059     if (lprbbi->fMask & RBBIM_ID)
1060         lpBand->wID = lprbbi->wID;
1061
1062     /* check for additional data */
1063     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1064         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1065             lpBand->cxIdeal = lprbbi->cxIdeal;
1066
1067         if (lprbbi->fMask & RBBIM_LPARAM)
1068             lpBand->lParam = lprbbi->lParam;
1069
1070         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1071             lpBand->cxHeader = lprbbi->cxHeader;
1072     }
1073
1074
1075     REBAR_Layout (hwnd, NULL);
1076     REBAR_ForceResize (hwnd);
1077     REBAR_MoveChildWindows (hwnd);
1078
1079     return TRUE;
1080 }
1081
1082
1083 static LRESULT
1084 REBAR_InsertBandW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1085 {
1086     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1087     LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1088     UINT uIndex = (UINT)wParam;
1089     REBAR_BAND *lpBand;
1090
1091     if (infoPtr == NULL)
1092         return FALSE;
1093     if (lprbbi == NULL)
1094         return FALSE;
1095     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1096         return FALSE;
1097
1098     TRACE("insert band at %u!\n", uIndex);
1099
1100     if (infoPtr->uNumBands == 0) {
1101         infoPtr->bands = (REBAR_BAND *)COMCTL32_Alloc (sizeof (REBAR_BAND));
1102         uIndex = 0;
1103     }
1104     else {
1105         REBAR_BAND *oldBands = infoPtr->bands;
1106         infoPtr->bands =
1107             (REBAR_BAND *)COMCTL32_Alloc ((infoPtr->uNumBands+1)*sizeof(REBAR_BAND));
1108         if (((INT)uIndex == -1) || (uIndex > infoPtr->uNumBands))
1109             uIndex = infoPtr->uNumBands;
1110
1111         /* pre insert copy */
1112         if (uIndex > 0) {
1113             memcpy (&infoPtr->bands[0], &oldBands[0],
1114                     uIndex * sizeof(REBAR_BAND));
1115         }
1116
1117         /* post copy */
1118         if (uIndex < infoPtr->uNumBands - 1) {
1119             memcpy (&infoPtr->bands[uIndex+1], &oldBands[uIndex],
1120                     (infoPtr->uNumBands - uIndex - 1) * sizeof(REBAR_BAND));
1121         }
1122
1123         COMCTL32_Free (oldBands);
1124     }
1125
1126     infoPtr->uNumBands++;
1127
1128     TRACE("index %u!\n", uIndex);
1129
1130     /* initialize band (infoPtr->bands[uIndex])*/
1131     lpBand = &infoPtr->bands[uIndex];
1132
1133     if (lprbbi->fMask & RBBIM_STYLE)
1134         lpBand->fStyle = lprbbi->fStyle;
1135
1136     if (lprbbi->fMask & RBBIM_COLORS) {
1137         lpBand->clrFore = lprbbi->clrFore;
1138         lpBand->clrBack = lprbbi->clrBack;
1139     }
1140     else {
1141         lpBand->clrFore = CLR_NONE;
1142         lpBand->clrBack = CLR_NONE;
1143     }
1144
1145     if ((lprbbi->fMask & RBBIM_TEXT) && (lprbbi->lpText)) {
1146         INT len = lstrlenW (lprbbi->lpText);
1147         if (len > 0) {
1148             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1149             lstrcpyW (lpBand->lpText, lprbbi->lpText);
1150         }
1151     }
1152
1153     if (lprbbi->fMask & RBBIM_IMAGE)
1154         lpBand->iImage = lprbbi->iImage;
1155     else
1156         lpBand->iImage = -1;
1157
1158     if (lprbbi->fMask & RBBIM_CHILD) {
1159         TRACE("hwndChild = %x\n", lprbbi->hwndChild);
1160         lpBand->hwndChild = lprbbi->hwndChild;
1161         lpBand->hwndPrevParent =
1162             SetParent (lpBand->hwndChild, hwnd);
1163     }
1164
1165     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1166         lpBand->cxMinChild = lprbbi->cxMinChild;
1167         lpBand->cyMinChild = lprbbi->cyMinChild;
1168         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1169         lpBand->cyChild    = lprbbi->cyChild;
1170         lpBand->cyIntegral = lprbbi->cyIntegral;
1171     }
1172     else {
1173         lpBand->cxMinChild = -1;
1174         lpBand->cyMinChild = -1;
1175         lpBand->cyMaxChild = -1;
1176         lpBand->cyChild    = -1;
1177         lpBand->cyIntegral = -1;
1178     }
1179
1180     if (lprbbi->fMask & RBBIM_SIZE)
1181         lpBand->cx = lprbbi->cx;
1182     else
1183         lpBand->cx = -1;
1184
1185     if (lprbbi->fMask & RBBIM_BACKGROUND)
1186         lpBand->hbmBack = lprbbi->hbmBack;
1187
1188     if (lprbbi->fMask & RBBIM_ID)
1189         lpBand->wID = lprbbi->wID;
1190
1191     /* check for additional data */
1192     if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1193         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1194             lpBand->cxIdeal = lprbbi->cxIdeal;
1195
1196         if (lprbbi->fMask & RBBIM_LPARAM)
1197             lpBand->lParam = lprbbi->lParam;
1198
1199         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1200             lpBand->cxHeader = lprbbi->cxHeader;
1201     }
1202
1203
1204     REBAR_Layout (hwnd, NULL);
1205     REBAR_ForceResize (hwnd);
1206     REBAR_MoveChildWindows (hwnd);
1207
1208     return TRUE;
1209 }
1210
1211
1212 static LRESULT
1213 REBAR_MaximizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1214 {
1215 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1216
1217     FIXME("(uBand = %u fIdeal = %s)\n",
1218            (UINT)wParam, lParam ? "TRUE" : "FALSE");
1219
1220  
1221     return 0;
1222 }
1223
1224
1225 static LRESULT
1226 REBAR_MinimizeBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1227 {
1228 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1229
1230     FIXME("(uBand = %u)\n", (UINT)wParam);
1231
1232  
1233     return 0;
1234 }
1235
1236
1237 static LRESULT
1238 REBAR_MoveBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1239 {
1240 /*    REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); */
1241
1242     FIXME("(iFrom = %u iTof = %u)\n",
1243            (UINT)wParam, (UINT)lParam);
1244
1245  
1246     return FALSE;
1247 }
1248
1249
1250 static LRESULT
1251 REBAR_SetBandInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam)
1252 {
1253     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1254     LPREBARBANDINFOA lprbbi = (LPREBARBANDINFOA)lParam;
1255     REBAR_BAND *lpBand;
1256
1257     if (lprbbi == NULL)
1258         return FALSE;
1259     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEA)
1260         return FALSE;
1261     if ((UINT)wParam >= infoPtr->uNumBands)
1262         return FALSE;
1263
1264     TRACE("index %u\n", (UINT)wParam);
1265
1266     /* set band information */
1267     lpBand = &infoPtr->bands[(UINT)wParam];
1268
1269     if (lprbbi->fMask & RBBIM_STYLE)
1270         lpBand->fStyle = lprbbi->fStyle;
1271
1272     if (lprbbi->fMask & RBBIM_COLORS) {
1273         lpBand->clrFore = lprbbi->clrFore;
1274         lpBand->clrBack = lprbbi->clrBack;
1275     }
1276
1277     if (lprbbi->fMask & RBBIM_TEXT) {
1278         if (lpBand->lpText) {
1279             COMCTL32_Free (lpBand->lpText);
1280             lpBand->lpText = NULL;
1281         }
1282         if (lprbbi->lpText) {
1283             INT len = lstrlenA (lprbbi->lpText);
1284             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1285             lstrcpyAtoW (lpBand->lpText, lprbbi->lpText);
1286         }
1287     }
1288
1289     if (lprbbi->fMask & RBBIM_IMAGE)
1290         lpBand->iImage = lprbbi->iImage;
1291
1292     if (lprbbi->fMask & RBBIM_CHILD) {
1293         if (lprbbi->hwndChild) {
1294             lpBand->hwndChild = lprbbi->hwndChild;
1295             lpBand->hwndPrevParent =
1296                 SetParent (lpBand->hwndChild, hwnd);
1297         }
1298         else {
1299             TRACE("child: 0x%x  prev parent: 0x%x\n",
1300                    lpBand->hwndChild, lpBand->hwndPrevParent);
1301             lpBand->hwndChild = 0;
1302             lpBand->hwndPrevParent = 0;
1303         }
1304     }
1305
1306     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1307         lpBand->cxMinChild = lprbbi->cxMinChild;
1308         lpBand->cyMinChild = lprbbi->cyMinChild;
1309         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1310         lpBand->cyChild    = lprbbi->cyChild;
1311         lpBand->cyIntegral = lprbbi->cyIntegral;
1312     }
1313
1314     if (lprbbi->fMask & RBBIM_SIZE)
1315         lpBand->cx = lprbbi->cx;
1316
1317     if (lprbbi->fMask & RBBIM_BACKGROUND)
1318         lpBand->hbmBack = lprbbi->hbmBack;
1319
1320     if (lprbbi->fMask & RBBIM_ID)
1321         lpBand->wID = lprbbi->wID;
1322
1323     /* check for additional data */
1324     if (lprbbi->cbSize >= sizeof (REBARBANDINFOA)) {
1325         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1326             lpBand->cxIdeal = lprbbi->cxIdeal;
1327
1328         if (lprbbi->fMask & RBBIM_LPARAM)
1329             lpBand->lParam = lprbbi->lParam;
1330
1331         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1332             lpBand->cxHeader = lprbbi->cxHeader;
1333     }
1334
1335     REBAR_Layout (hwnd, NULL);
1336     REBAR_ForceResize (hwnd);
1337     REBAR_MoveChildWindows (hwnd);
1338
1339     return TRUE;
1340 }
1341
1342
1343 static LRESULT
1344 REBAR_SetBandInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam)
1345 {
1346     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1347     LPREBARBANDINFOW lprbbi = (LPREBARBANDINFOW)lParam;
1348     REBAR_BAND *lpBand;
1349
1350     if (lprbbi == NULL)
1351         return FALSE;
1352     if (lprbbi->cbSize < REBARBANDINFO_V3_SIZEW)
1353         return FALSE;
1354     if ((UINT)wParam >= infoPtr->uNumBands)
1355         return FALSE;
1356
1357     TRACE("index %u\n", (UINT)wParam);
1358
1359     /* set band information */
1360     lpBand = &infoPtr->bands[(UINT)wParam];
1361
1362     if (lprbbi->fMask & RBBIM_STYLE)
1363         lpBand->fStyle = lprbbi->fStyle;
1364
1365     if (lprbbi->fMask & RBBIM_COLORS) {
1366         lpBand->clrFore = lprbbi->clrFore;
1367         lpBand->clrBack = lprbbi->clrBack;
1368     }
1369
1370     if (lprbbi->fMask & RBBIM_TEXT) {
1371         if (lpBand->lpText) {
1372             COMCTL32_Free (lpBand->lpText);
1373             lpBand->lpText = NULL;
1374         }
1375         if (lprbbi->lpText) {
1376             INT len = lstrlenW (lprbbi->lpText);
1377             lpBand->lpText = (LPWSTR)COMCTL32_Alloc ((len + 1)*sizeof(WCHAR));
1378             lstrcpyW (lpBand->lpText, lprbbi->lpText);
1379         }
1380     }
1381
1382     if (lprbbi->fMask & RBBIM_IMAGE)
1383         lpBand->iImage = lprbbi->iImage;
1384
1385     if (lprbbi->fMask & RBBIM_CHILD) {
1386         if (lprbbi->hwndChild) {
1387             lpBand->hwndChild = lprbbi->hwndChild;
1388             lpBand->hwndPrevParent =
1389                 SetParent (lpBand->hwndChild, hwnd);
1390         }
1391         else {
1392             TRACE("child: 0x%x  prev parent: 0x%x\n",
1393                    lpBand->hwndChild, lpBand->hwndPrevParent);
1394             lpBand->hwndChild = 0;
1395             lpBand->hwndPrevParent = 0;
1396         }
1397     }
1398
1399     if (lprbbi->fMask & RBBIM_CHILDSIZE) {
1400         lpBand->cxMinChild = lprbbi->cxMinChild;
1401         lpBand->cyMinChild = lprbbi->cyMinChild;
1402         lpBand->cyMaxChild = lprbbi->cyMaxChild;
1403         lpBand->cyChild    = lprbbi->cyChild;
1404         lpBand->cyIntegral = lprbbi->cyIntegral;
1405     }
1406
1407     if (lprbbi->fMask & RBBIM_SIZE)
1408         lpBand->cx = lprbbi->cx;
1409
1410     if (lprbbi->fMask & RBBIM_BACKGROUND)
1411         lpBand->hbmBack = lprbbi->hbmBack;
1412
1413     if (lprbbi->fMask & RBBIM_ID)
1414         lpBand->wID = lprbbi->wID;
1415
1416     /* check for additional data */
1417     if (lprbbi->cbSize >= sizeof (REBARBANDINFOW)) {
1418         if (lprbbi->fMask & RBBIM_IDEALSIZE)
1419             lpBand->cxIdeal = lprbbi->cxIdeal;
1420
1421         if (lprbbi->fMask & RBBIM_LPARAM)
1422             lpBand->lParam = lprbbi->lParam;
1423
1424         if (lprbbi->fMask & RBBIM_HEADERSIZE)
1425             lpBand->cxHeader = lprbbi->cxHeader;
1426     }
1427
1428     REBAR_Layout (hwnd, NULL);
1429     REBAR_ForceResize (hwnd);
1430     REBAR_MoveChildWindows (hwnd);
1431
1432     return TRUE;
1433 }
1434
1435
1436 static LRESULT
1437 REBAR_SetBarInfo (HWND hwnd, WPARAM wParam, LPARAM lParam)
1438 {
1439     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1440     LPREBARINFO lpInfo = (LPREBARINFO)lParam;
1441
1442     if (lpInfo == NULL)
1443         return FALSE;
1444
1445     if (lpInfo->cbSize < sizeof (REBARINFO))
1446         return FALSE;
1447
1448     TRACE("setting bar info!\n");
1449
1450     if (lpInfo->fMask & RBIM_IMAGELIST) {
1451         infoPtr->himl = lpInfo->himl;
1452         if (infoPtr->himl) {
1453             ImageList_GetIconSize (infoPtr->himl, &infoPtr->imageSize.cx,
1454                                    &infoPtr->imageSize.cy);
1455         }
1456         else {
1457             infoPtr->imageSize.cx = 0;
1458             infoPtr->imageSize.cy = 0;
1459         }
1460     }
1461
1462     return TRUE;
1463 }
1464
1465
1466 static LRESULT
1467 REBAR_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1468 {
1469     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1470     COLORREF clrTemp;
1471
1472     clrTemp = infoPtr->clrBk;
1473     infoPtr->clrBk = (COLORREF)lParam;
1474
1475     TRACE("background color 0x%06lx!\n", infoPtr->clrBk);
1476
1477     return clrTemp;
1478 }
1479
1480
1481 /* << REBAR_SetColorScheme >> */
1482 /* << REBAR_SetPalette >> */
1483
1484
1485 static LRESULT
1486 REBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam)
1487 {
1488     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1489     HWND hwndTemp = infoPtr->hwndNotify;
1490
1491     infoPtr->hwndNotify = (HWND)wParam;
1492
1493     return (LRESULT)hwndTemp;
1494 }
1495
1496
1497 static LRESULT
1498 REBAR_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1499 {
1500     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1501     COLORREF clrTemp;
1502
1503     clrTemp = infoPtr->clrText;
1504     infoPtr->clrText = (COLORREF)lParam;
1505
1506     TRACE("text color 0x%06lx!\n", infoPtr->clrText);
1507
1508     return clrTemp;
1509 }
1510
1511
1512 /* << REBAR_SetTooltips >> */
1513
1514
1515 inline static LRESULT
1516 REBAR_SetUnicodeFormat (HWND hwnd, WPARAM wParam)
1517 {
1518     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1519     BOOL bTemp = infoPtr->bUnicode;
1520     infoPtr->bUnicode = (BOOL)wParam;
1521     return bTemp;
1522 }
1523
1524
1525 static LRESULT
1526 REBAR_ShowBand (HWND hwnd, WPARAM wParam, LPARAM lParam)
1527 {
1528     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1529     REBAR_BAND *lpBand;
1530
1531     if (((INT)wParam < 0) || ((INT)wParam > infoPtr->uNumBands))
1532         return FALSE;
1533
1534     lpBand = &infoPtr->bands[(INT)wParam];
1535
1536     if ((BOOL)lParam) {
1537         TRACE("show band %d\n", (INT)wParam);
1538         lpBand->fStyle = lpBand->fStyle & ~RBBS_HIDDEN;
1539         if (IsWindow (lpBand->hwndChild))
1540             ShowWindow (lpBand->hwndChild, SW_SHOW);
1541     }
1542     else {
1543         TRACE("hide band %d\n", (INT)wParam);
1544         lpBand->fStyle = lpBand->fStyle | RBBS_HIDDEN;
1545         if (IsWindow (lpBand->hwndChild))
1546             ShowWindow (lpBand->hwndChild, SW_SHOW);
1547     }
1548
1549     REBAR_Layout (hwnd, NULL);
1550     REBAR_ForceResize (hwnd);
1551     REBAR_MoveChildWindows (hwnd);
1552
1553     return TRUE;
1554 }
1555
1556
1557 static LRESULT
1558 REBAR_SizeToRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
1559 {
1560     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1561     LPRECT lpRect = (LPRECT)lParam;
1562
1563     if (lpRect == NULL)
1564         return FALSE;
1565
1566     FIXME("layout change not implemented!\n");
1567     FIXME("[%d %d %d %d]\n",
1568            lpRect->left, lpRect->top, lpRect->right, lpRect->bottom);
1569
1570 #if 0
1571     SetWindowPos (hwnd, 0, lpRect->left, lpRect->top,
1572                     lpRect->right - lpRect->left, lpRect->bottom - lpRect->top,
1573                     SWP_NOZORDER);
1574 #endif
1575
1576     infoPtr->calcSize.cx = lpRect->right - lpRect->left;
1577     infoPtr->calcSize.cy = lpRect->bottom - lpRect->top;
1578
1579     REBAR_ForceResize (hwnd);
1580     return TRUE;
1581 }
1582
1583
1584
1585 static LRESULT
1586 REBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
1587 {
1588     REBAR_INFO *infoPtr;
1589
1590     /* allocate memory for info structure */
1591     infoPtr = (REBAR_INFO *)COMCTL32_Alloc (sizeof(REBAR_INFO));
1592     SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
1593
1594     /* initialize info structure */
1595     infoPtr->clrBk = CLR_NONE;
1596     infoPtr->clrText = RGB(0, 0, 0);
1597
1598     infoPtr->bAutoResize = FALSE;
1599     infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
1600     infoPtr->hcurHorz  = LoadCursorA (0, IDC_SIZEWEA);
1601     infoPtr->hcurVert  = LoadCursorA (0, IDC_SIZENSA);
1602     infoPtr->hcurDrag  = LoadCursorA (0, IDC_SIZEA);
1603
1604     infoPtr->bUnicode = IsWindowUnicode (hwnd);
1605
1606     if (GetWindowLongA (hwnd, GWL_STYLE) & RBS_AUTOSIZE)
1607         FIXME("style RBS_AUTOSIZE set!\n");
1608
1609 #if 0
1610     SendMessageA (hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
1611 #endif
1612
1613     TRACE("created!\n");
1614     return 0;
1615 }
1616
1617
1618 static LRESULT
1619 REBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam)
1620 {
1621     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1622     REBAR_BAND *lpBand;
1623     INT i;
1624
1625
1626     /* free rebar bands */
1627     if ((infoPtr->uNumBands > 0) && infoPtr->bands) {
1628         /* clean up each band */
1629         for (i = 0; i < infoPtr->uNumBands; i++) {
1630             lpBand = &infoPtr->bands[i];
1631
1632             /* delete text strings */
1633             if (lpBand->lpText) {
1634                 COMCTL32_Free (lpBand->lpText);
1635                 lpBand->lpText = NULL;
1636             }
1637             /* destroy child window */
1638             DestroyWindow (lpBand->hwndChild);
1639         }
1640
1641         /* free band array */
1642         COMCTL32_Free (infoPtr->bands);
1643         infoPtr->bands = NULL;
1644     }
1645
1646
1647
1648
1649     DeleteObject (infoPtr->hcurArrow);
1650     DeleteObject (infoPtr->hcurHorz);
1651     DeleteObject (infoPtr->hcurVert);
1652     DeleteObject (infoPtr->hcurDrag);
1653
1654
1655
1656
1657     /* free rebar info data */
1658     COMCTL32_Free (infoPtr);
1659
1660     TRACE("destroyed!\n");
1661     return 0;
1662 }
1663
1664
1665 static LRESULT
1666 REBAR_GetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1667 {
1668     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1669
1670     return (LRESULT)infoPtr->hFont;
1671 }
1672
1673
1674 #if 0
1675 static LRESULT
1676 REBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
1677 {
1678     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1679
1680     return 0;
1681 }
1682 #endif
1683
1684
1685 inline static LRESULT
1686 REBAR_NCCalcSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
1687 {
1688     if (GetWindowLongA (hwnd, GWL_STYLE) & WS_BORDER) {
1689         ((LPRECT)lParam)->left   += GetSystemMetrics(SM_CXEDGE);
1690         ((LPRECT)lParam)->top    += GetSystemMetrics(SM_CYEDGE);
1691         ((LPRECT)lParam)->right  -= GetSystemMetrics(SM_CXEDGE);
1692         ((LPRECT)lParam)->bottom -= GetSystemMetrics(SM_CYEDGE);
1693     }
1694
1695     return 0;
1696 }
1697
1698
1699 static LRESULT
1700 REBAR_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam)
1701 {
1702     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1703     RECT rcWindow;
1704     HDC hdc;
1705
1706     if (dwStyle & WS_MINIMIZE)
1707         return 0; /* Nothing to do */
1708
1709     DefWindowProcA (hwnd, WM_NCPAINT, wParam, lParam);
1710
1711     if (!(hdc = GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW )))
1712         return 0;
1713
1714     if (dwStyle & WS_BORDER) {
1715         GetWindowRect (hwnd, &rcWindow);
1716         OffsetRect (&rcWindow, -rcWindow.left, -rcWindow.top);
1717         DrawEdge (hdc, &rcWindow, EDGE_ETCHED, BF_RECT);
1718     }
1719
1720     ReleaseDC( hwnd, hdc );
1721
1722     return 0;
1723 }
1724
1725
1726 static LRESULT
1727 REBAR_Paint (HWND hwnd, WPARAM wParam)
1728 {
1729     HDC hdc;
1730     PAINTSTRUCT ps;
1731
1732     hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
1733     REBAR_Refresh (hwnd, hdc);
1734     if (!wParam)
1735         EndPaint (hwnd, &ps);
1736     return 0;
1737 }
1738
1739
1740 static LRESULT
1741 REBAR_SetCursor (HWND hwnd, WPARAM wParam, LPARAM lParam)
1742 {
1743     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1744     DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
1745     POINT pt;
1746     UINT  flags;
1747
1748     TRACE("code=0x%X  id=0x%X\n", LOWORD(lParam), HIWORD(lParam));
1749
1750     GetCursorPos (&pt);
1751     ScreenToClient (hwnd, &pt);
1752
1753     REBAR_InternalHitTest (hwnd, &pt, &flags, NULL);
1754
1755     if (flags == RBHT_GRABBER) {
1756         if ((dwStyle & CCS_VERT) &&
1757             !(dwStyle & RBS_VERTICALGRIPPER))
1758             SetCursor (infoPtr->hcurVert);
1759         else
1760             SetCursor (infoPtr->hcurHorz);
1761     }
1762     else if (flags != RBHT_CLIENT)
1763         SetCursor (infoPtr->hcurArrow);
1764
1765     return 0;
1766 }
1767
1768
1769 static LRESULT
1770 REBAR_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
1771 {
1772     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1773     
1774     /* TEXTMETRIC32A tm; */
1775     HFONT hFont /*, hOldFont */;
1776     /* HDC32 hdc; */
1777
1778     infoPtr->hFont = (HFONT)wParam;
1779
1780     hFont = infoPtr->hFont ? infoPtr->hFont : GetStockObject (SYSTEM_FONT);
1781 /*
1782     hdc = GetDC32 (0);
1783     hOldFont = SelectObject32 (hdc, hFont);
1784     GetTextMetrics32A (hdc, &tm);
1785     infoPtr->nHeight = tm.tmHeight + VERT_BORDER;
1786     SelectObject32 (hdc, hOldFont);
1787     ReleaseDC32 (0, hdc);
1788 */
1789     if (lParam) {
1790 /*
1791         REBAR_Layout (hwnd);
1792         hdc = GetDC32 (hwnd);
1793         REBAR_Refresh (hwnd, hdc);
1794         ReleaseDC32 (hwnd, hdc);
1795 */
1796     }
1797
1798     return 0;
1799 }
1800
1801 static LRESULT
1802 REBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam)
1803 {
1804     REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd);
1805     /* DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); */
1806     RECT rcParent;
1807     /* INT32 x, y, cx, cy; */
1808
1809     /* auto resize deadlock check */
1810     if (infoPtr->bAutoResize) {
1811         infoPtr->bAutoResize = FALSE;
1812         return 0;
1813     }
1814
1815     TRACE("sizing rebar!\n");
1816
1817     /* get parent rectangle */
1818     GetClientRect (GetParent (hwnd), &rcParent);
1819 /*
1820     REBAR_Layout (hwnd, &rcParent);
1821
1822     if (dwStyle & CCS_VERT) {
1823         if (dwStyle & CCS_LEFT == CCS_LEFT) {
1824             x = rcParent.left;
1825             y = rcParent.top;
1826             cx = infoPtr->calcSize.cx;
1827             cy = infoPtr->calcSize.cy;
1828         }
1829         else {
1830             x = rcParent.right - infoPtr->calcSize.cx;
1831             y = rcParent.top;
1832             cx = infoPtr->calcSize.cx;
1833             cy = infoPtr->calcSize.cy;
1834         }
1835     }
1836     else {
1837         if (dwStyle & CCS_TOP) {
1838             x = rcParent.left;
1839             y = rcParent.top;
1840             cx = infoPtr->calcSize.cx;
1841             cy = infoPtr->calcSize.cy;
1842         }
1843         else {
1844             x = rcParent.left;
1845             y = rcParent.bottom - infoPtr->calcSize.cy;
1846             cx = infoPtr->calcSize.cx;
1847             cy = infoPtr->calcSize.cy;
1848         }
1849     }
1850
1851     SetWindowPos32 (hwnd, 0, x, y, cx, cy,
1852                     SWP_NOZORDER | SWP_SHOWWINDOW);
1853 */
1854     REBAR_Layout (hwnd, NULL);
1855     REBAR_ForceResize (hwnd);
1856     REBAR_MoveChildWindows (hwnd);
1857
1858     return 0;
1859 }
1860
1861
1862 static LRESULT WINAPI
1863 REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1864 {
1865     switch (uMsg)
1866     {
1867 /*      case RB_BEGINDRAG: */
1868
1869         case RB_DELETEBAND:
1870             return REBAR_DeleteBand (hwnd, wParam, lParam);
1871
1872 /*      case RB_DRAGMOVE: */
1873 /*      case RB_ENDDRAG: */
1874
1875         case RB_GETBANDBORDERS:
1876             return REBAR_GetBandBorders (hwnd, wParam, lParam);
1877
1878         case RB_GETBANDCOUNT:
1879             return REBAR_GetBandCount (hwnd);
1880
1881 /*      case RB_GETBANDINFO32:  */ /* outdated, just for compatibility */
1882
1883         case RB_GETBANDINFOA:
1884             return REBAR_GetBandInfoA (hwnd, wParam, lParam);
1885
1886         case RB_GETBANDINFOW:
1887             return REBAR_GetBandInfoW (hwnd, wParam, lParam);
1888
1889         case RB_GETBARHEIGHT:
1890             return REBAR_GetBarHeight (hwnd, wParam, lParam);
1891
1892         case RB_GETBARINFO:
1893             return REBAR_GetBarInfo (hwnd, wParam, lParam);
1894
1895         case RB_GETBKCOLOR:
1896             return REBAR_GetBkColor (hwnd);
1897
1898 /*      case RB_GETCOLORSCHEME: */
1899 /*      case RB_GETDROPTARGET: */
1900
1901         case RB_GETPALETTE:
1902             return REBAR_GetPalette (hwnd, wParam, lParam);
1903
1904         case RB_GETRECT:
1905             return REBAR_GetRect (hwnd, wParam, lParam);
1906
1907         case RB_GETROWCOUNT:
1908             return REBAR_GetRowCount (hwnd);
1909
1910         case RB_GETROWHEIGHT:
1911             return REBAR_GetRowHeight (hwnd, wParam, lParam);
1912
1913         case RB_GETTEXTCOLOR:
1914             return REBAR_GetTextColor (hwnd);
1915
1916         case RB_GETTOOLTIPS:
1917             return REBAR_GetToolTips (hwnd);
1918
1919         case RB_GETUNICODEFORMAT:
1920             return REBAR_GetUnicodeFormat (hwnd);
1921
1922         case RB_HITTEST:
1923             return REBAR_HitTest (hwnd, wParam, lParam);
1924
1925         case RB_IDTOINDEX:
1926             return REBAR_IdToIndex (hwnd, wParam, lParam);
1927
1928         case RB_INSERTBANDA:
1929             return REBAR_InsertBandA (hwnd, wParam, lParam);
1930
1931         case RB_INSERTBANDW:
1932             return REBAR_InsertBandW (hwnd, wParam, lParam);
1933
1934         case RB_MAXIMIZEBAND:
1935             return REBAR_MaximizeBand (hwnd, wParam, lParam);
1936
1937         case RB_MINIMIZEBAND:
1938             return REBAR_MinimizeBand (hwnd, wParam, lParam);
1939
1940         case RB_MOVEBAND:
1941             return REBAR_MoveBand (hwnd, wParam, lParam);
1942
1943         case RB_SETBANDINFOA:
1944             return REBAR_SetBandInfoA (hwnd, wParam, lParam);
1945
1946         case RB_SETBANDINFOW:
1947             return REBAR_SetBandInfoW (hwnd, wParam, lParam);
1948
1949         case RB_SETBARINFO:
1950             return REBAR_SetBarInfo (hwnd, wParam, lParam);
1951
1952         case RB_SETBKCOLOR:
1953             return REBAR_SetBkColor (hwnd, wParam, lParam);
1954
1955 /*      case RB_SETCOLORSCHEME: */
1956 /*      case RB_SETPALETTE: */
1957 /*          return REBAR_GetPalette (hwnd, wParam, lParam); */
1958
1959         case RB_SETPARENT:
1960             return REBAR_SetParent (hwnd, wParam, lParam);
1961
1962         case RB_SETTEXTCOLOR:
1963             return REBAR_SetTextColor (hwnd, wParam, lParam);
1964
1965 /*      case RB_SETTOOLTIPS: */
1966
1967         case RB_SETUNICODEFORMAT:
1968             return REBAR_SetUnicodeFormat (hwnd, wParam);
1969
1970         case RB_SHOWBAND:
1971             return REBAR_ShowBand (hwnd, wParam, lParam);
1972
1973         case RB_SIZETORECT:
1974             return REBAR_SizeToRect (hwnd, wParam, lParam);
1975
1976
1977         case WM_COMMAND:
1978             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
1979
1980         case WM_CREATE:
1981             return REBAR_Create (hwnd, wParam, lParam);
1982
1983         case WM_DESTROY:
1984             return REBAR_Destroy (hwnd, wParam, lParam);
1985
1986         case WM_GETFONT:
1987             return REBAR_GetFont (hwnd, wParam, lParam);
1988
1989 /*      case WM_MOUSEMOVE: */
1990 /*          return REBAR_MouseMove (hwnd, wParam, lParam); */
1991
1992         case WM_NCCALCSIZE:
1993             return REBAR_NCCalcSize (hwnd, wParam, lParam);
1994
1995         case WM_NCPAINT:
1996             return REBAR_NCPaint (hwnd, wParam, lParam);
1997
1998         case WM_NOTIFY:
1999             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
2000
2001         case WM_PAINT:
2002             return REBAR_Paint (hwnd, wParam);
2003
2004         case WM_SETCURSOR:
2005             return REBAR_SetCursor (hwnd, wParam, lParam);
2006
2007         case WM_SETFONT:
2008             return REBAR_SetFont (hwnd, wParam, lParam);
2009
2010         case WM_SIZE:
2011             return REBAR_Size (hwnd, wParam, lParam);
2012
2013 /*      case WM_TIMER: */
2014
2015 /*      case WM_WININICHANGE: */
2016
2017         default:
2018             if (uMsg >= WM_USER)
2019                 ERR("unknown msg %04x wp=%08x lp=%08lx\n",
2020                      uMsg, wParam, lParam);
2021             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
2022     }
2023     return 0;
2024 }
2025
2026
2027 VOID
2028 REBAR_Register (void)
2029 {
2030     WNDCLASSA wndClass;
2031
2032     if (GlobalFindAtomA (REBARCLASSNAMEA)) return;
2033
2034     ZeroMemory (&wndClass, sizeof(WNDCLASSA));
2035     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS;
2036     wndClass.lpfnWndProc   = (WNDPROC)REBAR_WindowProc;
2037     wndClass.cbClsExtra    = 0;
2038     wndClass.cbWndExtra    = sizeof(REBAR_INFO *);
2039     wndClass.hCursor       = 0;
2040     wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
2041     wndClass.lpszClassName = REBARCLASSNAMEA;
2042  
2043     RegisterClassA (&wndClass);
2044 }
2045
2046
2047 VOID
2048 REBAR_Unregister (void)
2049 {
2050     if (GlobalFindAtomA (REBARCLASSNAMEA))
2051         UnregisterClassA (REBARCLASSNAMEA, (HINSTANCE)NULL);
2052 }
2053