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 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
22 * The text should not be changed. Windows doesn't clear the
23 * client rectangle, so the new text must be larger than the old one.
24 * - The SS_RIGHTJUST style is currently not implemented by Windows
25 * (or it does something different than documented).
37 #include "user_private.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(static);
42 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
43 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
44 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
45 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
46 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
47 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
48 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
50 static COLORREF color_3dshadow
, color_3ddkshadow
, color_3dhighlight
;
52 /* offsets for GetWindowLong for static private information */
53 #define HFONT_GWL_OFFSET 0
54 #define HICON_GWL_OFFSET (sizeof(HFONT))
55 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
57 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
59 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
61 STATIC_PaintTextfn
, /* SS_LEFT */
62 STATIC_PaintTextfn
, /* SS_CENTER */
63 STATIC_PaintTextfn
, /* SS_RIGHT */
64 STATIC_PaintIconfn
, /* SS_ICON */
65 STATIC_PaintRectfn
, /* SS_BLACKRECT */
66 STATIC_PaintRectfn
, /* SS_GRAYRECT */
67 STATIC_PaintRectfn
, /* SS_WHITERECT */
68 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
69 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
70 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
71 NULL
, /* SS_USERITEM */
72 STATIC_PaintTextfn
, /* SS_SIMPLE */
73 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
74 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
75 STATIC_PaintBitmapfn
, /* SS_BITMAP */
76 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
77 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
78 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
79 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
83 /*********************************************************************
84 * static class descriptor
86 const struct builtin_class_descr STATIC_builtin_class
=
89 CS_DBLCLKS
| CS_PARENTDC
, /* style */
90 WINPROC_STATIC
, /* proc */
91 STATIC_EXTRA_BYTES
, /* extra */
92 IDC_ARROW
, /* cursor */
96 /***********************************************************************
99 * Set the icon for an SS_ICON control.
101 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
106 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
107 if (hicon
&& !get_icon_size( hicon
, &size
))
109 WARN("hicon != 0, but invalid\n");
112 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
113 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
115 /* Windows currently doesn't implement SS_RIGHTJUST */
117 if ((style & SS_RIGHTJUST) != 0)
120 GetWindowRect(hwnd, &wr);
121 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
122 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
126 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
132 /***********************************************************************
135 * Set the bitmap for an SS_BITMAP control.
137 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
141 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
142 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
143 WARN("hBitmap != 0, but it's not a bitmap\n");
146 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
147 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
150 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
151 /* Windows currently doesn't implement SS_RIGHTJUST */
153 if ((style & SS_RIGHTJUST) != 0)
156 GetWindowRect(hwnd, &wr);
157 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
158 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
162 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
163 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
170 /***********************************************************************
171 * STATIC_SetEnhMetaFile
173 * Set the enhanced metafile for an SS_ENHMETAFILE control.
175 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
177 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
178 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
179 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
182 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
185 /***********************************************************************
188 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
189 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
191 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
193 switch(style
& SS_TYPEMASK
)
196 if ((wParam
!= IMAGE_ICON
) &&
197 (wParam
!= IMAGE_CURSOR
)) return NULL
;
200 if (wParam
!= IMAGE_BITMAP
) return NULL
;
203 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
208 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
211 /***********************************************************************
214 * Load the icon for an SS_ICON control.
216 static HICON
STATIC_LoadIconA( HINSTANCE hInstance
, LPCSTR name
, DWORD style
)
220 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
222 if ((style
& SS_REALSIZEIMAGE
) != 0)
223 hicon
= LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
226 hicon
= LoadIconA( hInstance
, name
);
227 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
230 if (!hicon
) hicon
= LoadIconA( 0, name
);
231 /* Windows doesn't try to load a standard cursor,
232 probably because most IDs for standard cursors conflict
233 with the IDs for standard icons anyway */
237 /***********************************************************************
240 * Load the icon for an SS_ICON control.
242 static HICON
STATIC_LoadIconW( HINSTANCE hInstance
, LPCWSTR name
, DWORD style
)
246 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
248 if ((style
& SS_REALSIZEIMAGE
) != 0)
249 hicon
= LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
252 hicon
= LoadIconW( hInstance
, name
);
253 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
256 if (!hicon
) hicon
= LoadIconW( 0, name
);
257 /* Windows doesn't try to load a standard cursor,
258 probably because most IDs for standard cursors conflict
259 with the IDs for standard icons anyway */
263 /***********************************************************************
266 * Try to immediately paint the control.
268 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
270 LONG style
= full_style
& SS_TYPEMASK
;
273 GetClientRect( hwnd
, &rc
);
274 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
280 hrgn
= set_control_clipping( hdc
, &rc
);
281 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
282 SelectClipRgn( hdc
, hrgn
);
283 if (hrgn
) DeleteObject( hrgn
);
284 ReleaseDC( hwnd
, hdc
);
288 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
291 HWND parent
= GetParent(hwnd
);
293 if (!parent
) parent
= hwnd
;
294 hBrush
= (HBRUSH
) SendMessageW( parent
,
295 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
296 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
298 /* FIXME: DefWindowProc should return different colors if a
299 manifest is present */
300 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
,
301 (WPARAM
)hdc
, (LPARAM
)hwnd
);
306 static VOID
STATIC_InitColours(void)
308 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
309 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
310 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
313 /***********************************************************************
316 * Tests if the control displays text.
318 static BOOL
hasTextStyle( DWORD style
)
320 switch(style
& SS_TYPEMASK
)
324 case SS_LEFTNOWORDWRAP
:
334 /***********************************************************************
335 * StaticWndProc_common
337 LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
340 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
341 LONG style
= full_style
& SS_TYPEMASK
;
343 if (!IsWindow( hwnd
)) return 0;
348 if (style
< 0L || style
> SS_TYPEMASK
)
350 ERR("Unknown style 0x%02x\n", style
);
353 STATIC_InitColours();
357 if (style
== SS_ICON
) {
360 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
362 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
363 * had already been loaded by the application the last thing we want to do is
364 * GlobalFree16 the handle.
368 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
369 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
372 /* do all painting in WM_PAINT like Windows does */
380 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
381 GetClientRect( hwnd
, &rect
);
382 if (staticPaintFunc
[style
])
384 HRGN hrgn
= set_control_clipping( hdc
, &rect
);
385 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
386 SelectClipRgn( hdc
, hrgn
);
387 if (hrgn
) DeleteObject( hrgn
);
389 if (!wParam
) EndPaint(hwnd
, &ps
);
394 STATIC_TryPaintFcn( hwnd
, full_style
);
395 if (full_style
& SS_NOTIFY
) {
397 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
398 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
401 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
402 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
407 case WM_SYSCOLORCHANGE
:
408 STATIC_InitColours();
409 STATIC_TryPaintFcn( hwnd
, full_style
);
414 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
416 if (full_style
& SS_SUNKEN
)
417 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
418 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
424 if (unicode
|| IS_INTRESOURCE(cs
->lpszName
))
425 hIcon
= STATIC_LoadIconW(cs
->hInstance
, cs
->lpszName
, full_style
);
427 hIcon
= STATIC_LoadIconA(cs
->hInstance
, (LPCSTR
)cs
->lpszName
, full_style
);
428 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
432 if ((ULONG_PTR
)cs
->hInstance
>> 16)
435 if (unicode
|| IS_INTRESOURCE(cs
->lpszName
))
436 hBitmap
= LoadBitmapW(cs
->hInstance
, cs
->lpszName
);
438 hBitmap
= LoadBitmapA(cs
->hInstance
, (LPCSTR
)cs
->lpszName
);
439 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
443 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
444 the enhanced metafile that was specified as the window text. */
446 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
447 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
450 if (hasTextStyle( full_style
))
453 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
455 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
456 STATIC_TryPaintFcn( hwnd
, full_style
);
461 if (hasTextStyle( full_style
))
463 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
465 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
470 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
473 if (full_style
& SS_NOTIFY
)
476 return HTTRANSPARENT
;
482 case WM_NCLBUTTONDOWN
:
483 if (full_style
& SS_NOTIFY
)
484 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
485 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
488 case WM_LBUTTONDBLCLK
:
489 case WM_NCLBUTTONDBLCLK
:
490 if (full_style
& SS_NOTIFY
)
491 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
492 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
496 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
499 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
504 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
506 case IMAGE_ENHMETAFILE
:
507 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
511 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
514 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam
);
517 STATIC_TryPaintFcn( hwnd
, full_style
);
521 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
522 STATIC_TryPaintFcn( hwnd
, full_style
);
526 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
527 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
532 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
535 HFONT font
, oldFont
= NULL
;
536 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
538 dis
.CtlType
= ODT_STATIC
;
541 dis
.itemAction
= ODA_DRAWENTIRE
;
542 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
546 GetClientRect( hwnd
, &dis
.rcItem
);
548 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
549 if (font
) oldFont
= SelectObject( hdc
, font
);
550 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
551 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
552 if (font
) SelectObject( hdc
, oldFont
);
555 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
559 HFONT hFont
, hOldFont
= NULL
;
564 GetClientRect( hwnd
, &rc
);
566 switch (style
& SS_TYPEMASK
)
569 format
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
573 format
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
577 format
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
581 format
= DT_LEFT
| DT_SINGLELINE
;
584 case SS_LEFTNOWORDWRAP
:
585 format
= DT_LEFT
| DT_EXPANDTABS
;
592 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
593 format
= DT_RIGHT
| (format
& ~(DT_LEFT
| DT_CENTER
));
595 if (style
& SS_NOPREFIX
)
596 format
|= DT_NOPREFIX
;
598 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
600 if (style
& SS_CENTERIMAGE
)
601 format
|= DT_SINGLELINE
| DT_VCENTER
;
602 if (style
& SS_EDITCONTROL
)
603 format
|= DT_EDITCONTROL
;
604 if (style
& SS_ENDELLIPSIS
)
605 format
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
606 if (style
& SS_PATHELLIPSIS
)
607 format
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
608 if (style
& SS_WORDELLIPSIS
)
609 format
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
612 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
613 hOldFont
= SelectObject( hdc
, hFont
);
615 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
617 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
619 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
621 FillRect( hdc
, &rc
, hBrush
);
622 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
626 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
629 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
632 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
636 if (!len
) goto no_TextOut
;
638 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
640 /* Windows uses the faster ExtTextOut() to draw the text and
641 to paint the whole client rectangle with the text background
642 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
643 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
644 &rc
, text
, len
, NULL
);
648 DrawTextW( hdc
, text
, -1, &rc
, format
);
652 HeapFree( GetProcessHeap(), 0, text
);
655 SelectObject( hdc
, hOldFont
);
658 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
663 GetClientRect( hwnd
, &rc
);
665 /* FIXME: send WM_CTLCOLORSTATIC */
666 switch (style
& SS_TYPEMASK
)
669 hBrush
= CreateSolidBrush(color_3ddkshadow
);
670 FillRect( hdc
, &rc
, hBrush
);
673 hBrush
= CreateSolidBrush(color_3dshadow
);
674 FillRect( hdc
, &rc
, hBrush
);
677 hBrush
= CreateSolidBrush(color_3dhighlight
);
678 FillRect( hdc
, &rc
, hBrush
);
681 hBrush
= CreateSolidBrush(color_3ddkshadow
);
682 FrameRect( hdc
, &rc
, hBrush
);
685 hBrush
= CreateSolidBrush(color_3dshadow
);
686 FrameRect( hdc
, &rc
, hBrush
);
689 hBrush
= CreateSolidBrush(color_3dhighlight
);
690 FrameRect( hdc
, &rc
, hBrush
);
695 DeleteObject( hBrush
);
699 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
706 GetClientRect( hwnd
, &rc
);
707 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
708 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
709 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
711 FillRect(hdc
, &rc
, hbrush
);
715 if (style
& SS_CENTERIMAGE
)
717 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
718 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
719 iconRect
.right
= iconRect
.left
+ size
.cx
;
720 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
724 FillRect( hdc
, &rc
, hbrush
);
725 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
726 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
730 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
733 HBITMAP hBitmap
, oldbitmap
;
735 /* message is still sent, even if the returned brush is not used */
736 STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
738 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
739 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
740 && (hMemDC
= CreateCompatibleDC( hdc
)))
745 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
746 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
748 GetClientRect(hwnd
, &rcClient
);
749 if (style
& SS_CENTERIMAGE
)
751 HBRUSH hbrush
= CreateSolidBrush(GetPixel(hMemDC
, 0, 0));
753 FillRect(hdc
, &rcClient
, hbrush
);
755 rcClient
.left
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
756 rcClient
.top
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
757 rcClient
.right
= rcClient
.left
+ bm
.bmWidth
;
758 rcClient
.bottom
= rcClient
.top
+ bm
.bmHeight
;
760 DeleteObject(hbrush
);
762 StretchBlt(hdc
, rcClient
.left
, rcClient
.top
, rcClient
.right
- rcClient
.left
,
763 rcClient
.bottom
- rcClient
.top
, hMemDC
,
764 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
765 SelectObject(hMemDC
, oldbitmap
);
771 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
773 HENHMETAFILE hEnhMetaFile
;
777 GetClientRect(hwnd
, &rc
);
778 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
779 FillRect(hdc
, &rc
, hbrush
);
780 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
782 /* The control's current font is not selected into the
784 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
785 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
790 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
794 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
795 GetClientRect( hwnd
, &rc
);
796 switch (style
& SS_TYPEMASK
)
799 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
802 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
805 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);