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 * - Windows XP introduced new behavior: The background of centered
22 * icons and bitmaps is painted differently. This is only done if
23 * a manifest is present.
24 * Because it has not yet been decided how to implement the two
25 * different modes in Wine, only the Windows XP mode is implemented.
26 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
27 * The text should not be changed. Windows doesn't clear the
28 * client rectangle, so the new text must be larger than the old one.
29 * - The SS_RIGHTJUST style is currently not implemented by Windows
30 * (or it does something different than documented).
44 #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
);
58 /* offsets for GetWindowLong for static private information */
59 #define HFONT_GWL_OFFSET 0
60 #define HICON_GWL_OFFSET (sizeof(HFONT))
61 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
63 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
65 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
67 STATIC_PaintTextfn
, /* SS_LEFT */
68 STATIC_PaintTextfn
, /* SS_CENTER */
69 STATIC_PaintTextfn
, /* SS_RIGHT */
70 STATIC_PaintIconfn
, /* SS_ICON */
71 STATIC_PaintRectfn
, /* SS_BLACKRECT */
72 STATIC_PaintRectfn
, /* SS_GRAYRECT */
73 STATIC_PaintRectfn
, /* SS_WHITERECT */
74 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
75 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
76 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
77 NULL
, /* SS_USERITEM */
78 STATIC_PaintTextfn
, /* SS_SIMPLE */
79 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
80 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
81 STATIC_PaintBitmapfn
, /* SS_BITMAP */
82 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
83 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
84 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
85 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
88 static BOOL
get_icon_size( HICON handle
, SIZE
*size
)
94 if (!GetIconInfo(handle
, &info
))
97 ret
= GetObjectW(info
.hbmColor
, sizeof(bmp
), &bmp
);
100 size
->cx
= bmp
.bmWidth
;
101 size
->cy
= bmp
.bmHeight
;
104 DeleteObject(info
.hbmMask
);
105 DeleteObject(info
.hbmColor
);
110 /***********************************************************************
113 * Set the icon for an SS_ICON control.
115 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
120 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
121 if (hicon
&& !get_icon_size( hicon
, &size
))
123 WARN("hicon != 0, but invalid\n");
126 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
127 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
129 /* Windows currently doesn't implement SS_RIGHTJUST */
131 if ((style & SS_RIGHTJUST) != 0)
134 GetWindowRect(hwnd, &wr);
135 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
136 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
140 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
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
)
158 WARN("hBitmap != 0, but it's not a bitmap\n");
161 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
162 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
165 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
166 /* Windows currently doesn't implement SS_RIGHTJUST */
168 if ((style & SS_RIGHTJUST) != 0)
171 GetWindowRect(hwnd, &wr);
172 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
173 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
177 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
178 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
)
194 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
197 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
200 /***********************************************************************
203 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
204 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
206 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
208 switch (style
& SS_TYPEMASK
)
211 if ((wParam
!= IMAGE_ICON
) &&
212 (wParam
!= IMAGE_CURSOR
)) return NULL
;
215 if (wParam
!= IMAGE_BITMAP
) return NULL
;
218 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
223 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
226 /***********************************************************************
229 * Load the icon for an SS_ICON control.
231 static HICON
STATIC_LoadIconW( HINSTANCE hInstance
, LPCWSTR name
, DWORD style
)
235 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
237 if ((style
& SS_REALSIZEIMAGE
) != 0)
238 hicon
= LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
241 hicon
= LoadIconW( hInstance
, name
);
242 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
245 if (!hicon
) hicon
= LoadIconW( 0, name
);
246 /* Windows doesn't try to load a standard cursor,
247 probably because most IDs for standard cursors conflict
248 with the IDs for standard icons anyway */
252 /***********************************************************************
255 * Try to immediately paint the control.
257 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
259 LONG style
= full_style
& SS_TYPEMASK
;
262 GetClientRect( hwnd
, &rc
);
263 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
269 hrgn
= set_control_clipping( hdc
, &rc
);
270 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
271 SelectClipRgn( hdc
, hrgn
);
272 if (hrgn
) DeleteObject( hrgn
);
273 ReleaseDC( hwnd
, hdc
);
277 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
280 HWND parent
= GetParent(hwnd
);
282 if (!parent
) parent
= hwnd
;
283 hBrush
= (HBRUSH
) SendMessageW( parent
, WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
284 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
286 /* FIXME: DefWindowProc should return different colors if a
287 manifest is present */
288 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
293 /***********************************************************************
296 * Tests if the control displays text.
298 static BOOL
hasTextStyle( DWORD style
)
300 switch (style
& SS_TYPEMASK
)
304 case SS_LEFTNOWORDWRAP
:
314 static LRESULT CALLBACK
STATIC_WindowProc( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
317 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
318 LONG style
= full_style
& SS_TYPEMASK
;
320 if (!IsWindow( hwnd
)) return 0;
325 if (style
< 0L || style
> SS_TYPEMASK
)
327 ERR("Unknown style 0x%02x\n", style
);
333 if (style
== SS_ICON
)
337 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
339 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
340 * had already been loaded by the application the last thing we want to do is
341 * GlobalFree16 the handle.
346 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
349 /* do all painting in WM_PAINT like Windows does */
357 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
358 GetClientRect( hwnd
, &rect
);
359 if (staticPaintFunc
[style
])
361 HRGN hrgn
= set_control_clipping( hdc
, &rect
);
362 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
363 SelectClipRgn( hdc
, hrgn
);
364 if (hrgn
) DeleteObject( hrgn
);
366 if (!wParam
) EndPaint(hwnd
, &ps
);
371 STATIC_TryPaintFcn( hwnd
, full_style
);
372 if (full_style
& SS_NOTIFY
)
375 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
376 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
378 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
379 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
383 case WM_SYSCOLORCHANGE
:
384 COMCTL32_RefreshSysColors();
385 STATIC_TryPaintFcn( hwnd
, full_style
);
390 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
392 if (full_style
& SS_SUNKEN
)
393 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
394 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
402 hIcon
= STATIC_LoadIconW(cs
->hInstance
, cs
->lpszName
, full_style
);
403 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
407 if ((ULONG_PTR
)cs
->hInstance
>> 16)
410 hBitmap
= LoadBitmapW(cs
->hInstance
, cs
->lpszName
);
411 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
415 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
416 the enhanced metafile that was specified as the window text. */
418 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
421 if (hasTextStyle( full_style
))
423 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
424 STATIC_TryPaintFcn( hwnd
, full_style
);
429 if (hasTextStyle( full_style
))
431 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
433 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
438 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
441 if (full_style
& SS_NOTIFY
)
444 return HTTRANSPARENT
;
450 case WM_NCLBUTTONDOWN
:
451 if (full_style
& SS_NOTIFY
)
452 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
453 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
456 case WM_LBUTTONDBLCLK
:
457 case WM_NCLBUTTONDBLCLK
:
458 if (full_style
& SS_NOTIFY
)
459 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
460 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
464 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
467 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
473 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
475 case IMAGE_ENHMETAFILE
:
476 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
480 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
483 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam
);
486 STATIC_TryPaintFcn( hwnd
, full_style
);
490 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
491 STATIC_TryPaintFcn( hwnd
, full_style
);
495 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
500 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
503 HFONT font
, oldFont
= NULL
;
504 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
506 dis
.CtlType
= ODT_STATIC
;
509 dis
.itemAction
= ODA_DRAWENTIRE
;
510 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
514 GetClientRect( hwnd
, &dis
.rcItem
);
516 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
517 if (font
) oldFont
= SelectObject( hdc
, font
);
518 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
519 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
520 if (font
) SelectObject( hdc
, oldFont
);
523 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
527 HFONT hFont
, hOldFont
= NULL
;
532 GetClientRect( hwnd
, &rc
);
534 switch (style
& SS_TYPEMASK
)
537 format
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
541 format
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
545 format
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
549 format
= DT_LEFT
| DT_SINGLELINE
;
552 case SS_LEFTNOWORDWRAP
:
553 format
= DT_LEFT
| DT_EXPANDTABS
;
560 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
561 format
= DT_RIGHT
| (format
& ~(DT_LEFT
| DT_CENTER
));
563 if (style
& SS_NOPREFIX
)
564 format
|= DT_NOPREFIX
;
566 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
568 if (style
& SS_CENTERIMAGE
)
569 format
|= DT_SINGLELINE
| DT_VCENTER
;
570 if (style
& SS_EDITCONTROL
)
571 format
|= DT_EDITCONTROL
;
572 if (style
& SS_ENDELLIPSIS
)
573 format
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
574 if (style
& SS_PATHELLIPSIS
)
575 format
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
576 if (style
& SS_WORDELLIPSIS
)
577 format
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
580 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
581 hOldFont
= SelectObject( hdc
, hFont
);
583 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
585 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
587 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
589 FillRect( hdc
, &rc
, hBrush
);
590 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
594 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
597 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
600 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
604 if (!len
) goto no_TextOut
;
606 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
608 /* Windows uses the faster ExtTextOut() to draw the text and
609 to paint the whole client rectangle with the text background
610 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
611 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
612 &rc
, text
, len
, NULL
);
616 DrawTextW( hdc
, text
, -1, &rc
, format
);
620 HeapFree( GetProcessHeap(), 0, text
);
623 SelectObject( hdc
, hOldFont
);
626 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
631 GetClientRect( hwnd
, &rc
);
633 /* FIXME: send WM_CTLCOLORSTATIC */
634 switch (style
& SS_TYPEMASK
)
637 hBrush
= CreateSolidBrush(comctl32_color
.clr3dDkShadow
);
638 FillRect( hdc
, &rc
, hBrush
);
641 hBrush
= CreateSolidBrush(comctl32_color
.clr3dShadow
);
642 FillRect( hdc
, &rc
, hBrush
);
645 hBrush
= CreateSolidBrush(comctl32_color
.clr3dHilight
);
646 FillRect( hdc
, &rc
, hBrush
);
649 hBrush
= CreateSolidBrush(comctl32_color
.clr3dDkShadow
);
650 FrameRect( hdc
, &rc
, hBrush
);
653 hBrush
= CreateSolidBrush(comctl32_color
.clr3dShadow
);
654 FrameRect( hdc
, &rc
, hBrush
);
657 hBrush
= CreateSolidBrush(comctl32_color
.clr3dHilight
);
658 FrameRect( hdc
, &rc
, hBrush
);
663 DeleteObject( hBrush
);
667 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
674 GetClientRect( hwnd
, &rc
);
675 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
676 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
677 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
679 FillRect(hdc
, &rc
, hbrush
);
683 if (style
& SS_CENTERIMAGE
)
685 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
686 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
687 iconRect
.right
= iconRect
.left
+ size
.cx
;
688 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
692 FillRect( hdc
, &rc
, hbrush
);
693 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
694 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
698 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
701 HBITMAP hBitmap
, oldbitmap
;
704 /* message is still sent, even if the returned brush is not used */
705 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
707 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
708 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
709 && (hMemDC
= CreateCompatibleDC( hdc
)))
715 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
716 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
718 /* Set the background color for monochrome bitmaps
719 to the color of the background brush */
720 if (GetObjectW( hbrush
, sizeof(brush
), &brush
))
722 if (brush
.lbStyle
== BS_SOLID
)
723 SetBkColor(hdc
, brush
.lbColor
);
725 GetClientRect(hwnd
, &rcClient
);
726 if (style
& SS_CENTERIMAGE
)
728 FillRect( hdc
, &rcClient
, hbrush
);
729 rcClient
.left
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
730 rcClient
.top
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
731 rcClient
.right
= rcClient
.left
+ bm
.bmWidth
;
732 rcClient
.bottom
= rcClient
.top
+ bm
.bmHeight
;
734 StretchBlt(hdc
, rcClient
.left
, rcClient
.top
, rcClient
.right
- rcClient
.left
,
735 rcClient
.bottom
- rcClient
.top
, hMemDC
,
736 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
737 SelectObject(hMemDC
, oldbitmap
);
742 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
744 HENHMETAFILE hEnhMetaFile
;
748 GetClientRect(hwnd
, &rc
);
749 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
750 FillRect(hdc
, &rc
, hbrush
);
751 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
753 /* The control's current font is not selected into the
755 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
756 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
760 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
764 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
765 GetClientRect( hwnd
, &rc
);
766 switch (style
& SS_TYPEMASK
)
769 DrawEdge(hdc
, &rc
, EDGE_ETCHED
, BF_TOP
| BF_BOTTOM
);
772 DrawEdge(hdc
, &rc
, EDGE_ETCHED
, BF_LEFT
| BF_RIGHT
);
775 DrawEdge(hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);
780 void STATIC_Register(void)
784 memset(&wndClass
, 0, sizeof(wndClass
));
785 wndClass
.style
= CS_DBLCLKS
| CS_PARENTDC
| CS_GLOBALCLASS
;
786 wndClass
.lpfnWndProc
= STATIC_WindowProc
;
787 wndClass
.cbClsExtra
= 0;
788 wndClass
.cbWndExtra
= STATIC_EXTRA_BYTES
;
789 wndClass
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
790 wndClass
.hbrBackground
= NULL
;
791 wndClass
.lpszClassName
= WC_STATICW
;
792 RegisterClassW(&wndClass
);