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.
35 * - STM_SETIMAGE: IMAGE_CURSOR
43 #include "wine/winuser16.h"
45 #include "user_private.h"
46 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(static);
50 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style );
51 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style );
52 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style );
53 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style );
54 static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, DWORD style );
55 static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, DWORD style );
56 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style );
57 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
58 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
60 static COLORREF color_3dshadow, color_3ddkshadow, color_3dhighlight;
62 /* offsets for GetWindowLong for static private information */
63 #define HFONT_GWL_OFFSET 0
64 #define HICON_GWL_OFFSET (sizeof(HFONT))
65 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
67 typedef void (*pfPaint)( HWND hwnd, HDC hdc, DWORD style );
69 static pfPaint staticPaintFunc[SS_TYPEMASK+1] =
71 STATIC_PaintTextfn, /* SS_LEFT */
72 STATIC_PaintTextfn, /* SS_CENTER */
73 STATIC_PaintTextfn, /* SS_RIGHT */
74 STATIC_PaintIconfn, /* SS_ICON */
75 STATIC_PaintRectfn, /* SS_BLACKRECT */
76 STATIC_PaintRectfn, /* SS_GRAYRECT */
77 STATIC_PaintRectfn, /* SS_WHITERECT */
78 STATIC_PaintRectfn, /* SS_BLACKFRAME */
79 STATIC_PaintRectfn, /* SS_GRAYFRAME */
80 STATIC_PaintRectfn, /* SS_WHITEFRAME */
81 NULL, /* SS_USERITEM */
82 STATIC_PaintTextfn, /* SS_SIMPLE */
83 STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
84 STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
85 STATIC_PaintBitmapfn, /* SS_BITMAP */
86 STATIC_PaintEnhMetafn, /* SS_ENHMETAFILE */
87 STATIC_PaintEtchedfn, /* SS_ETCHEDHORZ */
88 STATIC_PaintEtchedfn, /* SS_ETCHEDVERT */
89 STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
93 /*********************************************************************
94 * static class descriptor
96 const struct builtin_class_descr STATIC_builtin_class =
99 CS_DBLCLKS | CS_PARENTDC, /* style */
100 StaticWndProcA, /* procA */
101 StaticWndProcW, /* procW */
102 STATIC_EXTRA_BYTES, /* extra */
103 IDC_ARROW, /* cursor */
108 /***********************************************************************
111 * Set the icon for an SS_ICON control.
113 static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
116 CURSORICONINFO * info;
118 if ((style & SS_TYPEMASK) != SS_ICON) return 0;
119 info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL;
120 if (hicon && !info) {
121 WARN("hicon != 0, but info == 0\n");
124 prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
125 if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
127 /* Windows currently doesn't implement SS_RIGHTJUST */
129 if ((style & SS_RIGHTJUST) != 0)
132 GetWindowRect(hwnd, &wr);
133 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
134 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
138 SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
139 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
142 if (info) GlobalUnlock16(HICON_16(hicon));
146 /***********************************************************************
149 * Set the bitmap for an SS_BITMAP control.
151 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
155 if ((style & SS_TYPEMASK) != SS_BITMAP) return 0;
156 if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
157 WARN("hBitmap != 0, but it's not a bitmap\n");
160 hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
161 if (hBitmap && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
164 GetObjectW(hBitmap, sizeof(bm), &bm);
165 /* Windows currently doesn't implement SS_RIGHTJUST */
167 if ((style & SS_RIGHTJUST) != 0)
170 GetWindowRect(hwnd, &wr);
171 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
172 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
176 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
177 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
184 /***********************************************************************
185 * STATIC_SetEnhMetaFile
187 * Set the enhanced metafile for an SS_ENHMETAFILE control.
189 static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
191 if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
192 if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
193 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
196 return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
199 /***********************************************************************
202 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
203 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
205 static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style )
207 switch(style & SS_TYPEMASK)
210 if ((wParam != IMAGE_ICON) &&
211 (wParam != IMAGE_CURSOR)) return NULL;
214 if (wParam != IMAGE_BITMAP) return NULL;
217 if (wParam != IMAGE_ENHMETAFILE) return NULL;
222 return (HANDLE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
225 /***********************************************************************
228 * Load the icon for an SS_ICON control.
230 static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
232 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
233 if ((style & SS_REALSIZEIMAGE) != 0)
235 return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
239 HICON hicon = LoadIconA( hInstance, name );
240 if (!hicon) hicon = LoadCursorA( hInstance, name );
241 if (!hicon) hicon = LoadIconA( 0, name );
242 /* Windows doesn't try to load a standard cursor,
243 probably because most IDs for standard cursors conflict
244 with the IDs for standard icons anyway */
249 /***********************************************************************
252 * Load the icon for an SS_ICON control.
254 static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
256 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
257 if ((style & SS_REALSIZEIMAGE) != 0)
259 return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
263 HICON hicon = LoadIconW( hInstance, name );
264 if (!hicon) hicon = LoadCursorW( hInstance, name );
265 if (!hicon) hicon = LoadIconW( 0, name );
266 /* Windows doesn't try to load a standard cursor,
267 probably because most IDs for standard cursors conflict
268 with the IDs for standard icons anyway */
273 /***********************************************************************
276 * Load the bitmap for an SS_BITMAP control.
278 static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
280 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
281 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
282 return LoadBitmapA( hInstance, name );
285 /***********************************************************************
288 * Load the bitmap for an SS_BITMAP control.
290 static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
292 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
293 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
294 return LoadBitmapW( hInstance, name );
297 /***********************************************************************
300 * Try to immediately paint the control.
302 static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
304 LONG style = full_style & SS_TYPEMASK;
307 GetClientRect( hwnd, &rc );
308 if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
312 (staticPaintFunc[style])( hwnd, hdc, full_style );
313 ReleaseDC( hwnd, hdc );
317 static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
319 HBRUSH hBrush = (HBRUSH) SendMessageW( GetParent(hwnd),
320 WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
321 if (!hBrush) /* did the app forget to call DefWindowProc ? */
323 /* FIXME: DefWindowProc should return different colors if a
324 manifest is present */
325 hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
326 (WPARAM)hdc, (LPARAM)hwnd);
331 static VOID STATIC_InitColours(void)
333 color_3ddkshadow = GetSysColor(COLOR_3DDKSHADOW);
334 color_3dshadow = GetSysColor(COLOR_3DSHADOW);
335 color_3dhighlight = GetSysColor(COLOR_3DHIGHLIGHT);
338 /***********************************************************************
341 * Tests if the control displays text.
343 static BOOL hasTextStyle( DWORD style )
345 switch(style & SS_TYPEMASK)
349 case SS_LEFTNOWORDWRAP:
359 /***********************************************************************
360 * StaticWndProc_common
362 static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
363 LPARAM lParam, BOOL unicode )
366 LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
367 LONG style = full_style & SS_TYPEMASK;
372 if (style < 0L || style > SS_TYPEMASK)
374 ERR("Unknown style 0x%02lx\n", style );
377 STATIC_InitColours();
381 if (style == SS_ICON) {
384 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
386 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
387 * had already been loaded by the application the last thing we want to do is
388 * GlobalFree16 the handle.
392 else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
393 DefWindowProcA(hwnd, uMsg, wParam, lParam);
399 HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
400 if (staticPaintFunc[style])
401 (staticPaintFunc[style])( hwnd, hdc, full_style );
402 if (!wParam) EndPaint(hwnd, &ps);
407 STATIC_TryPaintFcn( hwnd, full_style );
408 if (full_style & SS_NOTIFY) {
410 SendMessageW( GetParent(hwnd), WM_COMMAND,
411 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_ENABLE ), (LPARAM)hwnd);
414 SendMessageW( GetParent(hwnd), WM_COMMAND,
415 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DISABLE ), (LPARAM)hwnd);
420 case WM_SYSCOLORCHANGE:
421 STATIC_InitColours();
422 STATIC_TryPaintFcn( hwnd, full_style );
430 if (full_style & SS_SUNKEN)
431 SetWindowLongW( hwnd, GWL_EXSTYLE,
432 GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
437 textW = ((LPCREATESTRUCTW)lParam)->lpszName;
441 textA = ((LPCREATESTRUCTA)lParam)->lpszName;
450 hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
452 hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
453 STATIC_SetIcon(hwnd, hIcon, full_style);
460 hBitmap = STATIC_LoadBitmapW(hwnd, textW);
462 hBitmap = STATIC_LoadBitmapA(hwnd, textA);
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 ))
479 lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
481 lResult = DefWindowProcA( hwnd, uMsg, wParam, lParam );
482 STATIC_TryPaintFcn( hwnd, full_style );
488 if (hasTextStyle( full_style ))
490 SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
492 STATIC_TryPaintFcn( hwnd, full_style );
497 return GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
500 if (full_style & SS_NOTIFY)
503 return HTTRANSPARENT;
509 case WM_NCLBUTTONDOWN:
510 if (full_style & SS_NOTIFY)
511 SendMessageW( GetParent(hwnd), WM_COMMAND,
512 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_CLICKED ), (LPARAM)hwnd);
515 case WM_LBUTTONDBLCLK:
516 case WM_NCLBUTTONDBLCLK:
517 if (full_style & SS_NOTIFY)
518 SendMessageW( GetParent(hwnd), WM_COMMAND,
519 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DBLCLK ), (LPARAM)hwnd);
523 return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
527 return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
532 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
535 FIXME("STM_SETIMAGE: Unhandled type IMAGE_CURSOR\n");
537 case IMAGE_ENHMETAFILE:
538 lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
541 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
544 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
547 STATIC_TryPaintFcn( hwnd, full_style );
552 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
553 STATIC_TryPaintFcn( hwnd, full_style );
557 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
558 DefWindowProcA(hwnd, uMsg, wParam, lParam);
563 /***********************************************************************
566 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
568 if (!IsWindow( hWnd )) return 0;
569 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
572 /***********************************************************************
575 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
577 if (!IsWindow( hWnd )) return 0;
578 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
581 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
584 HFONT font, oldFont = NULL;
585 UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
587 dis.CtlType = ODT_STATIC;
590 dis.itemAction = ODA_DRAWENTIRE;
591 dis.itemState = IsWindowEnabled(hwnd) ? 0 : ODS_DISABLED;
595 GetClientRect( hwnd, &dis.rcItem );
597 font = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
598 if (font) oldFont = SelectObject( hdc, font );
599 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
600 SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
601 if (font) SelectObject( hdc, oldFont );
604 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
608 HFONT hFont, hOldFont = NULL;
613 GetClientRect( hwnd, &rc);
615 switch (style & SS_TYPEMASK)
618 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
622 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
626 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
630 wFormat = DT_LEFT | DT_SINGLELINE;
633 case SS_LEFTNOWORDWRAP:
634 wFormat = DT_LEFT | DT_EXPANDTABS;
641 if (style & SS_NOPREFIX)
642 wFormat |= DT_NOPREFIX;
644 if ((style & SS_TYPEMASK) != SS_SIMPLE)
646 if (style & SS_CENTERIMAGE)
647 wFormat |= DT_SINGLELINE | DT_VCENTER;
648 if (style & SS_EDITCONTROL)
649 wFormat |= DT_EDITCONTROL;
650 if (style & SS_ENDELLIPSIS)
651 wFormat |= DT_SINGLELINE | DT_END_ELLIPSIS;
652 if (style & SS_PATHELLIPSIS)
653 wFormat |= DT_SINGLELINE | DT_PATH_ELLIPSIS;
654 if (style & SS_WORDELLIPSIS)
655 wFormat |= DT_SINGLELINE | DT_WORD_ELLIPSIS;
658 if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET )))
659 hOldFont = (HFONT)SelectObject( hdc, hFont );
661 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
663 hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
665 if ((style & SS_TYPEMASK) != SS_SIMPLE)
667 FillRect( hdc, &rc, hBrush );
668 if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
671 if (!(len = SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ))) return;
672 if (!(text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return;
673 SendMessageW( hwnd, WM_GETTEXT, len + 1, (LPARAM)text );
675 if (((style & SS_TYPEMASK) == SS_SIMPLE) && (style & SS_NOPREFIX))
677 /* Windows uses the faster ExtTextOut() to draw the text and
678 to paint the whole client rectangle with the text background
679 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
680 ExtTextOutW( hdc, rc.left, rc.top, ETO_CLIPPED | ETO_OPAQUE,
681 &rc, text, len, NULL );
685 DrawTextW( hdc, text, -1, &rc, wFormat );
688 HeapFree( GetProcessHeap(), 0, text );
691 SelectObject( hdc, hOldFont );
694 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
699 GetClientRect( hwnd, &rc);
701 switch (style & SS_TYPEMASK)
704 hBrush = CreateSolidBrush(color_3ddkshadow);
705 FillRect( hdc, &rc, hBrush );
708 hBrush = CreateSolidBrush(color_3dshadow);
709 FillRect( hdc, &rc, hBrush );
712 hBrush = CreateSolidBrush(color_3dhighlight);
713 FillRect( hdc, &rc, hBrush );
716 hBrush = CreateSolidBrush(color_3ddkshadow);
717 FrameRect( hdc, &rc, hBrush );
720 hBrush = CreateSolidBrush(color_3dshadow);
721 FrameRect( hdc, &rc, hBrush );
724 hBrush = CreateSolidBrush(color_3dhighlight);
725 FrameRect( hdc, &rc, hBrush );
730 DeleteObject( hBrush );
734 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
741 GetClientRect( hwnd, &rc );
742 hbrush = (HBRUSH)SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
743 (WPARAM)hdc, (LPARAM)hwnd );
744 FillRect( hdc, &rc, hbrush );
745 hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
746 if (style & SS_CENTERIMAGE)
748 CURSORICONINFO *info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
749 x = (rc.right - rc.left)/2 - (info ? info->nWidth/2 : 0);
750 y = (rc.bottom - rc.top)/2 - (info ? info->nHeight/2 : 0);
758 DrawIcon( hdc, x, y, hIcon );
761 static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
764 HBITMAP hBitmap, oldbitmap;
766 /* message is still sent, even if the returned brush is not used */
767 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC,
768 (WPARAM)hdc, (LPARAM)hwnd );
770 if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
775 if(GetObjectType(hBitmap) != OBJ_BITMAP) return;
776 if (!(hMemDC = CreateCompatibleDC( hdc ))) return;
777 GetObjectW(hBitmap, sizeof(bm), &bm);
778 oldbitmap = SelectObject(hMemDC, hBitmap);
779 if (style & SS_CENTERIMAGE)
782 GetClientRect(hwnd, &rcClient);
783 x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
784 y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
791 BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
793 SelectObject(hMemDC, oldbitmap);
799 static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
801 HENHMETAFILE hEnhMetaFile;
805 GetClientRect(hwnd, &rc);
806 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
807 FillRect(hdc, &rc, hbrush);
808 if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
810 /* The control's current font is not selected into the
812 if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
813 PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
818 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
822 GetClientRect( hwnd, &rc );
823 switch (style & SS_TYPEMASK)
826 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
829 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
832 DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);