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.
30 * - Windows XP introduced new behavior: The background of centered
31 * icons and bitmaps is painted differently. This is only done if
32 * a manifest is present.
33 * Because it has not yet been decided how to implement the two
34 * different modes in Wine, only the Windows XP mode is implemented.
35 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
36 * The text should not be changed. Windows doesn't clear the
37 * client rectangle, so the new text must be larger than the old one.
38 * - The SS_RIGHTJUST style is currently not implemented by Windows
39 * (or it does something different than documented).
47 #include <wine/debug.h>
49 WINE_DEFAULT_DEBUG_CHANNEL(static);
51 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
52 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
53 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
54 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
55 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
56 //static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
57 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
58 static LRESULT WINAPI
StaticWndProcA( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
59 static LRESULT WINAPI
StaticWndProcW( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
61 static COLORREF color_3dshadow
, color_3ddkshadow
, color_3dhighlight
;
63 /* offsets for GetWindowLong for static private information */
64 #define HFONT_GWL_OFFSET 0
65 #define HICON_GWL_OFFSET (sizeof(HFONT))
66 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
68 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
70 static pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
72 STATIC_PaintTextfn
, /* SS_LEFT */
73 STATIC_PaintTextfn
, /* SS_CENTER */
74 STATIC_PaintTextfn
, /* SS_RIGHT */
75 STATIC_PaintIconfn
, /* SS_ICON */
76 STATIC_PaintRectfn
, /* SS_BLACKRECT */
77 STATIC_PaintRectfn
, /* SS_GRAYRECT */
78 STATIC_PaintRectfn
, /* SS_WHITERECT */
79 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
80 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
81 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
82 NULL
, /* SS_USERITEM */
83 STATIC_PaintTextfn
, /* SS_SIMPLE */
84 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
85 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
86 STATIC_PaintBitmapfn
, /* SS_BITMAP */
87 NULL
, /* STATIC_PaintEnhMetafn, SS_ENHMETAFILE */
88 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
89 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
90 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
94 /*********************************************************************
95 * static class descriptor
97 const struct builtin_class_descr STATIC_builtin_class
=
100 L
"Static", /* name */
101 CS_DBLCLKS
| CS_PARENTDC
, /* style */
102 (WNDPROC
) StaticWndProcW
, /* procW */
103 (WNDPROC
) StaticWndProcA
, /* procA */
104 STATIC_EXTRA_BYTES
, /* extra */
105 (LPCWSTR
) IDC_ARROW
, /* cursor */ /* FIXME Wine uses IDC_ARROWA */
109 CS_DBLCLKS
| CS_PARENTDC
, /* style */
110 StaticWndProcA
, /* procA */
111 StaticWndProcW
, /* procW */
112 STATIC_EXTRA_BYTES
, /* extra */
113 IDC_ARROW
, /* cursor */
119 /***********************************************************************
122 * Set the icon for an SS_ICON control. Modified for ReactOS
124 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
129 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
130 if (hicon
&& (!GetIconInfo(hicon
, &info
))) {
131 WARN("hicon != 0, but info == 0\n");
134 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
135 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
139 if (!GetObjectW(info
.hbmColor
, sizeof(BITMAP
), &bm
))
143 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
144 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
149 /***********************************************************************
152 * Set the bitmap for an SS_BITMAP control. Modified for ReactOS
154 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
158 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
159 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
) {
160 ERR("huh? hBitmap!=0, but not bitmap\n");
163 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
164 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
167 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
168 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
169 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
174 /***********************************************************************
175 * STATIC_SetEnhMetaFile
177 * Set the enhanced metafile for an SS_ENHMETAFILE control.
179 //static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
181 // if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
182 // if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
183 // WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
186 // return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
189 /***********************************************************************
192 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
193 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
195 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
197 switch(style
& SS_TYPEMASK
)
200 if ((wParam
!= IMAGE_ICON
) &&
201 (wParam
!= IMAGE_CURSOR
)) return NULL
;
204 if (wParam
!= IMAGE_BITMAP
) return NULL
;
207 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
212 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
215 /***********************************************************************
218 * Load the icon for an SS_ICON control.
220 static HICON
STATIC_LoadIconA( HWND hwnd
, LPCSTR name
, DWORD style
)
222 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
223 if ((style
& SS_REALSIZEIMAGE
) != 0)
225 return LoadImageA(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
229 HICON hicon
= LoadIconA( hInstance
, name
);
230 if (!hicon
) hicon
= LoadCursorA( hInstance
, name
);
231 if (!hicon
) hicon
= LoadIconA( 0, name
);
232 /* Windows doesn't try to load a standard cursor,
233 probably because most IDs for standard cursors conflict
234 with the IDs for standard icons anyway */
239 /***********************************************************************
242 * Load the icon for an SS_ICON control.
244 static HICON
STATIC_LoadIconW( HWND hwnd
, LPCWSTR name
, DWORD style
)
246 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
247 if ((style
& SS_REALSIZEIMAGE
) != 0)
249 return LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
253 HICON hicon
= LoadIconW( hInstance
, name
);
254 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 */
263 /***********************************************************************
266 * Load the bitmap for an SS_BITMAP control.
268 static HBITMAP
STATIC_LoadBitmapA( HWND hwnd
, LPCSTR name
)
270 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
271 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
272 return LoadBitmapA( hInstance
, name
);
275 /***********************************************************************
278 * Load the bitmap for an SS_BITMAP control.
280 static HBITMAP
STATIC_LoadBitmapW( HWND hwnd
, LPCWSTR name
)
282 HINSTANCE hInstance
= (HINSTANCE
)GetWindowLongPtrW( hwnd
, GWLP_HINSTANCE
);
283 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
284 return LoadBitmapW( hInstance
, name
);
287 /***********************************************************************
290 * Try to immediately paint the control.
292 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
294 LONG style
= full_style
& SS_TYPEMASK
;
297 GetClientRect( hwnd
, &rc
);
298 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
302 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
303 ReleaseDC( hwnd
, hdc
);
307 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
309 HBRUSH hBrush
= (HBRUSH
) SendMessageW( GetParent(hwnd
),
310 WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
311 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
313 /* FIXME: DefWindowProc should return different colors if a
314 manifest is present */
315 hBrush
= (HBRUSH
)DefWindowProcW(GetParent(hwnd
), WM_CTLCOLORSTATIC
,
316 (WPARAM
)hdc
, (LPARAM
)hwnd
);
321 static VOID
STATIC_InitColours(void)
323 color_3ddkshadow
= GetSysColor(COLOR_3DDKSHADOW
);
324 color_3dshadow
= GetSysColor(COLOR_3DSHADOW
);
325 color_3dhighlight
= GetSysColor(COLOR_3DHIGHLIGHT
);
328 /***********************************************************************
331 * Tests if the control displays text.
333 static BOOL
hasTextStyle( DWORD style
)
335 switch(style
& SS_TYPEMASK
)
339 case SS_LEFTNOWORDWRAP
:
349 /***********************************************************************
350 * StaticWndProc_common
352 static LRESULT
StaticWndProc_common( HWND hwnd
, UINT uMsg
, WPARAM wParam
,
353 LPARAM lParam
, BOOL unicode
)
356 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
357 LONG style
= full_style
& SS_TYPEMASK
;
362 if (style
< 0L || style
> SS_TYPEMASK
)
364 ERR("Unknown style 0x%02lx\n", style
);
367 STATIC_InitColours();
371 if (style
== SS_ICON
) {
374 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
376 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
377 * had already been loaded by the application the last thing we want to do is
378 * GlobalFree16 the handle.
382 else return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
383 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
389 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
390 if (staticPaintFunc
[style
])
391 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
392 if (!wParam
) EndPaint(hwnd
, &ps
);
397 STATIC_TryPaintFcn( hwnd
, full_style
);
398 if (full_style
& SS_NOTIFY
) {
400 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
401 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
404 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
405 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
410 case WM_SYSCOLORCHANGE
:
411 STATIC_InitColours();
412 STATIC_TryPaintFcn( hwnd
, full_style
);
420 if (full_style
& SS_SUNKEN
)
421 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
422 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
427 textW
= ((LPCREATESTRUCTW
)lParam
)->lpszName
;
431 textA
= ((LPCREATESTRUCTA
)lParam
)->lpszName
;
440 hIcon
= STATIC_LoadIconW(hwnd
, textW
, full_style
);
442 hIcon
= STATIC_LoadIconA(hwnd
, textA
, full_style
);
443 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
450 hBitmap
= STATIC_LoadBitmapW(hwnd
, textW
);
452 hBitmap
= STATIC_LoadBitmapA(hwnd
, textA
);
453 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
457 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
458 the enhanced metafile that was specified as the window text. */
460 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
461 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
464 if (hasTextStyle( full_style
))
469 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
471 lResult
= DefWindowProcA( hwnd
, uMsg
, wParam
, lParam
);
472 STATIC_TryPaintFcn( hwnd
, full_style
);
478 if (hasTextStyle( full_style
))
480 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
482 STATIC_TryPaintFcn( hwnd
, full_style
);
487 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
490 if (full_style
& SS_NOTIFY
)
493 return HTTRANSPARENT
;
499 case WM_NCLBUTTONDOWN
:
500 if (full_style
& SS_NOTIFY
)
501 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
502 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
505 case WM_LBUTTONDBLCLK
:
506 case WM_NCLBUTTONDBLCLK
:
507 if (full_style
& SS_NOTIFY
)
508 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
509 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
513 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
518 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
523 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
525 // case IMAGE_ENHMETAFILE:
526 // lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
530 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
533 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam
);
536 STATIC_TryPaintFcn( hwnd
, full_style
);
543 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
544 STATIC_TryPaintFcn( hwnd
, full_style
);
548 return unicode
? DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
) :
549 DefWindowProcA(hwnd
, uMsg
, wParam
, lParam
);
554 /***********************************************************************
557 static LRESULT WINAPI
StaticWndProcA( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
559 if (!IsWindow( hWnd
)) return 0;
560 return StaticWndProc_common(hWnd
, uMsg
, wParam
, lParam
, FALSE
);
563 /***********************************************************************
566 static LRESULT WINAPI
StaticWndProcW( HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
568 if (!IsWindow( hWnd
)) return 0;
569 return StaticWndProc_common(hWnd
, uMsg
, wParam
, lParam
, TRUE
);
572 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
575 HFONT font
, oldFont
= NULL
;
576 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
578 dis
.CtlType
= ODT_STATIC
;
581 dis
.itemAction
= ODA_DRAWENTIRE
;
582 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
586 GetClientRect( hwnd
, &dis
.rcItem
);
588 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
589 if (font
) oldFont
= SelectObject( hdc
, font
);
590 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
591 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
592 if (font
) SelectObject( hdc
, oldFont
);
595 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
599 HFONT hFont
, hOldFont
= NULL
;
604 GetClientRect( hwnd
, &rc
);
606 switch (style
& SS_TYPEMASK
)
609 wFormat
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
613 wFormat
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
617 wFormat
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
621 wFormat
= DT_LEFT
| DT_SINGLELINE
;
624 case SS_LEFTNOWORDWRAP
:
625 wFormat
= DT_LEFT
| DT_EXPANDTABS
;
632 if (style
& SS_NOPREFIX
)
633 wFormat
|= DT_NOPREFIX
;
635 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
637 if (style
& SS_CENTERIMAGE
)
638 wFormat
|= DT_SINGLELINE
| DT_VCENTER
;
639 if (style
& SS_EDITCONTROL
)
640 wFormat
|= DT_EDITCONTROL
;
641 if (style
& SS_ENDELLIPSIS
)
642 wFormat
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
643 if (style
& SS_PATHELLIPSIS
)
644 wFormat
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
645 if (style
& SS_WORDELLIPSIS
)
646 wFormat
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
649 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
650 hOldFont
= (HFONT
)SelectObject( hdc
, hFont
);
652 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
654 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
656 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
658 FillRect( hdc
, &rc
, hBrush
);
659 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
662 if (!(len
= SendMessageW( hwnd
, WM_GETTEXTLENGTH
, 0, 0 ))) return;
663 if (!(text
= HeapAlloc( GetProcessHeap(), 0, (len
+ 1) * sizeof(WCHAR
) ))) return;
664 SendMessageW( hwnd
, WM_GETTEXT
, len
+ 1, (LPARAM
)text
);
666 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
668 /* Windows uses the faster ExtTextOut() to draw the text and
669 to paint the whole client rectangle with the text background
670 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
671 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
672 &rc
, text
, len
, NULL
);
676 DrawTextW( hdc
, text
, -1, &rc
, wFormat
);
679 HeapFree( GetProcessHeap(), 0, text
);
682 SelectObject( hdc
, hOldFont
);
685 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
690 GetClientRect( hwnd
, &rc
);
692 switch (style
& SS_TYPEMASK
)
695 hBrush
= CreateSolidBrush(color_3ddkshadow
);
696 FillRect( hdc
, &rc
, hBrush
);
699 hBrush
= CreateSolidBrush(color_3dshadow
);
700 FillRect( hdc
, &rc
, hBrush
);
703 hBrush
= CreateSolidBrush(color_3dhighlight
);
704 FillRect( hdc
, &rc
, hBrush
);
707 hBrush
= CreateSolidBrush(color_3ddkshadow
);
708 FrameRect( hdc
, &rc
, hBrush
);
711 hBrush
= CreateSolidBrush(color_3dshadow
);
712 FrameRect( hdc
, &rc
, hBrush
);
715 hBrush
= CreateSolidBrush(color_3dhighlight
);
716 FrameRect( hdc
, &rc
, hBrush
);
721 DeleteObject( hBrush
);
724 /* Modified for ReactOS */
725 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
732 GetClientRect( hwnd
, &rc
);
733 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
734 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
735 if (!hIcon
|| (!GetIconInfo(hIcon
, &info
)))
737 FillRect(hdc
, &rc
, hbrush
);
742 if (!GetObjectW(info
.hbmColor
, sizeof(BITMAP
), &bm
)) return;
743 if (style
& SS_CENTERIMAGE
)
745 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - bm
.bmWidth
/ 2;
746 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - bm
.bmHeight
/ 2;
747 iconRect
.right
= iconRect
.left
+ bm
.bmWidth
;
748 iconRect
.bottom
= iconRect
.top
+ bm
.bmHeight
;
752 FillRect( hdc
, &rc
, hbrush
);
753 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
754 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
758 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
761 HBITMAP hBitmap
, oldbitmap
;
764 /* message is still sent, even if the returned brush is not used */
765 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
767 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
768 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
769 && (hMemDC
= CreateCompatibleDC( hdc
)))
775 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
776 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
778 /* Set the background color for monochrome bitmaps
779 to the color of the background brush */
780 if (GetObjectW( hbrush
, sizeof(brush
), &brush
))
782 if (brush
.lbStyle
== BS_SOLID
)
783 SetBkColor(hdc
, brush
.lbColor
);
785 GetClientRect(hwnd
, &rcClient
);
786 if (style
& SS_CENTERIMAGE
)
789 x
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
790 y
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
791 FillRect( hdc
, &rcClient
, hbrush
);
792 BitBlt(hdc
, x
, y
, bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0,
797 StretchBlt(hdc
, 0, 0, rcClient
.right
- rcClient
.left
,
798 rcClient
.bottom
- rcClient
.top
, hMemDC
,
799 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
801 SelectObject(hMemDC
, oldbitmap
);
807 GetClientRect( hwnd
, &rcClient
);
808 FillRect( hdc
, &rcClient
, hbrush
);
813 //static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
815 // HENHMETAFILE hEnhMetaFile;
819 // GetClientRect(hwnd, &rc);
820 // hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
821 // FillRect(hdc, &rc, hbrush);
822 // if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
824 // /* The control's current font is not selected into the
825 // device context! */
826 // if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
827 // PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
832 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
836 GetClientRect( hwnd
, &rc
);
837 switch (style
& SS_TYPEMASK
)
840 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_TOP
|BF_BOTTOM
);
843 DrawEdge(hdc
,&rc
,EDGE_ETCHED
,BF_LEFT
|BF_RIGHT
);
846 DrawEdge (hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);