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.
39 * - STM_SETIMAGE: IMAGE_CURSOR
47 #include "wine/winuser16.h"
49 #include "user_private.h"
50 #include "wine/debug.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(static);
54 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
55 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
56 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
57 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
58 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
59 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
60 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
61 static LRESULT WINAPI
StaticWndProcA( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
62 static LRESULT WINAPI
StaticWndProcW( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
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 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 const struct builtin_class_descr STATIC_builtin_class
=
103 CS_DBLCLKS
| CS_PARENTDC
, /* style */
104 StaticWndProcA
, /* procA */
105 StaticWndProcW
, /* procW */
106 STATIC_EXTRA_BYTES
, /* extra */
107 IDC_ARROW
, /* cursor */
112 /***********************************************************************
115 * Set the icon for an SS_ICON control.
117 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
120 CURSORICONINFO
* info
;
122 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
123 info
= hicon
?(CURSORICONINFO
*) GlobalLock16(HICON_16(hicon
)):NULL
;
124 if (hicon
&& !info
) {
125 WARN("hicon != 0, but info == 0\n");
128 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
129 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
131 /* Windows currently doesn't implement SS_RIGHTJUST */
133 if ((style & SS_RIGHTJUST) != 0)
136 GetWindowRect(hwnd, &wr);
137 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
138 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
142 SetWindowPos( hwnd
, 0, 0, 0, info
->nWidth
, info
->nHeight
,
143 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
146 if (info
) GlobalUnlock16(HICON_16(hicon
));
150 /***********************************************************************
153 * Set the bitmap for an SS_BITMAP control.
155 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
159 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
160 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
161 WARN("hBitmap != 0, but it's not a bitmap\n");
164 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
165 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
168 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
169 /* Windows currently doesn't implement SS_RIGHTJUST */
171 if ((style & SS_RIGHTJUST) != 0)
174 GetWindowRect(hwnd, &wr);
175 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
176 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
180 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
181 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
188 /***********************************************************************
189 * STATIC_SetEnhMetaFile
191 * Set the enhanced metafile for an SS_ENHMETAFILE control.
193 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
195 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
196 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
197 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
200 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
203 /***********************************************************************
206 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
207 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
209 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
211 switch(style
& SS_TYPEMASK
)
214 if ((wParam
!= IMAGE_ICON
) &&
215 (wParam
!= IMAGE_CURSOR
)) return NULL
;
218 if (wParam
!= IMAGE_BITMAP
) return NULL
;
221 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
226 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
229 /***********************************************************************
232 * Load the icon for an SS_ICON control.
234 static HICON
STATIC_LoadIconA( HWND hwnd
, LPCSTR name
, DWORD style
)
236 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
237 if ((style
& SS_REALSIZEIMAGE
) != 0)
239 return LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
243 HICON hicon
= LoadIconA( hInstance
, name
);
244 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
245 if (!hicon
) hicon
= LoadIconA( 0, name
);
246 /* Windows doesn't try to load a standard cursor,
247 probably because most IDs for standard cursors conflict
248 with the IDs for standard icons anyway */
253 /***********************************************************************
256 * Load the icon for an SS_ICON control.
258 static HICON
STATIC_LoadIconW( HWND hwnd
, LPCWSTR name
, DWORD style
)
260 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
261 if ((style
& SS_REALSIZEIMAGE
) != 0)
263 return LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
267 HICON hicon
= LoadIconW( hInstance
, name
);
268 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
269 if (!hicon
) hicon
= LoadIconW( 0, name
);
270 /* Windows doesn't try to load a standard cursor,
271 probably because most IDs for standard cursors conflict
272 with the IDs for standard icons anyway */
277 /***********************************************************************
280 * Load the bitmap for an SS_BITMAP control.
282 static HBITMAP
STATIC_LoadBitmapA( HWND hwnd
, LPCSTR name
)
284 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
285 HBITMAP hbitmap
= LoadBitmapA( hInstance
, name
);
286 if (!hbitmap
) /* Try OEM icon (FIXME: is this right?) */
287 hbitmap
= LoadBitmapA( 0, name
);
291 /***********************************************************************
294 * Load the bitmap for an SS_BITMAP control.
296 static HBITMAP
STATIC_LoadBitmapW( HWND hwnd
, LPCWSTR name
)
298 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
299 HBITMAP hbitmap
= LoadBitmapW( hInstance
, name
);
300 if (!hbitmap
) /* Try OEM icon (FIXME: is this right?) */
301 hbitmap
= LoadBitmapW( 0, name
);
305 /***********************************************************************
308 * Try to immediately paint the control.
310 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
312 LONG style
= full_style
& SS_TYPEMASK
;
315 GetClientRect( hwnd
, &rc
);
316 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
320 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
321 ReleaseDC( hwnd
, hdc
);
325 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
327 HBRUSH hBrush
= (HBRUSH
) SendMessageW( GetParent(hwnd
),
328 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
329 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
331 /* FIXME: DefWindowProc should return different colors if a
332 manifest is present */
333 hBrush
= (HBRUSH
)DefWindowProcW(GetParent(hwnd
), WM_CTLCOLORSTATIC
,
334 (WPARAM
)hdc
, (LPARAM
)hwnd
);
339 static VOID
STATIC_InitColours(void)
341 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
342 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
343 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
346 /***********************************************************************
347 * StaticWndProc_common
349 static LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
,
350 LPARAM lParam
, BOOL unicode
)
353 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
354 LONG style
= full_style
& SS_TYPEMASK
;
359 if (style
< 0L || style
> SS_TYPEMASK
)
361 ERR("Unknown style 0x%02lx\n", style
);
364 STATIC_InitColours();
368 if (style
== SS_ICON
) {
371 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
373 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
374 * had already been loaded by the application the last thing we want to do is
375 * GlobalFree16 the handle.
379 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
380 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
386 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
387 if (staticPaintFunc
[style
])
388 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
389 if (!wParam
) EndPaint(hwnd
, &ps
);
394 InvalidateRect(hwnd
, NULL
, TRUE
);
397 case WM_SYSCOLORCHANGE
:
398 STATIC_InitColours();
399 InvalidateRect(hwnd
, NULL
, TRUE
);
403 if (full_style
& SS_SUNKEN
)
404 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
405 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
408 lParam
= (LPARAM
)(((LPCREATESTRUCTW
)lParam
)->lpszName
);
410 lParam
= (LPARAM
)(((LPCREATESTRUCTA
)lParam
)->lpszName
);
418 hIcon
= STATIC_LoadIconW(hwnd
, (LPCWSTR
)lParam
, full_style
);
420 hIcon
= STATIC_LoadIconA(hwnd
, (LPCSTR
)lParam
, full_style
);
421 /* FIXME : should we also return the previous hIcon here ??? */
422 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
429 hBitmap
= STATIC_LoadBitmapW(hwnd
, (LPCWSTR
)lParam
);
431 hBitmap
= STATIC_LoadBitmapA(hwnd
, (LPCSTR
)lParam
);
432 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
435 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
436 the enhanced metafile that was specified as the window text. */
442 case SS_LEFTNOWORDWRAP
:
447 lResult
= DefWindowProcW( hwnd
, WM_SETTEXT
, wParam
, lParam
);
449 lResult
= DefWindowProcA( hwnd
, WM_SETTEXT
, wParam
, lParam
);
451 if (uMsg
== WM_SETTEXT
)
452 STATIC_TryPaintFcn( hwnd
, full_style
);
459 lResult
= DefWindowProcW( hwnd
, WM_SETTEXT
, wParam
, lParam
);
461 lResult
= DefWindowProcA( hwnd
, WM_SETTEXT
, wParam
, lParam
);
463 if(uMsg
== WM_SETTEXT
)
464 InvalidateRect(hwnd
, NULL
, TRUE
);
466 return 1; /* success. FIXME: check text length */
469 if ((style
== SS_ICON
) || (style
== SS_BITMAP
)) return 0;
470 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
472 InvalidateRect( hwnd
, NULL
, TRUE
);
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
);
506 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
511 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
514 FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
516 case IMAGE_ENHMETAFILE
:
517 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
520 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
523 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam
);
526 InvalidateRect( hwnd
, NULL
, TRUE
);
531 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
532 InvalidateRect( hwnd
, NULL
, TRUE
);
536 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
537 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
542 /***********************************************************************
545 static LRESULT WINAPI
StaticWndProcA( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
547 if (!IsWindow( hWnd
)) return 0;
548 return StaticWndProc_common(hWnd
, uMsg
, wParam
, lParam
, FALSE
);
551 /***********************************************************************
554 static LRESULT WINAPI
StaticWndProcW( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
556 if (!IsWindow( hWnd
)) return 0;
557 return StaticWndProc_common(hWnd
, uMsg
, wParam
, lParam
, TRUE
);
560 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
563 HFONT font
, oldFont
= NULL
;
564 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
566 dis
.CtlType
= ODT_STATIC
;
569 dis
.itemAction
= ODA_DRAWENTIRE
;
570 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
574 GetClientRect( hwnd
, &dis
.rcItem
);
576 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
577 if (font
) oldFont
= SelectObject( hdc
, font
);
578 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
579 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
580 if (font
) SelectObject( hdc
, oldFont
);
583 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
587 HFONT hFont
, hOldFont
= NULL
;
592 GetClientRect( hwnd
, &rc
);
594 switch (style
& SS_TYPEMASK
)
597 wFormat
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
601 wFormat
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
605 wFormat
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
609 wFormat
= DT_LEFT
| DT_SINGLELINE
;
612 case SS_LEFTNOWORDWRAP
:
613 wFormat
= DT_LEFT
| DT_EXPANDTABS
;
620 if (style
& SS_NOPREFIX
)
621 wFormat
|= DT_NOPREFIX
;
623 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
625 if (style
& SS_CENTERIMAGE
)
626 wFormat
|= DT_SINGLELINE
| DT_VCENTER
;
627 if (style
& SS_EDITCONTROL
)
628 wFormat
|= DT_EDITCONTROL
;
629 if (style
& SS_ENDELLIPSIS
)
630 wFormat
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
631 if (style
& SS_PATHELLIPSIS
)
632 wFormat
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
633 if (style
& SS_WORDELLIPSIS
)
634 wFormat
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
637 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
638 hOldFont
= (HFONT
)SelectObject( hdc
, hFont
);
640 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
642 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
644 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
646 FillRect( hdc
, &rc
, hBrush
);
647 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
650 if (!(len
= SendMessageW( hwnd
, WM_GETTEXTLENGTH
, 0, 0 ))) return;
651 if (!(text
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
) ))) return;
652 SendMessageW( hwnd
, WM_GETTEXT
, len
+ 1, (LPARAM
)text
);
654 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
656 /* Windows uses the faster ExtTextOut() to draw the text and
657 to paint the whole client rectangle with the text background
658 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
659 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
660 &rc
, text
, len
, NULL
);
664 DrawTextW( hdc
, text
, -1, &rc
, wFormat
);
667 HeapFree( GetProcessHeap(), 0, text
);
670 SelectObject( hdc
, hOldFont
);
673 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
678 GetClientRect( hwnd
, &rc
);
680 switch (style
& SS_TYPEMASK
)
683 hBrush
= CreateSolidBrush(color_3ddkshadow
);
684 FillRect( hdc
, &rc
, hBrush
);
687 hBrush
= CreateSolidBrush(color_3dshadow
);
688 FillRect( hdc
, &rc
, hBrush
);
691 hBrush
= CreateSolidBrush(color_3dhighlight
);
692 FillRect( hdc
, &rc
, hBrush
);
695 hBrush
= CreateSolidBrush(color_3ddkshadow
);
696 FrameRect( hdc
, &rc
, hBrush
);
699 hBrush
= CreateSolidBrush(color_3dshadow
);
700 FrameRect( hdc
, &rc
, hBrush
);
703 hBrush
= CreateSolidBrush(color_3dhighlight
);
704 FrameRect( hdc
, &rc
, hBrush
);
709 DeleteObject( hBrush
);
713 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
720 GetClientRect( hwnd
, &rc
);
721 hbrush
= (HBRUSH
)SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
,
722 (WPARAM
)hdc
, (LPARAM
)hwnd
);
723 FillRect( hdc
, &rc
, hbrush
);
724 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
725 if (style
& SS_CENTERIMAGE
)
727 CURSORICONINFO
*info
= hIcon
? (CURSORICONINFO
*)GlobalLock16(HICON_16(hIcon
)) : NULL
;
728 x
= (rc
.right
- rc
.left
)/2 - (info
? info
->nWidth
/2 : 0);
729 y
= (rc
.bottom
- rc
.top
)/2 - (info
? info
->nHeight
/2 : 0);
737 DrawIcon( hdc
, x
, y
, hIcon
);
740 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
743 HBITMAP hBitmap
, oldbitmap
;
745 /* message is still sent, even if the returned brush is not used */
746 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
,
747 (WPARAM
)hdc
, (LPARAM
)hwnd
);
749 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
754 if(GetObjectType(hBitmap
) != OBJ_BITMAP
) return;
755 if (!(hMemDC
= CreateCompatibleDC( hdc
))) return;
756 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
757 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
758 if (style
& SS_CENTERIMAGE
)
761 GetClientRect(hwnd
, &rcClient
);
762 x
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
763 y
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
770 BitBlt(hdc
, x
, y
, bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0,
772 SelectObject(hMemDC
, oldbitmap
);
778 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
780 HENHMETAFILE hEnhMetaFile
;
784 GetClientRect(hwnd
, &rc
);
785 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
786 FillRect(hdc
, &rc
, hbrush
);
787 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
789 /* The control's current font is not selected into the
791 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
792 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
797 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
801 GetClientRect( hwnd
, &rc
);
802 switch (style
& SS_TYPEMASK
)
805 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
808 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
811 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);