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
, HBRUSH hbrush
, DWORD style
);
43 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
);
44 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
);
45 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
);
46 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
);
47 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
);
48 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, 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))
56 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
);
58 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
60 STATIC_PaintTextfn
, /* SS_LEFT */
61 STATIC_PaintTextfn
, /* SS_CENTER */
62 STATIC_PaintTextfn
, /* SS_RIGHT */
63 STATIC_PaintIconfn
, /* SS_ICON */
64 STATIC_PaintRectfn
, /* SS_BLACKRECT */
65 STATIC_PaintRectfn
, /* SS_GRAYRECT */
66 STATIC_PaintRectfn
, /* SS_WHITERECT */
67 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
68 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
69 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
70 NULL
, /* SS_USERITEM */
71 STATIC_PaintTextfn
, /* SS_SIMPLE */
72 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
73 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
74 STATIC_PaintBitmapfn
, /* SS_BITMAP */
75 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
76 NULL
, /* SS_ETCHEDHORZ */
77 NULL
, /* SS_ETCHEDVERT */
78 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
82 /***********************************************************************
85 * Set the icon for an SS_ICON control.
87 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
92 if (hicon
&& !get_icon_size( hicon
, &size
))
94 WARN("hicon != 0, but invalid\n");
97 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
98 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
100 /* Windows currently doesn't implement SS_RIGHTJUST */
102 if ((style & SS_RIGHTJUST) != 0)
105 GetWindowRect(hwnd, &wr);
106 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
107 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
111 NtUserSetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
117 /***********************************************************************
120 * Set the bitmap for an SS_BITMAP control.
122 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
126 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
127 WARN("hBitmap != 0, but it's not a bitmap\n");
130 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
131 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
134 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
135 /* Windows currently doesn't implement SS_RIGHTJUST */
137 if ((style & SS_RIGHTJUST) != 0)
140 GetWindowRect(hwnd, &wr);
141 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
142 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
146 NtUserSetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
147 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
154 /***********************************************************************
155 * STATIC_SetEnhMetaFile
157 * Set the enhanced metafile for an SS_ENHMETAFILE control.
159 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
161 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
) {
162 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
165 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
168 /***********************************************************************
171 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
172 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
174 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
176 switch(style
& SS_TYPEMASK
)
179 if ((wParam
!= IMAGE_ICON
) &&
180 (wParam
!= IMAGE_CURSOR
)) return NULL
;
183 if (wParam
!= IMAGE_BITMAP
) return NULL
;
186 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
191 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
194 /***********************************************************************
197 * Load the icon for an SS_ICON control.
199 static HICON
STATIC_LoadIconA( HINSTANCE hInstance
, LPCSTR name
, DWORD style
)
203 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
205 if ((style
& SS_REALSIZEIMAGE
) != 0)
206 hicon
= LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
209 hicon
= LoadIconA( hInstance
, name
);
210 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
213 if (!hicon
) hicon
= LoadIconA( 0, name
);
214 /* Windows doesn't try to load a standard cursor,
215 probably because most IDs for standard cursors conflict
216 with the IDs for standard icons anyway */
219 /***********************************************************************
220 * STATIC_SendWmCtlColorStatic
222 * Sends WM_CTLCOLORSTATIC message and returns brush to be used for painting.
224 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
227 HWND parent
= GetParent(hwnd
);
229 if (!parent
) parent
= hwnd
;
230 hBrush
= (HBRUSH
) SendMessageW( parent
, WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
231 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
232 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
236 /***********************************************************************
239 * Load the icon for an SS_ICON control.
241 static HICON
STATIC_LoadIconW( HINSTANCE hInstance
, LPCWSTR name
, DWORD style
)
245 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
247 if ((style
& SS_REALSIZEIMAGE
) != 0)
248 hicon
= LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
251 hicon
= LoadIconW( hInstance
, name
);
252 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
255 if (!hicon
) hicon
= LoadIconW( 0, name
);
256 /* Windows doesn't try to load a standard cursor,
257 probably because most IDs for standard cursors conflict
258 with the IDs for standard icons anyway */
262 /***********************************************************************
265 * Try to immediately paint the control.
267 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
269 if (IsWindowVisible(hwnd
))
275 LONG style
= full_style
& SS_TYPEMASK
;
277 GetClientRect( hwnd
, &rc
);
278 hdc
= NtUserGetDC( hwnd
);
279 hrgn
= set_control_clipping( hdc
, &rc
);
280 hbrush
= STATIC_SendWmCtlColorStatic( hwnd
, hdc
);
281 if (staticPaintFunc
[style
])
282 (staticPaintFunc
[style
])( hwnd
, hdc
, hbrush
, full_style
);
283 SelectClipRgn( hdc
, hrgn
);
284 if (hrgn
) DeleteObject( hrgn
);
285 NtUserReleaseDC( hwnd
, hdc
);
289 static VOID
STATIC_InitColours(void)
291 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
292 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
293 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
296 /***********************************************************************
299 * Tests if the control displays text.
301 static BOOL
hasTextStyle( DWORD style
)
303 switch(style
& SS_TYPEMASK
)
307 case SS_LEFTNOWORDWRAP
:
317 /***********************************************************************
318 * StaticWndProc_common
320 LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, BOOL unicode
)
323 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
324 LONG style
= full_style
& SS_TYPEMASK
;
326 if (!IsWindow( hwnd
)) return 0;
331 if (style
< 0L || style
> SS_TYPEMASK
)
333 ERR("Unknown style 0x%02lx\n", style
);
336 STATIC_InitColours();
340 if (style
== SS_ICON
) {
343 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
345 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
346 * had already been loaded by the application the last thing we want to do is
347 * GlobalFree16 the handle.
351 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
352 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
355 /* do all painting in WM_PAINT like Windows does */
363 HDC hdc
= wParam
? (HDC
)wParam
: NtUserBeginPaint( hwnd
, &ps
);
367 GetClientRect( hwnd
, &rect
);
368 hrgn
= set_control_clipping( hdc
, &rect
);
369 hbrush
= STATIC_SendWmCtlColorStatic( hwnd
, hdc
);
370 if (staticPaintFunc
[style
])
371 (staticPaintFunc
[style
])( hwnd
, hdc
, hbrush
, full_style
);
372 SelectClipRgn( hdc
, hrgn
);
373 if (hrgn
) DeleteObject( hrgn
);
374 if (!wParam
) NtUserEndPaint( hwnd
, &ps
);
379 STATIC_TryPaintFcn( hwnd
, full_style
);
380 if (full_style
& SS_NOTIFY
) {
382 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
383 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
386 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
387 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
392 case WM_SYSCOLORCHANGE
:
393 STATIC_InitColours();
394 STATIC_TryPaintFcn( hwnd
, full_style
);
399 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
401 if (full_style
& SS_SUNKEN
|| style
== SS_ETCHEDHORZ
|| style
== SS_ETCHEDVERT
)
402 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
403 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
405 if (style
== SS_ETCHEDHORZ
|| style
== SS_ETCHEDVERT
)
408 GetClientRect(hwnd
, &rc
);
409 if (style
== SS_ETCHEDHORZ
)
413 AdjustWindowRectEx(&rc
, full_style
, FALSE
, GetWindowLongW(hwnd
, GWL_EXSTYLE
));
414 NtUserSetWindowPos( hwnd
, NULL
, 0, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
415 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
421 const WCHAR
*name
= cs
->lpszName
;
426 const char *nameA
= (const char *)name
;
427 if (nameA
&& nameA
[0] == '\xff')
428 name
= MAKEINTRESOURCEW(MAKEWORD(nameA
[1], nameA
[2]));
430 else if (name
&& name
[0] == 0xffff)
432 name
= MAKEINTRESOURCEW(name
[1]);
435 if (unicode
|| IS_INTRESOURCE(name
))
436 hIcon
= STATIC_LoadIconW(cs
->hInstance
, name
, full_style
);
438 hIcon
= STATIC_LoadIconA(cs
->hInstance
, (const char *)name
, full_style
);
439 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
443 if ((ULONG_PTR
)cs
->hInstance
>> 16)
445 const WCHAR
*name
= cs
->lpszName
;
450 const char *nameA
= (const char *)name
;
451 if (nameA
&& nameA
[0] == '\xff')
452 name
= MAKEINTRESOURCEW(MAKEWORD(nameA
[1], nameA
[2]));
454 else if (name
&& name
[0] == 0xffff)
456 name
= MAKEINTRESOURCEW(name
[1]);
459 if (unicode
|| IS_INTRESOURCE(name
))
460 hBitmap
= LoadBitmapW(cs
->hInstance
, name
);
462 hBitmap
= LoadBitmapA(cs
->hInstance
, (const char *)name
);
463 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
467 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
468 the enhanced metafile that was specified as the window text. */
470 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
471 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
474 if (hasTextStyle( full_style
))
477 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
479 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
480 STATIC_TryPaintFcn( hwnd
, full_style
);
485 if (hasTextStyle( full_style
))
487 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
489 NtUserRedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
|
490 RDW_UPDATENOW
| RDW_ALLCHILDREN
);
495 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
498 if (full_style
& SS_NOTIFY
)
501 return HTTRANSPARENT
;
507 case WM_NCLBUTTONDOWN
:
508 if (full_style
& SS_NOTIFY
)
509 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
510 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
513 case WM_LBUTTONDBLCLK
:
514 case WM_NCLBUTTONDBLCLK
:
515 if (full_style
& SS_NOTIFY
)
516 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
517 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
521 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
524 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
529 if (style
!= SS_BITMAP
) return 0;
530 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
532 case IMAGE_ENHMETAFILE
:
533 if (style
!= SS_ENHMETAFILE
) return 0;
534 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
538 if (style
!= SS_ICON
) return 0;
539 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
542 FIXME("STM_SETIMAGE: Unhandled type %Ix\n", wParam
);
545 STATIC_TryPaintFcn( hwnd
, full_style
);
549 if (style
!= SS_ICON
) return 0;
550 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
551 STATIC_TryPaintFcn( hwnd
, full_style
);
555 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
556 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
561 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
564 HFONT font
, oldFont
= NULL
;
565 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
567 dis
.CtlType
= ODT_STATIC
;
570 dis
.itemAction
= ODA_DRAWENTIRE
;
571 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
575 GetClientRect( hwnd
, &dis
.rcItem
);
577 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
578 if (font
) oldFont
= SelectObject( hdc
, font
);
579 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
580 if (font
) SelectObject( hdc
, oldFont
);
583 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
586 HFONT hFont
, hOldFont
= NULL
;
591 GetClientRect( hwnd
, &rc
);
593 switch (style
& SS_TYPEMASK
)
596 format
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
600 format
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
604 format
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
608 format
= DT_LEFT
| DT_SINGLELINE
;
611 case SS_LEFTNOWORDWRAP
:
612 format
= DT_LEFT
| DT_EXPANDTABS
;
619 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
620 format
= DT_RIGHT
| (format
& ~(DT_LEFT
| DT_CENTER
));
622 if (style
& SS_NOPREFIX
)
623 format
|= DT_NOPREFIX
;
625 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
627 if (style
& SS_CENTERIMAGE
)
628 format
|= DT_SINGLELINE
| DT_VCENTER
;
629 if (style
& SS_EDITCONTROL
)
630 format
|= DT_EDITCONTROL
;
631 if (style
& SS_ENDELLIPSIS
)
632 format
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
633 if (style
& SS_PATHELLIPSIS
)
634 format
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
635 if (style
& SS_WORDELLIPSIS
)
636 format
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
639 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
640 hOldFont
= SelectObject( hdc
, hFont
);
642 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
644 FillRect( hdc
, &rc
, hbrush
);
645 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
649 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
652 while ((len
= NtUserInternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
655 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
659 if (!len
) goto no_TextOut
;
661 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
663 /* Windows uses the faster ExtTextOut() to draw the text and
664 to paint the whole client rectangle with the text background
665 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
666 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
667 &rc
, text
, len
, NULL
);
671 DrawTextW( hdc
, text
, -1, &rc
, format
);
675 HeapFree( GetProcessHeap(), 0, text
);
678 SelectObject( hdc
, hOldFont
);
681 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
685 GetClientRect( hwnd
, &rc
);
687 /* FIXME: send WM_CTLCOLORSTATIC */
688 switch (style
& SS_TYPEMASK
)
691 hbrush
= CreateSolidBrush(color_3ddkshadow
);
692 FillRect( hdc
, &rc
, hbrush
);
695 hbrush
= CreateSolidBrush(color_3dshadow
);
696 FillRect( hdc
, &rc
, hbrush
);
699 hbrush
= CreateSolidBrush(color_3dhighlight
);
700 FillRect( hdc
, &rc
, hbrush
);
703 hbrush
= CreateSolidBrush(color_3ddkshadow
);
704 FrameRect( hdc
, &rc
, hbrush
);
707 hbrush
= CreateSolidBrush(color_3dshadow
);
708 FrameRect( hdc
, &rc
, hbrush
);
711 hbrush
= CreateSolidBrush(color_3dhighlight
);
712 FrameRect( hdc
, &rc
, hbrush
);
717 DeleteObject( hbrush
);
721 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
727 GetClientRect( hwnd
, &rc
);
728 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
729 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
731 FillRect(hdc
, &rc
, hbrush
);
735 if (style
& SS_CENTERIMAGE
)
737 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
738 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
739 iconRect
.right
= iconRect
.left
+ size
.cx
;
740 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
744 FillRect( hdc
, &rc
, hbrush
);
745 NtUserDrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
746 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
750 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
753 HBITMAP hBitmap
, oldbitmap
;
755 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
756 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
757 && (hMemDC
= CreateCompatibleDC( hdc
)))
762 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
763 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
765 GetClientRect(hwnd
, &rcClient
);
766 if (style
& SS_CENTERIMAGE
)
768 hbrush
= CreateSolidBrush(GetPixel(hMemDC
, 0, 0));
770 FillRect(hdc
, &rcClient
, hbrush
);
772 rcClient
.left
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
773 rcClient
.top
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
774 rcClient
.right
= rcClient
.left
+ bm
.bmWidth
;
775 rcClient
.bottom
= rcClient
.top
+ bm
.bmHeight
;
777 DeleteObject(hbrush
);
779 StretchBlt(hdc
, rcClient
.left
, rcClient
.top
, rcClient
.right
- rcClient
.left
,
780 rcClient
.bottom
- rcClient
.top
, hMemDC
,
781 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
782 SelectObject(hMemDC
, oldbitmap
);
788 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
790 HENHMETAFILE hEnhMetaFile
;
793 GetClientRect(hwnd
, &rc
);
794 FillRect(hdc
, &rc
, hbrush
);
795 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
797 /* The control's current font is not selected into the
799 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
800 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
805 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, HBRUSH hbrush
, DWORD style
)
809 GetClientRect( hwnd
, &rc
);
810 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);