2 * Interface code to StatusWindow widget/control
4 * Copyright 1996 Bruce Milner
5 * Copyright 1998 Eric Kohl
16 * Run tests using Waite Group Windows95 API Bible Vol. 1&2
17 * The second cdrom contains executables drawstat.exe,gettext.exe,
18 * simple.exe, getparts.exe, setparts.exe, statwnd.exe
23 * 1) Don't hard code bar to bottom of window, allow CCS_TOP also.
24 + 2) Tooltip support (almost done).
27 #define _MAX(a,b) (((a)>(b))?(a):(b))
28 #define _MIN(a,b) (((a)>(b))?(b):(a))
34 #define STATUSBAR_GetInfoPtr(wndPtr) ((STATUSWINDOWINFO *)wndPtr->wExtra[0])
38 STATUSBAR_DrawSizeGrip (HDC32 hdc
, LPRECT32 lpRect
)
44 pt
.x
= lpRect
->right
- 1;
45 pt
.y
= lpRect
->bottom
- 1;
47 hOldPen
= SelectObject32 (hdc
, GetSysColorPen32 (COLOR_3DFACE
));
48 MoveToEx32 (hdc
, pt
.x
- 12, pt
.y
, NULL
);
49 LineTo32 (hdc
, pt
.x
, pt
.y
);
50 LineTo32 (hdc
, pt
.x
, pt
.y
- 12);
55 SelectObject32 (hdc
, GetSysColorPen32 (COLOR_3DSHADOW
));
56 for (i
= 1; i
< 11; i
+= 4) {
57 MoveToEx32 (hdc
, pt
.x
- i
, pt
.y
, NULL
);
58 LineTo32 (hdc
, pt
.x
, pt
.y
- i
);
60 MoveToEx32 (hdc
, pt
.x
- i
-1, pt
.y
, NULL
);
61 LineTo32 (hdc
, pt
.x
, pt
.y
- i
-1);
64 SelectObject32 (hdc
, GetSysColorPen32 (COLOR_3DHIGHLIGHT
));
65 for (i
= 3; i
< 13; i
+= 4) {
66 MoveToEx32 (hdc
, pt
.x
- i
, pt
.y
, NULL
);
67 LineTo32 (hdc
, pt
.x
, pt
.y
- i
);
70 SelectObject32 (hdc
, hOldPen
);
75 STATUSBAR_DrawPart (HDC32 hdc
, STATUSWINDOWPART
*part
)
77 RECT32 r
= part
->bound
;
78 UINT32 border
= BDR_SUNKENOUTER
;
80 if (part
->style
==SBT_POPOUT
)
81 border
= BDR_RAISEDOUTER
;
82 else if (part
->style
==SBT_NOBORDERS
)
85 DrawEdge32(hdc
, &r
, border
, BF_RECT
|BF_ADJUST
);
89 INT32 cy
= r
.bottom
- r
.top
;
92 DrawIconEx32 (hdc
, r
.left
, r
.top
, part
->hIcon
, cy
, cy
, 0, 0, DI_NORMAL
);
98 int oldbkmode
= SetBkMode32(hdc
, TRANSPARENT
);
99 LPSTR p
= (LPSTR
)part
->text
;
100 UINT32 align
= DT_LEFT
;
111 DrawText32A(hdc
, p
, lstrlen32A(p
), &r
, align
|DT_VCENTER
|DT_SINGLELINE
);
112 if (oldbkmode
!= TRANSPARENT
)
113 SetBkMode32(hdc
, oldbkmode
);
119 STATUSBAR_RefreshPart (WND
*wndPtr
, STATUSWINDOWPART
*part
, HDC32 hdc
)
121 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
125 if (!IsWindowVisible32(wndPtr
->hwndSelf
))
128 if (self
->clrBk
!= CLR_DEFAULT
)
129 hbrBk
= CreateSolidBrush32 (self
->clrBk
);
131 hbrBk
= GetSysColorBrush32 (COLOR_3DFACE
);
132 FillRect32(hdc
, &part
->bound
, hbrBk
);
134 hOldFont
= SelectObject32 (hdc
, self
->hFont
? self
->hFont
: self
->hDefaultFont
);
136 if (part
->style
== SBT_OWNERDRAW
) {
137 DRAWITEMSTRUCT32 dis
;
139 dis
.CtlID
= wndPtr
->wIDmenu
;
141 dis
.hwndItem
= wndPtr
->hwndSelf
;
143 dis
.rcItem
= part
->bound
;
144 dis
.itemData
= (INT32
)part
->text
;
145 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_DRAWITEM
,
146 (WPARAM32
)wndPtr
->wIDmenu
, (LPARAM
)&dis
);
149 STATUSBAR_DrawPart (hdc
, part
);
151 SelectObject32 (hdc
, hOldFont
);
153 if (self
->clrBk
!= CLR_DEFAULT
)
154 DeleteObject32 (hbrBk
);
156 if (wndPtr
->dwStyle
& SBARS_SIZEGRIP
) {
159 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
160 STATUSBAR_DrawSizeGrip (hdc
, &rect
);
166 STATUSBAR_Refresh (WND
*wndPtr
, HDC32 hdc
)
168 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
174 if (!IsWindowVisible32(wndPtr
->hwndSelf
))
177 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
179 if (self
->clrBk
!= CLR_DEFAULT
)
180 hbrBk
= CreateSolidBrush32 (self
->clrBk
);
182 hbrBk
= GetSysColorBrush32 (COLOR_3DFACE
);
183 FillRect32(hdc
, &rect
, hbrBk
);
185 hOldFont
= SelectObject32 (hdc
, self
->hFont
? self
->hFont
: self
->hDefaultFont
);
188 STATUSBAR_DrawPart (hdc
, &self
->part0
);
191 for (i
= 0; i
< self
->numParts
; i
++) {
192 if (self
->parts
[i
].style
== SBT_OWNERDRAW
) {
193 DRAWITEMSTRUCT32 dis
;
195 dis
.CtlID
= wndPtr
->wIDmenu
;
197 dis
.hwndItem
= wndPtr
->hwndSelf
;
199 dis
.rcItem
= self
->parts
[i
].bound
;
200 dis
.itemData
= (INT32
)self
->parts
[i
].text
;
201 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_DRAWITEM
,
202 (WPARAM32
)wndPtr
->wIDmenu
, (LPARAM
)&dis
);
205 STATUSBAR_DrawPart (hdc
, &self
->parts
[i
]);
209 SelectObject32 (hdc
, hOldFont
);
211 if (self
->clrBk
!= CLR_DEFAULT
)
212 DeleteObject32 (hbrBk
);
214 if (wndPtr
->dwStyle
& SBARS_SIZEGRIP
)
215 STATUSBAR_DrawSizeGrip (hdc
, &rect
);
222 STATUSBAR_SetPartBounds (WND
*wndPtr
)
224 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
225 STATUSWINDOWPART
*part
;
229 /* get our window size */
230 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
232 rect
.top
+= VERT_BORDER
;
234 /* set bounds for simple rectangle */
235 self
->part0
.bound
= rect
;
237 /* set bounds for non-simple rectangles */
238 for (i
= 0; i
< self
->numParts
; i
++) {
239 part
= &self
->parts
[i
];
240 r
= &self
->parts
[i
].bound
;
242 r
->bottom
= rect
.bottom
;
246 r
->left
= self
->parts
[i
-1].bound
.right
+ HORZ_GAP
;
248 r
->right
= rect
.right
;
252 if (self
->hwndToolTip
) {
255 ti
.cbSize
= sizeof(TTTOOLINFO32A
);
256 ti
.hwnd
= wndPtr
->hwndSelf
;
259 SendMessage32A (self
->hwndToolTip
, TTM_NEWTOOLRECT32A
,
267 STATUSBAR_RelayEvent (HWND32 hwndTip
, HWND32 hwndMsg
, UINT32 uMsg
,
268 WPARAM32 wParam
, LPARAM lParam
)
276 msg
.time
= GetMessageTime ();
277 msg
.pt
.x
= LOWORD(GetMessagePos ());
278 msg
.pt
.y
= HIWORD(GetMessagePos ());
280 SendMessage32A (hwndTip
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
284 __inline__
static LRESULT
285 STATUSBAR_GetBorders (LPARAM lParam
)
287 LPINT32 out
= (LPINT32
) lParam
;
289 out
[0] = HORZ_BORDER
; /* horizontal border width */
290 out
[1] = VERT_BORDER
; /* vertical border width */
291 out
[2] = HORZ_GAP
; /* width of border between rectangles */
298 STATUSBAR_GetIcon (WND
*wndPtr
, WPARAM32 wParam
)
300 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
303 nPart
= (INT32
)wParam
& 0x00ff;
304 if ((nPart
< -1) || (nPart
>= self
->numParts
)) return 0;
307 return (self
->part0
.hIcon
);
309 return (self
->parts
[nPart
].hIcon
);
314 STATUSBAR_GetParts (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
316 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
321 num_parts
= (INT32
) wParam
;
322 parts
= (LPINT32
) lParam
;
324 return (self
->numParts
);
325 for (i
= 0; i
< num_parts
; i
++) {
326 parts
[i
] = self
->parts
[i
].x
;
329 return (self
->numParts
);
334 STATUSBAR_GetRect (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
336 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
340 part_num
= ((INT32
) wParam
) & 0x00ff;
341 rect
= (LPRECT32
) lParam
;
343 *rect
= self
->part0
.bound
;
345 *rect
= self
->parts
[part_num
].bound
;
351 STATUSBAR_GetText32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
353 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
354 STATUSWINDOWPART
*part
;
359 part_num
= ((INT32
) wParam
) & 0x00ff;
360 out_text
= (LPSTR
) lParam
;
364 part
= &self
->parts
[part_num
];
366 if (part
->style
== SBT_OWNERDRAW
)
367 result
= (LRESULT
) part
->text
;
369 result
= part
->text
? lstrlen32A(part
->text
) : 0;
370 result
|= (part
->style
<< 16);
372 lstrcpy32A(out_text
, part
->text
);
379 // << STATUSBAR_GetText32W >>
383 STATUSBAR_GetTextLength32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
385 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
386 STATUSWINDOWPART
*part
;
390 part_num
= ((INT32
) wParam
) & 0x00ff;
395 part
= &self
->parts
[part_num
];
398 result
= lstrlen32A(part
->text
);
402 result
|= (part
->style
<< 16);
407 // << STATUSBAR_GetTextLength32W >>
411 STATUSBAR_GetTipText32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
413 STATUSWINDOWINFO
*infoPtr
= STATUSBAR_GetInfoPtr (wndPtr
);
415 if (infoPtr
->hwndToolTip
) {
418 ti
.cbSize
= sizeof(TTTOOLINFO32A
);
419 ti
.hwnd
= wndPtr
->hwndSelf
;
420 ti
.uId
= LOWORD(wParam
);
421 SendMessage32A (infoPtr
->hwndToolTip
, TTM_GETTEXT32A
, 0, (LPARAM
)&ti
);
424 lstrcpyn32A ((LPSTR
)lParam
, ti
.lpszText
, HIWORD(wParam
));
431 // << STATUSBAR_GetTipText32W >>
432 // << STATUSBAR_GetUnicodeFormat >>
435 __inline__
static LRESULT
436 STATUSBAR_IsSimple (WND
*wndPtr
)
438 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
445 STATUSBAR_SetBkColor (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
447 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
451 oldBkColor
= self
->clrBk
;
452 self
->clrBk
= (COLORREF
)lParam
;
453 hdc
= GetDC32 (wndPtr
->hwndSelf
);
454 STATUSBAR_Refresh (wndPtr
, hdc
);
455 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
462 STATUSBAR_SetIcon (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
464 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
465 INT32 nPart
= (INT32
)wParam
& 0x00ff;
468 if ((nPart
< -1) || (nPart
>= self
->numParts
)) return FALSE
;
470 hdc
= GetDC32 (wndPtr
->hwndSelf
);
472 self
->part0
.hIcon
= (HICON32
)lParam
;
474 STATUSBAR_RefreshPart (wndPtr
, &self
->part0
, hdc
);
477 self
->parts
[nPart
].hIcon
= (HICON32
)lParam
;
479 STATUSBAR_RefreshPart (wndPtr
, &self
->parts
[nPart
], hdc
);
481 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
488 STATUSBAR_SetMinHeight (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
490 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
492 if (IsWindowVisible32 (wndPtr
->hwndSelf
)) {
493 HWND32 parent
= GetParent32 (wndPtr
->hwndSelf
);
497 GetClientRect32 (parent
, &parent_rect
);
498 self
->height
= (INT32
)wParam
+ VERT_BORDER
;
499 width
= parent_rect
.right
- parent_rect
.left
;
500 x
= parent_rect
.left
;
501 y
= parent_rect
.bottom
- self
->height
;
502 MoveWindow32 (wndPtr
->hwndSelf
, parent_rect
.left
,
503 parent_rect
.bottom
- self
->height
,
504 width
, self
->height
, TRUE
);
505 STATUSBAR_SetPartBounds (wndPtr
);
513 STATUSBAR_SetParts (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
515 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
518 STATUSWINDOWPART
* tmp
;
523 self
->simple
= FALSE
;
525 oldNumParts
= self
->numParts
;
526 self
->numParts
= (INT32
) wParam
;
527 parts
= (LPINT32
) lParam
;
528 if (oldNumParts
> self
->numParts
) {
529 for (i
= self
->numParts
; i
< oldNumParts
; i
++) {
530 if (self
->parts
[i
].text
&& (self
->parts
[i
].style
!= SBT_OWNERDRAW
))
531 HeapFree(GetProcessHeap (), 0, self
->parts
[i
].text
);
534 else if (oldNumParts
< self
->numParts
) {
535 tmp
= HeapAlloc(GetProcessHeap (), HEAP_ZERO_MEMORY
,
536 sizeof(STATUSWINDOWPART
) * self
->numParts
);
537 for (i
= 0; i
< oldNumParts
; i
++) {
538 tmp
[i
] = self
->parts
[i
];
541 HeapFree(GetProcessHeap (), 0, self
->parts
);
545 for (i
= 0; i
< self
->numParts
; i
++) {
546 self
->parts
[i
].x
= parts
[i
];
549 if (self
->hwndToolTip
) {
551 SendMessage32A (self
->hwndToolTip
, TTM_GETTOOLCOUNT
, 0, 0);
553 if (nTipCount
< self
->numParts
) {
558 ZeroMemory (&ti
, sizeof(TTTOOLINFO32A
));
559 ti
.cbSize
= sizeof(TTTOOLINFO32A
);
560 ti
.hwnd
= wndPtr
->hwndSelf
;
561 for (i
= nTipCount
; i
< self
->numParts
; i
++) {
562 TRACE (statusbar
, "add tool %d\n", i
);
564 SendMessage32A (self
->hwndToolTip
, TTM_ADDTOOL32A
,
568 else if (nTipCount
> self
->numParts
) {
572 for (i
= nTipCount
- 1; i
>= self
->numParts
; i
--) {
574 TRACE (statusbar
, "delete tool %d\n", i
);
580 STATUSBAR_SetPartBounds (wndPtr
);
582 hdc
= GetDC32 (wndPtr
->hwndSelf
);
583 STATUSBAR_Refresh (wndPtr
, hdc
);
584 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
591 STATUSBAR_SetText32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
593 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
594 STATUSWINDOWPART
*part
;
601 text
= (LPSTR
) lParam
;
602 part_num
= ((INT32
) wParam
) & 0x00ff;
603 style
= ((INT32
) wParam
) & 0xff00;
605 if ((self
->simple
) || (self
->parts
==NULL
) || (part_num
==255))
608 part
= &self
->parts
[part_num
];
609 if (!part
) return FALSE
;
611 if (style
== SBT_OWNERDRAW
) {
615 /* duplicate string */
617 HeapFree (GetProcessHeap (), 0, part
->text
);
619 if (text
&& (len
= lstrlen32A(text
))) {
620 part
->text
= HeapAlloc (GetProcessHeap (), 0, len
+1);
621 lstrcpy32A(part
->text
, text
);
625 hdc
= GetDC32 (wndPtr
->hwndSelf
);
626 STATUSBAR_RefreshPart (wndPtr
, part
, hdc
);
627 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
633 // << STATUSBAR_SetText32W >>
637 STATUSBAR_SetTipText32A (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
639 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
642 TRACE (statusbar
, "part %d: \"%s\"\n", (INT32
)wParam
, (LPSTR
)lParam
);
643 if (self
->hwndToolTip
) {
644 ti
.cbSize
= sizeof(TTTOOLINFO32A
);
645 ti
.hwnd
= wndPtr
->hwndSelf
;
646 ti
.uId
= (INT32
)wParam
;
648 ti
.lpszText
= (LPSTR
)lParam
;
649 SendMessage32A (self
->hwndToolTip
, TTM_UPDATETIPTEXT32A
,
657 // << STATUSBAR_SetTipText32W >>
658 // << STATUSBAR_SetUnicodeFormat >>
662 STATUSBAR_Simple (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
664 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
669 simple
= (BOOL32
) wParam
;
670 self
->simple
= simple
;
672 /* send notification */
673 nmhdr
.hwndFrom
= wndPtr
->hwndSelf
;
674 nmhdr
.idFrom
= wndPtr
->wIDmenu
;
675 nmhdr
.code
= SBN_SIMPLEMODECHANGE
;
676 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NOTIFY
,
679 hdc
= GetDC32 (wndPtr
->hwndSelf
);
680 STATUSBAR_Refresh (wndPtr
, hdc
);
681 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
688 STATUSBAR_WMCreate (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
690 LPCREATESTRUCT32A lpCreate
= (LPCREATESTRUCT32A
) lParam
;
691 NONCLIENTMETRICS32A nclm
;
695 STATUSWINDOWINFO
*self
;
697 self
= (STATUSWINDOWINFO
*)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
698 sizeof(STATUSWINDOWINFO
));
699 wndPtr
->wExtra
[0] = (DWORD
)self
;
703 self
->simple
= FALSE
;
704 self
->clrBk
= CLR_DEFAULT
;
706 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
708 nclm
.cbSize
= sizeof(NONCLIENTMETRICS32A
);
709 SystemParametersInfo32A (SPI_GETNONCLIENTMETRICS
, 0, &nclm
, 0);
710 self
->hDefaultFont
= CreateFontIndirect32A (&nclm
.lfStatusFont
);
712 /* initialize simple case */
713 self
->part0
.bound
= rect
;
714 self
->part0
.text
= 0;
716 self
->part0
.style
= 0;
717 self
->part0
.hIcon
= 0;
719 /* initialize first part */
720 self
->parts
= HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY
,
721 sizeof(STATUSWINDOWPART
));
722 self
->parts
[0].bound
= rect
;
723 self
->parts
[0].text
= 0;
724 self
->parts
[0].x
= -1;
725 self
->parts
[0].style
= 0;
726 self
->parts
[0].hIcon
= 0;
728 if ((len
= lstrlen32A (lpCreate
->lpszName
))) {
729 self
->parts
[0].text
= HeapAlloc (GetProcessHeap (), 0, len
+ 1);
730 lstrcpy32A (self
->parts
[0].text
, lpCreate
->lpszName
);
733 if ((hdc
= GetDC32 (0))) {
737 hOldFont
= SelectObject32 (hdc
,self
->hDefaultFont
);
738 GetTextMetrics32A(hdc
, &tm
);
739 self
->textHeight
= tm
.tmHeight
;
740 SelectObject32 (hdc
, hOldFont
);
744 if (wndPtr
->dwStyle
& SBT_TOOLTIPS
) {
746 CreateWindowEx32A (0, TOOLTIPS_CLASS32A
, NULL
, 0,
747 CW_USEDEFAULT32
, CW_USEDEFAULT32
,
748 CW_USEDEFAULT32
, CW_USEDEFAULT32
,
750 wndPtr
->hInstance
, NULL
);
752 if (self
->hwndToolTip
) {
753 NMTOOLTIPSCREATED nmttc
;
755 nmttc
.hdr
.hwndFrom
= wndPtr
->hwndSelf
;
756 nmttc
.hdr
.idFrom
= wndPtr
->wIDmenu
;
757 nmttc
.hdr
.code
= NM_TOOLTIPSCREATED
;
758 nmttc
.hwndToolTips
= self
->hwndToolTip
;
760 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NOTIFY
,
761 (WPARAM32
)wndPtr
->wIDmenu
, (LPARAM
)&nmttc
);
765 GetClientRect32 (GetParent32 (wndPtr
->hwndSelf
), &rect
);
766 width
= rect
.right
- rect
.left
;
767 self
->height
= self
->textHeight
+ 4 + VERT_BORDER
;
768 MoveWindow32 (wndPtr
->hwndSelf
, lpCreate
->x
, lpCreate
->y
-1,
769 width
, self
->height
, FALSE
);
770 STATUSBAR_SetPartBounds (wndPtr
);
777 STATUSBAR_WMDestroy (WND
*wndPtr
)
779 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
782 for (i
= 0; i
< self
->numParts
; i
++) {
783 if (self
->parts
[i
].text
&& (self
->parts
[i
].style
!= SBT_OWNERDRAW
))
784 HeapFree(GetProcessHeap (), 0, self
->parts
[i
].text
);
786 if (self
->part0
.text
&& (self
->part0
.style
!= SBT_OWNERDRAW
))
787 HeapFree(GetProcessHeap (), 0, self
->part0
.text
);
788 HeapFree(GetProcessHeap (), 0, self
->parts
);
790 /* delete default font */
791 if (self
->hDefaultFont
)
792 DeleteObject32 (self
->hDefaultFont
);
794 /* delete tool tip control */
795 if (self
->hwndToolTip
)
796 DestroyWindow32 (self
->hwndToolTip
);
798 HeapFree(GetProcessHeap (), 0, self
);
804 static __inline__ LRESULT
805 STATUSBAR_WMGetFont (WND
*wndPtr
)
807 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
814 STATUSBAR_WMGetText (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
816 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
819 if (!(self
->parts
[0].text
))
821 len
= lstrlen32A (self
->parts
[0].text
);
823 lstrcpy32A ((LPSTR
)lParam
, self
->parts
[0].text
);
832 STATUSBAR_WMGetTextLength (WND
*wndPtr
)
834 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
836 if (!(self
->parts
[0].text
))
839 return (lstrlen32A (self
->parts
[0].text
));
843 __inline__
static LRESULT
844 STATUSBAR_WMMouseMove (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
846 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
848 if (self
->hwndToolTip
)
849 STATUSBAR_RelayEvent (self
->hwndToolTip
, wndPtr
->hwndSelf
,
850 WM_MOUSEMOVE
, wParam
, lParam
);
856 STATUSBAR_WMNCHitTest (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
858 if (wndPtr
->dwStyle
& SBARS_SIZEGRIP
) {
862 GetClientRect32 (wndPtr
->hwndSelf
, &rect
);
864 pt
.x
= (INT32
)LOWORD(lParam
);
865 pt
.y
= (INT32
)HIWORD(lParam
);
866 ScreenToClient32 (wndPtr
->hwndSelf
, &pt
);
868 rect
.left
= rect
.right
- 13;
871 if (PtInRect32 (&rect
, pt
))
872 return HTBOTTOMRIGHT
;
875 return DefWindowProc32A (wndPtr
->hwndSelf
, WM_NCHITTEST
, wParam
, lParam
);
879 static __inline__ LRESULT
880 STATUSBAR_WMNCLButtonDown (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
882 PostMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NCLBUTTONDOWN
,
888 static __inline__ LRESULT
889 STATUSBAR_WMNCLButtonUp (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
891 PostMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NCLBUTTONUP
,
898 STATUSBAR_WMPaint (WND
*wndPtr
, WPARAM32 wParam
)
903 hdc
= wParam
==0 ? BeginPaint32 (wndPtr
->hwndSelf
, &ps
) : (HDC32
)wParam
;
904 STATUSBAR_Refresh (wndPtr
, hdc
);
906 EndPaint32 (wndPtr
->hwndSelf
, &ps
);
913 STATUSBAR_WMSetFont (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
915 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
917 self
->hFont
= (HFONT32
)wParam
;
918 if (LOWORD(lParam
) == TRUE
) {
919 HDC32 hdc
= GetDC32 (wndPtr
->hwndSelf
);
920 STATUSBAR_Refresh (wndPtr
, hdc
);
921 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
929 STATUSBAR_WMSetText (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
931 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
932 STATUSWINDOWPART
*part
;
936 if (self
->numParts
== 0)
939 part
= &self
->parts
[0];
940 /* duplicate string */
942 HeapFree(GetProcessHeap (), 0, part
->text
);
944 if (lParam
&& (len
= lstrlen32A((LPCSTR
)lParam
))) {
945 part
->text
= HeapAlloc (GetProcessHeap (), 0, len
+1);
946 lstrcpy32A (part
->text
, (LPCSTR
)lParam
);
949 hdc
= GetDC32 (wndPtr
->hwndSelf
);
950 STATUSBAR_RefreshPart (wndPtr
, part
, hdc
);
951 ReleaseDC32 (wndPtr
->hwndSelf
, hdc
);
958 STATUSBAR_WMSize (WND
*wndPtr
, WPARAM32 wParam
, LPARAM lParam
)
960 STATUSWINDOWINFO
*self
= STATUSBAR_GetInfoPtr (wndPtr
);
961 INT32 width
, x
, y
, flags
;
965 /* Need to resize width to match parent */
966 flags
= (INT32
) wParam
;
969 * SIZE_MAXIMIZED, SIZE_MAXSHOW, SIZE_MINIMIZED, SIZE_RESTORED
972 if (flags
== SIZE_RESTORED
) {
973 /* width and height don't apply */
974 parent
= GetParent32 (wndPtr
->hwndSelf
);
975 GetClientRect32 (parent
, &parent_rect
);
976 width
= parent_rect
.right
- parent_rect
.left
;
977 x
= parent_rect
.left
;
978 y
= parent_rect
.bottom
- self
->height
;
979 MoveWindow32 (wndPtr
->hwndSelf
, parent_rect
.left
,
980 parent_rect
.bottom
- self
->height
,
981 width
, self
->height
, TRUE
);
982 STATUSBAR_SetPartBounds (wndPtr
);
989 STATUSBAR_SendNotify (WND
*wndPtr
, UINT32 code
)
993 nmhdr
.hwndFrom
= wndPtr
->hwndSelf
;
994 nmhdr
.idFrom
= wndPtr
->wIDmenu
;
996 SendMessage32A (GetParent32 (wndPtr
->hwndSelf
), WM_NOTIFY
,
1004 StatusWindowProc (HWND32 hwnd
, UINT32 msg
, WPARAM32 wParam
, LPARAM lParam
)
1006 WND
*wndPtr
= WIN_FindWndPtr (hwnd
);
1010 return STATUSBAR_GetBorders (lParam
);
1013 return STATUSBAR_GetIcon (wndPtr
, wParam
);
1016 return STATUSBAR_GetParts (wndPtr
, wParam
, lParam
);
1019 return STATUSBAR_GetRect (wndPtr
, wParam
, lParam
);
1022 return STATUSBAR_GetText32A (wndPtr
, wParam
, lParam
);
1024 // case SB_GETTEXT32W:
1026 case SB_GETTEXTLENGTH32A
:
1027 return STATUSBAR_GetTextLength32A (wndPtr
, wParam
, lParam
);
1029 // case SB_GETTEXTLENGHT32W:
1031 case SB_GETTIPTEXT32A
:
1032 return STATUSBAR_GetTipText32A (wndPtr
, wParam
, lParam
);
1034 // case SB_GETTIPTEXT32W:
1035 // case SB_GETUNICODEFORMAT:
1038 return STATUSBAR_IsSimple (wndPtr
);
1041 return STATUSBAR_SetBkColor (wndPtr
, wParam
, lParam
);
1044 return STATUSBAR_SetIcon (wndPtr
, wParam
, lParam
);
1046 case SB_SETMINHEIGHT
:
1047 return STATUSBAR_SetMinHeight (wndPtr
, wParam
, lParam
);
1050 return STATUSBAR_SetParts (wndPtr
, wParam
, lParam
);
1053 return STATUSBAR_SetText32A (wndPtr
, wParam
, lParam
);
1055 // case SB_SETTEXT32W:
1057 case SB_SETTIPTEXT32A
:
1058 return STATUSBAR_SetTipText32A (wndPtr
, wParam
, lParam
);
1060 // case SB_SETTIPTEXT32W:
1061 // case SB_SETUNICODEFORMAT:
1064 return STATUSBAR_Simple (wndPtr
, wParam
, lParam
);
1068 return STATUSBAR_WMCreate (wndPtr
, wParam
, lParam
);
1071 return STATUSBAR_WMDestroy (wndPtr
);
1074 return STATUSBAR_WMGetFont (wndPtr
);
1077 return STATUSBAR_WMGetText (wndPtr
, wParam
, lParam
);
1079 case WM_GETTEXTLENGTH
:
1080 return STATUSBAR_WMGetTextLength (wndPtr
);
1082 case WM_LBUTTONDBLCLK
:
1083 return STATUSBAR_SendNotify (wndPtr
, NM_DBLCLK
);
1086 return STATUSBAR_SendNotify (wndPtr
, NM_CLICK
);
1089 return STATUSBAR_WMMouseMove (wndPtr
, wParam
, lParam
);
1092 return STATUSBAR_WMNCHitTest (wndPtr
, wParam
, lParam
);
1094 case WM_NCLBUTTONDOWN
:
1095 return STATUSBAR_WMNCLButtonDown (wndPtr
, wParam
, lParam
);
1097 case WM_NCLBUTTONUP
:
1098 return STATUSBAR_WMNCLButtonUp (wndPtr
, wParam
, lParam
);
1101 return STATUSBAR_WMPaint (wndPtr
, wParam
);
1103 case WM_RBUTTONDBLCLK
:
1104 return STATUSBAR_SendNotify (wndPtr
, NM_RDBLCLK
);
1107 return STATUSBAR_SendNotify (wndPtr
, NM_RCLICK
);
1110 return STATUSBAR_WMSetFont (wndPtr
, wParam
, lParam
);
1113 return STATUSBAR_WMSetText (wndPtr
, wParam
, lParam
);
1116 return STATUSBAR_WMSize (wndPtr
, wParam
, lParam
);
1120 ERR (statusbar
, "unknown msg %04x wp=%04x lp=%08lx\n",
1121 msg
, wParam
, lParam
);
1122 return DefWindowProc32A (hwnd
, msg
, wParam
, lParam
);
1128 /***********************************************************************
1129 * STATUS_Register [Internal]
1131 * Registers the status window class.
1133 void STATUS_Register (void)
1135 WNDCLASS32A wndClass
;
1137 if (GlobalFindAtom32A (STATUSCLASSNAME32A
)) return;
1139 ZeroMemory (&wndClass
, sizeof(WNDCLASS32A
));
1140 wndClass
.style
= CS_GLOBALCLASS
| CS_DBLCLKS
| CS_VREDRAW
;
1141 wndClass
.lpfnWndProc
= (WNDPROC32
)StatusWindowProc
;
1142 wndClass
.cbClsExtra
= 0;
1143 wndClass
.cbWndExtra
= sizeof(STATUSWINDOWINFO
*);
1144 wndClass
.hCursor
= LoadCursor32A (0, IDC_ARROW32A
);
1145 wndClass
.hbrBackground
= (HBRUSH32
)(COLOR_3DFACE
+ 1);
1146 wndClass
.lpszClassName
= STATUSCLASSNAME32A
;
1148 RegisterClass32A (&wndClass
);