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 * - Controls with SS_SIMPLE but without SS_NOPREFIX:
22 * The text should not be changed. Windows doesn't clear the
23 * client rectangle, so the new text must be larger than the old one.
24 * - The SS_RIGHTJUST style is currently not implemented by Windows
25 * (or it does something different than documented).
39 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(static);
45 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
);
46 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
);
47 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
);
48 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
);
49 static void STATIC_PaintBitmapfn( HWND hwnd
, HDC hdc
, DWORD style
);
50 static void STATIC_PaintEnhMetafn( HWND hwnd
, HDC hdc
, DWORD style
);
51 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
);
53 /* offsets for GetWindowLong for static private information */
54 #define HFONT_GWL_OFFSET 0
55 #define HICON_GWL_OFFSET (sizeof(HFONT))
56 #define STATIC_EXTRA_BYTES (HICON_GWL_OFFSET + sizeof(HICON))
58 typedef void (*pfPaint
)( HWND hwnd
, HDC hdc
, DWORD style
);
60 static const pfPaint staticPaintFunc
[SS_TYPEMASK
+1] =
62 STATIC_PaintTextfn
, /* SS_LEFT */
63 STATIC_PaintTextfn
, /* SS_CENTER */
64 STATIC_PaintTextfn
, /* SS_RIGHT */
65 STATIC_PaintIconfn
, /* SS_ICON */
66 STATIC_PaintRectfn
, /* SS_BLACKRECT */
67 STATIC_PaintRectfn
, /* SS_GRAYRECT */
68 STATIC_PaintRectfn
, /* SS_WHITERECT */
69 STATIC_PaintRectfn
, /* SS_BLACKFRAME */
70 STATIC_PaintRectfn
, /* SS_GRAYFRAME */
71 STATIC_PaintRectfn
, /* SS_WHITEFRAME */
72 NULL
, /* SS_USERITEM */
73 STATIC_PaintTextfn
, /* SS_SIMPLE */
74 STATIC_PaintTextfn
, /* SS_LEFTNOWORDWRAP */
75 STATIC_PaintOwnerDrawfn
, /* SS_OWNERDRAW */
76 STATIC_PaintBitmapfn
, /* SS_BITMAP */
77 STATIC_PaintEnhMetafn
, /* SS_ENHMETAFILE */
78 STATIC_PaintEtchedfn
, /* SS_ETCHEDHORZ */
79 STATIC_PaintEtchedfn
, /* SS_ETCHEDVERT */
80 STATIC_PaintEtchedfn
, /* SS_ETCHEDFRAME */
83 static BOOL
get_icon_size( HICON handle
, SIZE
*size
)
89 if (!GetIconInfo(handle
, &info
))
92 ret
= GetObjectW(info
.hbmColor
, sizeof(bmp
), &bmp
);
95 size
->cx
= bmp
.bmWidth
;
96 size
->cy
= bmp
.bmHeight
;
99 DeleteObject(info
.hbmMask
);
100 DeleteObject(info
.hbmColor
);
105 /***********************************************************************
108 * Set the icon for an SS_ICON control.
110 static HICON
STATIC_SetIcon( HWND hwnd
, HICON hicon
, DWORD style
)
115 if ((style
& SS_TYPEMASK
) != SS_ICON
) return 0;
116 if (hicon
&& !get_icon_size( hicon
, &size
))
118 WARN("hicon != 0, but invalid\n");
121 prevIcon
= (HICON
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hicon
);
122 if (hicon
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
124 /* Windows currently doesn't implement SS_RIGHTJUST */
126 if ((style & SS_RIGHTJUST) != 0)
129 GetWindowRect(hwnd, &wr);
130 SetWindowPos( hwnd, 0, wr.right - info->nWidth, wr.bottom - info->nHeight,
131 info->nWidth, info->nHeight, SWP_NOACTIVATE | SWP_NOZORDER );
135 SetWindowPos( hwnd
, 0, 0, 0, size
.cx
, size
.cy
, SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
141 /***********************************************************************
144 * Set the bitmap for an SS_BITMAP control.
146 static HBITMAP
STATIC_SetBitmap( HWND hwnd
, HBITMAP hBitmap
, DWORD style
)
150 if ((style
& SS_TYPEMASK
) != SS_BITMAP
) return 0;
151 if (hBitmap
&& GetObjectType(hBitmap
) != OBJ_BITMAP
)
153 WARN("hBitmap != 0, but it's not a bitmap\n");
156 hOldBitmap
= (HBITMAP
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hBitmap
);
157 if (hBitmap
&& !(style
& SS_CENTERIMAGE
) && !(style
& SS_REALSIZECONTROL
))
160 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
161 /* Windows currently doesn't implement SS_RIGHTJUST */
163 if ((style & SS_RIGHTJUST) != 0)
166 GetWindowRect(hwnd, &wr);
167 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
168 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
172 SetWindowPos( hwnd
, 0, 0, 0, bm
.bmWidth
, bm
.bmHeight
,
173 SWP_NOACTIVATE
| SWP_NOMOVE
| SWP_NOZORDER
);
179 /***********************************************************************
180 * STATIC_SetEnhMetaFile
182 * Set the enhanced metafile for an SS_ENHMETAFILE control.
184 static HENHMETAFILE
STATIC_SetEnhMetaFile( HWND hwnd
, HENHMETAFILE hEnhMetaFile
, DWORD style
)
186 if ((style
& SS_TYPEMASK
) != SS_ENHMETAFILE
) return 0;
187 if (hEnhMetaFile
&& GetObjectType(hEnhMetaFile
) != OBJ_ENHMETAFILE
)
189 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
192 return (HENHMETAFILE
)SetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
, (LONG_PTR
)hEnhMetaFile
);
195 /***********************************************************************
198 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
199 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
201 static HANDLE
STATIC_GetImage( HWND hwnd
, WPARAM wParam
, DWORD style
)
203 switch (style
& SS_TYPEMASK
)
206 if ((wParam
!= IMAGE_ICON
) &&
207 (wParam
!= IMAGE_CURSOR
)) return NULL
;
210 if (wParam
!= IMAGE_BITMAP
) return NULL
;
213 if (wParam
!= IMAGE_ENHMETAFILE
) return NULL
;
218 return (HANDLE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
221 /***********************************************************************
224 * Load the icon for an SS_ICON control.
226 static HICON
STATIC_LoadIconW( HINSTANCE hInstance
, LPCWSTR name
, DWORD style
)
230 if (hInstance
&& ((ULONG_PTR
)hInstance
>> 16))
232 if ((style
& SS_REALSIZEIMAGE
) != 0)
233 hicon
= LoadImageW(hInstance
, name
, IMAGE_ICON
, 0, 0, LR_SHARED
);
236 hicon
= LoadIconW( hInstance
, name
);
237 if (!hicon
) hicon
= LoadCursorW( hInstance
, name
);
240 if (!hicon
) hicon
= LoadIconW( 0, name
);
241 /* Windows doesn't try to load a standard cursor,
242 probably because most IDs for standard cursors conflict
243 with the IDs for standard icons anyway */
247 /***********************************************************************
250 * Try to immediately paint the control.
252 static VOID
STATIC_TryPaintFcn(HWND hwnd
, LONG full_style
)
254 LONG style
= full_style
& SS_TYPEMASK
;
257 GetClientRect( hwnd
, &rc
);
258 if (!IsRectEmpty(&rc
) && IsWindowVisible(hwnd
) && staticPaintFunc
[style
])
264 hrgn
= set_control_clipping( hdc
, &rc
);
265 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
266 SelectClipRgn( hdc
, hrgn
);
267 if (hrgn
) DeleteObject( hrgn
);
268 ReleaseDC( hwnd
, hdc
);
272 static HBRUSH
STATIC_SendWmCtlColorStatic(HWND hwnd
, HDC hdc
)
275 HWND parent
= GetParent(hwnd
);
277 if (!parent
) parent
= hwnd
;
278 hBrush
= (HBRUSH
) SendMessageW( parent
, WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
279 if (!hBrush
) /* did the app forget to call DefWindowProc ? */
281 /* FIXME: DefWindowProc should return different colors if a
282 manifest is present */
283 hBrush
= (HBRUSH
)DefWindowProcW( parent
, WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
288 /***********************************************************************
291 * Tests if the control displays text.
293 static BOOL
hasTextStyle( DWORD style
)
295 switch (style
& SS_TYPEMASK
)
299 case SS_LEFTNOWORDWRAP
:
309 static LRESULT CALLBACK
STATIC_WindowProc( HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
312 LONG full_style
= GetWindowLongW( hwnd
, GWL_STYLE
);
313 LONG style
= full_style
& SS_TYPEMASK
;
315 if (!IsWindow( hwnd
)) return 0;
320 if (style
< 0L || style
> SS_TYPEMASK
)
322 ERR("Unknown style 0x%02x\n", style
);
328 if (style
== SS_ICON
)
332 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
334 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
335 * had already been loaded by the application the last thing we want to do is
336 * GlobalFree16 the handle.
341 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
344 /* do all painting in WM_PAINT like Windows does */
352 HDC hdc
= wParam
? (HDC
)wParam
: BeginPaint(hwnd
, &ps
);
353 GetClientRect( hwnd
, &rect
);
354 if (staticPaintFunc
[style
])
356 HRGN hrgn
= set_control_clipping( hdc
, &rect
);
357 (staticPaintFunc
[style
])( hwnd
, hdc
, full_style
);
358 SelectClipRgn( hdc
, hrgn
);
359 if (hrgn
) DeleteObject( hrgn
);
361 if (!wParam
) EndPaint(hwnd
, &ps
);
366 STATIC_TryPaintFcn( hwnd
, full_style
);
367 if (full_style
& SS_NOTIFY
)
370 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
371 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_ENABLE
), (LPARAM
)hwnd
);
373 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
374 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DISABLE
), (LPARAM
)hwnd
);
378 case WM_SYSCOLORCHANGE
:
379 COMCTL32_RefreshSysColors();
380 STATIC_TryPaintFcn( hwnd
, full_style
);
385 CREATESTRUCTW
*cs
= (CREATESTRUCTW
*)lParam
;
387 if (full_style
& SS_SUNKEN
)
388 SetWindowLongW( hwnd
, GWL_EXSTYLE
,
389 GetWindowLongW( hwnd
, GWL_EXSTYLE
) | WS_EX_STATICEDGE
);
397 hIcon
= STATIC_LoadIconW(cs
->hInstance
, cs
->lpszName
, full_style
);
398 STATIC_SetIcon(hwnd
, hIcon
, full_style
);
402 if ((ULONG_PTR
)cs
->hInstance
>> 16)
405 hBitmap
= LoadBitmapW(cs
->hInstance
, cs
->lpszName
);
406 STATIC_SetBitmap(hwnd
, hBitmap
, full_style
);
410 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
411 the enhanced metafile that was specified as the window text. */
413 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
416 if (hasTextStyle( full_style
))
418 lResult
= DefWindowProcW( hwnd
, uMsg
, wParam
, lParam
);
419 STATIC_TryPaintFcn( hwnd
, full_style
);
424 if (hasTextStyle( full_style
))
426 SetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
, wParam
);
428 RedrawWindow( hwnd
, NULL
, 0, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ALLCHILDREN
);
433 return GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
436 if (full_style
& SS_NOTIFY
)
439 return HTTRANSPARENT
;
445 case WM_NCLBUTTONDOWN
:
446 if (full_style
& SS_NOTIFY
)
447 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
448 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_CLICKED
), (LPARAM
)hwnd
);
451 case WM_LBUTTONDBLCLK
:
452 case WM_NCLBUTTONDBLCLK
:
453 if (full_style
& SS_NOTIFY
)
454 SendMessageW( GetParent(hwnd
), WM_COMMAND
,
455 MAKEWPARAM( GetWindowLongPtrW(hwnd
,GWLP_ID
), STN_DBLCLK
), (LPARAM
)hwnd
);
459 return (LRESULT
)STATIC_GetImage( hwnd
, wParam
, full_style
);
462 return (LRESULT
)STATIC_GetImage( hwnd
, IMAGE_ICON
, full_style
);
468 lResult
= (LRESULT
)STATIC_SetBitmap( hwnd
, (HBITMAP
)lParam
, full_style
);
470 case IMAGE_ENHMETAFILE
:
471 lResult
= (LRESULT
)STATIC_SetEnhMetaFile( hwnd
, (HENHMETAFILE
)lParam
, full_style
);
475 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)lParam
, full_style
);
478 FIXME("STM_SETIMAGE: Unhandled type %lx\n", wParam
);
481 STATIC_TryPaintFcn( hwnd
, full_style
);
485 lResult
= (LRESULT
)STATIC_SetIcon( hwnd
, (HICON
)wParam
, full_style
);
486 STATIC_TryPaintFcn( hwnd
, full_style
);
490 return DefWindowProcW(hwnd
, uMsg
, wParam
, lParam
);
495 static void STATIC_PaintOwnerDrawfn( HWND hwnd
, HDC hdc
, DWORD style
)
498 HFONT font
, oldFont
= NULL
;
499 UINT id
= (UINT
)GetWindowLongPtrW( hwnd
, GWLP_ID
);
501 dis
.CtlType
= ODT_STATIC
;
504 dis
.itemAction
= ODA_DRAWENTIRE
;
505 dis
.itemState
= IsWindowEnabled(hwnd
) ? 0 : ODS_DISABLED
;
509 GetClientRect( hwnd
, &dis
.rcItem
);
511 font
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
);
512 if (font
) oldFont
= SelectObject( hdc
, font
);
513 SendMessageW( GetParent(hwnd
), WM_CTLCOLORSTATIC
, (WPARAM
)hdc
, (LPARAM
)hwnd
);
514 SendMessageW( GetParent(hwnd
), WM_DRAWITEM
, id
, (LPARAM
)&dis
);
515 if (font
) SelectObject( hdc
, oldFont
);
518 static void STATIC_PaintTextfn( HWND hwnd
, HDC hdc
, DWORD style
)
522 HFONT hFont
, hOldFont
= NULL
;
527 GetClientRect( hwnd
, &rc
);
529 switch (style
& SS_TYPEMASK
)
532 format
= DT_LEFT
| DT_EXPANDTABS
| DT_WORDBREAK
;
536 format
= DT_CENTER
| DT_EXPANDTABS
| DT_WORDBREAK
;
540 format
= DT_RIGHT
| DT_EXPANDTABS
| DT_WORDBREAK
;
544 format
= DT_LEFT
| DT_SINGLELINE
;
547 case SS_LEFTNOWORDWRAP
:
548 format
= DT_LEFT
| DT_EXPANDTABS
;
555 if (GetWindowLongW( hwnd
, GWL_EXSTYLE
) & WS_EX_RIGHT
)
556 format
= DT_RIGHT
| (format
& ~(DT_LEFT
| DT_CENTER
));
558 if (style
& SS_NOPREFIX
)
559 format
|= DT_NOPREFIX
;
561 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
563 if (style
& SS_CENTERIMAGE
)
564 format
|= DT_SINGLELINE
| DT_VCENTER
;
565 if (style
& SS_EDITCONTROL
)
566 format
|= DT_EDITCONTROL
;
567 if (style
& SS_ENDELLIPSIS
)
568 format
|= DT_SINGLELINE
| DT_END_ELLIPSIS
;
569 if (style
& SS_PATHELLIPSIS
)
570 format
|= DT_SINGLELINE
| DT_PATH_ELLIPSIS
;
571 if (style
& SS_WORDELLIPSIS
)
572 format
|= DT_SINGLELINE
| DT_WORD_ELLIPSIS
;
575 if ((hFont
= (HFONT
)GetWindowLongPtrW( hwnd
, HFONT_GWL_OFFSET
)))
576 hOldFont
= SelectObject( hdc
, hFont
);
578 /* SS_SIMPLE controls: WM_CTLCOLORSTATIC is sent, but the returned
580 hBrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
582 if ((style
& SS_TYPEMASK
) != SS_SIMPLE
)
584 FillRect( hdc
, &rc
, hBrush
);
585 if (!IsWindowEnabled(hwnd
)) SetTextColor(hdc
, GetSysColor(COLOR_GRAYTEXT
));
589 if (!(text
= HeapAlloc( GetProcessHeap(), 0, buf_size
* sizeof(WCHAR
) )))
592 while ((len
= InternalGetWindowText( hwnd
, text
, buf_size
)) == buf_size
- 1)
595 if (!(text
= HeapReAlloc( GetProcessHeap(), 0, text
, buf_size
* sizeof(WCHAR
) )))
599 if (!len
) goto no_TextOut
;
601 if (((style
& SS_TYPEMASK
) == SS_SIMPLE
) && (style
& SS_NOPREFIX
))
603 /* Windows uses the faster ExtTextOut() to draw the text and
604 to paint the whole client rectangle with the text background
605 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
606 ExtTextOutW( hdc
, rc
.left
, rc
.top
, ETO_CLIPPED
| ETO_OPAQUE
,
607 &rc
, text
, len
, NULL
);
611 DrawTextW( hdc
, text
, -1, &rc
, format
);
615 HeapFree( GetProcessHeap(), 0, text
);
618 SelectObject( hdc
, hOldFont
);
621 static void STATIC_PaintRectfn( HWND hwnd
, HDC hdc
, DWORD style
)
626 GetClientRect( hwnd
, &rc
);
628 /* FIXME: send WM_CTLCOLORSTATIC */
629 switch (style
& SS_TYPEMASK
)
632 hBrush
= CreateSolidBrush(comctl32_color
.clr3dDkShadow
);
633 FillRect( hdc
, &rc
, hBrush
);
636 hBrush
= CreateSolidBrush(comctl32_color
.clr3dShadow
);
637 FillRect( hdc
, &rc
, hBrush
);
640 hBrush
= CreateSolidBrush(comctl32_color
.clr3dHilight
);
641 FillRect( hdc
, &rc
, hBrush
);
644 hBrush
= CreateSolidBrush(comctl32_color
.clr3dDkShadow
);
645 FrameRect( hdc
, &rc
, hBrush
);
648 hBrush
= CreateSolidBrush(comctl32_color
.clr3dShadow
);
649 FrameRect( hdc
, &rc
, hBrush
);
652 hBrush
= CreateSolidBrush(comctl32_color
.clr3dHilight
);
653 FrameRect( hdc
, &rc
, hBrush
);
658 DeleteObject( hBrush
);
662 static void STATIC_PaintIconfn( HWND hwnd
, HDC hdc
, DWORD style
)
669 GetClientRect( hwnd
, &rc
);
670 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
671 hIcon
= (HICON
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
);
672 if (!hIcon
|| !get_icon_size( hIcon
, &size
))
674 FillRect(hdc
, &rc
, hbrush
);
678 if (style
& SS_CENTERIMAGE
)
680 iconRect
.left
= (rc
.right
- rc
.left
) / 2 - size
.cx
/ 2;
681 iconRect
.top
= (rc
.bottom
- rc
.top
) / 2 - size
.cy
/ 2;
682 iconRect
.right
= iconRect
.left
+ size
.cx
;
683 iconRect
.bottom
= iconRect
.top
+ size
.cy
;
687 FillRect( hdc
, &rc
, hbrush
);
688 DrawIconEx( hdc
, iconRect
.left
, iconRect
.top
, hIcon
, iconRect
.right
- iconRect
.left
,
689 iconRect
.bottom
- iconRect
.top
, 0, NULL
, DI_NORMAL
);
693 static void STATIC_PaintBitmapfn(HWND hwnd
, HDC hdc
, DWORD style
)
696 HBITMAP hBitmap
, oldbitmap
;
699 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
701 if ((hBitmap
= (HBITMAP
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
))
702 && (GetObjectType(hBitmap
) == OBJ_BITMAP
)
703 && (hMemDC
= CreateCompatibleDC( hdc
)))
709 GetObjectW(hBitmap
, sizeof(bm
), &bm
);
710 oldbitmap
= SelectObject(hMemDC
, hBitmap
);
712 /* Set the background color for monochrome bitmaps
713 to the color of the background brush */
714 if (GetObjectW( hbrush
, sizeof(brush
), &brush
))
716 if (brush
.lbStyle
== BS_SOLID
)
717 SetBkColor(hdc
, brush
.lbColor
);
719 GetClientRect(hwnd
, &rcClient
);
720 if (style
& SS_CENTERIMAGE
)
722 FillRect( hdc
, &rcClient
, hbrush
);
723 rcClient
.left
= (rcClient
.right
- rcClient
.left
)/2 - bm
.bmWidth
/2;
724 rcClient
.top
= (rcClient
.bottom
- rcClient
.top
)/2 - bm
.bmHeight
/2;
725 rcClient
.right
= rcClient
.left
+ bm
.bmWidth
;
726 rcClient
.bottom
= rcClient
.top
+ bm
.bmHeight
;
728 StretchBlt(hdc
, rcClient
.left
, rcClient
.top
, rcClient
.right
- rcClient
.left
,
729 rcClient
.bottom
- rcClient
.top
, hMemDC
,
730 0, 0, bm
.bmWidth
, bm
.bmHeight
, SRCCOPY
);
731 SelectObject(hMemDC
, oldbitmap
);
736 static void STATIC_PaintEnhMetafn(HWND hwnd
, HDC hdc
, DWORD style
)
738 HENHMETAFILE hEnhMetaFile
;
742 GetClientRect(hwnd
, &rc
);
743 hbrush
= STATIC_SendWmCtlColorStatic(hwnd
, hdc
);
744 FillRect(hdc
, &rc
, hbrush
);
745 if ((hEnhMetaFile
= (HENHMETAFILE
)GetWindowLongPtrW( hwnd
, HICON_GWL_OFFSET
)))
747 /* The control's current font is not selected into the
749 if (GetObjectType(hEnhMetaFile
) == OBJ_ENHMETAFILE
)
750 PlayEnhMetaFile(hdc
, hEnhMetaFile
, &rc
);
754 static void STATIC_PaintEtchedfn( HWND hwnd
, HDC hdc
, DWORD style
)
758 /* FIXME: sometimes (not always) sends WM_CTLCOLORSTATIC */
759 GetClientRect( hwnd
, &rc
);
760 switch (style
& SS_TYPEMASK
)
763 DrawEdge(hdc
, &rc
, EDGE_ETCHED
, BF_TOP
| BF_BOTTOM
);
766 DrawEdge(hdc
, &rc
, EDGE_ETCHED
, BF_LEFT
| BF_RIGHT
);
769 DrawEdge(hdc
, &rc
, EDGE_ETCHED
, BF_RECT
);
774 void STATIC_Register(void)
778 memset(&wndClass
, 0, sizeof(wndClass
));
779 wndClass
.style
= CS_DBLCLKS
| CS_PARENTDC
| CS_GLOBALCLASS
;
780 wndClass
.lpfnWndProc
= STATIC_WindowProc
;
781 wndClass
.cbClsExtra
= 0;
782 wndClass
.cbWndExtra
= STATIC_EXTRA_BYTES
;
783 wndClass
.hCursor
= LoadCursorW(0, (LPWSTR
)IDC_ARROW
);
784 wndClass
.hbrBackground
= NULL
;
785 wndClass
.lpszClassName
= WC_STATICW
;
786 RegisterClassW(&wndClass
);