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 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 const struct builtin_class_descr STATIC_builtin_class =
106 CS_DBLCLKS | CS_PARENTDC, /* style */
107 StaticWndProcA, /* procA */
108 StaticWndProcW, /* procW */
109 STATIC_EXTRA_BYTES, /* extra */
110 IDC_ARROW, /* cursor */
115 /***********************************************************************
118 * Set the icon for an SS_ICON control.
120 static HICON STATIC_SetIcon( HWND hwnd, HICON hicon, DWORD style )
123 CURSORICONINFO * info;
125 if ((style & SS_TYPEMASK) != SS_ICON) return 0;
126 info = hicon?(CURSORICONINFO *) GlobalLock16(HICON_16(hicon)):NULL;
127 if (hicon && !info) {
128 WARN("hicon != 0, but info == 0\n");
131 prevIcon = (HICON)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hicon );
132 if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
134 /* Windows currently doesn't implement SS_RIGHTJUST */
136 if ((style & SS_RIGHTJUST) != 0)
139 GetWindowRect(hwnd, &wr);
140 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
141 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
145 SetWindowPos( hwnd, 0, 0, 0, info->nWidth, info->nHeight,
146 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
149 if (info) GlobalUnlock16(HICON_16(hicon));
153 /***********************************************************************
156 * Set the bitmap for an SS_BITMAP control.
158 static HBITMAP STATIC_SetBitmap( HWND hwnd, HBITMAP hBitmap, DWORD style )
162 if ((style & SS_TYPEMASK) != SS_BITMAP) return 0;
163 if (hBitmap && GetObjectType(hBitmap) != OBJ_BITMAP) {
164 WARN("hBitmap != 0, but it's not a bitmap\n");
167 hOldBitmap = (HBITMAP)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hBitmap );
168 if (hBitmap && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
171 GetObjectW(hBitmap, sizeof(bm), &bm);
172 /* Windows currently doesn't implement SS_RIGHTJUST */
174 if ((style & SS_RIGHTJUST) != 0)
177 GetWindowRect(hwnd, &wr);
178 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
179 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
183 SetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
184 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
191 /***********************************************************************
192 * STATIC_SetEnhMetaFile
194 * Set the enhanced metafile for an SS_ENHMETAFILE control.
196 static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
198 if ((style & SS_TYPEMASK) != SS_ENHMETAFILE) return 0;
199 if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
200 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
203 return (HENHMETAFILE)SetWindowLongPtrW( hwnd, HICON_GWL_OFFSET, (LONG_PTR)hEnhMetaFile );
206 /***********************************************************************
209 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
210 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
212 static HANDLE STATIC_GetImage( HWND hwnd, WPARAM wParam, DWORD style )
214 switch(style & SS_TYPEMASK)
217 if ((wParam != IMAGE_ICON) &&
218 (wParam != IMAGE_CURSOR)) return NULL;
221 if (wParam != IMAGE_BITMAP) return NULL;
224 if (wParam != IMAGE_ENHMETAFILE) return NULL;
229 return (HANDLE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
232 /***********************************************************************
235 * Load the icon for an SS_ICON control.
237 static HICON STATIC_LoadIconA( HWND hwnd, LPCSTR name, DWORD style )
239 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
240 if ((style & SS_REALSIZEIMAGE) != 0)
242 return LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
246 HICON hicon = LoadIconA( hInstance, name );
247 if (!hicon) hicon = LoadCursorA( hInstance, name );
248 if (!hicon) hicon = LoadIconA( 0, name );
249 /* Windows doesn't try to load a standard cursor,
250 probably because most IDs for standard cursors conflict
251 with the IDs for standard icons anyway */
256 /***********************************************************************
259 * Load the icon for an SS_ICON control.
261 static HICON STATIC_LoadIconW( HWND hwnd, LPCWSTR name, DWORD style )
263 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
264 if ((style & SS_REALSIZEIMAGE) != 0)
266 return LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
270 HICON hicon = LoadIconW( hInstance, name );
271 if (!hicon) hicon = LoadCursorW( hInstance, name );
272 if (!hicon) hicon = LoadIconW( 0, name );
273 /* Windows doesn't try to load a standard cursor,
274 probably because most IDs for standard cursors conflict
275 with the IDs for standard icons anyway */
280 /***********************************************************************
283 * Load the bitmap for an SS_BITMAP control.
285 static HBITMAP STATIC_LoadBitmapA( HWND hwnd, LPCSTR name )
287 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
288 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
289 return LoadBitmapA( hInstance, name );
292 /***********************************************************************
295 * Load the bitmap for an SS_BITMAP control.
297 static HBITMAP STATIC_LoadBitmapW( HWND hwnd, LPCWSTR name )
299 HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
300 /* Windows doesn't try to load OEM Bitmaps (hInstance == NULL) */
301 return LoadBitmapW( hInstance, name );
304 /***********************************************************************
307 * Try to immediately paint the control.
309 static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
311 LONG style = full_style & SS_TYPEMASK;
314 GetClientRect( hwnd, &rc );
315 if (!IsRectEmpty(&rc) && IsWindowVisible(hwnd) && staticPaintFunc[style])
319 (staticPaintFunc[style])( hwnd, hdc, full_style );
320 ReleaseDC( hwnd, hdc );
324 static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
326 HBRUSH hBrush = (HBRUSH) SendMessageW( GetParent(hwnd),
327 WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
328 if (!hBrush) /* did the app forget to call DefWindowProc ? */
330 /* FIXME: DefWindowProc should return different colors if a
331 manifest is present */
332 hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORSTATIC,
333 (WPARAM)hdc, (LPARAM)hwnd);
338 static VOID STATIC_InitColours(void)
340 color_3ddkshadow = GetSysColor(COLOR_3DDKSHADOW);
341 color_3dshadow = GetSysColor(COLOR_3DSHADOW);
342 color_3dhighlight = GetSysColor(COLOR_3DHIGHLIGHT);
345 /***********************************************************************
348 * Tests if the control displays text.
350 static BOOL hasTextStyle( DWORD style )
352 switch(style & SS_TYPEMASK)
356 case SS_LEFTNOWORDWRAP:
366 /***********************************************************************
367 * StaticWndProc_common
369 static LRESULT StaticWndProc_common( HWND hwnd, UINT uMsg, WPARAM wParam,
370 LPARAM lParam, BOOL unicode )
373 LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
374 LONG style = full_style & SS_TYPEMASK;
379 if (style < 0L || style > SS_TYPEMASK)
381 ERR("Unknown style 0x%02lx\n", style );
384 STATIC_InitColours();
388 if (style == SS_ICON) {
391 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
393 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
394 * had already been loaded by the application the last thing we want to do is
395 * GlobalFree16 the handle.
399 else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
400 DefWindowProcA(hwnd, uMsg, wParam, lParam);
406 HDC hdc = wParam ? (HDC)wParam : BeginPaint(hwnd, &ps);
407 if (staticPaintFunc[style])
408 (staticPaintFunc[style])( hwnd, hdc, full_style );
409 if (!wParam) EndPaint(hwnd, &ps);
414 STATIC_TryPaintFcn( hwnd, full_style );
415 if (full_style & SS_NOTIFY) {
417 SendMessageW( GetParent(hwnd), WM_COMMAND,
418 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_ENABLE ), (LPARAM)hwnd);
421 SendMessageW( GetParent(hwnd), WM_COMMAND,
422 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DISABLE ), (LPARAM)hwnd);
427 case WM_SYSCOLORCHANGE:
428 STATIC_InitColours();
429 STATIC_TryPaintFcn( hwnd, full_style );
437 if (full_style & SS_SUNKEN)
438 SetWindowLongW( hwnd, GWL_EXSTYLE,
439 GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_STATICEDGE );
444 textW = ((LPCREATESTRUCTW)lParam)->lpszName;
448 textA = ((LPCREATESTRUCTA)lParam)->lpszName;
457 hIcon = STATIC_LoadIconW(hwnd, textW, full_style);
459 hIcon = STATIC_LoadIconA(hwnd, textA, full_style);
460 STATIC_SetIcon(hwnd, hIcon, full_style);
467 hBitmap = STATIC_LoadBitmapW(hwnd, textW);
469 hBitmap = STATIC_LoadBitmapA(hwnd, textA);
470 STATIC_SetBitmap(hwnd, hBitmap, full_style);
474 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
475 the enhanced metafile that was specified as the window text. */
477 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
478 DefWindowProcA(hwnd, uMsg, wParam, lParam);
481 if (hasTextStyle( full_style ))
486 lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
488 lResult = DefWindowProcA( hwnd, uMsg, wParam, lParam );
489 STATIC_TryPaintFcn( hwnd, full_style );
495 if (hasTextStyle( full_style ))
497 SetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET, wParam );
499 STATIC_TryPaintFcn( hwnd, full_style );
504 return GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
507 if (full_style & SS_NOTIFY)
510 return HTTRANSPARENT;
516 case WM_NCLBUTTONDOWN:
517 if (full_style & SS_NOTIFY)
518 SendMessageW( GetParent(hwnd), WM_COMMAND,
519 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_CLICKED ), (LPARAM)hwnd);
522 case WM_LBUTTONDBLCLK:
523 case WM_NCLBUTTONDBLCLK:
524 if (full_style & SS_NOTIFY)
525 SendMessageW( GetParent(hwnd), WM_COMMAND,
526 MAKEWPARAM( GetWindowLongPtrW(hwnd,GWLP_ID), STN_DBLCLK ), (LPARAM)hwnd);
530 return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
534 return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
539 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
541 case IMAGE_ENHMETAFILE:
542 lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
546 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
549 FIXME("STM_SETIMAGE: Unhandled type %x\n", wParam);
552 STATIC_TryPaintFcn( hwnd, full_style );
557 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
558 STATIC_TryPaintFcn( hwnd, full_style );
562 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
563 DefWindowProcA(hwnd, uMsg, wParam, lParam);
568 /***********************************************************************
571 static LRESULT WINAPI StaticWndProcA( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
573 if (!IsWindow( hWnd )) return 0;
574 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
577 /***********************************************************************
580 static LRESULT WINAPI StaticWndProcW( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
582 if (!IsWindow( hWnd )) return 0;
583 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
586 static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
589 HFONT font, oldFont = NULL;
590 UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
592 dis.CtlType = ODT_STATIC;
595 dis.itemAction = ODA_DRAWENTIRE;
596 dis.itemState = IsWindowEnabled(hwnd) ? 0 : ODS_DISABLED;
600 GetClientRect( hwnd, &dis.rcItem );
602 font = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
603 if (font) oldFont = SelectObject( hdc, font );
604 SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
605 SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
606 if (font) SelectObject( hdc, oldFont );
609 static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, DWORD style )
613 HFONT hFont, hOldFont = NULL;
618 GetClientRect( hwnd, &rc);
620 switch (style & SS_TYPEMASK)
623 wFormat = DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK;
627 wFormat = DT_CENTER | DT_EXPANDTABS | DT_WORDBREAK;
631 wFormat = DT_RIGHT | DT_EXPANDTABS | DT_WORDBREAK;
635 wFormat = DT_LEFT | DT_SINGLELINE;
638 case SS_LEFTNOWORDWRAP:
639 wFormat = DT_LEFT | DT_EXPANDTABS;
646 if (style & SS_NOPREFIX)
647 wFormat |= DT_NOPREFIX;
649 if ((style & SS_TYPEMASK) != SS_SIMPLE)
651 if (style & SS_CENTERIMAGE)
652 wFormat |= DT_SINGLELINE | DT_VCENTER;
653 if (style & SS_EDITCONTROL)
654 wFormat |= DT_EDITCONTROL;
655 if (style & SS_ENDELLIPSIS)
656 wFormat |= DT_SINGLELINE | DT_END_ELLIPSIS;
657 if (style & SS_PATHELLIPSIS)
658 wFormat |= DT_SINGLELINE | DT_PATH_ELLIPSIS;
659 if (style & SS_WORDELLIPSIS)
660 wFormat |= DT_SINGLELINE | DT_WORD_ELLIPSIS;
663 if ((hFont = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET )))
664 hOldFont = (HFONT)SelectObject( hdc, hFont );
666 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
668 hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
670 if ((style & SS_TYPEMASK) != SS_SIMPLE)
672 FillRect( hdc, &rc, hBrush );
673 if (!IsWindowEnabled(hwnd)) SetTextColor(hdc, GetSysColor(COLOR_GRAYTEXT));
676 if (!(len = SendMessageW( hwnd, WM_GETTEXTLENGTH, 0, 0 ))) return;
677 if (!(text = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return;
678 SendMessageW( hwnd, WM_GETTEXT, len + 1, (LPARAM)text );
680 if (((style & SS_TYPEMASK) == SS_SIMPLE) && (style & SS_NOPREFIX))
682 /* Windows uses the faster ExtTextOut() to draw the text and
683 to paint the whole client rectangle with the text background
684 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
685 ExtTextOutW( hdc, rc.left, rc.top, ETO_CLIPPED | ETO_OPAQUE,
686 &rc, text, len, NULL );
690 DrawTextW( hdc, text, -1, &rc, wFormat );
693 HeapFree( GetProcessHeap(), 0, text );
696 SelectObject( hdc, hOldFont );
699 static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, DWORD style )
704 GetClientRect( hwnd, &rc);
706 switch (style & SS_TYPEMASK)
709 hBrush = CreateSolidBrush(color_3ddkshadow);
710 FillRect( hdc, &rc, hBrush );
713 hBrush = CreateSolidBrush(color_3dshadow);
714 FillRect( hdc, &rc, hBrush );
717 hBrush = CreateSolidBrush(color_3dhighlight);
718 FillRect( hdc, &rc, hBrush );
721 hBrush = CreateSolidBrush(color_3ddkshadow);
722 FrameRect( hdc, &rc, hBrush );
725 hBrush = CreateSolidBrush(color_3dshadow);
726 FrameRect( hdc, &rc, hBrush );
729 hBrush = CreateSolidBrush(color_3dhighlight);
730 FrameRect( hdc, &rc, hBrush );
735 DeleteObject( hBrush );
739 static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, DWORD style )
744 CURSORICONINFO * info;
746 GetClientRect( hwnd, &rc );
747 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
748 hIcon = (HICON)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET );
749 info = hIcon ? (CURSORICONINFO *)GlobalLock16(HICON_16(hIcon)) : NULL;
752 FillRect(hdc, &rc, hbrush);
756 if (style & SS_CENTERIMAGE)
758 iconRect.left = (rc.right - rc.left) / 2 - info->nWidth / 2;
759 iconRect.top = (rc.bottom - rc.top) / 2 - info->nHeight / 2;
760 iconRect.right = iconRect.left + info->nWidth;
761 iconRect.bottom = iconRect.top + info->nHeight;
765 FillRect( hdc, &rc, hbrush );
766 DrawIconEx( hdc, iconRect.left, iconRect.top, hIcon, iconRect.right - iconRect.left,
767 iconRect.bottom - iconRect.top, 0, NULL, DI_NORMAL );
769 if (info) GlobalUnlock16(HICON_16(hIcon));
772 static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style )
775 HBITMAP hBitmap, oldbitmap;
778 /* message is still sent, even if the returned brush is not used */
779 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
781 if ((hBitmap = (HBITMAP)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET ))
782 && (GetObjectType(hBitmap) == OBJ_BITMAP)
783 && (hMemDC = CreateCompatibleDC( hdc )))
789 GetObjectW(hBitmap, sizeof(bm), &bm);
790 oldbitmap = SelectObject(hMemDC, hBitmap);
792 /* Set the background color for monochrome bitmaps
793 to the color of the background brush */
794 if (GetObjectW( hbrush, sizeof(brush), &brush ))
796 if (brush.lbStyle == BS_SOLID)
797 SetBkColor(hdc, brush.lbColor);
799 GetClientRect(hwnd, &rcClient);
800 if (style & SS_CENTERIMAGE)
803 x = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
804 y = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
805 FillRect( hdc, &rcClient, hbrush );
806 BitBlt(hdc, x, y, bm.bmWidth, bm.bmHeight, hMemDC, 0, 0,
811 StretchBlt(hdc, 0, 0, rcClient.right - rcClient.left,
812 rcClient.bottom - rcClient.top, hMemDC,
813 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
815 SelectObject(hMemDC, oldbitmap);
821 GetClientRect( hwnd, &rcClient );
822 FillRect( hdc, &rcClient, hbrush );
827 static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style )
829 HENHMETAFILE hEnhMetaFile;
833 GetClientRect(hwnd, &rc);
834 hbrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
835 FillRect(hdc, &rc, hbrush);
836 if ((hEnhMetaFile = (HENHMETAFILE)GetWindowLongPtrW( hwnd, HICON_GWL_OFFSET )))
838 /* The control's current font is not selected into the
840 if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
841 PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
846 static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, DWORD style )
850 GetClientRect( hwnd, &rc );
851 switch (style & SS_TYPEMASK)
854 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_TOP|BF_BOTTOM);
857 DrawEdge(hdc,&rc,EDGE_ETCHED,BF_LEFT|BF_RIGHT);
860 DrawEdge (hdc, &rc, EDGE_ETCHED, BF_RECT);