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