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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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.
40 * - STM_SETIMAGE: IMAGE_CURSOR
48 #include "wine/winuser16.h"
50 #include "user_private.h"
51 #include "wine/debug.h"
53 WINE_DEFAULT_DEBUG_CHANNEL(static);
55 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
56 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
57 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
58 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
59 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
60 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
61 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
62 static LRESULT WINAPI
StaticWndProcA( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
63 static LRESULT WINAPI
StaticWndProcW( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
65 static COLORREF color_3dshadow
, color_3ddkshadow
, color_3dhighlight
;
67 /* offsets for GetWindowLong for static private information */
68 #define HFONT_GWL_OFFSET 0
69 #define HICON_GWL_OFFSET (sizeof(HFONT))
70 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
72 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
74 static pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
76 STATIC_PaintTextfn
, /* SS_LEFT */
77 STATIC_PaintTextfn
, /* SS_CENTER */
78 STATIC_PaintTextfn
, /* SS_RIGHT */
79 STATIC_PaintIconfn
, /* SS_ICON */
80 STATIC_PaintRectfn
, /* SS_BLACKRECT */
81 STATIC_PaintRectfn
, /* SS_GRAYRECT */
82 STATIC_PaintRectfn
, /* SS_WHITERECT */
83 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
84 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
85 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
86 NULL
, /* SS_USERITEM */
87 STATIC_PaintTextfn
, /* SS_SIMPLE */
88 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
89 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
90 STATIC_PaintBitmapfn
, /* SS_BITMAP */
91 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
92 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
93 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
94 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
98 /*********************************************************************
99 * static class descriptor
101 const struct builtin_class_descr STATIC_builtin_class
=
104 CS_DBLCLKS
| CS_PARENTDC
, /* style */
105 StaticWndProcA
, /* procA */
106 StaticWndProcW
, /* procW */
107 STATIC_EXTRA_BYTES
, /* extra */
108 IDC_ARROW
, /* cursor */
113 /***********************************************************************
116 * Set the icon for an SS_ICON control.
118 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
121 CURSORICONINFO
* info
;
123 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
124 info
= hicon
?(CURSORICONINFO
*) GlobalLock16(HICON_16(hicon
)):NULL
;
125 if (hicon
&& !info
) {
126 WARN("hicon != 0, but info == 0\n");
129 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
130 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
132 /* Windows currently doesn't implement SS_RIGHTJUST */
134 if ((style & SS_RIGHTJUST) != 0)
137 GetWindowRect(hwnd, &wr);
138 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
139 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
143 SetWindowPos( hwnd
, 0, 0, 0, info
->nWidth
, info
->nHeight
,
144 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
147 if (info
) GlobalUnlock16(HICON_16(hicon
));
151 /***********************************************************************
154 * Set the bitmap for an SS_BITMAP control.
156 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
160 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
161 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
162 WARN("hBitmap != 0, but it's not a bitmap\n");
165 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
166 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
169 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
170 /* Windows currently doesn't implement SS_RIGHTJUST */
172 if ((style & SS_RIGHTJUST) != 0)
175 GetWindowRect(hwnd, &wr);
176 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
177 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
181 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
182 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
189 /***********************************************************************
190 * STATIC_SetEnhMetaFile
192 * Set the enhanced metafile for an SS_ENHMETAFILE control.
194 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
196 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
197 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
198 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
201 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
204 /***********************************************************************
207 * Load the icon for an SS_ICON control.
209 static HICON
STATIC_LoadIconA( HWND hwnd
, LPCSTR name
)
211 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
212 HICON hicon
= LoadIconA( hInstance
, name
);
213 if (!hicon
) hicon
= LoadIconA( 0, name
);
217 /***********************************************************************
220 * Load the icon for an SS_ICON control.
222 static HICON
STATIC_LoadIconW( HWND hwnd
, LPCWSTR name
)
224 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
225 HICON hicon
= LoadIconW( hInstance
, name
);
226 if (!hicon
) hicon
= LoadIconW( 0, name
);
230 /***********************************************************************
233 * Load the bitmap for an SS_BITMAP control.
235 static HBITMAP
STATIC_LoadBitmapA( HWND hwnd
, LPCSTR name
)
237 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
238 HBITMAP hbitmap
= LoadBitmapA( hInstance
, name
);
239 if (!hbitmap
) /* Try OEM icon (FIXME: is this right?) */
240 hbitmap
= LoadBitmapA( 0, name
);
244 /***********************************************************************
247 * Load the bitmap for an SS_BITMAP control.
249 static HBITMAP
STATIC_LoadBitmapW( HWND hwnd
, LPCWSTR name
)
251 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
252 HBITMAP hbitmap
= LoadBitmapW( hInstance
, name
);
253 if (!hbitmap
) /* Try OEM icon (FIXME: is this right?) */
254 hbitmap
= LoadBitmapW( 0, name
);
258 /***********************************************************************
261 * Try to immediately paint the control.
263 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
265 LONG style
= full_style
& SS_TYPEMASK
;
268 GetClientRect( hwnd
, &rc
);
269 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
273 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
274 ReleaseDC( hwnd
, hdc
);
278 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
280 HBRUSH hBrush
= (HBRUSH
) SendMessageW( GetParent(hwnd
),
281 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
282 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
284 /* FIXME: DefWindowProc should return different colors if a
285 manifest is present */
286 hBrush
= (HBRUSH
)DefWindowProcW(GetParent(hwnd
), WM_CTLCOLORSTATIC
,
287 (WPARAM
)hdc
, (LPARAM
)hwnd
);
292 static VOID
STATIC_InitColours(void)
294 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
295 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
296 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
299 /***********************************************************************
300 * StaticWndProc_common
302 static LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
,
303 LPARAM lParam
, BOOL unicode
)
306 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
307 LONG style
= full_style
& SS_TYPEMASK
;
312 if (style
< 0L || style
> SS_TYPEMASK
)
314 ERR("Unknown style 0x%02lx\n", style
);
317 STATIC_InitColours();
321 if (style
== SS_ICON
) {
324 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
326 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
327 * had already been loaded by the application the last thing we want to do is
328 * GlobalFree16 the handle.
332 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
333 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
339 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
340 if (staticPaintFunc
[style
])
341 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
342 if (!wParam
) EndPaint(hwnd
, &ps
);
347 InvalidateRect(hwnd
, NULL
, TRUE
);
350 case WM_SYSCOLORCHANGE
:
351 STATIC_InitColours();
352 InvalidateRect(hwnd
, NULL
, TRUE
);
356 if (full_style
& SS_SUNKEN
)
357 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
358 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
361 lParam
= (LPARAM
)(((LPCREATESTRUCTW
)lParam
)->lpszName
);
363 lParam
= (LPARAM
)(((LPCREATESTRUCTA
)lParam
)->lpszName
);
371 hIcon
= STATIC_LoadIconW(hwnd
, (LPCWSTR
)lParam
);
373 hIcon
= STATIC_LoadIconA(hwnd
, (LPCSTR
)lParam
);
374 /* FIXME : should we also return the previous hIcon here ??? */
375 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
382 hBitmap
= STATIC_LoadBitmapW(hwnd
, (LPCWSTR
)lParam
);
384 hBitmap
= STATIC_LoadBitmapA(hwnd
, (LPCSTR
)lParam
);
385 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
388 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
389 the enhanced metafile that was specified as the window text. */
395 case SS_LEFTNOWORDWRAP
:
400 lResult
= DefWindowProcW( hwnd
, WM_SETTEXT
, wParam
, lParam
);
402 lResult
= DefWindowProcA( hwnd
, WM_SETTEXT
, wParam
, lParam
);
404 if (uMsg
== WM_SETTEXT
)
405 STATIC_TryPaintFcn( hwnd
, full_style
);
412 lResult
= DefWindowProcW( hwnd
, WM_SETTEXT
, wParam
, lParam
);
414 lResult
= DefWindowProcA( hwnd
, WM_SETTEXT
, wParam
, lParam
);
416 if(uMsg
== WM_SETTEXT
)
417 InvalidateRect(hwnd
, NULL
, TRUE
);
419 return 1; /* success. FIXME: check text length */
422 if ((style
== SS_ICON
) || (style
== SS_BITMAP
)) return 0;
423 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
425 InvalidateRect( hwnd
, NULL
, TRUE
);
429 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
432 if (full_style
& SS_NOTIFY
)
435 return HTTRANSPARENT
;
441 case WM_NCLBUTTONDOWN
:
442 if (full_style
& SS_NOTIFY
)
443 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
444 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
447 case WM_LBUTTONDBLCLK
:
448 case WM_NCLBUTTONDBLCLK
:
449 if (full_style
& SS_NOTIFY
)
450 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
451 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
455 /* FIXME: Return NULL if wParam doesn't match the control's style.
456 wParam is IMAGE_BITMAP, IMAGE_CURSOR, IMAGE_ENHMETAFILE
460 /* FIXME: Return NULL if this control doesn't show an icon */
461 return GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
466 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
469 FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
471 case IMAGE_ENHMETAFILE
:
472 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
475 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
478 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam
);
481 InvalidateRect( hwnd
, NULL
, TRUE
);
486 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
487 InvalidateRect( hwnd
, NULL
, TRUE
);
491 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
492 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
497 /***********************************************************************
500 static LRESULT WINAPI
StaticWndProcA( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
502 if (!IsWindow( hWnd
)) return 0;
503 return StaticWndProc_common(hWnd
, uMsg
, wParam
, lParam
, FALSE
);
506 /***********************************************************************
509 static LRESULT WINAPI
StaticWndProcW( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
511 if (!IsWindow( hWnd
)) return 0;
512 return StaticWndProc_common(hWnd
, uMsg
, wParam
, lParam
, TRUE
);
515 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
518 HFONT font
, oldFont
= NULL
;
519 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
521 dis
.CtlType
= ODT_STATIC
;
524 dis
.itemAction
= ODA_DRAWENTIRE
;
525 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
529 GetClientRect( hwnd
, &dis
.rcItem
);
531 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
532 if (font
) oldFont
= SelectObject( hdc
, font
);
533 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
534 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
535 if (font
) SelectObject( hdc
, oldFont
);
538 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
542 HFONT hFont
, hOldFont
= NULL
;
547 GetClientRect( hwnd
, &rc
);
549 switch (style
& SS_TYPEMASK
)
552 wFormat
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
556 wFormat
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
560 wFormat
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
564 wFormat
= DT_LEFT
| DT_SINGLELINE
;
567 case SS_LEFTNOWORDWRAP
:
568 wFormat
= DT_LEFT
| DT_EXPANDTABS
;
575 if (style
& SS_NOPREFIX
)
576 wFormat
|= DT_NOPREFIX
;
578 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
580 if (style
& SS_CENTERIMAGE
)
581 wFormat
|= DT_SINGLELINE
| DT_VCENTER
;
582 if (style
& SS_EDITCONTROL
)
583 wFormat
|= DT_EDITCONTROL
;
584 if (style
& SS_ENDELLIPSIS
)
585 wFormat
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
586 if (style
& SS_PATHELLIPSIS
)
587 wFormat
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
588 if (style
& SS_WORDELLIPSIS
)
589 wFormat
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
592 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
593 hOldFont
= (HFONT
)SelectObject( hdc
, hFont
);
595 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
597 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
599 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
601 FillRect( hdc
, &rc
, hBrush
);
602 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
605 if (!(len
= SendMessageW( hwnd
, WM_GETTEXTLENGTH
, 0, 0 ))) return;
606 if (!(text
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
) ))) return;
607 SendMessageW( hwnd
, WM_GETTEXT
, len
+ 1, (LPARAM
)text
);
609 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
611 /* Windows uses the faster ExtTextOut() to draw the text and
612 to paint the whole client rectangle with the text background
613 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
614 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
615 &rc
, text
, len
, NULL
);
619 DrawTextW( hdc
, text
, -1, &rc
, wFormat
);
622 HeapFree( GetProcessHeap(), 0, text
);
625 SelectObject( hdc
, hOldFont
);
628 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
633 GetClientRect( hwnd
, &rc
);
635 switch (style
& SS_TYPEMASK
)
638 hBrush
= CreateSolidBrush(color_3ddkshadow
);
639 FillRect( hdc
, &rc
, hBrush
);
642 hBrush
= CreateSolidBrush(color_3dshadow
);
643 FillRect( hdc
, &rc
, hBrush
);
646 hBrush
= CreateSolidBrush(color_3dhighlight
);
647 FillRect( hdc
, &rc
, hBrush
);
650 hBrush
= CreateSolidBrush(color_3ddkshadow
);
651 FrameRect( hdc
, &rc
, hBrush
);
654 hBrush
= CreateSolidBrush(color_3dshadow
);
655 FrameRect( hdc
, &rc
, hBrush
);
658 hBrush
= CreateSolidBrush(color_3dhighlight
);
659 FrameRect( hdc
, &rc
, hBrush
);
664 DeleteObject( hBrush
);
668 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
675 GetClientRect( hwnd
, &rc
);
676 hbrush
= (HBRUSH
)SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
,
677 (WPARAM
)hdc
, (LPARAM
)hwnd
);
678 FillRect( hdc
, &rc
, hbrush
);
679 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
680 if (style
& SS_CENTERIMAGE
)
682 CURSORICONINFO
*info
= hIcon
? (CURSORICONINFO
*)GlobalLock16(HICON_16(hIcon
)) : NULL
;
683 x
= (rc
.right
- rc
.left
)/2 - (info
? info
->nWidth
/2 : 0);
684 y
= (rc
.bottom
- rc
.top
)/2 - (info
? info
->nHeight
/2 : 0);
692 DrawIcon( hdc
, x
, y
, hIcon
);
695 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
698 HBITMAP hBitmap
, oldbitmap
;
700 /* message is still sent, even if the returned brush is not used */
701 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
,
702 (WPARAM
)hdc
, (LPARAM
)hwnd
);
704 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
709 if(GetObjectType(hBitmap
) != OBJ_BITMAP
) return;
710 if (!(hMemDC
= CreateCompatibleDC( hdc
))) return;
711 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
712 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
713 if (style
& SS_CENTERIMAGE
)
716 GetClientRect(hwnd
, &rcClient
);
717 x
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
718 y
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
725 BitBlt(hdc
, x
, y
, bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0,
727 SelectObject(hMemDC
, oldbitmap
);
733 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
735 HENHMETAFILE hEnhMetaFile
;
739 GetClientRect(hwnd
, &rc
);
740 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
741 FillRect(hdc
, &rc
, hbrush
);
742 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
744 /* The control's current font is not selected into the
746 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
747 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
752 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
756 GetClientRect( hwnd
, &rc
);
757 switch (style
& SS_TYPEMASK
)
760 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
763 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
766 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);