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