comctl32: statusbar: Rename NtfUnicode to bUnicode to make is more consistent with...
[wine] / dlls / comctl32 / status.c
1 /*
2  * Interface code to StatusWindow widget/control
3  *
4  * Copyright 1996 Bruce Milner
5  * Copyright 1998, 1999 Eric Kohl
6  * Copyright 2002 Dimitrie O. Paun
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  *
22  * NOTE
23  * 
24  * This code was audited for completeness against the documented features
25  * of Comctl32.dll version 6.0 on Sep. 24, 2002, by Dimitrie O. Paun.
26  * 
27  * Unless otherwise noted, we believe this code to be complete, as per
28  * the specification mentioned above.
29  * If you discover missing features, or bugs, please note them below.
30  * 
31  * TODO:
32  *      -- CCS_BOTTOM (default)
33  *      -- CCS_LEFT
34  *      -- CCS_NODIVIDER
35  *      -- CCS_NOMOVEX
36  *      -- CCS_NOMOVEY
37  *      -- CCS_NOPARENTALIGN
38  *      -- CCS_RIGHT
39  *      -- CCS_TOP
40  *      -- CCS_VERT (defaults to RIGHT)
41  */
42
43 #include <stdarg.h>
44 #include <string.h>
45
46 #include "windef.h"
47 #include "winbase.h"
48 #include "wine/unicode.h"
49 #include "wingdi.h"
50 #include "winuser.h"
51 #include "winnls.h"
52 #include "commctrl.h"
53 #include "comctl32.h"
54 #include "uxtheme.h"
55 #include "tmschema.h"
56 #include "wine/debug.h"
57
58 WINE_DEFAULT_DEBUG_CHANNEL(statusbar);
59
60 typedef struct
61 {
62     INT         x;
63     INT         style;
64     RECT        bound;
65     LPWSTR      text;
66     HICON       hIcon;
67 } STATUSWINDOWPART;
68
69 typedef struct
70 {
71     HWND              Self;
72     HWND              Notify;
73     WORD              numParts;
74     UINT              height;
75     BOOL              simple;
76     HWND              hwndToolTip;
77     HFONT             hFont;
78     HFONT             hDefaultFont;
79     COLORREF          clrBk;            /* background color */
80     BOOL              bUnicode;         /* notify format. TRUE if notifies in Unicode */
81     STATUSWINDOWPART  part0;            /* simple window */
82     STATUSWINDOWPART* parts;
83     INT               horizontalBorder;
84     INT               verticalBorder;
85     INT               horizontalGap;
86 } STATUS_INFO;
87
88 /*
89  * Run tests using Waite Group Windows95 API Bible Vol. 1&2
90  * The second cdrom contains executables drawstat.exe, gettext.exe,
91  * simple.exe, getparts.exe, setparts.exe, statwnd.exe
92  */
93
94 #define HORZ_BORDER 0
95 #define VERT_BORDER 2
96 #define HORZ_GAP    2
97
98 static const WCHAR themeClass[] = { 'S','t','a','t','u','s',0 };
99
100 /* prototype */
101 static void
102 STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr);
103 static LRESULT
104 STATUSBAR_NotifyFormat (STATUS_INFO *infoPtr, HWND from, INT cmd);
105
106 static inline LPCSTR debugstr_t(LPCWSTR text, BOOL isW)
107 {
108   return isW ? debugstr_w(text) : debugstr_a((LPCSTR)text);
109 }
110
111 static void
112 STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect)
113 {
114     HPEN hPenFace, hPenShadow, hPenHighlight, hOldPen;
115     POINT pt;
116     INT i;
117
118     TRACE("draw size grip %s\n", wine_dbgstr_rect(lpRect));
119
120     if (theme)
121     {
122         RECT gripperRect;
123         SIZE gripperSize;
124         gripperRect = *lpRect;
125         if (SUCCEEDED (GetThemePartSize (theme, hdc, SP_GRIPPER, 0, lpRect, 
126             TS_DRAW, &gripperSize)))
127         {
128             gripperRect.left = gripperRect.right - gripperSize.cx;
129             gripperRect.top = gripperRect.bottom - gripperSize.cy;
130             if (SUCCEEDED (DrawThemeBackground(theme, hdc, SP_GRIPPER, 0, &gripperRect, NULL)))
131                 return;
132         }
133     }
134
135     pt.x = lpRect->right - 1;
136     pt.y = lpRect->bottom - 1;
137
138     hPenFace = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DFACE ));
139     hOldPen = SelectObject( hdc, hPenFace );
140     MoveToEx (hdc, pt.x - 12, pt.y, NULL);
141     LineTo (hdc, pt.x, pt.y);
142     LineTo (hdc, pt.x, pt.y - 13);
143
144     pt.x--;
145     pt.y--;
146
147     hPenShadow = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DSHADOW ));
148     SelectObject( hdc, hPenShadow );
149     for (i = 1; i < 11; i += 4) {
150         MoveToEx (hdc, pt.x - i, pt.y, NULL);
151         LineTo (hdc, pt.x + 1, pt.y - i - 1);
152
153         MoveToEx (hdc, pt.x - i - 1, pt.y, NULL);
154         LineTo (hdc, pt.x + 1, pt.y - i - 2);
155     }
156
157     hPenHighlight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DHIGHLIGHT ));
158     SelectObject( hdc, hPenHighlight );
159     for (i = 3; i < 13; i += 4) {
160         MoveToEx (hdc, pt.x - i, pt.y, NULL);
161         LineTo (hdc, pt.x + 1, pt.y - i - 1);
162     }
163
164     SelectObject (hdc, hOldPen);
165     DeleteObject( hPenFace );
166     DeleteObject( hPenShadow );
167     DeleteObject( hPenHighlight );
168 }
169
170
171 static void
172 STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID)
173 {
174     RECT r = part->bound;
175     UINT border = BDR_SUNKENOUTER;
176     HTHEME theme = GetWindowTheme (infoPtr->Self);
177     int themePart = SP_PANE;
178
179     TRACE("part bound %s\n", wine_dbgstr_rect(&r));
180     if (part->style & SBT_POPOUT)
181         border = BDR_RAISEDOUTER;
182     else if (part->style & SBT_NOBORDERS)
183         border = 0;
184
185     if (theme)
186     {
187         if ((GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
188             && (infoPtr->simple || (itemID == (infoPtr->numParts-1))))
189             themePart = SP_GRIPPERPANE;
190         DrawThemeBackground(theme, hdc, themePart, 0, &r, NULL);
191     }
192     else
193         DrawEdge(hdc, &r, border, BF_RECT|BF_ADJUST);
194
195     if (part->style & SBT_OWNERDRAW) {
196         DRAWITEMSTRUCT dis;
197
198         dis.CtlID = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
199         dis.itemID = itemID;
200         dis.hwndItem = infoPtr->Self;
201         dis.hDC = hdc;
202         dis.rcItem = r;
203         dis.itemData = (ULONG_PTR)part->text;
204         SendMessageW (infoPtr->Notify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis);
205     } else {
206         if (part->hIcon) {
207            INT cy = r.bottom - r.top;
208
209             r.left += 2;
210             DrawIconEx (hdc, r.left, r.top, part->hIcon, cy, cy, 0, 0, DI_NORMAL);
211             r.left += cy;
212         }
213         DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS);
214     }
215 }
216
217
218 static void
219 STATUSBAR_RefreshPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID)
220 {
221     HBRUSH hbrBk;
222     HFONT  hOldFont;
223     HTHEME theme;
224
225     TRACE("item %d\n", itemID);
226     if (!IsWindowVisible (infoPtr->Self))
227         return;
228
229     if (part->bound.right < part->bound.left) return;
230
231     if ((theme = GetWindowTheme (infoPtr->Self)))
232     {
233         RECT cr;
234         GetClientRect (infoPtr->Self, &cr);
235         DrawThemeBackground(theme, hdc, 0, 0, &cr, &part->bound);
236     }
237     else
238     {
239         if (infoPtr->clrBk != CLR_DEFAULT)
240                 hbrBk = CreateSolidBrush (infoPtr->clrBk);
241         else
242                 hbrBk = GetSysColorBrush (COLOR_3DFACE);
243         FillRect(hdc, &part->bound, hbrBk);
244         if (infoPtr->clrBk != CLR_DEFAULT)
245                 DeleteObject (hbrBk);
246     }
247
248     hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
249
250         STATUSBAR_DrawPart (infoPtr, hdc, part, itemID);
251
252     SelectObject (hdc, hOldFont);
253
254     if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) {
255         RECT rect;
256
257         GetClientRect (infoPtr->Self, &rect);
258         STATUSBAR_DrawSizeGrip (theme, hdc, &rect);
259     }
260 }
261
262
263 static LRESULT
264 STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc)
265 {
266     int      i;
267     RECT   rect;
268     HBRUSH hbrBk;
269     HFONT  hOldFont;
270     HTHEME theme;
271
272     TRACE("\n");
273     if (!IsWindowVisible(infoPtr->Self))
274         return 0;
275
276     STATUSBAR_SetPartBounds(infoPtr);
277
278     GetClientRect (infoPtr->Self, &rect);
279
280     if ((theme = GetWindowTheme (infoPtr->Self)))
281     {
282         DrawThemeBackground(theme, hdc, 0, 0, &rect, NULL);
283     }
284     else
285     {
286         if (infoPtr->clrBk != CLR_DEFAULT)
287             hbrBk = CreateSolidBrush (infoPtr->clrBk);
288         else
289             hbrBk = GetSysColorBrush (COLOR_3DFACE);
290         FillRect(hdc, &rect, hbrBk);
291         if (infoPtr->clrBk != CLR_DEFAULT)
292             DeleteObject (hbrBk);
293     }
294
295     hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont);
296
297     if (infoPtr->simple) {
298         STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0);
299     } else {
300         for (i = 0; i < infoPtr->numParts; i++) {
301             STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i);
302         }
303     }
304
305     SelectObject (hdc, hOldFont);
306
307     if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP)
308             STATUSBAR_DrawSizeGrip (theme, hdc, &rect);
309
310     return 0;
311 }
312
313
314 static int
315 STATUSBAR_InternalHitTest(const STATUS_INFO *infoPtr, const LPPOINT pt)
316 {
317     int i;
318     if (infoPtr->simple)
319         return 255;
320
321     for (i = 0; i < infoPtr->numParts; i++)
322         if (pt->x >= infoPtr->parts[i].bound.left && pt->x <= infoPtr->parts[i].bound.right)
323             return i;
324     return -2;
325 }
326
327
328 static void
329 STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr)
330 {
331     STATUSWINDOWPART *part;
332     RECT rect, *r;
333     int i;
334
335     /* get our window size */
336     GetClientRect (infoPtr->Self, &rect);
337     TRACE("client wnd size is %s\n", wine_dbgstr_rect(&rect));
338
339     rect.left += infoPtr->horizontalBorder;
340     rect.top += infoPtr->verticalBorder;
341
342     /* set bounds for simple rectangle */
343     infoPtr->part0.bound = rect;
344
345     /* set bounds for non-simple rectangles */
346     for (i = 0; i < infoPtr->numParts; i++) {
347         part = &infoPtr->parts[i];
348         r = &infoPtr->parts[i].bound;
349         r->top = rect.top;
350         r->bottom = rect.bottom;
351         if (i == 0)
352             r->left = 0;
353         else
354             r->left = infoPtr->parts[i-1].bound.right + infoPtr->horizontalGap;
355         if (part->x == -1)
356             r->right = rect.right;
357         else
358             r->right = part->x;
359
360         if (infoPtr->hwndToolTip) {
361             TTTOOLINFOW ti;
362
363             ti.cbSize = sizeof(TTTOOLINFOW);
364             ti.hwnd = infoPtr->Self;
365             ti.uId = i;
366             ti.rect = *r;
367             SendMessageW (infoPtr->hwndToolTip, TTM_NEWTOOLRECTW,
368                             0, (LPARAM)&ti);
369         }
370     }
371 }
372
373
374 static LRESULT
375 STATUSBAR_Relay2Tip (const STATUS_INFO *infoPtr, UINT uMsg,
376                      WPARAM wParam, LPARAM lParam)
377 {
378     MSG msg;
379
380     msg.hwnd = infoPtr->Self;
381     msg.message = uMsg;
382     msg.wParam = wParam;
383     msg.lParam = lParam;
384     msg.time = GetMessageTime ();
385     msg.pt.x = (short)LOWORD(GetMessagePos ());
386     msg.pt.y = (short)HIWORD(GetMessagePos ());
387
388     return SendMessageW (infoPtr->hwndToolTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
389 }
390
391
392 static BOOL
393 STATUSBAR_GetBorders (const STATUS_INFO *infoPtr, INT out[])
394 {
395     TRACE("\n");
396     out[0] = infoPtr->horizontalBorder;
397     out[1] = infoPtr->verticalBorder;
398     out[2] = infoPtr->horizontalGap;
399
400     return TRUE;
401 }
402
403
404 static BOOL
405 STATUSBAR_SetBorders (STATUS_INFO *infoPtr, const INT in[])
406 {
407     TRACE("\n");
408     infoPtr->horizontalBorder = in[0];
409     infoPtr->verticalBorder = in[1];
410     infoPtr->horizontalGap = in[2];
411     InvalidateRect(infoPtr->Self, NULL, FALSE);
412
413     return TRUE;
414 }
415
416
417 static HICON
418 STATUSBAR_GetIcon (const STATUS_INFO *infoPtr, INT nPart)
419 {
420     TRACE("%d\n", nPart);
421     /* MSDN says: "simple parts are indexed with -1" */
422     if ((nPart < -1) || (nPart >= infoPtr->numParts))
423         return 0;
424
425     if (nPart == -1)
426         return (infoPtr->part0.hIcon);
427     else
428         return (infoPtr->parts[nPart].hIcon);
429 }
430
431
432 static INT
433 STATUSBAR_GetParts (const STATUS_INFO *infoPtr, INT num_parts, INT parts[])
434 {
435     INT   i;
436
437     TRACE("(%d)\n", num_parts);
438     if (parts) {
439         for (i = 0; i < num_parts; i++) {
440             parts[i] = infoPtr->parts[i].x;
441         }
442     }
443     return infoPtr->numParts;
444 }
445
446
447 static BOOL
448 STATUSBAR_GetRect (const STATUS_INFO *infoPtr, INT nPart, LPRECT rect)
449 {
450     TRACE("part %d\n", nPart);
451     if(nPart >= infoPtr->numParts || nPart < 0)
452       return FALSE;
453     if (infoPtr->simple)
454         *rect = infoPtr->part0.bound;
455     else
456         *rect = infoPtr->parts[nPart].bound;
457     return TRUE;
458 }
459
460
461 static LRESULT
462 STATUSBAR_GetTextA (STATUS_INFO *infoPtr, INT nPart, LPSTR buf)
463 {
464     STATUSWINDOWPART *part;
465     LRESULT result;
466
467     TRACE("part %d\n", nPart);
468
469     /* MSDN says: "simple parts use index of 0", so this check is ok. */
470     if (nPart < 0 || nPart >= infoPtr->numParts) return 0;
471
472     if (infoPtr->simple)
473         part = &infoPtr->part0;
474     else
475         part = &infoPtr->parts[nPart];
476
477     if (part->style & SBT_OWNERDRAW)
478         result = (LRESULT)part->text;
479     else {
480         DWORD len = part->text ? WideCharToMultiByte( CP_ACP, 0, part->text, -1,
481                                                       NULL, 0, NULL, NULL ) - 1 : 0;
482         result = MAKELONG( len, part->style );
483         if (part->text && buf)
484             WideCharToMultiByte( CP_ACP, 0, part->text, -1, buf, len+1, NULL, NULL );
485     }
486     return result;
487 }
488
489
490 static LRESULT
491 STATUSBAR_GetTextW (STATUS_INFO *infoPtr, INT nPart, LPWSTR buf)
492 {
493     STATUSWINDOWPART *part;
494     LRESULT result;
495
496     TRACE("part %d\n", nPart);
497     if (nPart < 0 || nPart >= infoPtr->numParts) return 0;
498
499     if (infoPtr->simple)
500         part = &infoPtr->part0;
501     else
502         part = &infoPtr->parts[nPart];
503
504     if (part->style & SBT_OWNERDRAW)
505         result = (LRESULT)part->text;
506     else {
507         result = part->text ? strlenW (part->text) : 0;
508         result |= (part->style << 16);
509         if (part->text && buf)
510             strcpyW (buf, part->text);
511     }
512     return result;
513 }
514
515
516 static LRESULT
517 STATUSBAR_GetTextLength (STATUS_INFO *infoPtr, INT nPart)
518 {
519     STATUSWINDOWPART *part;
520     DWORD result;
521
522     TRACE("part %d\n", nPart);
523
524     /* MSDN says: "simple parts use index of 0", so this check is ok. */
525     if (nPart < 0 || nPart >= infoPtr->numParts) return 0;
526
527     if (infoPtr->simple)
528         part = &infoPtr->part0;
529     else
530         part = &infoPtr->parts[nPart];
531
532     if ((~part->style & SBT_OWNERDRAW) && part->text)
533         result = strlenW(part->text);
534     else
535         result = 0;
536
537     result |= (part->style << 16);
538     return result;
539 }
540
541 static LRESULT
542 STATUSBAR_GetTipTextA (const STATUS_INFO *infoPtr, INT id, LPSTR tip, INT size)
543 {
544     TRACE("\n");
545     if (tip) {
546         CHAR buf[INFOTIPSIZE];
547         buf[0]='\0';
548
549         if (infoPtr->hwndToolTip) {
550             TTTOOLINFOA ti;
551             ti.cbSize = sizeof(TTTOOLINFOA);
552             ti.hwnd = infoPtr->Self;
553             ti.uId = id;
554             ti.lpszText = buf;
555             SendMessageA (infoPtr->hwndToolTip, TTM_GETTEXTA, 0, (LPARAM)&ti);
556         }
557         lstrcpynA (tip, buf, size);
558     }
559     return 0;
560 }
561
562
563 static LRESULT
564 STATUSBAR_GetTipTextW (const STATUS_INFO *infoPtr, INT id, LPWSTR tip, INT size)
565 {
566     TRACE("\n");
567     if (tip) {
568         WCHAR buf[INFOTIPSIZE];
569         buf[0]=0;
570
571         if (infoPtr->hwndToolTip) {
572             TTTOOLINFOW ti;
573             ti.cbSize = sizeof(TTTOOLINFOW);
574             ti.hwnd = infoPtr->Self;
575             ti.uId = id;
576             ti.lpszText = buf;
577             SendMessageW(infoPtr->hwndToolTip, TTM_GETTEXTW, 0, (LPARAM)&ti);
578         }
579         lstrcpynW(tip, buf, size);
580     }
581
582     return 0;
583 }
584
585
586 static COLORREF
587 STATUSBAR_SetBkColor (STATUS_INFO *infoPtr, COLORREF color)
588 {
589     COLORREF oldBkColor;
590
591     oldBkColor = infoPtr->clrBk;
592     infoPtr->clrBk = color;
593     InvalidateRect(infoPtr->Self, NULL, FALSE);
594
595     TRACE("CREF: %08x -> %08x\n", oldBkColor, infoPtr->clrBk);
596     return oldBkColor;
597 }
598
599
600 static BOOL
601 STATUSBAR_SetIcon (STATUS_INFO *infoPtr, INT nPart, HICON hIcon)
602 {
603     if ((nPart < -1) || (nPart >= infoPtr->numParts))
604         return FALSE;
605
606     TRACE("setting part %d\n", nPart);
607
608     /* FIXME: MSDN says "if nPart is -1, the status bar is assumed simple" */
609     if (nPart == -1) {
610         if (infoPtr->part0.hIcon == hIcon) /* same as - no redraw */
611             return TRUE;
612         infoPtr->part0.hIcon = hIcon;
613         if (infoPtr->simple)
614             InvalidateRect(infoPtr->Self, &infoPtr->part0.bound, FALSE);
615     } else {
616         if (infoPtr->parts[nPart].hIcon == hIcon) /* same as - no redraw */
617             return TRUE;
618
619         infoPtr->parts[nPart].hIcon = hIcon;
620         if (!(infoPtr->simple))
621             InvalidateRect(infoPtr->Self, &infoPtr->parts[nPart].bound, FALSE);
622     }
623     return TRUE;
624 }
625
626
627 static BOOL
628 STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height)
629 {
630
631     TRACE("(height=%d)\n", height);
632     if (IsWindowVisible (infoPtr->Self)) {
633         INT  width, x, y;
634         RECT parent_rect;
635         HTHEME theme;
636
637         infoPtr->height = height + infoPtr->verticalBorder;
638         
639         if ((theme = GetWindowTheme (infoPtr->Self)))
640         {
641             /* Determine bar height from theme such that the content area is
642              * 'height' pixels large */
643             HDC hdc = GetDC (infoPtr->Self);
644             RECT r;
645             memset (&r, 0, sizeof (r));
646             r.bottom = height;
647             if (SUCCEEDED(GetThemeBackgroundExtent (theme, hdc, SP_PANE, 0, &r, &r)))
648             {
649                 infoPtr->height = r.bottom - r.top;
650             }
651             ReleaseDC (infoPtr->Self, hdc);
652         }
653         
654         if (GetClientRect (infoPtr->Notify, &parent_rect))
655         {
656             width = parent_rect.right - parent_rect.left;
657             x = parent_rect.left;
658             y = parent_rect.bottom - infoPtr->height;
659             MoveWindow (infoPtr->Self, x, y, width, infoPtr->height, TRUE);
660             STATUSBAR_SetPartBounds (infoPtr);
661         }
662     }
663
664     return TRUE;
665 }
666
667
668 static BOOL
669 STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts)
670 {
671     STATUSWINDOWPART *tmp;
672     UINT i, oldNumParts;
673
674     TRACE("(%d,%p)\n", count, parts);
675
676     oldNumParts = infoPtr->numParts;
677     infoPtr->numParts = count;
678     if (oldNumParts > infoPtr->numParts) {
679         for (i = infoPtr->numParts ; i < oldNumParts; i++) {
680             if (!(infoPtr->parts[i].style & SBT_OWNERDRAW))
681                 Free (infoPtr->parts[i].text);
682         }
683     } else if (oldNumParts < infoPtr->numParts) {
684         tmp = Alloc (sizeof(STATUSWINDOWPART) * infoPtr->numParts);
685         if (!tmp) return FALSE;
686         for (i = 0; i < oldNumParts; i++) {
687             tmp[i] = infoPtr->parts[i];
688         }
689         Free (infoPtr->parts);
690         infoPtr->parts = tmp;
691     }
692     if (oldNumParts == infoPtr->numParts) {
693         for (i=0; i < oldNumParts; i++)
694             if (infoPtr->parts[i].x != parts[i])
695                 break;
696         if (i==oldNumParts) /* Unchanged? no need to redraw! */
697             return TRUE;
698     }
699
700     for (i = 0; i < infoPtr->numParts; i++)
701         infoPtr->parts[i].x = parts[i];
702
703     if (infoPtr->hwndToolTip) {
704         UINT nTipCount;
705         TTTOOLINFOW ti;
706
707         ZeroMemory (&ti, sizeof(TTTOOLINFOW));
708         ti.cbSize = sizeof(TTTOOLINFOW);
709         ti.hwnd = infoPtr->Self;
710
711         nTipCount = SendMessageW (infoPtr->hwndToolTip, TTM_GETTOOLCOUNT, 0, 0);
712         if (nTipCount < infoPtr->numParts) {
713             /* add tools */
714             for (i = nTipCount; i < infoPtr->numParts; i++) {
715                 TRACE("add tool %d\n", i);
716                 ti.uId = i;
717                 SendMessageW (infoPtr->hwndToolTip, TTM_ADDTOOLW,
718                                 0, (LPARAM)&ti);
719             }
720         }
721         else if (nTipCount > infoPtr->numParts) {
722             /* delete tools */
723             for (i = nTipCount - 1; i >= infoPtr->numParts; i--) {
724                 TRACE("delete tool %d\n", i);
725                 ti.uId = i;
726                 SendMessageW (infoPtr->hwndToolTip, TTM_DELTOOLW,
727                                 0, (LPARAM)&ti);
728             }
729         }
730     }
731     STATUSBAR_SetPartBounds (infoPtr);
732     InvalidateRect(infoPtr->Self, NULL, FALSE);
733     return TRUE;
734 }
735
736
737 static BOOL
738 STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
739                     LPCWSTR text, BOOL isW)
740 {
741     STATUSWINDOWPART *part=NULL;
742     BOOL changed = FALSE;
743     INT  oldStyle;
744
745     if (style & SBT_OWNERDRAW) {
746          TRACE("part %d, text %p\n",nPart,text);
747     }
748     else TRACE("part %d, text %s\n", nPart, debugstr_t(text, isW));
749
750     /* MSDN says: "If the parameter is set to SB_SIMPLEID (255), the status
751      * window is assumed to be a simple window */
752
753     if (nPart == 0x00ff) {
754         part = &infoPtr->part0;
755     } else {
756         if (infoPtr->parts && nPart >= 0 && nPart < infoPtr->numParts) {
757             part = &infoPtr->parts[nPart];
758         }
759     }
760     if (!part) return FALSE;
761
762     if (part->style != style)
763         changed = TRUE;
764
765     oldStyle = part->style;
766     part->style = style;
767     if (style & SBT_OWNERDRAW) {
768         if (!(oldStyle & SBT_OWNERDRAW))
769             Free (part->text);
770         else if (part->text == text)
771             return TRUE;
772         part->text = (LPWSTR)text;
773     } else {
774         LPWSTR ntext;
775
776         if (text && !isW) {
777             LPCSTR atxt = (LPCSTR)text;
778             DWORD len = MultiByteToWideChar( CP_ACP, 0, atxt, -1, NULL, 0 );
779             ntext = Alloc( (len + 1)*sizeof(WCHAR) );
780             if (!ntext) return FALSE;
781             MultiByteToWideChar( CP_ACP, 0, atxt, -1, ntext, len );
782         } else if (text) {
783             ntext = Alloc( (strlenW(text) + 1)*sizeof(WCHAR) );
784             if (!ntext) return FALSE;
785             strcpyW (ntext, text);
786         } else ntext = 0;
787
788         /* check if text is unchanged -> no need to redraw */
789         if (text) {
790             if (!changed && part->text && !lstrcmpW(ntext, part->text)) {
791                 Free(ntext);
792                 return TRUE;
793             }
794         } else {
795             if (!changed && !part->text)
796                 return TRUE;
797         }
798
799         if (!(oldStyle & SBT_OWNERDRAW))
800             Free (part->text);
801         part->text = ntext;
802     }
803     InvalidateRect(infoPtr->Self, &part->bound, FALSE);
804     UpdateWindow(infoPtr->Self);
805
806     return TRUE;
807 }
808
809
810 static LRESULT
811 STATUSBAR_SetTipTextA (const STATUS_INFO *infoPtr, INT id, LPSTR text)
812 {
813     TRACE("part %d: \"%s\"\n", id, text);
814     if (infoPtr->hwndToolTip) {
815         TTTOOLINFOA ti;
816         ti.cbSize = sizeof(TTTOOLINFOA);
817         ti.hwnd = infoPtr->Self;
818         ti.uId = id;
819         ti.hinst = 0;
820         ti.lpszText = text;
821         SendMessageA (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTA, 0, (LPARAM)&ti);
822     }
823
824     return 0;
825 }
826
827
828 static LRESULT
829 STATUSBAR_SetTipTextW (const STATUS_INFO *infoPtr, INT id, LPWSTR text)
830 {
831     TRACE("part %d: \"%s\"\n", id, debugstr_w(text));
832     if (infoPtr->hwndToolTip) {
833         TTTOOLINFOW ti;
834         ti.cbSize = sizeof(TTTOOLINFOW);
835         ti.hwnd = infoPtr->Self;
836         ti.uId = id;
837         ti.hinst = 0;
838         ti.lpszText = text;
839         SendMessageW (infoPtr->hwndToolTip, TTM_UPDATETIPTEXTW, 0, (LPARAM)&ti);
840     }
841
842     return 0;
843 }
844
845
846 static inline LRESULT
847 STATUSBAR_SetUnicodeFormat (STATUS_INFO *infoPtr, BOOL bUnicode)
848 {
849     BOOL bOld = infoPtr->bUnicode;
850
851     TRACE("(0x%x)\n", bUnicode);
852     infoPtr->bUnicode = bUnicode;
853
854     return bOld;
855 }
856
857
858 static BOOL
859 STATUSBAR_Simple (STATUS_INFO *infoPtr, BOOL simple)
860 {
861     NMHDR  nmhdr;
862
863     TRACE("(simple=%d)\n", simple);
864     if (infoPtr->simple == simple) /* no need to change */
865         return TRUE;
866
867     infoPtr->simple = simple;
868
869     /* send notification */
870     nmhdr.hwndFrom = infoPtr->Self;
871     nmhdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
872     nmhdr.code = SBN_SIMPLEMODECHANGE;
873     SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
874     InvalidateRect(infoPtr->Self, NULL, FALSE);
875     return TRUE;
876 }
877
878
879 static LRESULT
880 STATUSBAR_WMDestroy (STATUS_INFO *infoPtr)
881 {
882     int i;
883
884     TRACE("\n");
885     for (i = 0; i < infoPtr->numParts; i++) {
886         if (!(infoPtr->parts[i].style & SBT_OWNERDRAW))
887             Free (infoPtr->parts[i].text);
888     }
889     if (!(infoPtr->part0.style & SBT_OWNERDRAW))
890         Free (infoPtr->part0.text);
891     Free (infoPtr->parts);
892
893     /* delete default font */
894     if (infoPtr->hDefaultFont)
895         DeleteObject (infoPtr->hDefaultFont);
896
897     /* delete tool tip control */
898     if (infoPtr->hwndToolTip)
899         DestroyWindow (infoPtr->hwndToolTip);
900
901     CloseThemeData (GetWindowTheme (infoPtr->Self));
902
903     SetWindowLongPtrW(infoPtr->Self, 0, 0);
904     Free (infoPtr);
905     return 0;
906 }
907
908
909 static LRESULT
910 STATUSBAR_WMCreate (HWND hwnd, const CREATESTRUCTA *lpCreate)
911 {
912     STATUS_INFO *infoPtr;
913     NONCLIENTMETRICSW nclm;
914     DWORD dwStyle;
915     RECT rect;
916     int width, len, textHeight = 0;
917     HDC hdc;
918
919     TRACE("\n");
920     infoPtr = (STATUS_INFO*)Alloc (sizeof(STATUS_INFO));
921     if (!infoPtr) goto create_fail;
922     SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr);
923
924     infoPtr->Self = hwnd;
925     infoPtr->Notify = lpCreate->hwndParent;
926     infoPtr->numParts = 1;
927     infoPtr->parts = 0;
928     infoPtr->simple = FALSE;
929     infoPtr->clrBk = CLR_DEFAULT;
930     infoPtr->hFont = 0;
931     infoPtr->horizontalBorder = HORZ_BORDER;
932     infoPtr->verticalBorder = VERT_BORDER;
933     infoPtr->horizontalGap = HORZ_GAP;
934
935     STATUSBAR_NotifyFormat(infoPtr, infoPtr->Notify, NF_REQUERY);
936
937     GetClientRect (hwnd, &rect);
938     InvalidateRect (hwnd, &rect, 0);
939     UpdateWindow(hwnd);
940
941     ZeroMemory (&nclm, sizeof(nclm));
942     nclm.cbSize = sizeof(nclm);
943     SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, nclm.cbSize, &nclm, 0);
944     infoPtr->hDefaultFont = CreateFontIndirectW (&nclm.lfStatusFont);
945
946     /* initialize simple case */
947     infoPtr->part0.bound = rect;
948     infoPtr->part0.text = 0;
949     infoPtr->part0.x = 0;
950     infoPtr->part0.style = 0;
951     infoPtr->part0.hIcon = 0;
952
953     /* initialize first part */
954     infoPtr->parts = Alloc (sizeof(STATUSWINDOWPART));
955     if (!infoPtr->parts) goto create_fail;
956     infoPtr->parts[0].bound = rect;
957     infoPtr->parts[0].text = 0;
958     infoPtr->parts[0].x = -1;
959     infoPtr->parts[0].style = 0;
960     infoPtr->parts[0].hIcon = 0;
961     
962     OpenThemeData (hwnd, themeClass);
963
964     if (lpCreate->lpszName && (len = strlenW ((LPCWSTR)lpCreate->lpszName)))
965     {
966         infoPtr->parts[0].text = Alloc ((len + 1)*sizeof(WCHAR));
967         if (!infoPtr->parts[0].text) goto create_fail;
968         strcpyW (infoPtr->parts[0].text, (LPCWSTR)lpCreate->lpszName);
969     }
970
971     dwStyle = GetWindowLongW (hwnd, GWL_STYLE);
972     /* native seems to clear WS_BORDER, too */
973     dwStyle &= ~WS_BORDER;
974     SetWindowLongW (hwnd, GWL_STYLE, dwStyle);
975
976     if ((hdc = GetDC (hwnd))) {
977         TEXTMETRICW tm;
978         HFONT hOldFont;
979
980         hOldFont = SelectObject (hdc, infoPtr->hDefaultFont);
981         GetTextMetricsW (hdc, &tm);
982         textHeight = tm.tmHeight;
983         SelectObject (hdc, hOldFont);
984         ReleaseDC (hwnd, hdc);
985     }
986     TRACE("    textHeight=%d\n", textHeight);
987
988     if (dwStyle & SBT_TOOLTIPS) {
989         infoPtr->hwndToolTip =
990             CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, WS_POPUP | TTS_ALWAYSTIP,
991                              CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
992                              CW_USEDEFAULT, hwnd, 0,
993                              (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL);
994
995         if (infoPtr->hwndToolTip) {
996             NMTOOLTIPSCREATED nmttc;
997
998             nmttc.hdr.hwndFrom = hwnd;
999             nmttc.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID);
1000             nmttc.hdr.code = NM_TOOLTIPSCREATED;
1001             nmttc.hwndToolTips = infoPtr->hwndToolTip;
1002
1003             SendMessageW (lpCreate->hwndParent, WM_NOTIFY, nmttc.hdr.idFrom, (LPARAM)&nmttc);
1004         }
1005     }
1006
1007     if (!(dwStyle & CCS_NORESIZE)) { /* don't resize wnd if it doesn't want it ! */
1008         HTHEME theme;
1009         GetClientRect (infoPtr->Notify, &rect);
1010         width = rect.right - rect.left;
1011         infoPtr->height = textHeight + 4 + infoPtr->verticalBorder;
1012         
1013         if ((theme = GetWindowTheme (hwnd)))
1014         {
1015             /* Determine bar height from theme such that the content area is
1016              * textHeight pixels large */
1017             HDC hdc = GetDC (hwnd);
1018             RECT r;
1019             memset (&r, 0, sizeof (r));
1020             r.bottom = textHeight;
1021             if (SUCCEEDED(GetThemeBackgroundExtent (theme, hdc, SP_PANE, 0, &r, &r)))
1022             {
1023                 infoPtr->height = r.bottom - r.top;
1024             }
1025             ReleaseDC (hwnd, hdc);
1026         }
1027     
1028         SetWindowPos(hwnd, 0, lpCreate->x, lpCreate->y - 1,
1029                         width, infoPtr->height, SWP_NOZORDER);
1030         STATUSBAR_SetPartBounds (infoPtr);
1031     }
1032
1033     return 0;
1034
1035 create_fail:
1036     TRACE("    failed!\n");
1037     if (infoPtr) STATUSBAR_WMDestroy(infoPtr);
1038     return -1;
1039 }
1040
1041
1042 /* in contrast to SB_GETTEXT*, WM_GETTEXT handles the text
1043  * of the first part only (usual behaviour) */
1044 static INT
1045 STATUSBAR_WMGetText (const STATUS_INFO *infoPtr, INT size, LPWSTR buf)
1046 {
1047     INT len;
1048
1049     TRACE("\n");
1050     if (!(infoPtr->parts[0].text))
1051         return 0;
1052
1053     len = strlenW (infoPtr->parts[0].text);
1054
1055     if (size > len) {
1056         strcpyW (buf, infoPtr->parts[0].text);
1057         return len;
1058     }
1059
1060     return -1;
1061 }
1062
1063
1064 static BOOL
1065 STATUSBAR_WMNCHitTest (const STATUS_INFO *infoPtr, INT x, INT y)
1066 {
1067     if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) {
1068         RECT  rect;
1069         POINT pt;
1070
1071         GetClientRect (infoPtr->Self, &rect);
1072
1073         pt.x = x;
1074         pt.y = y;
1075         ScreenToClient (infoPtr->Self, &pt);
1076
1077         rect.left = rect.right - 13;
1078         rect.top += 2;
1079
1080         if (PtInRect (&rect, pt))
1081             return HTBOTTOMRIGHT;
1082     }
1083
1084     return HTERROR;
1085 }
1086
1087
1088 static LRESULT
1089 STATUSBAR_WMPaint (STATUS_INFO *infoPtr, HDC hdc)
1090 {
1091     PAINTSTRUCT ps;
1092
1093     TRACE("\n");
1094     if (hdc) return STATUSBAR_Refresh (infoPtr, hdc);
1095     hdc = BeginPaint (infoPtr->Self, &ps);
1096     STATUSBAR_Refresh (infoPtr, hdc);
1097     EndPaint (infoPtr->Self, &ps);
1098
1099     return 0;
1100 }
1101
1102
1103 static LRESULT
1104 STATUSBAR_WMSetFont (STATUS_INFO *infoPtr, HFONT font, BOOL redraw)
1105 {
1106     infoPtr->hFont = font;
1107     TRACE("%p\n", infoPtr->hFont);
1108     if (redraw)
1109         InvalidateRect(infoPtr->Self, NULL, FALSE);
1110
1111     return 0;
1112 }
1113
1114
1115 static BOOL
1116 STATUSBAR_WMSetText (const STATUS_INFO *infoPtr, LPCSTR text)
1117 {
1118     STATUSWINDOWPART *part;
1119     int len;
1120
1121     TRACE("\n");
1122     if (infoPtr->numParts == 0)
1123         return FALSE;
1124
1125     part = &infoPtr->parts[0];
1126     /* duplicate string */
1127     Free (part->text);
1128     part->text = 0;
1129
1130     if (text && (len = strlenW((LPCWSTR)text))) {
1131         part->text = Alloc ((len+1)*sizeof(WCHAR));
1132         if (!part->text) return FALSE;
1133         strcpyW (part->text, (LPCWSTR)text);
1134     }
1135
1136     InvalidateRect(infoPtr->Self, &part->bound, FALSE);
1137
1138     return TRUE;
1139 }
1140
1141
1142 static BOOL
1143 STATUSBAR_WMSize (STATUS_INFO *infoPtr, WORD flags)
1144 {
1145     INT  width, x, y;
1146     RECT parent_rect;
1147
1148     /* Need to resize width to match parent */
1149     TRACE("flags %04x\n", flags);
1150
1151     if (flags != SIZE_RESTORED && flags != SIZE_MAXIMIZED) {
1152         WARN("flags MUST be SIZE_RESTORED or SIZE_MAXIMIZED\n");
1153         return FALSE;
1154     }
1155
1156     if (GetWindowLongW(infoPtr->Self, GWL_STYLE) & CCS_NORESIZE) return FALSE;
1157
1158     /* width and height don't apply */
1159     if (!GetClientRect (infoPtr->Notify, &parent_rect))
1160         return FALSE;
1161
1162     width = parent_rect.right - parent_rect.left;
1163     x = parent_rect.left;
1164     y = parent_rect.bottom - infoPtr->height;
1165     MoveWindow (infoPtr->Self, x, y, width, infoPtr->height, TRUE);
1166     STATUSBAR_SetPartBounds (infoPtr);
1167     return TRUE;
1168 }
1169
1170
1171 /* update theme after a WM_THEMECHANGED message */
1172 static LRESULT theme_changed (const STATUS_INFO* infoPtr)
1173 {
1174     HTHEME theme = GetWindowTheme (infoPtr->Self);
1175     CloseThemeData (theme);
1176     OpenThemeData (infoPtr->Self, themeClass);
1177     return 0;
1178 }
1179
1180
1181 static LRESULT
1182 STATUSBAR_NotifyFormat (STATUS_INFO *infoPtr, HWND from, INT cmd)
1183 {
1184     if (cmd == NF_REQUERY) {
1185         INT i = SendMessageW(from, WM_NOTIFYFORMAT, (WPARAM)infoPtr->Self, NF_QUERY);
1186         infoPtr->bUnicode = (i == NFR_UNICODE);
1187     }
1188     return infoPtr->bUnicode ? NFR_UNICODE : NFR_ANSI;
1189 }
1190
1191
1192 static LRESULT
1193 STATUSBAR_SendMouseNotify(const STATUS_INFO *infoPtr, UINT code, LPARAM lParam)
1194 {
1195     NMMOUSE  nm;
1196
1197     TRACE("code %04x, lParam=%lx\n", code, lParam);
1198     nm.hdr.hwndFrom = infoPtr->Self;
1199     nm.hdr.idFrom = GetWindowLongPtrW(infoPtr->Self, GWLP_ID);
1200     nm.hdr.code = code;
1201     nm.pt.x = (short)LOWORD(lParam);
1202     nm.pt.y = (short)HIWORD(lParam);
1203     nm.dwItemSpec = STATUSBAR_InternalHitTest(infoPtr, &nm.pt);
1204     nm.dwItemData = 0;
1205     nm.dwHitInfo = 0x30000;     /* seems constant */
1206     SendMessageW(infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nm);
1207     return 0;
1208 }
1209
1210
1211
1212 static LRESULT WINAPI
1213 StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
1214 {
1215     STATUS_INFO *infoPtr = (STATUS_INFO *)GetWindowLongPtrW (hwnd, 0);
1216     INT nPart = ((INT) wParam) & 0x00ff;
1217     LRESULT res;
1218
1219     TRACE("hwnd=%p msg=%x wparam=%lx lparam=%lx\n", hwnd, msg, wParam, lParam);
1220     if (!infoPtr && msg != WM_CREATE)
1221         return DefWindowProcW (hwnd, msg, wParam, lParam);
1222
1223     switch (msg) {
1224         case SB_GETBORDERS:
1225             return STATUSBAR_GetBorders (infoPtr, (INT *)lParam);
1226
1227         case SB_GETICON:
1228             return (LRESULT)STATUSBAR_GetIcon (infoPtr, nPart);
1229
1230         case SB_GETPARTS:
1231             return STATUSBAR_GetParts (infoPtr, (INT)wParam, (INT *)lParam);
1232
1233         case SB_GETRECT:
1234             return STATUSBAR_GetRect (infoPtr, nPart, (LPRECT)lParam);
1235
1236         case SB_GETTEXTA:
1237             return STATUSBAR_GetTextA (infoPtr, nPart, (LPSTR)lParam);
1238
1239         case SB_GETTEXTW:
1240             return STATUSBAR_GetTextW (infoPtr, nPart, (LPWSTR)lParam);
1241
1242         case SB_GETTEXTLENGTHA:
1243         case SB_GETTEXTLENGTHW:
1244             return STATUSBAR_GetTextLength (infoPtr, nPart);
1245
1246         case SB_GETTIPTEXTA:
1247             return STATUSBAR_GetTipTextA (infoPtr,  LOWORD(wParam), (LPSTR)lParam,  HIWORD(wParam));
1248
1249         case SB_GETTIPTEXTW:
1250             return STATUSBAR_GetTipTextW (infoPtr,  LOWORD(wParam), (LPWSTR)lParam,  HIWORD(wParam));
1251
1252         case SB_GETUNICODEFORMAT:
1253             return infoPtr->bUnicode;
1254
1255         case SB_ISSIMPLE:
1256             return infoPtr->simple;
1257
1258         case SB_SETBORDERS:
1259             return STATUSBAR_SetBorders (infoPtr, (INT *)lParam);
1260
1261         case SB_SETBKCOLOR:
1262             return STATUSBAR_SetBkColor (infoPtr, (COLORREF)lParam);
1263
1264         case SB_SETICON:
1265             return STATUSBAR_SetIcon (infoPtr, nPart, (HICON)lParam);
1266
1267         case SB_SETMINHEIGHT:
1268             return STATUSBAR_SetMinHeight (infoPtr, (INT)wParam);
1269
1270         case SB_SETPARTS:
1271             return STATUSBAR_SetParts (infoPtr, (INT)wParam, (LPINT)lParam);
1272
1273         case SB_SETTEXTA:
1274             return STATUSBAR_SetTextT (infoPtr, nPart, wParam & 0xff00, (LPCWSTR)lParam, FALSE);
1275
1276         case SB_SETTEXTW:
1277             return STATUSBAR_SetTextT (infoPtr, nPart, wParam & 0xff00, (LPCWSTR)lParam, TRUE);
1278
1279         case SB_SETTIPTEXTA:
1280             return STATUSBAR_SetTipTextA (infoPtr, (INT)wParam, (LPSTR)lParam);
1281
1282         case SB_SETTIPTEXTW:
1283             return STATUSBAR_SetTipTextW (infoPtr, (INT)wParam, (LPWSTR)lParam);
1284
1285         case SB_SETUNICODEFORMAT:
1286             return STATUSBAR_SetUnicodeFormat (infoPtr, (BOOL)wParam);
1287
1288         case SB_SIMPLE:
1289             return STATUSBAR_Simple (infoPtr, (BOOL)wParam);
1290
1291         case WM_CREATE:
1292             return STATUSBAR_WMCreate (hwnd, (LPCREATESTRUCTA)lParam);
1293
1294         case WM_DESTROY:
1295             return STATUSBAR_WMDestroy (infoPtr);
1296
1297         case WM_GETFONT:
1298             return (LRESULT)(infoPtr->hFont? infoPtr->hFont : infoPtr->hDefaultFont);
1299
1300         case WM_GETTEXT:
1301             return STATUSBAR_WMGetText (infoPtr, (INT)wParam, (LPWSTR)lParam);
1302
1303         case WM_GETTEXTLENGTH:
1304             return STATUSBAR_GetTextLength (infoPtr, 0);
1305
1306         case WM_LBUTTONDBLCLK:
1307             return STATUSBAR_SendMouseNotify(infoPtr, NM_DBLCLK, lParam);
1308
1309         case WM_LBUTTONUP:
1310             return STATUSBAR_SendMouseNotify(infoPtr, NM_CLICK, lParam);
1311
1312         case WM_MOUSEMOVE:
1313             return STATUSBAR_Relay2Tip (infoPtr, msg, wParam, lParam);
1314
1315         case WM_NCHITTEST:
1316             res = STATUSBAR_WMNCHitTest(infoPtr, (short)LOWORD(lParam),
1317                                         (short)HIWORD(lParam));
1318             if (res != HTERROR) return res;
1319             return DefWindowProcW (hwnd, msg, wParam, lParam);
1320
1321         case WM_NCLBUTTONUP:
1322         case WM_NCLBUTTONDOWN:
1323             PostMessageW (infoPtr->Notify, msg, wParam, lParam);
1324             return 0;
1325
1326         case WM_NOTIFYFORMAT:
1327             return STATUSBAR_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam);
1328
1329         case WM_PRINTCLIENT:
1330         case WM_PAINT:
1331             return STATUSBAR_WMPaint (infoPtr, (HDC)wParam);
1332
1333         case WM_RBUTTONDBLCLK:
1334             return STATUSBAR_SendMouseNotify(infoPtr, NM_RDBLCLK, lParam);
1335
1336         case WM_RBUTTONUP:
1337             return STATUSBAR_SendMouseNotify(infoPtr, NM_RCLICK, lParam);
1338
1339         case WM_SETFONT:
1340             return STATUSBAR_WMSetFont (infoPtr, (HFONT)wParam, LOWORD(lParam));
1341
1342         case WM_SETTEXT:
1343             return STATUSBAR_WMSetText (infoPtr, (LPCSTR)lParam);
1344
1345         case WM_SIZE:
1346             if (STATUSBAR_WMSize (infoPtr, (WORD)wParam)) return 0;
1347             return DefWindowProcW (hwnd, msg, wParam, lParam);
1348
1349         case WM_THEMECHANGED:
1350             return theme_changed (infoPtr);
1351
1352         default:
1353             if ((msg >= WM_USER) && (msg < WM_APP))
1354                 ERR("unknown msg %04x wp=%04lx lp=%08lx\n",
1355                      msg, wParam, lParam);
1356             return DefWindowProcW (hwnd, msg, wParam, lParam);
1357     }
1358 }
1359
1360
1361 /***********************************************************************
1362  * STATUS_Register [Internal]
1363  *
1364  * Registers the status window class.
1365  */
1366
1367 void
1368 STATUS_Register (void)
1369 {
1370     WNDCLASSW wndClass;
1371
1372     ZeroMemory (&wndClass, sizeof(WNDCLASSW));
1373     wndClass.style         = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW;
1374     wndClass.lpfnWndProc   = StatusWindowProc;
1375     wndClass.cbClsExtra    = 0;
1376     wndClass.cbWndExtra    = sizeof(STATUS_INFO *);
1377     wndClass.hCursor       = LoadCursorW (0, (LPWSTR)IDC_ARROW);
1378     wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
1379     wndClass.lpszClassName = STATUSCLASSNAMEW;
1380
1381     RegisterClassW (&wndClass);
1382 }
1383
1384
1385 /***********************************************************************
1386  * STATUS_Unregister [Internal]
1387  *
1388  * Unregisters the status window class.
1389  */
1390
1391 void
1392 STATUS_Unregister (void)
1393 {
1394     UnregisterClassW (STATUSCLASSNAMEW, NULL);
1395 }