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