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