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