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
21 * - Windows XP introduced new behavior: The background of centered
22 * icons and bitmaps is painted differently. This is only done if
23 * a manifest is present.
24 * Because it has not yet been decided how to implement the two
25 * different modes in Wine, only the Windows XP mode is implemented.
26 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
27 * The text should not be changed. Windows doesn't clear the
28 * client rectangle, so the new text must be larger than the old one.
29 * - The SS_RIGHTJUST style is currently not implemented by Windows
30 * (or it does something different than documented).
42 #include "user_private.h"
43 #include "wine/debug.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(static);
47 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
48 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
49 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
50 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
51 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
52 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
53 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
55 static COLORREF color_3dshadow
, color_3ddkshadow
, color_3dhighlight
;
57 /* offsets for GetWindowLong for static private information */
58 #define HFONT_GWL_OFFSET 0
59 #define HICON_GWL_OFFSET (sizeof(HFONT))
60 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
62 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
64 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
66 STATIC_PaintTextfn
, /* SS_LEFT */
67 STATIC_PaintTextfn
, /* SS_CENTER */
68 STATIC_PaintTextfn
, /* SS_RIGHT */
69 STATIC_PaintIconfn
, /* SS_ICON */
70 STATIC_PaintRectfn
, /* SS_BLACKRECT */
71 STATIC_PaintRectfn
, /* SS_GRAYRECT */
72 STATIC_PaintRectfn
, /* SS_WHITERECT */
73 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
74 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
75 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
76 NULL
, /* SS_USERITEM */
77 STATIC_PaintTextfn
, /* SS_SIMPLE */
78 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
79 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
80 STATIC_PaintBitmapfn
, /* SS_BITMAP */
81 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
82 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
83 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
84 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
88 /*********************************************************************
89 * static class descriptor
91 static const WCHAR staticW
[] = {'S','t','a','t','i','c',0};
92 const struct builtin_class_descr STATIC_builtin_class
=
95 CS_DBLCLKS
| CS_PARENTDC
, /* style */
96 WINPROC_STATIC
, /* proc */
97 STATIC_EXTRA_BYTES
, /* extra */
98 IDC_ARROW
, /* cursor */
102 /***********************************************************************
105 * Set the icon for an SS_ICON control.
107 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
112 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
113 if (hicon
&& !get_icon_size( hicon
, &size
))
115 WARN("hicon != 0, but invalid\n");
118 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
119 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
121 /* Windows currently doesn't implement SS_RIGHTJUST */
123 if ((style & SS_RIGHTJUST) != 0)
126 GetWindowRect(hwnd, &wr);
127 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
128 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
132 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
138 /***********************************************************************
141 * Set the bitmap for an SS_BITMAP control.
143 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
147 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
148 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
149 WARN("hBitmap != 0, but it's not a bitmap\n");
152 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
153 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
156 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
157 /* Windows currently doesn't implement SS_RIGHTJUST */
159 if ((style & SS_RIGHTJUST) != 0)
162 GetWindowRect(hwnd, &wr);
163 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
164 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
168 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
169 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
176 /***********************************************************************
177 * STATIC_SetEnhMetaFile
179 * Set the enhanced metafile for an SS_ENHMETAFILE control.
181 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
183 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
184 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
185 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
188 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
191 /***********************************************************************
194 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
195 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
197 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
199 switch(style
& SS_TYPEMASK
)
202 if ((wParam
!= IMAGE_ICON
) &&
203 (wParam
!= IMAGE_CURSOR
)) return NULL
;
206 if (wParam
!= IMAGE_BITMAP
) return NULL
;
209 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
214 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
217 /***********************************************************************
220 * Load the icon for an SS_ICON control.
222 static HICON
STATIC_LoadIconA( HINSTANCE hInstance
, LPCSTR name
, DWORD style
)
226 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
228 if ((style
& SS_REALSIZEIMAGE
) != 0)
229 hicon
= LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
232 hicon
= LoadIconA( hInstance
, name
);
233 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
236 if (!hicon
) hicon
= LoadIconA( 0, name
);
237 /* Windows doesn't try to load a standard cursor,
238 probably because most IDs for standard cursors conflict
239 with the IDs for standard icons anyway */
243 /***********************************************************************
246 * Load the icon for an SS_ICON control.
248 static HICON
STATIC_LoadIconW( HINSTANCE hInstance
, LPCWSTR name
, DWORD style
)
252 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
254 if ((style
& SS_REALSIZEIMAGE
) != 0)
255 hicon
= LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
258 hicon
= LoadIconW( hInstance
, name
);
259 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
262 if (!hicon
) hicon
= LoadIconW( 0, name
);
263 /* Windows doesn't try to load a standard cursor,
264 probably because most IDs for standard cursors conflict
265 with the IDs for standard icons anyway */
269 /***********************************************************************
272 * Try to immediately paint the control.
274 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
276 LONG style
= full_style
& SS_TYPEMASK
;
279 GetClientRect( hwnd
, &rc
);
280 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
286 hrgn
= set_control_clipping( hdc
, &rc
);
287 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
288 SelectClipRgn( hdc
, hrgn
);
289 if (hrgn
) DeleteObject( hrgn
);
290 ReleaseDC( hwnd
, hdc
);
294 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
297 HWND parent
= GetParent(hwnd
);
299 if (!parent
) parent
= hwnd
;
300 hBrush
= (HBRUSH
) SendMessageW( parent
,
301 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
302 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
304 /* FIXME: DefWindowProc should return different colors if a
305 manifest is present */
306 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
,
307 (WPARAM
)hdc
, (LPARAM
)hwnd
);
312 static VOID
STATIC_InitColours(void)
314 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
315 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
316 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
319 /***********************************************************************
322 * Tests if the control displays text.
324 static BOOL
hasTextStyle( DWORD style
)
326 switch(style
& SS_TYPEMASK
)
330 case SS_LEFTNOWORDWRAP
:
340 /***********************************************************************
341 * StaticWndProc_common
343 LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
346 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
347 LONG style
= full_style
& SS_TYPEMASK
;
349 if (!IsWindow( hwnd
)) return 0;
354 if (style
< 0L || style
> SS_TYPEMASK
)
356 ERR("Unknown style 0x%02x\n", style
);
359 STATIC_InitColours();
363 if (style
== SS_ICON
) {
366 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
368 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
369 * had already been loaded by the application the last thing we want to do is
370 * GlobalFree16 the handle.
374 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
375 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
378 /* do all painting in WM_PAINT like Windows does */
386 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
387 GetClientRect( hwnd
, &rect
);
388 if (staticPaintFunc
[style
])
390 HRGN hrgn
= set_control_clipping( hdc
, &rect
);
391 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
392 SelectClipRgn( hdc
, hrgn
);
393 if (hrgn
) DeleteObject( hrgn
);
395 if (!wParam
) EndPaint(hwnd
, &ps
);
400 STATIC_TryPaintFcn( hwnd
, full_style
);
401 if (full_style
& SS_NOTIFY
) {
403 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
404 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
407 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
408 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
413 case WM_SYSCOLORCHANGE
:
414 STATIC_InitColours();
415 STATIC_TryPaintFcn( hwnd
, full_style
);
420 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
422 if (full_style
& SS_SUNKEN
)
423 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
424 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
430 if (unicode
|| IS_INTRESOURCE(cs
->lpszName
))
431 hIcon
= STATIC_LoadIconW(cs
->hInstance
, cs
->lpszName
, full_style
);
433 hIcon
= STATIC_LoadIconA(cs
->hInstance
, (LPCSTR
)cs
->lpszName
, full_style
);
434 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
438 if ((ULONG_PTR
)cs
->hInstance
>> 16)
441 if (unicode
|| IS_INTRESOURCE(cs
->lpszName
))
442 hBitmap
= LoadBitmapW(cs
->hInstance
, cs
->lpszName
);
444 hBitmap
= LoadBitmapA(cs
->hInstance
, (LPCSTR
)cs
->lpszName
);
445 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
449 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
450 the enhanced metafile that was specified as the window text. */
452 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
453 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
456 if (hasTextStyle( full_style
))
459 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
461 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
462 STATIC_TryPaintFcn( hwnd
, full_style
);
467 if (hasTextStyle( full_style
))
469 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
471 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
476 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
479 if (full_style
& SS_NOTIFY
)
482 return HTTRANSPARENT
;
488 case WM_NCLBUTTONDOWN
:
489 if (full_style
& SS_NOTIFY
)
490 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
491 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
494 case WM_LBUTTONDBLCLK
:
495 case WM_NCLBUTTONDBLCLK
:
496 if (full_style
& SS_NOTIFY
)
497 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
498 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
502 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
505 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
510 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
512 case IMAGE_ENHMETAFILE
:
513 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
517 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
520 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam
);
523 STATIC_TryPaintFcn( hwnd
, full_style
);
527 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
528 STATIC_TryPaintFcn( hwnd
, full_style
);
532 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
533 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
538 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
541 HFONT font
, oldFont
= NULL
;
542 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
544 dis
.CtlType
= ODT_STATIC
;
547 dis
.itemAction
= ODA_DRAWENTIRE
;
548 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
552 GetClientRect( hwnd
, &dis
.rcItem
);
554 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
555 if (font
) oldFont
= SelectObject( hdc
, font
);
556 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
557 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
558 if (font
) SelectObject( hdc
, oldFont
);
561 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
565 HFONT hFont
, hOldFont
= NULL
;
570 GetClientRect( hwnd
, &rc
);
572 switch (style
& SS_TYPEMASK
)
575 format
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
579 format
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
583 format
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
587 format
= DT_LEFT
| DT_SINGLELINE
;
590 case SS_LEFTNOWORDWRAP
:
591 format
= DT_LEFT
| DT_EXPANDTABS
;
598 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
599 format
= DT_RIGHT
| (format
& ~(DT_LEFT
| DT_CENTER
));
601 if (style
& SS_NOPREFIX
)
602 format
|= DT_NOPREFIX
;
604 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
606 if (style
& SS_CENTERIMAGE
)
607 format
|= DT_SINGLELINE
| DT_VCENTER
;
608 if (style
& SS_EDITCONTROL
)
609 format
|= DT_EDITCONTROL
;
610 if (style
& SS_ENDELLIPSIS
)
611 format
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
612 if (style
& SS_PATHELLIPSIS
)
613 format
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
614 if (style
& SS_WORDELLIPSIS
)
615 format
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
618 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
619 hOldFont
= SelectObject( hdc
, hFont
);
621 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
623 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
625 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
627 FillRect( hdc
, &rc
, hBrush
);
628 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
632 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
635 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
638 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
642 if (!len
) goto no_TextOut
;
644 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
646 /* Windows uses the faster ExtTextOut() to draw the text and
647 to paint the whole client rectangle with the text background
648 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
649 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
650 &rc
, text
, len
, NULL
);
654 DrawTextW( hdc
, text
, -1, &rc
, format
);
658 HeapFree( GetProcessHeap(), 0, text
);
661 SelectObject( hdc
, hOldFont
);
664 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
669 GetClientRect( hwnd
, &rc
);
671 /* FIXME: send WM_CTLCOLORSTATIC */
672 switch (style
& SS_TYPEMASK
)
675 hBrush
= CreateSolidBrush(color_3ddkshadow
);
676 FillRect( hdc
, &rc
, hBrush
);
679 hBrush
= CreateSolidBrush(color_3dshadow
);
680 FillRect( hdc
, &rc
, hBrush
);
683 hBrush
= CreateSolidBrush(color_3dhighlight
);
684 FillRect( hdc
, &rc
, hBrush
);
687 hBrush
= CreateSolidBrush(color_3ddkshadow
);
688 FrameRect( hdc
, &rc
, hBrush
);
691 hBrush
= CreateSolidBrush(color_3dshadow
);
692 FrameRect( hdc
, &rc
, hBrush
);
695 hBrush
= CreateSolidBrush(color_3dhighlight
);
696 FrameRect( hdc
, &rc
, hBrush
);
701 DeleteObject( hBrush
);
705 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
712 GetClientRect( hwnd
, &rc
);
713 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
714 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
715 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
717 FillRect(hdc
, &rc
, hbrush
);
721 if (style
& SS_CENTERIMAGE
)
723 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
724 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
725 iconRect
.right
= iconRect
.left
+ size
.cx
;
726 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
730 FillRect( hdc
, &rc
, hbrush
);
731 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
732 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
736 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
739 HBITMAP hBitmap
, oldbitmap
;
742 /* message is still sent, even if the returned brush is not used */
743 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
745 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
746 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
747 && (hMemDC
= CreateCompatibleDC( hdc
)))
753 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
754 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
756 /* Set the background color for monochrome bitmaps
757 to the color of the background brush */
758 if (GetObjectW( hbrush
, sizeof(brush
), &brush
))
760 if (brush
.lbStyle
== BS_SOLID
)
761 SetBkColor(hdc
, brush
.lbColor
);
763 GetClientRect(hwnd
, &rcClient
);
764 if (style
& SS_CENTERIMAGE
)
766 FillRect( hdc
, &rcClient
, hbrush
);
767 rcClient
.left
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
768 rcClient
.top
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
769 rcClient
.right
= rcClient
.left
+ bm
.bmWidth
;
770 rcClient
.bottom
= rcClient
.top
+ bm
.bmHeight
;
772 StretchBlt(hdc
, rcClient
.left
, rcClient
.top
, rcClient
.right
- rcClient
.left
,
773 rcClient
.bottom
- rcClient
.top
, hMemDC
,
774 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
775 SelectObject(hMemDC
, oldbitmap
);
781 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
783 HENHMETAFILE hEnhMetaFile
;
787 GetClientRect(hwnd
, &rc
);
788 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
789 FillRect(hdc
, &rc
, hbrush
);
790 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
792 /* The control's current font is not selected into the
794 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
795 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
800 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
804 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
805 GetClientRect( hwnd
, &rc
);
806 switch (style
& SS_TYPEMASK
)
809 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
812 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
815 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);