ReactOS 0.4.17-dev-1321-g5c122a9
static.c
Go to the documentation of this file.
1/*
2 * Static control
3 *
4 * Copyright David W. Metcalfe, 1993
5 *
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.
10 *
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.
15 *
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
19 *
20 * Notes:
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).
26 *
27 * TODO:
28 * - Animated cursors
29 */
30
31#include <user32.h>
32
34
35static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
36static void STATIC_PaintTextfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
37static void STATIC_PaintRectfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
38static void STATIC_PaintIconfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
39static void STATIC_PaintBitmapfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
40static void STATIC_PaintEnhMetafn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
41static void STATIC_PaintEtchedfn( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
42
44
45/* offsets for GetWindowLong for static private information */
46#define HFONT_GWL_OFFSET 0
47#define HICON_GWL_OFFSET (sizeof(HFONT))
48#ifdef __REACTOS__
49#define UISTATE_GWL_OFFSET (HICON_GWL_OFFSET+sizeof(HICON)) // ReactOS: keep in sync with STATIC_UISTATE_GWL_OFFSET
50#define STATIC_EXTRA_BYTES (UISTATE_GWL_OFFSET + sizeof(LONG))
51#endif
52
53typedef void (*pfPaint)( HWND hwnd, HDC hdc, HBRUSH hbrush, DWORD style );
54
56{
57 STATIC_PaintTextfn, /* SS_LEFT */
58 STATIC_PaintTextfn, /* SS_CENTER */
59 STATIC_PaintTextfn, /* SS_RIGHT */
60 STATIC_PaintIconfn, /* SS_ICON */
61 STATIC_PaintRectfn, /* SS_BLACKRECT */
62 STATIC_PaintRectfn, /* SS_GRAYRECT */
63 STATIC_PaintRectfn, /* SS_WHITERECT */
64 STATIC_PaintRectfn, /* SS_BLACKFRAME */
65 STATIC_PaintRectfn, /* SS_GRAYFRAME */
66 STATIC_PaintRectfn, /* SS_WHITEFRAME */
67 NULL, /* SS_USERITEM */
68 STATIC_PaintTextfn, /* SS_SIMPLE */
69 STATIC_PaintTextfn, /* SS_LEFTNOWORDWRAP */
70 STATIC_PaintOwnerDrawfn, /* SS_OWNERDRAW */
71 STATIC_PaintBitmapfn, /* SS_BITMAP */
72 STATIC_PaintEnhMetafn, /* SS_ENHMETAFILE */
73 NULL, /* SS_ETCHEDHORZ */
74 NULL, /* SS_ETCHEDVERT */
75 STATIC_PaintEtchedfn, /* SS_ETCHEDFRAME */
76};
77
78
79#ifdef __REACTOS__
80/*********************************************************************
81 * static class descriptor
82 */
83static const WCHAR staticW[] = {'S','t','a','t','i','c',0};
85{
86 staticW, /* name */
87 CS_DBLCLKS | CS_PARENTDC, /* style */
88 &pfnClientA.pfnStaticWndProc, /* procA */
89 &pfnClientW.pfnStaticWndProc, /* procW */
90 STATIC_EXTRA_BYTES, /* extra */
91 IDC_ARROW, /* cursor */
92 0 /* brush */
93};
94#endif
95
96static HFONT get_control_font( HWND hwnd )
97{
98 return (HFONT)NtUserGetPrivateData( hwnd, HFONT_GWL_OFFSET, sizeof(HFONT) );
99}
100
101static HFONT set_control_font( HWND hwnd, HFONT font )
102{
103 return (HFONT)NtUserSetPrivateData( hwnd, HFONT_GWL_OFFSET, sizeof(font), (LONG_PTR)font );
104}
105
107{
108 return (HFONT)NtUserGetPrivateData( hwnd, HICON_GWL_OFFSET, sizeof(HICON) );
109}
110
112{
113 return (HANDLE)NtUserSetPrivateData( hwnd, HICON_GWL_OFFSET, sizeof(icon), (LONG_PTR)icon );
114}
115
116/***********************************************************************
117 * STATIC_SetIcon
118 *
119 * Set the icon for an SS_ICON control.
120 */
122{
123 HICON prevIcon;
124 SIZE size;
125
126 if (hicon && !get_icon_size( hicon, &size ))
127 {
128 WARN("hicon != 0, but invalid\n");
129 return 0;
130 }
131 prevIcon = set_control_icon( hwnd, hicon );
132 if (hicon && !(style & SS_CENTERIMAGE) && !(style & SS_REALSIZECONTROL))
133 {
134 /* Windows currently doesn't implement SS_RIGHTJUST */
135 /*
136 if ((style & SS_RIGHTJUST) != 0)
137 {
138 RECT wr;
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 );
142 }
143 else */
144 {
146 }
147 }
148 return prevIcon;
149}
150
151/***********************************************************************
152 * STATIC_SetBitmap
153 *
154 * Set the bitmap for an SS_BITMAP control.
155 */
157{
158 HBITMAP hOldBitmap;
159
161 WARN("hBitmap != 0, but it's not a bitmap\n");
162 return 0;
163 }
164 hOldBitmap = set_control_icon( hwnd, hBitmap );
166 {
167 BITMAP bm;
168 GetObjectW(hBitmap, sizeof(bm), &bm);
169 /* Windows currently doesn't implement SS_RIGHTJUST */
170 /*
171 if ((style & SS_RIGHTJUST) != 0)
172 {
173 RECT wr;
174 GetWindowRect(hwnd, &wr);
175 SetWindowPos( hwnd, 0, wr.right - bm.bmWidth, wr.bottom - bm.bmHeight,
176 bm.bmWidth, bm.bmHeight, SWP_NOACTIVATE | SWP_NOZORDER );
177 }
178 else */
179 {
180 NtUserSetWindowPos( hwnd, 0, 0, 0, bm.bmWidth, bm.bmHeight,
182 }
183
184 }
185 return hOldBitmap;
186}
187
188/***********************************************************************
189 * STATIC_SetEnhMetaFile
190 *
191 * Set the enhanced metafile for an SS_ENHMETAFILE control.
192 */
193static HENHMETAFILE STATIC_SetEnhMetaFile( HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style )
194{
195 if (hEnhMetaFile && GetObjectType(hEnhMetaFile) != OBJ_ENHMETAFILE) {
196 WARN("hEnhMetaFile != 0, but it's not an enhanced metafile\n");
197 return 0;
198 }
199 return set_control_icon( hwnd, hEnhMetaFile );
200}
201
202/***********************************************************************
203 * STATIC_GetImage
204 *
205 * Gets the bitmap for an SS_BITMAP control, the icon/cursor for an
206 * SS_ICON control or the enhanced metafile for an SS_ENHMETAFILE control.
207 */
209{
210 switch(style & SS_TYPEMASK)
211 {
212 case SS_ICON:
213 if ((wParam != IMAGE_ICON) &&
214 (wParam != IMAGE_CURSOR)) return NULL;
215 break;
216 case SS_BITMAP:
217 if (wParam != IMAGE_BITMAP) return NULL;
218 break;
219 case SS_ENHMETAFILE:
220 if (wParam != IMAGE_ENHMETAFILE) return NULL;
221 break;
222 default:
223 return NULL;
224 }
225 return get_control_icon( hwnd );
226}
227
228/***********************************************************************
229 * STATIC_LoadIconA
230 *
231 * Load the icon for an SS_ICON control.
232 */
234{
235 HICON hicon = 0;
236
237 if (hInstance && ((ULONG_PTR)hInstance >> 16))
238 {
239 if ((style & SS_REALSIZEIMAGE) != 0)
240 hicon = LoadImageA(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
241 else
242 {
243 hicon = LoadIconA( hInstance, name );
244 if (!hicon) hicon = LoadCursorA( hInstance, name );
245 }
246 }
247 if (!hicon) hicon = LoadIconA( 0, name );
248 /* Windows doesn't try to load a standard cursor,
249 probably because most IDs for standard cursors conflict
250 with the IDs for standard icons anyway */
251 return hicon;
252}
253/***********************************************************************
254 * STATIC_SendWmCtlColorStatic
255 *
256 * Sends WM_CTLCOLORSTATIC message and returns brush to be used for painting.
257 */
259{
260#ifdef __REACTOS__
262#else
263 HBRUSH hBrush;
265
266 if (!parent) parent = hwnd;
267 hBrush = (HBRUSH) SendMessageW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
268 if (!hBrush) /* did the app forget to call DefWindowProc ? */
270 return hBrush;
271#endif
272}
273
274/***********************************************************************
275 * STATIC_LoadIconW
276 *
277 * Load the icon for an SS_ICON control.
278 */
280{
281 HICON hicon = 0;
282
283 if (hInstance && ((ULONG_PTR)hInstance >> 16))
284 {
285 if ((style & SS_REALSIZEIMAGE) != 0)
286 hicon = LoadImageW(hInstance, name, IMAGE_ICON, 0, 0, LR_SHARED);
287 else
288 {
289 hicon = LoadIconW( hInstance, name );
290 if (!hicon) hicon = LoadCursorW( hInstance, name );
291 }
292 }
293 if (!hicon) hicon = LoadIconW( 0, name );
294 /* Windows doesn't try to load a standard cursor,
295 probably because most IDs for standard cursors conflict
296 with the IDs for standard icons anyway */
297 return hicon;
298}
299
300/***********************************************************************
301 * STATIC_TryPaintFcn
302 *
303 * Try to immediately paint the control.
304 */
306{
308 {
309 RECT rc;
310 HDC hdc;
311 HRGN hrgn;
312 HBRUSH hbrush;
313 LONG style = full_style & SS_TYPEMASK;
314
315 GetClientRect( hwnd, &rc );
316 hdc = NtUserGetDC( hwnd );
317 hrgn = set_control_clipping( hdc, &rc );
320 (staticPaintFunc[style])( hwnd, hdc, hbrush, full_style );
322 if (hrgn) DeleteObject( hrgn );
324 }
325}
326
328{
332}
333
334/***********************************************************************
335 * hasTextStyle
336 *
337 * Tests if the control displays text.
338 */
340{
341 switch(style & SS_TYPEMASK)
342 {
343 case SS_SIMPLE:
344 case SS_LEFT:
346 case SS_CENTER:
347 case SS_RIGHT:
348 case SS_OWNERDRAW:
349 return TRUE;
350 }
351
352 return FALSE;
353}
354
355/***********************************************************************
356 * StaticWndProc_common
357 */
359{
360 LRESULT lResult = 0;
361 LONG full_style = GetWindowLongW( hwnd, GWL_STYLE );
362 LONG style = full_style & SS_TYPEMASK;
363
364 if (!IsWindow( hwnd )) return 0;
366
367 switch (uMsg)
368 {
369 case WM_CREATE:
370 if (style < 0L || style > SS_TYPEMASK)
371 {
372 ERR("Unknown style 0x%02lx\n", style );
373 return -1;
374 }
375 STATIC_update_uistate(hwnd, unicode); // ReactOS r30727
377 break;
378
379 case WM_NCDESTROY:
380#ifdef __REACTOS__
382#endif
383 if (style == SS_ICON) {
384/*
385 * FIXME
386 * DestroyIcon32( STATIC_SetIcon( wndPtr, 0 ) );
387 *
388 * We don't want to do this yet because DestroyIcon32 is broken. If the icon
389 * had already been loaded by the application the last thing we want to do is
390 * GlobalFree16 the handle.
391 */
392 break;
393 }
394 else return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
396
397 case WM_ERASEBKGND:
398 /* do all painting in WM_PAINT like Windows does */
399 return 1;
400
401 case WM_PRINTCLIENT:
402 case WM_PAINT:
403 {
404 PAINTSTRUCT ps;
405 RECT rect;
407 HRGN hrgn;
408 HBRUSH hbrush;
409
414 (staticPaintFunc[style])( hwnd, hdc, hbrush, full_style );
416 if (hrgn) DeleteObject( hrgn );
417 if (!wParam) NtUserEndPaint( hwnd, &ps );
418 }
419 break;
420
421 case WM_ENABLE:
422 STATIC_TryPaintFcn( hwnd, full_style );
423 if (full_style & SS_NOTIFY) {
424 if (wParam) {
427 }
428 else {
431 }
432 }
433 break;
434
437 STATIC_TryPaintFcn( hwnd, full_style );
438 break;
439
440 case WM_NCCREATE:
441 {
443
444 if (full_style & SS_SUNKEN || style == SS_ETCHEDHORZ || style == SS_ETCHEDVERT)
447
449 {
450 RECT rc;
451 GetClientRect(hwnd, &rc);
452 if (style == SS_ETCHEDHORZ)
453 rc.bottom = rc.top;
454 else
455 rc.right = rc.left;
457 NtUserSetWindowPos( hwnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
459 }
460
461 switch (style) {
462 case SS_ICON:
463 {
464 const WCHAR *name = cs->lpszName;
465 HICON hIcon;
466
467 if (!unicode)
468 {
469 const char *nameA = (const char *)name;
470 if (nameA && nameA[0] == '\xff')
471 name = MAKEINTRESOURCEW(MAKEWORD(nameA[1], nameA[2]));
472 }
473 else if (name && name[0] == 0xffff)
474 {
476 }
477
478 if (unicode || IS_INTRESOURCE(name))
479 hIcon = STATIC_LoadIconW(cs->hInstance, name, full_style);
480 else
481 hIcon = STATIC_LoadIconA(cs->hInstance, (const char *)name, full_style);
482 STATIC_SetIcon(hwnd, hIcon, full_style);
483 }
484 break;
485 case SS_BITMAP:
486 if ((ULONG_PTR)cs->hInstance >> 16)
487 {
488 const WCHAR *name = cs->lpszName;
490
491 if (!unicode)
492 {
493 const char *nameA = (const char *)name;
494 if (nameA && nameA[0] == '\xff')
495 name = MAKEINTRESOURCEW(MAKEWORD(nameA[1], nameA[2]));
496 }
497 else if (name && name[0] == 0xffff)
498 {
500 }
501
502 if (unicode || IS_INTRESOURCE(name))
503 hBitmap = LoadBitmapW(cs->hInstance, name);
504 else
505 hBitmap = LoadBitmapA(cs->hInstance, (const char *)name);
506 STATIC_SetBitmap(hwnd, hBitmap, full_style);
507 }
508 break;
509 }
510 /* SS_ENHMETAFILE: Despite what MSDN says, Windows does not load
511 the enhanced metafile that was specified as the window text. */
512 }
513 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
515
516 case WM_SETTEXT:
517 if (hasTextStyle( full_style ))
518 {
519 if (unicode)
520 lResult = DefWindowProcW( hwnd, uMsg, wParam, lParam );
521 else
522 lResult = DefWindowProcA( hwnd, uMsg, wParam, lParam );
523 STATIC_TryPaintFcn( hwnd, full_style );
524 }
525 break;
526
527 case WM_SETFONT:
528 if (hasTextStyle( full_style ))
529 {
530 set_control_font( hwnd, (HFONT)wParam );
531 if (LOWORD(lParam))
534 }
535 break;
536
537 case WM_GETFONT:
538 return (LRESULT)get_control_font( hwnd );
539
540 case WM_NCHITTEST:
541 if (full_style & SS_NOTIFY)
542 return HTCLIENT;
543 else
544 return HTTRANSPARENT;
545
546 case WM_GETDLGCODE:
547 return DLGC_STATIC;
548
549 case WM_LBUTTONDOWN:
550 case WM_NCLBUTTONDOWN:
551 if (full_style & SS_NOTIFY)
554 return 0;
555
556 case WM_LBUTTONDBLCLK:
558 if (full_style & SS_NOTIFY)
561 return 0;
562
563 case STM_GETIMAGE:
564 return (LRESULT)STATIC_GetImage( hwnd, wParam, full_style );
565
566 case STM_GETICON:
567 return (LRESULT)STATIC_GetImage( hwnd, IMAGE_ICON, full_style );
568
569 case STM_SETIMAGE:
570 switch(wParam) {
571 case IMAGE_BITMAP:
572 if (style != SS_BITMAP) return 0; // ReactOS r43158
573 if (style != SS_BITMAP) return 0;
574 lResult = (LRESULT)STATIC_SetBitmap( hwnd, (HBITMAP)lParam, full_style );
575 break;
577 if (style != SS_ENHMETAFILE) return 0; // ReactOS r43158
578 if (style != SS_ENHMETAFILE) return 0;
579 lResult = (LRESULT)STATIC_SetEnhMetaFile( hwnd, (HENHMETAFILE)lParam, full_style );
580 break;
581 case IMAGE_ICON:
582 case IMAGE_CURSOR:
583 if (style != SS_ICON) return 0; // ReactOS r43158
584 if (style != SS_ICON) return 0;
585 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)lParam, full_style );
586 break;
587 default:
588 FIXME("STM_SETIMAGE: Unhandled type %Ix\n", wParam);
589 break;
590 }
591 STATIC_TryPaintFcn( hwnd, full_style );
592 break;
593
594 case STM_SETICON:
595 if (style != SS_ICON) return 0;
596 lResult = (LRESULT)STATIC_SetIcon( hwnd, (HICON)wParam, full_style );
597 STATIC_TryPaintFcn( hwnd, full_style );
598 break;
599
600#ifdef __REACTOS__
601 case WM_UPDATEUISTATE:
602 if (unicode)
604 else
606
607 if (STATIC_update_uistate(hwnd, unicode) && hasTextStyle( full_style ))
608 {
610 }
611 break;
612#endif
613
614 default:
615 return unicode ? DefWindowProcW(hwnd, uMsg, wParam, lParam) :
617 }
618 return lResult;
619}
620
621/***********************************************************************
622 * StaticWndProcA
623 */
625{
626 if (!IsWindow( hWnd )) return 0;
628}
629
630/***********************************************************************
631 * StaticWndProcW
632 */
634{
635 if (!IsWindow( hWnd )) return 0;
636 return StaticWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
637}
638
640{
641 DRAWITEMSTRUCT dis;
642 HFONT font, oldFont = NULL;
644
645 dis.CtlType = ODT_STATIC;
646 dis.CtlID = id;
647 dis.itemID = 0;
650 dis.hwndItem = hwnd;
651 dis.hDC = hdc;
652 dis.itemData = 0;
653 GetClientRect( hwnd, &dis.rcItem );
654
656 if (font) oldFont = SelectObject( hdc, font );
658 if (font) SelectObject( hdc, oldFont );
659}
660
662{
663 RECT rc;
664
665 SetRect(&rc, 0, 0, cx, cy);
666 DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
667 return TRUE;
668}
669
671{
672 RECT rc;
673 HFONT hFont, hOldFont = NULL;
674 UINT format;
675 INT len, buf_size;
676 WCHAR *text;
677
678 GetClientRect( hwnd, &rc);
679
680 switch (style & SS_TYPEMASK)
681 {
682 case SS_LEFT:
684 break;
685
686 case SS_CENTER:
688 break;
689
690 case SS_RIGHT:
692 break;
693
694 case SS_SIMPLE:
696 break;
697
700 break;
701
702 default:
703 return;
704 }
705
708
709 if (style & SS_NOPREFIX)
711#ifdef __REACTOS__
712 else if (GetWindowLongW(hwnd, UISTATE_GWL_OFFSET) & UISF_HIDEACCEL) // ReactOS r30727
714#endif
715
716 if ((style & SS_TYPEMASK) != SS_SIMPLE)
717 {
718 if (style & SS_CENTERIMAGE)
720 if (style & SS_EDITCONTROL)
722 if (style & SS_ENDELLIPSIS)
728 }
729
730 if ((hFont = get_control_font( hwnd )))
731 hOldFont = SelectObject( hdc, hFont );
732
733 if ((style & SS_TYPEMASK) != SS_SIMPLE)
734 {
735 FillRect( hdc, &rc, hbrush );
737 }
738
739 buf_size = 256;
740 if (!(text = HeapAlloc( GetProcessHeap(), 0, buf_size * sizeof(WCHAR) )))
741 goto no_TextOut;
742
743 while ((len = NtUserInternalGetWindowText( hwnd, text, buf_size )) == buf_size - 1)
744 {
745 buf_size *= 2;
746 if (!(text = HeapReAlloc( GetProcessHeap(), 0, text, buf_size * sizeof(WCHAR) )))
747 goto no_TextOut;
748 }
749
750 if (!len) goto no_TextOut;
751
752 if (((style & SS_TYPEMASK) == SS_SIMPLE) && (style & SS_NOPREFIX))
753 {
754 /* Windows uses the faster ExtTextOut() to draw the text and
755 to paint the whole client rectangle with the text background
756 color. Reference: "Static Controls" by Kyle Marsh, 1992 */
758 &rc, text, len, NULL );
759 }
760#ifdef __REACTOS__
761 else
762 {
764 if (style & WS_DISABLED)
768 rc.left, rc.top,
769 rc.right - rc.left, rc.bottom - rc.top,
770 flags);
771 }
772#else
773 else
774 {
775 DrawTextW( hdc, text, -1, &rc, format );
776 }
777#endif
778
779no_TextOut:
781
782 if (hFont)
783 SelectObject( hdc, hOldFont );
784}
785
787{
788 RECT rc;
789
790 GetClientRect( hwnd, &rc);
791
792 /* FIXME: send WM_CTLCOLORSTATIC */
793 switch (style & SS_TYPEMASK)
794 {
795 case SS_BLACKRECT:
797 FillRect( hdc, &rc, hbrush );
798 break;
799 case SS_GRAYRECT:
801 FillRect( hdc, &rc, hbrush );
802 break;
803 case SS_WHITERECT:
805 FillRect( hdc, &rc, hbrush );
806 break;
807 case SS_BLACKFRAME:
809 FrameRect( hdc, &rc, hbrush );
810 break;
811 case SS_GRAYFRAME:
813 FrameRect( hdc, &rc, hbrush );
814 break;
815 case SS_WHITEFRAME:
817 FrameRect( hdc, &rc, hbrush );
818 break;
819 default:
820 return;
821 }
823}
824
825
827{
828 RECT rc, iconRect;
829 HICON hIcon;
830 SIZE size;
831
832 GetClientRect( hwnd, &rc );
834 if (!hIcon || !get_icon_size( hIcon, &size ))
835 {
836 FillRect(hdc, &rc, hbrush);
837 }
838 else
839 {
840 if (style & SS_CENTERIMAGE)
841 {
842 iconRect.left = (rc.right - rc.left) / 2 - size.cx / 2;
843 iconRect.top = (rc.bottom - rc.top) / 2 - size.cy / 2;
844 iconRect.right = iconRect.left + size.cx;
845 iconRect.bottom = iconRect.top + size.cy;
846 }
847 else
848 iconRect = rc;
849 FillRect( hdc, &rc, hbrush );
850#ifdef __REACTOS__
851 NtUserDrawIconEx( hdc, iconRect.left, iconRect.top, hIcon, iconRect.right - iconRect.left,
852 iconRect.bottom - iconRect.top, 0, NULL, DI_NORMAL, 0, 0 );
853#else
854 NtUserDrawIconEx( hdc, iconRect.left, iconRect.top, hIcon, iconRect.right - iconRect.left,
855 iconRect.bottom - iconRect.top, 0, NULL, DI_NORMAL );
856#endif
857 }
858}
859
861{
862 HDC hMemDC;
863 HBITMAP hBitmap, oldbitmap;
864
865 if ((hBitmap = get_control_icon( hwnd ))
867 && (hMemDC = CreateCompatibleDC( hdc )))
868 {
869 BITMAP bm;
870 RECT rcClient;
871
872 GetObjectW(hBitmap, sizeof(bm), &bm);
873 oldbitmap = SelectObject(hMemDC, hBitmap);
874
875 GetClientRect(hwnd, &rcClient);
876 if (style & SS_CENTERIMAGE)
877 {
878 hbrush = CreateSolidBrush(GetPixel(hMemDC, 0, 0));
879
880 FillRect(hdc, &rcClient, hbrush);
881
882 rcClient.left = (rcClient.right - rcClient.left)/2 - bm.bmWidth/2;
883 rcClient.top = (rcClient.bottom - rcClient.top)/2 - bm.bmHeight/2;
884 rcClient.right = rcClient.left + bm.bmWidth;
885 rcClient.bottom = rcClient.top + bm.bmHeight;
886
888 }
889 StretchBlt(hdc, rcClient.left, rcClient.top, rcClient.right - rcClient.left,
890 rcClient.bottom - rcClient.top, hMemDC,
891 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
892 SelectObject(hMemDC, oldbitmap);
893 DeleteDC(hMemDC);
894 }
895}
896
897
899{
900 HENHMETAFILE hEnhMetaFile;
901 RECT rc;
902
903 GetClientRect(hwnd, &rc);
904 FillRect(hdc, &rc, hbrush);
905 if ((hEnhMetaFile = get_control_icon( hwnd )))
906 {
907 /* The control's current font is not selected into the
908 device context! */
909 if (GetObjectType(hEnhMetaFile) == OBJ_ENHMETAFILE)
910 PlayEnhMetaFile(hdc, hEnhMetaFile, &rc);
911 }
912}
913
914
916{
917 RECT rc;
918
919 GetClientRect( hwnd, &rc );
921}
static HRGN hrgn
static HBRUSH hbrush
static POBJECT_TYPE GetObjectType(IN PCWSTR TypeName)
Definition: ObTypes.cpp:68
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
HFONT hFont
Definition: main.c:53
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
HINSTANCE hInstance
Definition: charmap.c:19
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HBITMAP hBitmap
Definition: timezone.c:26
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:242
static void STATIC_PaintEnhMetafn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:765
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
Definition: static.c:285
void(* pfPaint)(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:58
static BOOL CALLBACK STATIC_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: static.c:531
#define HICON_GWL_OFFSET
Definition: static.c:55
static HBITMAP STATIC_SetBitmap(HWND hwnd, HBITMAP hBitmap, DWORD style)
Definition: static.c:159
static HICON STATIC_LoadIconW(HINSTANCE hInstance, LPCWSTR name, DWORD style)
Definition: static.c:239
static void STATIC_PaintOwnerDrawfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:508
static HICON STATIC_SetIcon(HWND hwnd, HICON hicon, DWORD style)
Definition: static.c:123
static void STATIC_PaintTextfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:540
static BOOL get_icon_size(HICON handle, SIZE *size)
Definition: static.c:83
static BOOL hasTextStyle(DWORD style)
Definition: static.c:306
static void STATIC_PaintRectfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:650
static HANDLE STATIC_GetImage(HWND hwnd, WPARAM wParam, DWORD style)
Definition: static.c:214
#define HFONT_GWL_OFFSET
Definition: static.c:54
static void STATIC_PaintBitmapfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:722
static void STATIC_PaintIconfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:691
static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style)
Definition: static.c:265
#define STATIC_EXTRA_BYTES
Definition: static.c:56
static void STATIC_PaintEtchedfn(HWND hwnd, HDC hdc, DWORD style)
Definition: static.c:783
static const pfPaint staticPaintFunc[SS_TYPEMASK+1]
Definition: static.c:60
static HENHMETAFILE STATIC_SetEnhMetaFile(HWND hwnd, HENHMETAFILE hEnhMetaFile, DWORD style)
Definition: static.c:197
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define IS_INTRESOURCE(x)
Definition: loader.c:613
const WCHAR * text
Definition: package.c:1826
r parent
Definition: btrfs.c:3010
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLsizeiptr size
Definition: glext.h:5919
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
unsigned int UINT
Definition: sysinfo.c:13
#define cs
Definition: i386-dis.c:442
BOOL NTAPI NtUserDrawIconEx(HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyWidth, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, BOOL bMetaHDC, PVOID pDIXData)
Definition: cursoricon.c:2086
BOOL NTAPI NtUserSetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, UINT uFlags)
Definition: winpos.c:3573
#define FNID_DESTROY
Definition: ntuser.h:905
INT NTAPI NtUserInternalGetWindowText(HWND hWnd, LPWSTR lpString, INT nMaxCount)
Definition: window.c:4592
BOOL NTAPI NtUserEndPaint(HWND hWnd, CONST PAINTSTRUCT *lPs)
Definition: painting.c:1660
HDC NTAPI NtUserBeginPaint(HWND hWnd, PAINTSTRUCT *lPs)
Definition: painting.c:1614
BOOL NTAPI NtUserRedrawWindow(HWND hWnd, CONST RECT *lprcUpdate, HRGN hrgnUpdate, UINT flags)
Definition: painting.c:2002
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4335
HDC NTAPI NtUserGetDC(HWND hWnd)
Definition: windc.c:1014
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
Definition: mk_font.cpp:20
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define OBJ_BITMAP
Definition: objidl.idl:1020
#define OBJ_ENHMETAFILE
Definition: objidl.idl:1026
#define LRESULT
Definition: ole.h:14
#define LOWORD(l)
Definition: pedump.c:82
#define SS_WHITERECT
Definition: pedump.c:698
#define SS_WHITEFRAME
Definition: pedump.c:701
#define SS_BLACKRECT
Definition: pedump.c:696
short WCHAR
Definition: pedump.c:58
#define SS_RIGHT
Definition: pedump.c:694
#define SS_SIMPLE
Definition: pedump.c:702
long LONG
Definition: pedump.c:60
#define SS_BITMAP
Definition: pedump.c:704
#define SS_GRAYFRAME
Definition: pedump.c:700
#define WS_DISABLED
Definition: pedump.c:621
#define SS_LEFTNOWORDWRAP
Definition: pedump.c:703
#define SS_CENTER
Definition: pedump.c:693
#define SS_LEFT
Definition: pedump.c:692
#define SS_GRAYRECT
Definition: pedump.c:697
#define SS_BLACKFRAME
Definition: pedump.c:699
#define SS_ICON
Definition: pedump.c:695
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
#define WM_PAINT
Definition: winuser.h:1648
#define ODS_DISABLED
Definition: winuser.h:2583
#define WM_ERASEBKGND
Definition: winuser.h:1653
DWORD WINAPI GetSysColor(_In_ int)
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
#define WS_EX_STATICEDGE
Definition: winuser.h:403
BOOL WINAPI IsWindow(_In_opt_ HWND)
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define DT_NOPREFIX
Definition: winuser.h:537
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define WM_ENABLE
Definition: winuser.h:1643
#define COLOR_GRAYTEXT
Definition: winuser.h:943
#define SS_PATHELLIPSIS
Definition: winuser.h:364
#define DT_CENTER
Definition: winuser.h:527
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define STM_SETICON
Definition: winuser.h:2128
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DT_END_ELLIPSIS
Definition: winuser.h:529
#define IMAGE_ICON
Definition: winuser.h:212
#define DSS_DISABLED
Definition: winuser.h:519
#define WM_CREATE
Definition: winuser.h:1636
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define SS_OWNERDRAW
Definition: winuser.h:352
#define DT_SINGLELINE
Definition: winuser.h:540
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define SWP_NOMOVE
Definition: winuser.h:1255
#define WM_COMMAND
Definition: winuser.h:1768
#define SS_NOTIFY
Definition: winuser.h:351
HANDLE WINAPI LoadImageW(_In_opt_ HINSTANCE hInst, _In_ LPCWSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2572
#define IDC_ARROW
Definition: winuser.h:695
#define WM_NCHITTEST
Definition: winuser.h:1714
#define COLOR_3DDKSHADOW
Definition: winuser.h:950
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define COLOR_3DHIGHLIGHT
Definition: winuser.h:947
#define COLOR_3DSHADOW
Definition: winuser.h:942
#define EDGE_ETCHED
Definition: winuser.h:452
#define SS_EDITCONTROL
Definition: winuser.h:340
#define SS_NOPREFIX
Definition: winuser.h:350
#define RDW_UPDATENOW
Definition: winuser.h:1231
#define SS_ETCHEDHORZ
Definition: winuser.h:343
#define RDW_ERASE
Definition: winuser.h:1222
#define CS_DBLCLKS
Definition: winuser.h:659
HBITMAP WINAPI LoadBitmapA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2517
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define SS_ENHMETAFILE
Definition: winuser.h:341
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1654
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2474
#define SS_CENTERIMAGE
Definition: winuser.h:339
#define WM_GETFONT
Definition: winuser.h:1679
#define SS_ETCHEDVERT
Definition: winuser.h:344
#define STM_SETIMAGE
Definition: winuser.h:2129
#define WM_NCLBUTTONDBLCLK
Definition: winuser.h:1722
#define WM_DRAWITEM
Definition: winuser.h:1673
#define WM_NCCREATE
Definition: winuser.h:1711
#define STM_GETICON
Definition: winuser.h:2126
#define STN_DISABLE
Definition: winuser.h:2132
#define WM_SETTEXT
Definition: winuser.h:1645
#define SS_WORDELLIPSIS
Definition: winuser.h:365
#define SS_TYPEMASK
Definition: winuser.h:362
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define IMAGE_ENHMETAFILE
Definition: winuser.h:214
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define SS_REALSIZEIMAGE
Definition: winuser.h:354
#define DST_COMPLEX
Definition: winuser.h:512
#define RDW_ALLCHILDREN
Definition: winuser.h:1232
#define WM_SETFONT
Definition: winuser.h:1678
HICON WINAPI LoadIconA(_In_opt_ HINSTANCE hInstance, _In_ LPCSTR lpIconName)
Definition: cursoricon.c:2429
#define DT_WORDBREAK
Definition: winuser.h:544
#define HTCLIENT
Definition: winuser.h:2511
#define DLGC_STATIC
Definition: winuser.h:2661
#define LR_SHARED
Definition: winuser.h:1111
#define SS_REALSIZECONTROL
Definition: winuser.h:353
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define DT_VCENTER
Definition: winuser.h:543
HWND WINAPI GetParent(_In_ HWND)
#define IMAGE_CURSOR
Definition: winuser.h:213
#define WM_NCDESTROY
Definition: winuser.h:1712
HANDLE WINAPI LoadImageA(_In_opt_ HINSTANCE hInst, _In_ LPCSTR name, _In_ UINT type, _In_ int cx, _In_ int cy, _In_ UINT fuLoad)
Definition: cursoricon.c:2547
#define HTTRANSPARENT
Definition: winuser.h:2509
#define GWLP_ID
Definition: winuser.h:871
#define DT_WORD_ELLIPSIS
Definition: winuser.h:531
#define DT_RIGHT
Definition: winuser.h:538
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HBITMAP WINAPI LoadBitmapW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2532
#define SWP_NOZORDER
Definition: winuser.h:1258
#define DT_EXPANDTABS
Definition: winuser.h:532
#define ODT_STATIC
Definition: winuser.h:2577
#define DT_HIDEPREFIX
Definition: winuser.h:547
#define DT_EDITCONTROL
Definition: winuser.h:528
#define BF_RECT
Definition: winuser.h:462
BOOL WINAPI DrawStateW(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define GWL_STYLE
Definition: winuser.h:863
#define STN_DBLCLK
Definition: winuser.h:2131
#define CS_PARENTDC
Definition: winuser.h:664
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define STM_GETIMAGE
Definition: winuser.h:2127
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2444
#define SS_SUNKEN
Definition: winuser.h:358
#define STN_ENABLE
Definition: winuser.h:2133
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1720
#define STN_CLICKED
Definition: winuser.h:2130
#define RDW_INVALIDATE
Definition: winuser.h:1225
#define DT_PATH_ELLIPSIS
Definition: winuser.h:530
#define WM_GETDLGCODE
Definition: winuser.h:1717
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HCURSOR WINAPI LoadCursorA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2459
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define WS_EX_RIGHT
Definition: winuser.h:400
#define GWL_EXSTYLE
Definition: winuser.h:862
PFNCLIENT pfnClientA
Definition: regcontrol.c:15
PFNCLIENT pfnClientW
Definition: regcontrol.c:16
const struct builtin_class_descr STATIC_builtin_class
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define UINT
Definition: utils.c:29
#define SS_ENDELLIPSIS
Definition: statst2.c:8
Definition: dcommon.idl:28
long bottom
Definition: dcommon.idl:29
long right
Definition: dcommon.idl:29
long left
Definition: dcommon.idl:29
long top
Definition: dcommon.idl:29
WNDPROC pfnStaticWndProc
Definition: ntuser.h:814
Definition: name.c:39
Definition: style.c:91
LONG bmHeight
Definition: wingdi.h:1869
LONG bmWidth
Definition: wingdi.h:1868
ULONG_PTR itemData
Definition: winuser.h:3201
const char * LPCSTR
Definition: typedefs.h:52
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define MAKEWORD(a, b)
Definition: typedefs.h:248
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define NtUserSetPrivateData(HWND, OFFSET, SIZE, VALUE)
Definition: user_x.h:132
#define NtUserReleaseDC(HWND, HDC)
Definition: user_x.h:120
static __inline BOOL STATIC_update_uistate(HWND hwnd, BOOL unicode)
Definition: user_x.h:65
#define MAKE_FNID(index)
Definition: user_x.h:143
#define NTUSER_WNDPROC_STATIC
Definition: user_x.h:139
#define NtUserGetPrivateData(HWND, OFFSET, SIZE)
Definition: user_x.h:131
HBRUSH FASTCALL GetControlBrush(PWND pwnd, HDC hdc, UINT ctlType)
Definition: misc.c:179
static COLORREF color_3ddkshadow
Definition: static.c:43
static COLORREF color_3dhighlight
Definition: static.c:43
static HFONT get_control_font(HWND hwnd)
Definition: static.c:96
static VOID STATIC_InitColours(void)
Definition: static.c:327
LRESULT WINAPI StaticWndProc_common(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: static.c:358
static HANDLE get_control_icon(HWND hwnd)
Definition: static.c:106
LRESULT WINAPI StaticWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: static.c:633
static HFONT set_control_font(HWND hwnd, HFONT font)
Definition: static.c:101
static HICON STATIC_LoadIconA(HINSTANCE hInstance, LPCSTR name, DWORD style)
Definition: static.c:233
static COLORREF color_3dshadow
Definition: static.c:43
static HANDLE set_control_icon(HWND hwnd, HANDLE icon)
Definition: static.c:111
LRESULT WINAPI StaticWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: static.c:624
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define WINAPI
Definition: msvc.h:6
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define DI_NORMAL
Definition: wingdi.h:72
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define SRCCOPY
Definition: wingdi.h:333
#define ETO_CLIPPED
Definition: wingdi.h:648
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)