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
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).
50 #include "wine/winuser16.h"
52 #include "user_private.h"
53 #include "wine/debug.h"
55 WINE_DEFAULT_DEBUG_CHANNEL(static);
57 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style );
58 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style );
59 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style );
60 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style );
61 static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style );
62 static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
63 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
64 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
65 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
67 static COLORREF color_3dshadow, color_3ddkshadow, color_3dhighlight;
69 /* offsets for GetWindowLong for static private information */
70 #define HFONT_GWL_OFFSET 0
71 #define HICON_GWL_OFFSET (sizeof(HFONT))
72 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
74 typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
76 static const pfPaint staticPaintFunc[SS_TYPEMASK+1] =
78 STATIC_PaintTextfn, /* SS_LEFT */
79 STATIC_PaintTextfn, /* SS_CENTER */
80 STATIC_PaintTextfn, /* SS_RIGHT */
81 STATIC_PaintIconfn, /* SS_ICON */
82 STATIC_PaintRectfn, /* SS_BLACKRECT */
83 STATIC_PaintRectfn, /* SS_GRAYRECT */
84 STATIC_PaintRectfn, /* SS_WHITERECT */
85 STATIC_PaintRectfn, /* SS_BLACKFRAME */
86 STATIC_PaintRectfn, /* SS_GRAYFRAME */
87 STATIC_PaintRectfn, /* SS_WHITEFRAME */
88 NULL, /* SS_USERITEM */
89 STATIC_PaintTextfn, /* SS_SIMPLE */
90 STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
91 STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
92 STATIC_PaintBitmapfn, /* SS_BITMAP */
93 STATIC_PaintEnhMetafn, /* SS_ENHMETAFILE */
94 STATIC_PaintEtchedfn, /* SS_ETCHEDHORZ */
95 STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
96 STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
100 /*********************************************************************
101 * static class descriptor
103 static const WCHAR staticW[] = {'S','t','a','t','i','c',0};
104 const struct builtin_class_descr STATIC_builtin_class =
107 CS_DBLCLKS | CS_PARENTDC, /* style */
108 StaticWndProcA, /* procA */
109 StaticWndProcW, /* procW */
110 STATIC_EXTRA_BYTES, /* extra */
111 IDC_ARROW, /* cursor */
115 static void setup_clipping(HWND hwnd, HDC hdc, HRGN *orig)
120 /* Native control has always a clipping region set (this may be because
121 * builtin controls uses CS_PARENTDC) and an application depends on it
123 hrgn = CreateRectRgn(0, 0, 1, 1);
124 if (GetClipRgn(hdc, hrgn) != 1)
131 GetClientRect(hwnd, &rc);
132 DPtoLP(hdc, (POINT *)&rc, 2);
133 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
136 static void restore_clipping(HDC hdc, HRGN hrgn)
138 SelectClipRgn(hdc, hrgn);
143 /***********************************************************************
146 * Set the icon for an SS_ICON control.
148 static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
151 CURSORICONINFO * info;
153 if ((style & SS_TYPEMASK) != SS_ICON) return 0;
154 info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL;
155 if (hicon && !info) {
156 WARN("hicon != 0, but info == 0\n");
159 prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
160 if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
162 /* Windows currently doesn't implement SS_RIGHTJUST */
164 if ((style & SS_RIGHTJUST) != 0)
167 GetWindowRect(hwnd, &wr);
168 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
169 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
173 SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
174 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
177 if (info) GlobalUnlock16(HICON_16(hicon));
181 /***********************************************************************
184 * Set the bitmap for an SS_BITMAP control.
186 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
190 if ((style & SS_TYPEMASK) != SS_BITMAP) return 0;
191 if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
192 WARN("hBitmap != 0, but it's not a bitmap\n");
195 hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
196 if (hBitmap && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
199 GetObjectW(hBitmap, sizeof(bm), &bm);
200 /* Windows currently doesn't implement SS_RIGHTJUST */
202 if ((style & SS_RIGHTJUST) != 0)
205 GetWindowRect(hwnd, &wr);
206 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
207 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
211 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
212 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
219 /***********************************************************************
220 * STATIC_SetEnhMetaFile
222 * Set the enhanced metafile for an SS_ENHMETAFILE control.
224 static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
226 if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
227 if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
228 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
231 return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
234 /***********************************************************************
237 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
238 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
240 static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style )
242 switch(style & SS_TYPEMASK)
245 if ((wParam != IMAGE_ICON) &&
246 (wParam != IMAGE_CURSOR)) return NULL;
249 if (wParam != IMAGE_BITMAP) return NULL;
252 if (wParam != IMAGE_ENHMETAFILE) return NULL;
257 return (HANDLE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
260 /***********************************************************************
263 * Load the icon for an SS_ICON control.
265 static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
267 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
268 if ((style & SS_REALSIZEIMAGE) != 0)
270 return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
274 HICON hicon = LoadIconA( hInstance, name );
275 if (!hicon) hicon = LoadCursorA( hInstance, name );
276 if (!hicon) hicon = LoadIconA( 0, name );
277 /* Windows doesn't try to load a standard cursor,
278 probably because most IDs for standard cursors conflict
279 with the IDs for standard icons anyway */
284 /***********************************************************************
287 * Load the icon for an SS_ICON control.
289 static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
291 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
292 if ((style & SS_REALSIZEIMAGE) != 0)
294 return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
298 HICON hicon = LoadIconW( hInstance, name );
299 if (!hicon) hicon = LoadCursorW( hInstance, name );
300 if (!hicon) hicon = LoadIconW( 0, name );
301 /* Windows doesn't try to load a standard cursor,
302 probably because most IDs for standard cursors conflict
303 with the IDs for standard icons anyway */
308 /***********************************************************************
311 * Load the bitmap for an SS_BITMAP control.
313 static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
315 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
316 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
317 return LoadBitmapA( hInstance, name );
320 /***********************************************************************
323 * Load the bitmap for an SS_BITMAP control.
325 static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
327 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
328 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
329 return LoadBitmapW( hInstance, name );
332 /***********************************************************************
335 * Try to immediately paint the control.
337 static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
339 LONG style = full_style & SS_TYPEMASK;
342 GetClientRect( hwnd, &rc );
343 if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
349 setup_clipping(hwnd, hdc, &hOrigClipping);
350 (staticPaintFunc[style])( hwnd, hdc, full_style );
351 restore_clipping(hdc, hOrigClipping);
352 ReleaseDC( hwnd, hdc );
356 static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
359 HWND parent = GetParent(hwnd);
361 if (!parent) parent = hwnd;
362 hBrush = (HBRUSH) SendMessageW( parent,
363 WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
364 if (!hBrush) /* did the app forget to call DefWindowProc ? */
366 /* FIXME: DefWindowProc should return different colors if a
367 manifest is present */
368 hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC,
369 (WPARAM)hdc, (LPARAM)hwnd);
374 static VOID STATIC_InitColours(void)
376 color_3ddkshadow = GetSysColor(COLOR_3DDKSHADOW);
377 color_3dshadow = GetSysColor(COLOR_3DSHADOW);
378 color_3dhighlight = GetSysColor(COLOR_3DHIGHLIGHT);
381 /***********************************************************************
384 * Tests if the control displays text.
386 static BOOL hasTextStyle( DWORD style )
388 switch(style & SS_TYPEMASK)
392 case SS_LEFTNOWORDWRAP:
402 /***********************************************************************
403 * StaticWndProc_common
405 static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
406 LPARAM lParam, BOOL unicode )
409 LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
410 LONG style = full_style & SS_TYPEMASK;
415 if (style < 0L || style > SS_TYPEMASK)
417 ERR("Unknown style 0x%02x\n", style );
420 STATIC_InitColours();
424 if (style == SS_ICON) {
427 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
429 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
430 * had already been loaded by the application the last thing we want to do is
431 * GlobalFree16 the handle.
435 else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
436 DefWindowProcA(hwnd, uMsg, wParam, lParam);
439 /* do all painting in WM_PAINT like Windows does */
446 HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
447 if (staticPaintFunc[style])
450 setup_clipping(hwnd, hdc, &hOrigClipping);
451 (staticPaintFunc[style])( hwnd, hdc, full_style );
452 restore_clipping(hdc, hOrigClipping);
454 if (!wParam) EndPaint(hwnd, &ps);
459 STATIC_TryPaintFcn( hwnd, full_style );
460 if (full_style & SS_NOTIFY) {
462 SendMessageW( GetParent(hwnd), WM_COMMAND,
463 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_ENABLE ), (LPARAM)hwnd);
466 SendMessageW( GetParent(hwnd), WM_COMMAND,
467 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DISABLE ), (LPARAM)hwnd);
472 case WM_SYSCOLORCHANGE:
473 STATIC_InitColours();
474 STATIC_TryPaintFcn( hwnd, full_style );
482 if (full_style & SS_SUNKEN)
483 SetWindowLongW( hwnd, GWL_EXSTYLE,
484 GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
489 textW = ((LPCREATESTRUCTW)lParam)->lpszName;
493 textA = ((LPCREATESTRUCTA)lParam)->lpszName;
502 hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
504 hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
505 STATIC_SetIcon(hwnd, hIcon, full_style);
512 hBitmap = STATIC_LoadBitmapW(hwnd, textW);
514 hBitmap = STATIC_LoadBitmapA(hwnd, textA);
515 STATIC_SetBitmap(hwnd, hBitmap, full_style);
519 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
520 the enhanced metafile that was specified as the window text. */
522 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
523 DefWindowProcA(hwnd, uMsg, wParam, lParam);
526 if (hasTextStyle( full_style ))
531 lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
533 lResult = DefWindowProcA( hwnd, uMsg, wParam, lParam );
534 STATIC_TryPaintFcn( hwnd, full_style );
540 if (hasTextStyle( full_style ))
542 SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
544 RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
549 return GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
552 if (full_style & SS_NOTIFY)
555 return HTTRANSPARENT;
561 case WM_NCLBUTTONDOWN:
562 if (full_style & SS_NOTIFY)
563 SendMessageW( GetParent(hwnd), WM_COMMAND,
564 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_CLICKED ), (LPARAM)hwnd);
567 case WM_LBUTTONDBLCLK:
568 case WM_NCLBUTTONDBLCLK:
569 if (full_style & SS_NOTIFY)
570 SendMessageW( GetParent(hwnd), WM_COMMAND,
571 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DBLCLK ), (LPARAM)hwnd);
575 return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
579 return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
584 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
586 case IMAGE_ENHMETAFILE:
587 lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
591 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
594 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam);
597 STATIC_TryPaintFcn( hwnd, full_style );
602 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
603 STATIC_TryPaintFcn( hwnd, full_style );
607 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
608 DefWindowProcA(hwnd, uMsg, wParam, lParam);
613 /***********************************************************************
616 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
618 if (!IsWindow( hWnd )) return 0;
619 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
622 /***********************************************************************
625 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
627 if (!IsWindow( hWnd )) return 0;
628 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
631 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
634 HFONT font, oldFont = NULL;
635 UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
637 dis.CtlType = ODT_STATIC;
640 dis.itemAction = ODA_DRAWENTIRE;
641 dis.itemState = IsWindowEnabled(hwnd) ? 0 : ODS_DISABLED;
645 GetClientRect( hwnd, &dis.rcItem );
647 font = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
648 if (font) oldFont = SelectObject( hdc, font );
649 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
650 SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
651 if (font) SelectObject( hdc, oldFont );
654 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
658 HFONT hFont, hOldFont = NULL;
663 GetClientRect( hwnd, &rc);
665 switch (style & SS_TYPEMASK)
668 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
672 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
676 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
680 wFormat = DT_LEFT | DT_SINGLELINE;
683 case SS_LEFTNOWORDWRAP:
684 wFormat = DT_LEFT | DT_EXPANDTABS;
691 if (style & SS_NOPREFIX)
692 wFormat |= DT_NOPREFIX;
694 if ((style & SS_TYPEMASK) != SS_SIMPLE)
696 if (style & SS_CENTERIMAGE)
697 wFormat |= DT_SINGLELINE | DT_VCENTER;
698 if (style & SS_EDITCONTROL)
699 wFormat |= DT_EDITCONTROL;
700 if (style & SS_ENDELLIPSIS)
701 wFormat |= DT_SINGLELINE | DT_END_ELLIPSIS;
702 if (style & SS_PATHELLIPSIS)
703 wFormat |= DT_SINGLELINE | DT_PATH_ELLIPSIS;
704 if (style & SS_WORDELLIPSIS)
705 wFormat |= DT_SINGLELINE | DT_WORD_ELLIPSIS;
708 if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET )))
709 hOldFont = (HFONT)SelectObject( hdc, hFont );
711 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
713 hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
715 if ((style & SS_TYPEMASK) != SS_SIMPLE)
717 FillRect( hdc, &rc, hBrush );
718 if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
722 if (!(text = HeapAlloc( GetProcessHeap(), 0, buf_size * sizeof(WCHAR) )))
725 while ((len = InternalGetWindowText( hwnd, text, buf_size )) == buf_size - 1)
728 if (!(text = HeapReAlloc( GetProcessHeap(), 0, text, buf_size * sizeof(WCHAR) )))
732 if (!len) goto no_TextOut;
734 if (((style & SS_TYPEMASK) == SS_SIMPLE) && (style & SS_NOPREFIX))
736 /* Windows uses the faster ExtTextOut() to draw the text and
737 to paint the whole client rectangle with the text background
738 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
739 ExtTextOutW( hdc, rc.left, rc.top, ETO_CLIPPED | ETO_OPAQUE,
740 &rc, text, len, NULL );
744 DrawTextW( hdc, text, -1, &rc, wFormat );
748 HeapFree( GetProcessHeap(), 0, text );
751 SelectObject( hdc, hOldFont );
754 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
759 GetClientRect( hwnd, &rc);
761 /* FIXME: send WM_CTLCOLORSTATIC */
762 switch (style & SS_TYPEMASK)
765 hBrush = CreateSolidBrush(color_3ddkshadow);
766 FillRect( hdc, &rc, hBrush );
769 hBrush = CreateSolidBrush(color_3dshadow);
770 FillRect( hdc, &rc, hBrush );
773 hBrush = CreateSolidBrush(color_3dhighlight);
774 FillRect( hdc, &rc, hBrush );
777 hBrush = CreateSolidBrush(color_3ddkshadow);
778 FrameRect( hdc, &rc, hBrush );
781 hBrush = CreateSolidBrush(color_3dshadow);
782 FrameRect( hdc, &rc, hBrush );
785 hBrush = CreateSolidBrush(color_3dhighlight);
786 FrameRect( hdc, &rc, hBrush );
791 DeleteObject( hBrush );
795 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
800 CURSORICONINFO * info;
802 GetClientRect( hwnd, &rc );
803 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
804 hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
805 info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
808 FillRect(hdc, &rc, hbrush);
812 if (style & SS_CENTERIMAGE)
814 iconRect.left = (rc.right - rc.left) / 2 - info->nWidth / 2;
815 iconRect.top = (rc.bottom - rc.top) / 2 - info->nHeight / 2;
816 iconRect.right = iconRect.left + info->nWidth;
817 iconRect.bottom = iconRect.top + info->nHeight;
821 FillRect( hdc, &rc, hbrush );
822 DrawIconEx( hdc, iconRect.left, iconRect.top, hIcon, iconRect.right - iconRect.left,
823 iconRect.bottom - iconRect.top, 0, NULL, DI_NORMAL );
825 if (info) GlobalUnlock16(HICON_16(hIcon));
828 static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
831 HBITMAP hBitmap, oldbitmap;
834 /* message is still sent, even if the returned brush is not used */
835 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
837 if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET ))
838 && (GetObjectType(hBitmap) == OBJ_BITMAP)
839 && (hMemDC = CreateCompatibleDC( hdc )))
845 GetObjectW(hBitmap, sizeof(bm), &bm);
846 oldbitmap = SelectObject(hMemDC, hBitmap);
848 /* Set the background color for monochrome bitmaps
849 to the color of the background brush */
850 if (GetObjectW( hbrush, sizeof(brush), &brush ))
852 if (brush.lbStyle == BS_SOLID)
853 SetBkColor(hdc, brush.lbColor);
855 GetClientRect(hwnd, &rcClient);
856 if (style & SS_CENTERIMAGE)
859 x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
860 y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
861 FillRect( hdc, &rcClient, hbrush );
862 BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
867 StretchBlt(hdc, 0, 0, rcClient.right - rcClient.left,
868 rcClient.bottom - rcClient.top, hMemDC,
869 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
871 SelectObject(hMemDC, oldbitmap);
877 GetClientRect( hwnd, &rcClient );
878 FillRect( hdc, &rcClient, hbrush );
883 static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
885 HENHMETAFILE hEnhMetaFile;
889 GetClientRect(hwnd, &rc);
890 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
891 FillRect(hdc, &rc, hbrush);
892 if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
894 /* The control's current font is not selected into the
896 if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
897 PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
902 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
906 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
907 GetClientRect( hwnd, &rc );
908 switch (style & SS_TYPEMASK)
911 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
914 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
917 DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);