4 * Copyright David W. Metcalfe, 1993
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 * This code was audited for completeness against the documented features
23 * of Comctl32.dll version 6.0 on Oct. 4, 2004, by Dimitrie O. Paun.
25 * Unless otherwise noted, we believe this code to be complete, as per
26 * the specification mentioned above.
27 * If you discover missing features, or bugs, please note them below.
30 * - Windows XP introduced new behavior: The background of centered
31 * icons and bitmaps is painted differently. This is only done if
32 * a manifest is present.
33 * Because it has not yet been decided how to implement the two
34 * different modes in Wine, only the Windows XP mode is implemented.
35 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
36 * The text should not be changed. Windows doesn't clear the
37 * client rectangle, so the new text must be larger than the old one.
38 * - The SS_RIGHTJUST style is currently not implemented by Windows
39 * (or it does something different than documented).
51 #include "user_private.h"
52 #include "wine/debug.h"
54 WINE_DEFAULT_DEBUG_CHANNEL(static);
56 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
57 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
58 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
59 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
60 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
61 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
62 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
64 static COLORREF color_3dshadow
, color_3ddkshadow
, color_3dhighlight
;
66 /* offsets for GetWindowLong for static private information */
67 #define HFONT_GWL_OFFSET 0
68 #define HICON_GWL_OFFSET (sizeof(HFONT))
69 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
71 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
73 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
75 STATIC_PaintTextfn
, /* SS_LEFT */
76 STATIC_PaintTextfn
, /* SS_CENTER */
77 STATIC_PaintTextfn
, /* SS_RIGHT */
78 STATIC_PaintIconfn
, /* SS_ICON */
79 STATIC_PaintRectfn
, /* SS_BLACKRECT */
80 STATIC_PaintRectfn
, /* SS_GRAYRECT */
81 STATIC_PaintRectfn
, /* SS_WHITERECT */
82 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
83 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
84 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
85 NULL
, /* SS_USERITEM */
86 STATIC_PaintTextfn
, /* SS_SIMPLE */
87 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
88 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
89 STATIC_PaintBitmapfn
, /* SS_BITMAP */
90 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
91 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
92 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
93 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
97 /*********************************************************************
98 * static class descriptor
100 static const WCHAR staticW
[] = {'S','t','a','t','i','c',0};
101 const struct builtin_class_descr STATIC_builtin_class
=
104 CS_DBLCLKS
| CS_PARENTDC
, /* style */
106 BUILTIN_WINPROC(WINPROC_STATIC
), /* procW */
107 STATIC_EXTRA_BYTES
, /* extra */
108 IDC_ARROW
, /* cursor */
112 static void setup_clipping(HWND hwnd
, HDC hdc
, HRGN
*orig
)
117 /* Native control has always a clipping region set (this may be because
118 * builtin controls uses CS_PARENTDC) and an application depends on it
120 hrgn
= CreateRectRgn(0, 0, 1, 1);
121 if (GetClipRgn(hdc
, hrgn
) != 1)
128 GetClientRect(hwnd
, &rc
);
129 DPtoLP(hdc
, (POINT
*)&rc
, 2);
130 IntersectClipRect(hdc
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
133 static void restore_clipping(HDC hdc
, HRGN hrgn
)
135 SelectClipRgn(hdc
, hrgn
);
140 /***********************************************************************
143 * Set the icon for an SS_ICON control.
145 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
150 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
151 if (hicon
&& !get_icon_size( hicon
, &size
))
153 WARN("hicon != 0, but invalid\n");
156 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
157 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
159 /* Windows currently doesn't implement SS_RIGHTJUST */
161 if ((style & SS_RIGHTJUST) != 0)
164 GetWindowRect(hwnd, &wr);
165 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
166 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
170 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
176 /***********************************************************************
179 * Set the bitmap for an SS_BITMAP control.
181 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
185 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
186 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
187 WARN("hBitmap != 0, but it's not a bitmap\n");
190 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
191 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
194 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
195 /* Windows currently doesn't implement SS_RIGHTJUST */
197 if ((style & SS_RIGHTJUST) != 0)
200 GetWindowRect(hwnd, &wr);
201 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
202 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
206 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
207 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
214 /***********************************************************************
215 * STATIC_SetEnhMetaFile
217 * Set the enhanced metafile for an SS_ENHMETAFILE control.
219 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
221 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
222 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
223 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
226 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
229 /***********************************************************************
232 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
233 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
235 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
237 switch(style
& SS_TYPEMASK
)
240 if ((wParam
!= IMAGE_ICON
) &&
241 (wParam
!= IMAGE_CURSOR
)) return NULL
;
244 if (wParam
!= IMAGE_BITMAP
) return NULL
;
247 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
252 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
255 /***********************************************************************
258 * Load the icon for an SS_ICON control.
260 static HICON
STATIC_LoadIconA( HWND hwnd
, LPCSTR name
, DWORD style
)
262 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
263 if ((style
& SS_REALSIZEIMAGE
) != 0)
265 return LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
269 HICON hicon
= LoadIconA( hInstance
, name
);
270 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
271 if (!hicon
) hicon
= LoadIconA( 0, name
);
272 /* Windows doesn't try to load a standard cursor,
273 probably because most IDs for standard cursors conflict
274 with the IDs for standard icons anyway */
279 /***********************************************************************
282 * Load the icon for an SS_ICON control.
284 static HICON
STATIC_LoadIconW( HWND hwnd
, LPCWSTR name
, DWORD style
)
286 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
287 if ((style
& SS_REALSIZEIMAGE
) != 0)
289 return LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
293 HICON hicon
= LoadIconW( hInstance
, name
);
294 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
295 if (!hicon
) hicon
= LoadIconW( 0, name
);
296 /* Windows doesn't try to load a standard cursor,
297 probably because most IDs for standard cursors conflict
298 with the IDs for standard icons anyway */
303 /***********************************************************************
306 * Load the bitmap for an SS_BITMAP control.
308 static HBITMAP
STATIC_LoadBitmapA( HWND hwnd
, LPCSTR name
)
310 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
311 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
312 return LoadBitmapA( hInstance
, name
);
315 /***********************************************************************
318 * Load the bitmap for an SS_BITMAP control.
320 static HBITMAP
STATIC_LoadBitmapW( HWND hwnd
, LPCWSTR name
)
322 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
323 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
324 return LoadBitmapW( hInstance
, name
);
327 /***********************************************************************
330 * Try to immediately paint the control.
332 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
334 LONG style
= full_style
& SS_TYPEMASK
;
337 GetClientRect( hwnd
, &rc
);
338 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
344 setup_clipping(hwnd
, hdc
, &hOrigClipping
);
345 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
346 restore_clipping(hdc
, hOrigClipping
);
347 ReleaseDC( hwnd
, hdc
);
351 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
354 HWND parent
= GetParent(hwnd
);
356 if (!parent
) parent
= hwnd
;
357 hBrush
= (HBRUSH
) SendMessageW( parent
,
358 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
359 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
361 /* FIXME: DefWindowProc should return different colors if a
362 manifest is present */
363 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
,
364 (WPARAM
)hdc
, (LPARAM
)hwnd
);
369 static VOID
STATIC_InitColours(void)
371 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
372 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
373 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
376 /***********************************************************************
379 * Tests if the control displays text.
381 static BOOL
hasTextStyle( DWORD style
)
383 switch(style
& SS_TYPEMASK
)
387 case SS_LEFTNOWORDWRAP
:
397 /***********************************************************************
398 * StaticWndProc_common
400 LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
403 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
404 LONG style
= full_style
& SS_TYPEMASK
;
406 if (!IsWindow( hwnd
)) return 0;
411 if (style
< 0L || style
> SS_TYPEMASK
)
413 ERR("Unknown style 0x%02x\n", style
);
416 STATIC_InitColours();
420 if (style
== SS_ICON
) {
423 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
425 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
426 * had already been loaded by the application the last thing we want to do is
427 * GlobalFree16 the handle.
431 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
432 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
435 /* do all painting in WM_PAINT like Windows does */
442 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
443 if (staticPaintFunc
[style
])
446 setup_clipping(hwnd
, hdc
, &hOrigClipping
);
447 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
448 restore_clipping(hdc
, hOrigClipping
);
450 if (!wParam
) EndPaint(hwnd
, &ps
);
455 STATIC_TryPaintFcn( hwnd
, full_style
);
456 if (full_style
& SS_NOTIFY
) {
458 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
459 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
462 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
463 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
468 case WM_SYSCOLORCHANGE
:
469 STATIC_InitColours();
470 STATIC_TryPaintFcn( hwnd
, full_style
);
478 if (full_style
& SS_SUNKEN
)
479 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
480 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
485 textW
= ((LPCREATESTRUCTW
)lParam
)->lpszName
;
489 textA
= ((LPCREATESTRUCTA
)lParam
)->lpszName
;
498 hIcon
= STATIC_LoadIconW(hwnd
, textW
, full_style
);
500 hIcon
= STATIC_LoadIconA(hwnd
, textA
, full_style
);
501 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
508 hBitmap
= STATIC_LoadBitmapW(hwnd
, textW
);
510 hBitmap
= STATIC_LoadBitmapA(hwnd
, textA
);
511 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
515 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
516 the enhanced metafile that was specified as the window text. */
518 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
519 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
522 if (hasTextStyle( full_style
))
527 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
529 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
530 STATIC_TryPaintFcn( hwnd
, full_style
);
536 if (hasTextStyle( full_style
))
538 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
540 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
545 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
548 if (full_style
& SS_NOTIFY
)
551 return HTTRANSPARENT
;
557 case WM_NCLBUTTONDOWN
:
558 if (full_style
& SS_NOTIFY
)
559 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
560 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
563 case WM_LBUTTONDBLCLK
:
564 case WM_NCLBUTTONDBLCLK
:
565 if (full_style
& SS_NOTIFY
)
566 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
567 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
571 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
574 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
579 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
581 case IMAGE_ENHMETAFILE
:
582 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
586 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
589 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam
);
592 STATIC_TryPaintFcn( hwnd
, full_style
);
596 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
597 STATIC_TryPaintFcn( hwnd
, full_style
);
601 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
602 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
607 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
610 HFONT font
, oldFont
= NULL
;
611 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
613 dis
.CtlType
= ODT_STATIC
;
616 dis
.itemAction
= ODA_DRAWENTIRE
;
617 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
621 GetClientRect( hwnd
, &dis
.rcItem
);
623 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
624 if (font
) oldFont
= SelectObject( hdc
, font
);
625 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
626 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
627 if (font
) SelectObject( hdc
, oldFont
);
630 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
634 HFONT hFont
, hOldFont
= NULL
;
639 GetClientRect( hwnd
, &rc
);
641 switch (style
& SS_TYPEMASK
)
644 wFormat
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
648 wFormat
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
652 wFormat
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
656 wFormat
= DT_LEFT
| DT_SINGLELINE
;
659 case SS_LEFTNOWORDWRAP
:
660 wFormat
= DT_LEFT
| DT_EXPANDTABS
;
667 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
668 wFormat
= DT_RIGHT
| (wFormat
& ~(DT_LEFT
| DT_CENTER
));
670 if (style
& SS_NOPREFIX
)
671 wFormat
|= DT_NOPREFIX
;
673 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
675 if (style
& SS_CENTERIMAGE
)
676 wFormat
|= DT_SINGLELINE
| DT_VCENTER
;
677 if (style
& SS_EDITCONTROL
)
678 wFormat
|= DT_EDITCONTROL
;
679 if (style
& SS_ENDELLIPSIS
)
680 wFormat
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
681 if (style
& SS_PATHELLIPSIS
)
682 wFormat
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
683 if (style
& SS_WORDELLIPSIS
)
684 wFormat
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
687 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
688 hOldFont
= SelectObject( hdc
, hFont
);
690 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
692 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
694 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
696 FillRect( hdc
, &rc
, hBrush
);
697 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
701 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
704 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
707 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
711 if (!len
) goto no_TextOut
;
713 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
715 /* Windows uses the faster ExtTextOut() to draw the text and
716 to paint the whole client rectangle with the text background
717 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
718 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
719 &rc
, text
, len
, NULL
);
723 DrawTextW( hdc
, text
, -1, &rc
, wFormat
);
727 HeapFree( GetProcessHeap(), 0, text
);
730 SelectObject( hdc
, hOldFont
);
733 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
738 GetClientRect( hwnd
, &rc
);
740 /* FIXME: send WM_CTLCOLORSTATIC */
741 switch (style
& SS_TYPEMASK
)
744 hBrush
= CreateSolidBrush(color_3ddkshadow
);
745 FillRect( hdc
, &rc
, hBrush
);
748 hBrush
= CreateSolidBrush(color_3dshadow
);
749 FillRect( hdc
, &rc
, hBrush
);
752 hBrush
= CreateSolidBrush(color_3dhighlight
);
753 FillRect( hdc
, &rc
, hBrush
);
756 hBrush
= CreateSolidBrush(color_3ddkshadow
);
757 FrameRect( hdc
, &rc
, hBrush
);
760 hBrush
= CreateSolidBrush(color_3dshadow
);
761 FrameRect( hdc
, &rc
, hBrush
);
764 hBrush
= CreateSolidBrush(color_3dhighlight
);
765 FrameRect( hdc
, &rc
, hBrush
);
770 DeleteObject( hBrush
);
774 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
781 GetClientRect( hwnd
, &rc
);
782 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
783 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
784 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
786 FillRect(hdc
, &rc
, hbrush
);
790 if (style
& SS_CENTERIMAGE
)
792 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
793 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
794 iconRect
.right
= iconRect
.left
+ size
.cx
;
795 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
799 FillRect( hdc
, &rc
, hbrush
);
800 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
801 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
805 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
808 HBITMAP hBitmap
, oldbitmap
;
811 /* message is still sent, even if the returned brush is not used */
812 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
814 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
815 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
816 && (hMemDC
= CreateCompatibleDC( hdc
)))
822 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
823 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
825 /* Set the background color for monochrome bitmaps
826 to the color of the background brush */
827 if (GetObjectW( hbrush
, sizeof(brush
), &brush
))
829 if (brush
.lbStyle
== BS_SOLID
)
830 SetBkColor(hdc
, brush
.lbColor
);
832 GetClientRect(hwnd
, &rcClient
);
833 if (style
& SS_CENTERIMAGE
)
836 x
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
837 y
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
838 FillRect( hdc
, &rcClient
, hbrush
);
839 BitBlt(hdc
, x
, y
, bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0,
844 StretchBlt(hdc
, 0, 0, rcClient
.right
- rcClient
.left
,
845 rcClient
.bottom
- rcClient
.top
, hMemDC
,
846 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
848 SelectObject(hMemDC
, oldbitmap
);
854 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
856 HENHMETAFILE hEnhMetaFile
;
860 GetClientRect(hwnd
, &rc
);
861 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
862 FillRect(hdc
, &rc
, hbrush
);
863 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
865 /* The control's current font is not selected into the
867 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
868 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
873 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
877 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
878 GetClientRect( hwnd
, &rc
);
879 switch (style
& SS_TYPEMASK
)
882 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
885 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
888 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);