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