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