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 (hicon
&& !get_icon_size( hicon
, &size
))
108 WARN("hicon != 0, but invalid\n");
111 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
112 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
114 /* Windows currently doesn't implement SS_RIGHTJUST */
116 if ((style & SS_RIGHTJUST) != 0)
119 GetWindowRect(hwnd, &wr);
120 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
121 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
125 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
131 /***********************************************************************
134 * Set the bitmap for an SS_BITMAP control.
136 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
140 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
141 WARN("hBitmap != 0, but it's not a bitmap\n");
144 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
145 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
148 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
149 /* Windows currently doesn't implement SS_RIGHTJUST */
151 if ((style & SS_RIGHTJUST) != 0)
154 GetWindowRect(hwnd, &wr);
155 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
156 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
160 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
161 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
168 /***********************************************************************
169 * STATIC_SetEnhMetaFile
171 * Set the enhanced metafile for an SS_ENHMETAFILE control.
173 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
175 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
176 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
179 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
182 /***********************************************************************
185 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
186 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
188 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
190 switch(style
& SS_TYPEMASK
)
193 if ((wParam
!= IMAGE_ICON
) &&
194 (wParam
!= IMAGE_CURSOR
)) return NULL
;
197 if (wParam
!= IMAGE_BITMAP
) return NULL
;
200 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
205 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
208 /***********************************************************************
211 * Load the icon for an SS_ICON control.
213 static HICON
STATIC_LoadIconA( HINSTANCE hInstance
, LPCSTR name
, DWORD style
)
217 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
219 if ((style
& SS_REALSIZEIMAGE
) != 0)
220 hicon
= LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
223 hicon
= LoadIconA( hInstance
, name
);
224 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
227 if (!hicon
) hicon
= LoadIconA( 0, name
);
228 /* Windows doesn't try to load a standard cursor,
229 probably because most IDs for standard cursors conflict
230 with the IDs for standard icons anyway */
234 /***********************************************************************
237 * Load the icon for an SS_ICON control.
239 static HICON
STATIC_LoadIconW( HINSTANCE hInstance
, LPCWSTR name
, DWORD style
)
243 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
245 if ((style
& SS_REALSIZEIMAGE
) != 0)
246 hicon
= LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
249 hicon
= LoadIconW( hInstance
, name
);
250 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
253 if (!hicon
) hicon
= LoadIconW( 0, name
);
254 /* Windows doesn't try to load a standard cursor,
255 probably because most IDs for standard cursors conflict
256 with the IDs for standard icons anyway */
260 /***********************************************************************
263 * Try to immediately paint the control.
265 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
267 LONG style
= full_style
& SS_TYPEMASK
;
270 GetClientRect( hwnd
, &rc
);
271 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
277 hrgn
= set_control_clipping( hdc
, &rc
);
278 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
279 SelectClipRgn( hdc
, hrgn
);
280 if (hrgn
) DeleteObject( hrgn
);
281 ReleaseDC( hwnd
, hdc
);
285 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
288 HWND parent
= GetParent(hwnd
);
290 if (!parent
) parent
= hwnd
;
291 hBrush
= (HBRUSH
) SendMessageW( parent
,
292 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
293 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
295 /* FIXME: DefWindowProc should return different colors if a
296 manifest is present */
297 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
,
298 (WPARAM
)hdc
, (LPARAM
)hwnd
);
303 static VOID
STATIC_InitColours(void)
305 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
306 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
307 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
310 /***********************************************************************
313 * Tests if the control displays text.
315 static BOOL
hasTextStyle( DWORD style
)
317 switch(style
& SS_TYPEMASK
)
321 case SS_LEFTNOWORDWRAP
:
331 /***********************************************************************
332 * StaticWndProc_common
334 LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
337 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
338 LONG style
= full_style
& SS_TYPEMASK
;
340 if (!IsWindow( hwnd
)) return 0;
345 if (style
< 0L || style
> SS_TYPEMASK
)
347 ERR("Unknown style 0x%02x\n", style
);
350 STATIC_InitColours();
354 if (style
== SS_ICON
) {
357 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
359 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
360 * had already been loaded by the application the last thing we want to do is
361 * GlobalFree16 the handle.
365 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
366 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
369 /* do all painting in WM_PAINT like Windows does */
377 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
378 GetClientRect( hwnd
, &rect
);
379 if (staticPaintFunc
[style
])
381 HRGN hrgn
= set_control_clipping( hdc
, &rect
);
382 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
383 SelectClipRgn( hdc
, hrgn
);
384 if (hrgn
) DeleteObject( hrgn
);
386 if (!wParam
) EndPaint(hwnd
, &ps
);
391 STATIC_TryPaintFcn( hwnd
, full_style
);
392 if (full_style
& SS_NOTIFY
) {
394 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
395 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
398 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
399 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
404 case WM_SYSCOLORCHANGE
:
405 STATIC_InitColours();
406 STATIC_TryPaintFcn( hwnd
, full_style
);
411 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
413 if (full_style
& SS_SUNKEN
)
414 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
415 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
421 if (unicode
|| IS_INTRESOURCE(cs
->lpszName
))
422 hIcon
= STATIC_LoadIconW(cs
->hInstance
, cs
->lpszName
, full_style
);
424 hIcon
= STATIC_LoadIconA(cs
->hInstance
, (LPCSTR
)cs
->lpszName
, full_style
);
425 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
429 if ((ULONG_PTR
)cs
->hInstance
>> 16)
432 if (unicode
|| IS_INTRESOURCE(cs
->lpszName
))
433 hBitmap
= LoadBitmapW(cs
->hInstance
, cs
->lpszName
);
435 hBitmap
= LoadBitmapA(cs
->hInstance
, (LPCSTR
)cs
->lpszName
);
436 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
440 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
441 the enhanced metafile that was specified as the window text. */
443 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
444 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
447 if (hasTextStyle( full_style
))
450 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
452 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
453 STATIC_TryPaintFcn( hwnd
, full_style
);
458 if (hasTextStyle( full_style
))
460 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
462 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
467 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
470 if (full_style
& SS_NOTIFY
)
473 return HTTRANSPARENT
;
479 case WM_NCLBUTTONDOWN
:
480 if (full_style
& SS_NOTIFY
)
481 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
482 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
485 case WM_LBUTTONDBLCLK
:
486 case WM_NCLBUTTONDBLCLK
:
487 if (full_style
& SS_NOTIFY
)
488 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
489 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
493 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
496 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
501 if (style
!= SS_BITMAP
) return 0;
502 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
504 case IMAGE_ENHMETAFILE
:
505 if (style
!= SS_ENHMETAFILE
) return 0;
506 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
510 if (style
!= SS_ICON
) return 0;
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 if (style
!= SS_ICON
) return 0;
522 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
523 STATIC_TryPaintFcn( hwnd
, full_style
);
527 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
528 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
533 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
536 HFONT font
, oldFont
= NULL
;
537 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
539 dis
.CtlType
= ODT_STATIC
;
542 dis
.itemAction
= ODA_DRAWENTIRE
;
543 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
547 GetClientRect( hwnd
, &dis
.rcItem
);
549 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
550 if (font
) oldFont
= SelectObject( hdc
, font
);
551 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
552 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
553 if (font
) SelectObject( hdc
, oldFont
);
556 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
560 HFONT hFont
, hOldFont
= NULL
;
565 GetClientRect( hwnd
, &rc
);
567 switch (style
& SS_TYPEMASK
)
570 format
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
574 format
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
578 format
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
582 format
= DT_LEFT
| DT_SINGLELINE
;
585 case SS_LEFTNOWORDWRAP
:
586 format
= DT_LEFT
| DT_EXPANDTABS
;
593 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
594 format
= DT_RIGHT
| (format
& ~(DT_LEFT
| DT_CENTER
));
596 if (style
& SS_NOPREFIX
)
597 format
|= DT_NOPREFIX
;
599 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
601 if (style
& SS_CENTERIMAGE
)
602 format
|= DT_SINGLELINE
| DT_VCENTER
;
603 if (style
& SS_EDITCONTROL
)
604 format
|= DT_EDITCONTROL
;
605 if (style
& SS_ENDELLIPSIS
)
606 format
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
607 if (style
& SS_PATHELLIPSIS
)
608 format
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
609 if (style
& SS_WORDELLIPSIS
)
610 format
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
613 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
614 hOldFont
= SelectObject( hdc
, hFont
);
616 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
618 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
620 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
622 FillRect( hdc
, &rc
, hBrush
);
623 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
627 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
630 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
633 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
637 if (!len
) goto no_TextOut
;
639 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
641 /* Windows uses the faster ExtTextOut() to draw the text and
642 to paint the whole client rectangle with the text background
643 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
644 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
645 &rc
, text
, len
, NULL
);
649 DrawTextW( hdc
, text
, -1, &rc
, format
);
653 HeapFree( GetProcessHeap(), 0, text
);
656 SelectObject( hdc
, hOldFont
);
659 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
664 GetClientRect( hwnd
, &rc
);
666 /* FIXME: send WM_CTLCOLORSTATIC */
667 switch (style
& SS_TYPEMASK
)
670 hBrush
= CreateSolidBrush(color_3ddkshadow
);
671 FillRect( hdc
, &rc
, hBrush
);
674 hBrush
= CreateSolidBrush(color_3dshadow
);
675 FillRect( hdc
, &rc
, hBrush
);
678 hBrush
= CreateSolidBrush(color_3dhighlight
);
679 FillRect( hdc
, &rc
, hBrush
);
682 hBrush
= CreateSolidBrush(color_3ddkshadow
);
683 FrameRect( hdc
, &rc
, hBrush
);
686 hBrush
= CreateSolidBrush(color_3dshadow
);
687 FrameRect( hdc
, &rc
, hBrush
);
690 hBrush
= CreateSolidBrush(color_3dhighlight
);
691 FrameRect( hdc
, &rc
, hBrush
);
696 DeleteObject( hBrush
);
700 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
707 GetClientRect( hwnd
, &rc
);
708 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
709 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
710 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
712 FillRect(hdc
, &rc
, hbrush
);
716 if (style
& SS_CENTERIMAGE
)
718 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
719 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
720 iconRect
.right
= iconRect
.left
+ size
.cx
;
721 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
725 FillRect( hdc
, &rc
, hbrush
);
726 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
727 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
731 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
734 HBITMAP hBitmap
, oldbitmap
;
736 /* message is still sent, even if the returned brush is not used */
737 STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
739 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
740 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
741 && (hMemDC
= CreateCompatibleDC( hdc
)))
746 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
747 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
749 GetClientRect(hwnd
, &rcClient
);
750 if (style
& SS_CENTERIMAGE
)
752 HBRUSH hbrush
= CreateSolidBrush(GetPixel(hMemDC
, 0, 0));
754 FillRect(hdc
, &rcClient
, hbrush
);
756 rcClient
.left
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
757 rcClient
.top
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
758 rcClient
.right
= rcClient
.left
+ bm
.bmWidth
;
759 rcClient
.bottom
= rcClient
.top
+ bm
.bmHeight
;
761 DeleteObject(hbrush
);
763 StretchBlt(hdc
, rcClient
.left
, rcClient
.top
, rcClient
.right
- rcClient
.left
,
764 rcClient
.bottom
- rcClient
.top
, hMemDC
,
765 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
766 SelectObject(hMemDC
, oldbitmap
);
772 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
774 HENHMETAFILE hEnhMetaFile
;
778 GetClientRect(hwnd
, &rc
);
779 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
780 FillRect(hdc
, &rc
, hbrush
);
781 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
783 /* The control's current font is not selected into the
785 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
786 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
791 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
795 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
796 GetClientRect( hwnd
, &rc
);
797 switch (style
& SS_TYPEMASK
)
800 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
803 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
806 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);