ReactOS 0.4.17-dev-1196-gb6224c3
button.c
Go to the documentation of this file.
1/* File: button.c -- Button type widgets
2 *
3 * Copyright (C) 1993 Johannes Ruscheinski
4 * Copyright (C) 1993 David Metcalfe
5 * Copyright (C) 1994 Alexandre Julliard
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 * NOTES
22 *
23 * This code was audited for completeness against the documented features
24 * of Comctl32.dll version 6.0 on Oct. 3, 2004, by Dimitrie O. Paun.
25 *
26 * Unless otherwise noted, we believe this code to be complete, as per
27 * the specification mentioned above.
28 * If you discover missing features, or bugs, please note them below.
29 *
30 * TODO
31 * Styles
32 * - BS_NOTIFY: is it complete?
33 * - BS_RIGHTBUTTON: same as BS_LEFTTEXT
34 *
35 * Messages
36 * - WM_CHAR: Checks a (manual or automatic) check box on '+' or '=', clears it on '-' key.
37 * - WM_SETFOCUS: For (manual or automatic) radio buttons, send the parent window BN_CLICKED
38 * - WM_NCCREATE: Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button.
39 * - WM_SYSKEYUP
40 * - BCM_GETIDEALSIZE
41 * - BCM_GETIMAGELIST
42 * - BCM_GETTEXTMARGIN
43 * - BCM_SETIMAGELIST
44 * - BCM_SETTEXTMARGIN
45 *
46 * Notifications
47 * - BCN_HOTITEMCHANGE
48 * - BN_DISABLE
49 * - BN_PUSHED/BN_HILITE
50 * + BN_KILLFOCUS: is it OK?
51 * - BN_PAINT
52 * + BN_SETFOCUS: is it OK?
53 * - BN_UNPUSHED/BN_UNHILITE
54 * - NM_CUSTOMDRAW
55 *
56 * Structures/Macros/Definitions
57 * - BUTTON_IMAGELIST
58 * - NMBCHOTITEM
59 * - Button_GetIdealSize
60 * - Button_GetImageList
61 * - Button_GetTextMargin
62 * - Button_SetImageList
63 * - Button_SetTextMargin
64 */
65
66#include <user32.h>
67
69
70/* GetWindowLong offsets for window extra information */
71#define STATE_GWL_OFFSET 0
72#define BUTTON_HFONT_GWL_OFFSET (sizeof(LONG))
73#define HIMAGE_GWL_OFFSET (BUTTON_HFONT_GWL_OFFSET+sizeof(HFONT))
74#define BUTTON_UISTATE_GWL_OFFSET (HIMAGE_GWL_OFFSET+sizeof(HFONT))
75#define NB_EXTRA_BYTES (BUTTON_UISTATE_GWL_OFFSET+sizeof(LONG_PTR))
76
77/* undocumented flags */
78#define BUTTON_NSTATES 0x0F
79#define BUTTON_BTNPRESSED 0x40
80#define BUTTON_UNKNOWN2 0x20
81#define BUTTON_UNKNOWN3 0x10
82#ifdef __REACTOS__
83#define BUTTON_BMCLICK 0x100 // ReactOS Need to up to wine!
84#endif
85
86#define BUTTON_NOTIFY_PARENT(hWnd, code) \
87 do { /* Notify parent which has created this button control */ \
88 TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \
89 SendMessageW(GetParent(hWnd), WM_COMMAND, \
90 MAKEWPARAM(GetWindowLongPtrW((hWnd),GWLP_ID), (code)), \
91 (LPARAM)(hWnd)); \
92 } while(0)
93
95static void PB_Paint( HWND hwnd, HDC hDC, UINT action );
96static void CB_Paint( HWND hwnd, HDC hDC, UINT action );
97static void GB_Paint( HWND hwnd, HDC hDC, UINT action );
98static void UB_Paint( HWND hwnd, HDC hDC, UINT action );
99static void OB_Paint( HWND hwnd, HDC hDC, UINT action );
101
102#define MAX_BTN_TYPE 16
103
105{
106 BST_UNCHECKED, /* BS_PUSHBUTTON */
107 BST_UNCHECKED, /* BS_DEFPUSHBUTTON */
108 BST_CHECKED, /* BS_CHECKBOX */
109 BST_CHECKED, /* BS_AUTOCHECKBOX */
110 BST_CHECKED, /* BS_RADIOBUTTON */
111 BST_INDETERMINATE, /* BS_3STATE */
112 BST_INDETERMINATE, /* BS_AUTO3STATE */
113 BST_UNCHECKED, /* BS_GROUPBOX */
114 BST_UNCHECKED, /* BS_USERBUTTON */
115 BST_CHECKED, /* BS_AUTORADIOBUTTON */
116 BST_UNCHECKED, /* BS_PUSHBOX */
117 BST_UNCHECKED /* BS_OWNERDRAW */
118};
119
121
123{
124 PB_Paint, /* BS_PUSHBUTTON */
125 PB_Paint, /* BS_DEFPUSHBUTTON */
126 CB_Paint, /* BS_CHECKBOX */
127 CB_Paint, /* BS_AUTOCHECKBOX */
128 CB_Paint, /* BS_RADIOBUTTON */
129 CB_Paint, /* BS_3STATE */
130 CB_Paint, /* BS_AUTO3STATE */
131 GB_Paint, /* BS_GROUPBOX */
132 UB_Paint, /* BS_USERBUTTON */
133 CB_Paint, /* BS_AUTORADIOBUTTON */
134 NULL, /* BS_PUSHBOX */
135 OB_Paint /* BS_OWNERDRAW */
136};
137
138/*********************************************************************
139 * button class descriptor
140 */
141static const WCHAR buttonW[] = {'B','u','t','t','o','n',0};
143{
144 buttonW, /* name */
146 &pfnClientA.pfnButtonWndProc, /* procA */
147 &pfnClientW.pfnButtonWndProc, /* procW */
148 NB_EXTRA_BYTES, /* extra */
149 IDC_ARROW, /* cursor */
150 0 /* brush */
151};
152
153
155{
157}
158
159static inline void set_button_state( HWND hwnd, LONG state )
160{
162}
163
164#ifdef __REACTOS__
165
166static __inline void set_ui_state( HWND hwnd, LONG flags )
167{
169}
170
171static __inline LONG get_ui_state( HWND hwnd )
172{
174}
175
176#endif /* __REACTOS__ */
177
178static inline HFONT get_button_font( HWND hwnd )
179{
181}
182
183static inline void set_button_font( HWND hwnd, HFONT font )
184{
186}
187
188static inline UINT get_button_type( LONG window_style )
189{
190 return (window_style & BS_TYPEMASK);
191}
192
193/* paint a button of any type */
194static inline void paint_button( HWND hwnd, LONG style, UINT action )
195{
197 {
198 HDC hdc = GetDC( hwnd );
200 ReleaseDC( hwnd, hdc );
201 }
202}
203
204/* retrieve the button text; returned buffer must be freed by caller */
206{
207 INT len = 512;
208 WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
210 return buffer;
211}
212
213#ifdef __REACTOS__
214/* Retrieve the UI state for the control */
215static BOOL button_update_uistate(HWND hwnd, BOOL unicode)
216{
217 LONG flags, prevflags;
218
219 if (unicode)
220 flags = DefWindowProcW(hwnd, WM_QUERYUISTATE, 0, 0);
221 else
222 flags = DefWindowProcA(hwnd, WM_QUERYUISTATE, 0, 0);
223
224 prevflags = get_ui_state(hwnd);
225
226 if (prevflags != flags)
227 {
228 set_ui_state(hwnd, flags);
229 return TRUE;
230 }
231
232 return FALSE;
233}
234#endif
235
236/***********************************************************************
237 * ButtonWndProc_common
238 */
240 WPARAM wParam, LPARAM lParam, BOOL unicode )
241{
242 RECT rect;
243 POINT pt;
245 UINT btn_type = get_button_type( style );
246 LONG state;
247 HANDLE oldHbitmap;
248#ifdef __REACTOS__
249 PWND pWnd;
250
251 pWnd = ValidateHwnd(hWnd);
252 if (pWnd)
253 {
254 if (!pWnd->fnid)
255 {
257 }
258 else
259 {
260 if (pWnd->fnid != FNID_BUTTON)
261 {
262 ERR("Wrong window class for Button! fnId 0x%x\n",pWnd->fnid);
263 return 0;
264 }
265 }
266 }
267 else
268 return 0;
269#else
270 if (!IsWindow( hWnd )) return 0;
271#endif
272
273 pt.x = (short)LOWORD(lParam);
274 pt.y = (short)HIWORD(lParam);
275
276 switch (uMsg)
277 {
278 case WM_GETDLGCODE:
279 switch(btn_type)
280 {
281 case BS_USERBUTTON:
284 case BS_RADIOBUTTON:
286 case BS_GROUPBOX: return DLGC_STATIC;
287 default: return DLGC_BUTTON;
288 }
289
290 case WM_ENABLE:
291 paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
292 break;
293
294 case WM_CREATE:
295 if (btn_type >= MAX_BTN_TYPE)
296 return -1; /* abort */
297
298 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
299 if (btn_type == BS_USERBUTTON )
300 {
301 style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
302#ifdef __REACTOS__
304#else
306#endif
307 }
309#ifdef __REACTOS__
310 button_update_uistate( hWnd, unicode );
311#endif
312 return 0;
313
314#ifdef __REACTOS__
315 case WM_NCDESTROY:
317 case WM_DESTROY:
318 break;
319#endif
320
321 case WM_ERASEBKGND:
322 if (btn_type == BS_OWNERDRAW)
323 {
324 HDC hdc = (HDC)wParam;
325 RECT rc;
326 HBRUSH hBrush;
328 if (!parent) parent = hWnd;
329#ifdef __REACTOS__
331#else
332 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
333 if (!hBrush) /* did the app forget to call defwindowproc ? */
334 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
335 (WPARAM)hdc, (LPARAM)hWnd);
336#endif
337 GetClientRect(hWnd, &rc);
338 FillRect(hdc, &rc, hBrush);
339 }
340 return 1;
341
342 case WM_PRINTCLIENT:
343 case WM_PAINT:
344 {
345 PAINTSTRUCT ps;
346 HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
347 if (btnPaintFunc[btn_type])
348 {
349 int nOldMode = SetBkMode( hdc, OPAQUE );
350 (btnPaintFunc[btn_type])( hWnd, hdc, ODA_DRAWENTIRE );
351 SetBkMode(hdc, nOldMode); /* reset painting mode */
352 }
353 if ( !wParam ) EndPaint( hWnd, &ps );
354 break;
355 }
356
357 case WM_KEYDOWN:
358 if (wParam == VK_SPACE)
359 {
362 SetCapture( hWnd );
363 }
364 break;
365
366 case WM_LBUTTONDBLCLK:
367 if(style & BS_NOTIFY ||
368 btn_type == BS_RADIOBUTTON ||
369 btn_type == BS_USERBUTTON ||
370 btn_type == BS_OWNERDRAW)
371 {
373 break;
374 }
375 /* fall through */
376 case WM_LBUTTONDOWN:
377 SetCapture( hWnd );
378 SetFocus( hWnd );
381 break;
382
383 case WM_KEYUP:
384 if (wParam != VK_SPACE)
385 break;
386 /* fall through */
387 case WM_LBUTTONUP:
388#ifdef __REACTOS__
389 {
390 BOOL TellParent = FALSE;
391#endif
393 if (!(state & BUTTON_BTNPRESSED)) break;
396 if (!(state & BST_PUSHED))
397 {
399 break;
400 }
403 if (uMsg == WM_KEYUP || PtInRect( &rect, pt ))
404 {
406 switch(btn_type)
407 {
408 case BS_AUTOCHECKBOX:
410 break;
413 break;
414 case BS_AUTO3STATE:
416 (state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 );
417 break;
418 }
419#ifdef __REACTOS__
420 TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
421#else
424#endif
425 }
426#ifndef __REACTOS__
427 else
428 {
430 }
431#else
433 if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
434 }
435#endif
436 break;
437
439 TRACE("WM_CAPTURECHANGED %p\n", hWnd);
440 if (hWnd == (HWND)lParam) break;
443 {
447 }
448 break;
449
450 case WM_MOUSEMOVE:
451 if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
452 {
455 }
456 break;
457
458 case WM_SETTEXT:
459 {
460 /* Clear an old text here as Windows does */
461//
462// ReactOS Note :
463// wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
464// Patch: http://source.winehq.org/patches/data/70889
465// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
466//
467#ifdef __REACTOS__
468 if (style & WS_VISIBLE)
469#else
471#endif
472 {
473 HDC hdc = GetDC(hWnd);
474 HBRUSH hbrush;
475 RECT client, rc;
477 UINT message = (btn_type == BS_PUSHBUTTON ||
478 btn_type == BS_DEFPUSHBUTTON ||
479 btn_type == BS_PUSHLIKE ||
480 btn_type == BS_USERBUTTON ||
481 btn_type == BS_OWNERDRAW) ?
483
484 if (!parent) parent = hWnd;
485#ifdef __REACTOS__
487#else
489 (WPARAM)hdc, (LPARAM)hWnd);
490 if (!hbrush) /* did the app forget to call DefWindowProc ? */
492 (WPARAM)hdc, (LPARAM)hWnd);
493#endif
494
496 rc = client;
497 /* FIXME: check other BS_* handlers */
498 if (btn_type == BS_GROUPBOX)
499 InflateRect(&rc, -7, 1); /* GB_Paint does this */
501 /* Clip by client rect bounds */
502 if (rc.right > client.right) rc.right = client.right;
503 if (rc.bottom > client.bottom) rc.bottom = client.bottom;
504 FillRect(hdc, &rc, hbrush);
506 }
507
508 if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
510 if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */
512 else
513 paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
514 return 1; /* success. FIXME: check text length */
515 }
516
517 case WM_SETFONT:
518 set_button_font( hWnd, (HFONT)wParam );
520 break;
521
522 case WM_GETFONT:
523 return (LRESULT)get_button_font( hWnd );
524
525 case WM_SETFOCUS:
526 TRACE("WM_SETFOCUS %p\n",hWnd);
528 paint_button( hWnd, btn_type, ODA_FOCUS );
529 if (style & BS_NOTIFY)
531#ifdef __REACTOS__
532 if (((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) &&
534 {
536 }
537#endif
538 break;
539
540 case WM_KILLFOCUS:
541 TRACE("WM_KILLFOCUS %p\n",hWnd);
544 paint_button( hWnd, btn_type, ODA_FOCUS );
545
546 if ((state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
548 if (style & BS_NOTIFY)
550
552 break;
553
556 break;
557
558 case BM_SETSTYLE:
559 btn_type = wParam & BS_TYPEMASK;
560 style = (style & ~BS_TYPEMASK) | btn_type;
561#ifdef __REACTOS__
563#else
565#endif
566
567 /* Only redraw if lParam flag is set.*/
568 if (lParam)
570
571 break;
572
573 case BM_CLICK:
574#ifdef __REACTOS__
576 if (state & BUTTON_BMCLICK)
577 break;
578 set_button_state(hWnd, state | BUTTON_BMCLICK); // Tracked in STATE_GWL_OFFSET.
579#endif
582#ifdef __REACTOS__
584 if (!(state & BUTTON_BMCLICK)) break;
585 state &= ~BUTTON_BMCLICK;
587#endif
588 break;
589
590 case BM_SETIMAGE:
591 /* Check that image format matches button style */
592 switch (style & (BS_BITMAP|BS_ICON))
593 {
594 case BS_BITMAP:
595 if (wParam != IMAGE_BITMAP) return 0;
596 break;
597 case BS_ICON:
598 if (wParam != IMAGE_ICON) return 0;
599 break;
600 default:
601 return 0;
602 }
605 return (LRESULT)oldHbitmap;
606
607 case BM_GETIMAGE:
609
610 case BM_GETCHECK:
611 return get_button_state( hWnd ) & 3;
612
613 case BM_SETCHECK:
614 if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type];
616 if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON))
617 {
618#ifdef __REACTOS__
619 if (wParam) style |= WS_TABSTOP;
620 else style &= ~WS_TABSTOP;
622#else
624 else WIN_SetStyle( hWnd, 0, WS_TABSTOP );
625#endif
626 }
627 if ((state & 3) != wParam)
628 {
629 set_button_state( hWnd, (state & ~3) | wParam );
630 paint_button( hWnd, btn_type, ODA_SELECT );
631 }
632 break;
633
634 case BM_GETSTATE:
635 return get_button_state( hWnd );
636
637 case BM_SETSTATE:
639 if (wParam)
641 else
643
644 paint_button( hWnd, btn_type, ODA_SELECT );
645 break;
646
647#ifdef __REACTOS__
648 case WM_UPDATEUISTATE:
649 if (unicode)
651 else
653
654 if (button_update_uistate(hWnd, unicode))
655 paint_button( hWnd, btn_type, ODA_DRAWENTIRE );
656 break;
657#endif
658
659 case WM_NCHITTEST:
660 if(btn_type == BS_GROUPBOX) return HTTRANSPARENT;
661 /* fall through */
662 default:
663 return unicode ? DefWindowProcW(hWnd, uMsg, wParam, lParam) :
665 }
666 return 0;
667}
668
669#ifdef __REACTOS__
670
671/***********************************************************************
672 * ButtonWndProcW
673 * The button window procedure. This is just a wrapper which locks
674 * the passed HWND and calls the real window procedure (with a WND*
675 * pointer pointing to the locked windowstructure).
676 */
678{
679 if (!IsWindow(hWnd)) return 0;
680 return ButtonWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
681}
682
683/***********************************************************************
684 * ButtonWndProcA
685 */
687{
688 if (!IsWindow(hWnd)) return 0;
690}
691
692#endif /* __REACTOS__ */
693
694/**********************************************************************
695 * Convert button styles to flags used by DrawText.
696 */
697static UINT BUTTON_BStoDT( DWORD style, DWORD ex_style )
698{
699 UINT dtStyle = DT_NOCLIP; /* We use SelectClipRgn to limit output */
700
701 /* "Convert" pushlike buttons to pushbuttons */
702 if (style & BS_PUSHLIKE)
703 style &= ~BS_TYPEMASK;
704
705 if (!(style & BS_MULTILINE))
706 dtStyle |= DT_SINGLELINE;
707 else
708 dtStyle |= DT_WORDBREAK;
709
710 switch (style & BS_CENTER)
711 {
712 case BS_LEFT: /* DT_LEFT is 0 */ break;
713 case BS_RIGHT: dtStyle |= DT_RIGHT; break;
714 case BS_CENTER: dtStyle |= DT_CENTER; break;
715 default:
716 /* Pushbutton's text is centered by default */
718 /* all other flavours have left aligned text */
719 }
720
721 if (ex_style & WS_EX_RIGHT) dtStyle = DT_RIGHT | (dtStyle & ~(DT_LEFT | DT_CENTER));
722
723 /* DrawText ignores vertical alignment for multiline text,
724 * but we use these flags to align label manually.
725 */
727 {
728 switch (style & BS_VCENTER)
729 {
730 case BS_TOP: /* DT_TOP is 0 */ break;
731 case BS_BOTTOM: dtStyle |= DT_BOTTOM; break;
732 case BS_VCENTER: /* fall through */
733 default: dtStyle |= DT_VCENTER; break;
734 }
735 }
736 else
737 /* GroupBox's text is always single line and is top aligned. */
738 dtStyle |= DT_SINGLELINE;
739
740 return dtStyle;
741}
742
743/**********************************************************************
744 * BUTTON_CalcLabelRect
745 *
746 * Calculates label's rectangle depending on button style.
747 *
748 * Returns flags to be passed to DrawText.
749 * Calculated rectangle doesn't take into account button state
750 * (pushed, etc.). If there is nothing to draw (no text/image) output
751 * rectangle is empty, and return value is (UINT)-1.
752 */
754{
756 LONG ex_style = GetWindowLongPtrW( hwnd, GWL_EXSTYLE );
757 WCHAR *text;
758 ICONINFO iconInfo;
759 BITMAP bm;
760 UINT dtStyle = BUTTON_BStoDT( style, ex_style );
761 RECT r = *rc;
762 INT n;
763
764 /* Calculate label rectangle according to label type */
765 switch (style & (BS_ICON|BS_BITMAP))
766 {
767 case BS_TEXT:
768 {
769 HFONT hFont, hPrevFont = 0;
770
771 if (!(text = get_button_text( hwnd ))) goto empty_rect;
772 if (!text[0])
773 {
775 goto empty_rect;
776 }
777
778 if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hdc, hFont );
779#ifdef __REACTOS__
780 DrawTextW(hdc, text, -1, &r, ((dtStyle | DT_CALCRECT) & ~(DT_VCENTER | DT_BOTTOM)));
781#else
782 DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
783#endif
784 if (hPrevFont) SelectObject( hdc, hPrevFont );
786#ifdef __REACTOS__
787 if (get_ui_state(hwnd) & UISF_HIDEACCEL)
788 dtStyle |= DT_HIDEPREFIX;
789#endif
790 break;
791 }
792
793 case BS_ICON:
795 goto empty_rect;
796
797 GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm);
798
799 r.right = r.left + bm.bmWidth;
800 r.bottom = r.top + bm.bmHeight;
801
802 DeleteObject(iconInfo.hbmColor);
803 DeleteObject(iconInfo.hbmMask);
804 break;
805
806 case BS_BITMAP:
808 goto empty_rect;
809
810 r.right = r.left + bm.bmWidth;
811 r.bottom = r.top + bm.bmHeight;
812 break;
813
814 default:
815 empty_rect:
816 rc->right = r.left;
817 rc->bottom = r.top;
818 return (UINT)-1;
819 }
820
821 /* Position label inside bounding rectangle according to
822 * alignment flags. (calculated rect is always left-top aligned).
823 * If label is aligned to any side - shift label in opposite
824 * direction to leave extra space for focus rectangle.
825 */
826 switch (dtStyle & (DT_CENTER|DT_RIGHT))
827 {
828 case DT_LEFT: r.left++; r.right++; break;
829 case DT_CENTER: n = r.right - r.left;
830 r.left = rc->left + ((rc->right - rc->left) - n) / 2;
831 r.right = r.left + n; break;
832 case DT_RIGHT: n = r.right - r.left;
833 r.right = rc->right - 1;
834 r.left = r.right - n;
835 break;
836 }
837
838 switch (dtStyle & (DT_VCENTER|DT_BOTTOM))
839 {
840 case DT_TOP: r.top++; r.bottom++; break;
841 case DT_VCENTER: n = r.bottom - r.top;
842#ifdef __REACTOS__
843 r.top = rc->top + ((rc->bottom - 1 - rc->top) - n) / 2;
844#else
845 r.top = rc->top + ((rc->bottom - rc->top) - n) / 2;
846#endif
847 r.bottom = r.top + n; break;
848 case DT_BOTTOM: n = r.bottom - r.top;
849 r.bottom = rc->bottom - 1;
850 r.top = r.bottom - n;
851 break;
852 }
853
854 *rc = r;
855 return dtStyle;
856}
857
858
859/**********************************************************************
860 * BUTTON_DrawTextCallback
861 *
862 * Callback function used by DrawStateW function.
863 */
865{
866 RECT rc;
867
868 SetRect(&rc, 0, 0, cx, cy);
869 DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
870 return TRUE;
871}
872
873
874/**********************************************************************
875 * BUTTON_DrawLabel
876 *
877 * Common function for drawing button label.
878 */
879static void BUTTON_DrawLabel(HWND hwnd, HDC hdc, UINT dtFlags, const RECT *rc)
880{
881 DRAWSTATEPROC lpOutputProc = NULL;
882 LPARAM lp;
883 WPARAM wp = 0;
884 HBRUSH hbr = 0;
888 WCHAR *text = NULL;
889
890 /* FIXME: To draw disabled label in Win31 look-and-feel, we probably
891 * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION).
892 * I don't have Win31 on hand to verify that, so I leave it as is.
893 */
894
896 {
898 flags |= DSS_MONO;
899 }
900
901 switch (style & (BS_ICON|BS_BITMAP))
902 {
903 case BS_TEXT:
904 /* DST_COMPLEX -- is 0 */
905 lpOutputProc = BUTTON_DrawTextCallback;
906 if (!(text = get_button_text( hwnd ))) return;
907 lp = (LPARAM)text;
908 wp = (WPARAM)dtFlags;
909
910#ifdef __REACTOS__
911 if (dtFlags & DT_HIDEPREFIX)
913#endif
914 break;
915
916 case BS_ICON:
917 flags |= DST_ICON;
919 break;
920
921 case BS_BITMAP:
922 flags |= DST_BITMAP;
924 break;
925
926 default:
927 return;
928 }
929
930 DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top,
931 rc->right - rc->left, rc->bottom - rc->top, flags);
933}
934
935/**********************************************************************
936 * Push Button Functions
937 */
939{
940 RECT rc, r;
941 UINT dtFlags, uState;
942 HPEN hOldPen;
943 HBRUSH hOldBrush;
944 INT oldBkMode;
945 COLORREF oldTxtColor;
946 HFONT hFont;
949 BOOL pushedState = (state & BST_PUSHED);
950 HWND parent;
951 HRGN hrgn;
952
953 GetClientRect( hwnd, &rc );
954
955 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
958 if (!parent) parent = hwnd;
959#ifdef __REACTOS__
961#else
963#endif
964
965 hrgn = set_control_clipping( hDC, &rc );
966#ifdef __REACTOS__
967 hOldPen = SelectObject(hDC, GetStockObject(DC_PEN));
969#else
970 hOldPen = SelectObject(hDC, SYSCOLOR_GetPen(COLOR_WINDOWFRAME));
971#endif
973 oldBkMode = SetBkMode(hDC, TRANSPARENT);
974
976 {
977 if (action != ODA_FOCUS)
978 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
979 InflateRect( &rc, -1, -1 );
980 }
981
982 /* completely skip the drawing if only focus has changed */
983 if (action == ODA_FOCUS) goto draw_focus;
984
985 uState = DFCS_BUTTONPUSH;
986
987 if (style & BS_FLAT)
988 uState |= DFCS_MONO;
989 else if (pushedState)
990 {
992 uState |= DFCS_FLAT;
993 else
994 uState |= DFCS_PUSHED;
995 }
996
998 uState |= DFCS_CHECKED;
999
1000 DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
1001
1002 /* draw button label */
1003 r = rc;
1004 dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &r);
1005
1006 if (dtFlags == (UINT)-1L)
1007 goto cleanup;
1008
1009 if (pushedState)
1010 OffsetRect(&r, 1, 1);
1011
1012 oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
1013
1014 BUTTON_DrawLabel(hwnd, hDC, dtFlags, &r);
1015
1016 SetTextColor( hDC, oldTxtColor );
1017
1018draw_focus:
1019 if (action == ODA_FOCUS || (state & BST_FOCUS))
1020 {
1021#ifdef __REACTOS__
1022 if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1023 {
1024#endif
1025 InflateRect( &rc, -2, -2 );
1026 DrawFocusRect( hDC, &rc );
1027#ifdef __REACTOS__
1028 }
1029#endif
1030 }
1031
1032 cleanup:
1033 SelectObject( hDC, hOldPen );
1034 SelectObject( hDC, hOldBrush );
1035 SetBkMode(hDC, oldBkMode);
1037 if (hrgn) DeleteObject( hrgn );
1038}
1039
1040/**********************************************************************
1041 * Check Box & Radio Button Functions
1042 */
1043
1045{
1046 RECT rbox, rtext, client;
1047 HBRUSH hBrush;
1048 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1049 UINT dtFlags;
1050 HFONT hFont;
1053 LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
1054 HWND parent;
1055 HRGN hrgn;
1056
1057 if (style & BS_PUSHLIKE)
1058 {
1059 PB_Paint( hwnd, hDC, action );
1060 return;
1061 }
1062
1064 rbox = rtext = client;
1065
1066 checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
1067 checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
1068
1070 GetCharWidthW( hDC, '0', '0', &text_offset );
1071 text_offset /= 2;
1072
1074 if (!parent) parent = hwnd;
1075#ifdef __REACTOS__
1077#else
1078 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
1079 (WPARAM)hDC, (LPARAM)hwnd);
1080 if (!hBrush) /* did the app forget to call defwindowproc ? */
1081 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
1082 (WPARAM)hDC, (LPARAM)hwnd );
1083#endif
1085
1086 if (style & BS_LEFTTEXT || ex_style & WS_EX_RIGHT)
1087 {
1088 /* magic +4 is what CTL3D expects */
1089
1090 rtext.right -= checkBoxWidth + text_offset;;
1091 rbox.left = rbox.right - checkBoxWidth;
1092 }
1093 else
1094 {
1095 rtext.left += checkBoxWidth + text_offset;;
1096 rbox.right = checkBoxWidth;
1097 }
1098
1099 /* Since WM_ERASEBKGND does nothing, first prepare background */
1100 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
1101 if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush );
1102
1103 /* Draw label */
1104 client = rtext;
1105 dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rtext);
1106
1107 /* Only adjust rbox when rtext is valid */
1108 if (dtFlags != (UINT)-1L)
1109 {
1110 rbox.top = rtext.top;
1111 rbox.bottom = rtext.bottom;
1112 }
1113
1114 /* Draw the check-box bitmap */
1116 {
1117 UINT flags;
1118
1122 else flags = DFCS_BUTTONCHECK;
1123
1126
1128
1129 /* rbox must have the correct height */
1130 delta = rbox.bottom - rbox.top - checkBoxHeight;
1131
1132 if (style & BS_TOP) {
1133 if (delta > 0) {
1134 rbox.bottom = rbox.top + checkBoxHeight;
1135 } else {
1136 rbox.top -= -delta/2 + 1;
1137 rbox.bottom = rbox.top + checkBoxHeight;
1138 }
1139 } else if (style & BS_BOTTOM) {
1140 if (delta > 0) {
1141 rbox.top = rbox.bottom - checkBoxHeight;
1142 } else {
1143 rbox.bottom += -delta/2 + 1;
1144 rbox.top = rbox.bottom - checkBoxHeight;
1145 }
1146 } else { /* Default */
1147 if (delta > 0) {
1148 int ofs = (delta / 2);
1149 rbox.bottom -= ofs + 1;
1150 rbox.top = rbox.bottom - checkBoxHeight;
1151 } else if (delta < 0) {
1152 int ofs = (-delta / 2);
1153 rbox.top -= ofs + 1;
1154 rbox.bottom = rbox.top + checkBoxHeight;
1155 }
1156 }
1157
1159 }
1160
1161 if (dtFlags == (UINT)-1L) /* Noting to draw */
1162 return;
1163
1164 if (action == ODA_DRAWENTIRE)
1165 BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rtext);
1166
1167 /* ... and focus */
1168 if (action == ODA_FOCUS || (state & BST_FOCUS))
1169 {
1170#ifdef __REACTOS__
1171 if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1172 {
1173#endif
1174 rtext.left--;
1175 rtext.right++;
1176 IntersectRect(&rtext, &rtext, &client);
1177 DrawFocusRect( hDC, &rtext );
1178#ifdef __REACTOS__
1179 }
1180#endif
1181 }
1183 if (hrgn) DeleteObject( hrgn );
1184}
1185
1186
1187/**********************************************************************
1188 * BUTTON_CheckAutoRadioButton
1189 *
1190 * hwnd is checked, uncheck every other auto radio button in group
1191 */
1193{
1194 HWND parent, sibling, start;
1195
1197 /* make sure that starting control is not disabled or invisible */
1198 start = sibling = hwnd;
1199 do
1200 {
1201 if (!sibling) break;
1202#ifdef __REACTOS__
1204#else
1205 if (SendMessageW( sibling, WM_GETDLGCODE, 0, 0 ) == (DLGC_BUTTON | DLGC_RADIOBUTTON))
1206#endif
1207 SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED : BST_UNCHECKED, 0 );
1208 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
1209 } while (sibling != start);
1210}
1211
1212
1213/**********************************************************************
1214 * Group Box Functions
1215 */
1216
1218{
1219 RECT rc, rcFrame;
1220 HBRUSH hbr;
1221 HFONT hFont;
1222 UINT dtFlags;
1225 HWND parent;
1226 HRGN hrgn;
1227
1229 /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
1231 if (!parent) parent = hwnd;
1232#ifdef __REACTOS__
1234#else
1236 if (!hbr) /* did the app forget to call defwindowproc ? */
1238 (WPARAM)hDC, (LPARAM)hwnd);
1239#endif
1240 GetClientRect( hwnd, &rc);
1241 rcFrame = rc;
1242 hrgn = set_control_clipping( hDC, &rc );
1243
1245 rcFrame.top += (tm.tmHeight / 2) - 1;
1246 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0));
1247
1248 InflateRect(&rc, -7, 1);
1249 dtFlags = BUTTON_CalcLabelRect(hwnd, hDC, &rc);
1250
1251 if (dtFlags != (UINT)-1L)
1252 {
1253 /* Because buttons have CS_PARENTDC class style, there is a chance
1254 * that label will be drawn out of client rect.
1255 * But Windows doesn't clip label's rect, so do I.
1256 */
1257
1258 /* There is 1-pixel margin at the left, right, and bottom */
1259 rc.left--; rc.right++; rc.bottom++;
1260 FillRect(hDC, &rc, hbr);
1261 rc.left++; rc.right--; rc.bottom--;
1262
1263 BUTTON_DrawLabel(hwnd, hDC, dtFlags, &rc);
1264 }
1266 if (hrgn) DeleteObject( hrgn );
1267}
1268
1269
1270/**********************************************************************
1271 * User Button Functions
1272 */
1273
1275{
1276 RECT rc;
1277 HBRUSH hBrush;
1278 HFONT hFont;
1280 HWND parent;
1281
1282 GetClientRect( hwnd, &rc);
1283
1285
1287 if (!parent) parent = hwnd;
1288#ifdef __REACTOS__
1290#else
1291 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd);
1292 if (!hBrush) /* did the app forget to call defwindowproc ? */
1293 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
1294 (WPARAM)hDC, (LPARAM)hwnd);
1295#endif
1296
1297 FillRect( hDC, &rc, hBrush );
1298 if (action == ODA_FOCUS || (state & BST_FOCUS))
1299#ifdef __REACTOS__
1300 {
1301 if (!(get_ui_state(hwnd) & UISF_HIDEFOCUS))
1302#endif
1303 DrawFocusRect( hDC, &rc );
1304#ifdef __REACTOS__
1305 }
1306#endif
1307
1308 switch (action)
1309 {
1310 case ODA_FOCUS:
1312 break;
1313
1314 case ODA_SELECT:
1316 break;
1317
1318 default:
1320 break;
1321 }
1322}
1323
1324
1325/**********************************************************************
1326 * Ownerdrawn Button Functions
1327 */
1328
1330{
1332 DRAWITEMSTRUCT dis;
1334 HWND parent;
1335 HFONT hFont, hPrevFont = 0;
1336 HRGN hrgn;
1337
1338 dis.CtlType = ODT_BUTTON;
1339 dis.CtlID = id;
1340 dis.itemID = 0;
1341 dis.itemAction = action;
1342 dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) |
1343 ((state & BST_PUSHED) ? ODS_SELECTED : 0) |
1345 dis.hwndItem = hwnd;
1346 dis.hDC = hDC;
1347 dis.itemData = 0;
1348 GetClientRect( hwnd, &dis.rcItem );
1349
1350 if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
1352 if (!parent) parent = hwnd;
1353#ifdef __REACTOS__
1355#else
1357#endif
1358
1360
1362 if (hPrevFont) SelectObject(hDC, hPrevFont);
1364 if (hrgn) DeleteObject( hrgn );
1365}
static HDC hDC
Definition: 3dtext.c:33
static HRGN hrgn
static HBRUSH hbrush
#define __inline
Definition: _wctype.cpp:15
static int state
Definition: maze.c:121
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
HFONT hFont
Definition: main.c:53
#define ERR(fmt,...)
Definition: precomp.h:57
RECT rect
Definition: combotst.c:67
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
LRESULT WINAPI ButtonWndProcA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
LRESULT WINAPI ButtonWndProcW(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:242
#define BUTTON_NSTATES
Definition: button.c:77
static void BUTTON_DrawLabel(const BUTTON_INFO *infoPtr, HDC hdc, UINT dtFlags, const RECT *rc)
Definition: button.c:1429
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: button.c:1414
static void GB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1784
#define BUTTON_NOTIFY_PARENT(hWnd, code)
Definition: button.c:85
static void CB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1620
static const pfPaint btnPaintFunc[MAX_BTN_TYPE]
Definition: button.c:157
static UINT BUTTON_CalcLabelRect(const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc)
Definition: button.c:1282
static void paint_button(BUTTON_INFO *infoPtr, LONG style, UINT action)
Definition: button.c:221
static UINT BUTTON_BStoDT(DWORD style, DWORD ex_style)
Definition: button.c:273
#define BUTTON_BTNPRESSED
Definition: button.c:78
static UINT get_button_type(LONG window_style)
Definition: button.c:214
static void PB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1497
static WCHAR * get_button_text(const BUTTON_INFO *infoPtr)
Definition: button.c:233
static const WORD maxCheckState[MAX_BTN_TYPE]
Definition: button.c:125
static void UB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1836
#define MAX_BTN_TYPE
Definition: button.c:123
static void OB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1878
static void BUTTON_CheckAutoRadioButton(HWND hwnd)
Definition: button.c:1753
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
static void cleanup(void)
Definition: main.c:1335
const WCHAR * text
Definition: package.c:1826
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
action
Definition: namespace.c:714
r parent
Definition: btrfs.c:3010
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLuint start
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
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 FNID_DESTROY
Definition: ntuser.h:905
#define FNID_BUTTON
Definition: ntuser.h:873
DWORD NTAPI NtUserAlterWindowStyle(HWND hWnd, DWORD Index, LONG NewValue)
Definition: window.c:4092
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4335
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 WPARAM
Definition: button.c:42
static HBITMAP
Definition: button.c:44
DWORD button
Definition: button.c:166
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
__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 LOWORD(l)
Definition: pedump.c:82
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
#define BS_USERBUTTON
Definition: pedump.c:659
#define BS_LEFTTEXT
Definition: pedump.c:662
#define WS_TABSTOP
Definition: pedump.c:634
short WCHAR
Definition: pedump.c:58
#define WS_VISIBLE
Definition: pedump.c:620
#define BS_AUTOCHECKBOX
Definition: pedump.c:654
long LONG
Definition: pedump.c:60
#define BS_GROUPBOX
Definition: pedump.c:658
#define BS_OWNERDRAW
Definition: pedump.c:661
#define WS_DISABLED
Definition: pedump.c:621
#define BS_AUTO3STATE
Definition: pedump.c:657
#define BS_RADIOBUTTON
Definition: pedump.c:655
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
_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
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define BST_INDETERMINATE
Definition: winuser.h:198
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_ERASEBKGND
Definition: winuser.h:1653
#define CS_VREDRAW
Definition: winuser.h:666
DWORD WINAPI GetSysColor(_In_ int)
#define BS_BITMAP
Definition: winuser.h:258
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1800
#define ODS_SELECTED
Definition: winuser.h:2581
#define BM_GETSTATE
Definition: winuser.h:1949
#define COLOR_BTNTEXT
Definition: winuser.h:944
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetWindowLongPtrW
Definition: winuser.h:4983
#define WM_ENABLE
Definition: winuser.h:1643
#define WM_KEYUP
Definition: winuser.h:1744
#define COLOR_GRAYTEXT
Definition: winuser.h:943
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define COLOR_WINDOWFRAME
Definition: winuser.h:930
#define DT_CENTER
Definition: winuser.h:527
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
#define BS_RIGHT
Definition: winuser.h:274
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DLGC_BUTTON
Definition: winuser.h:2662
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_UNCHECKED
Definition: winuser.h:199
#define BN_DOUBLECLICKED
Definition: winuser.h:1957
#define IMAGE_ICON
Definition: winuser.h:212
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
#define BN_SETFOCUS
Definition: winuser.h:1962
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2414
#define WM_CAPTURECHANGED
Definition: winuser.h:1836
#define DSS_DISABLED
Definition: winuser.h:519
#define WM_CREATE
Definition: winuser.h:1636
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define DFCS_FLAT
Definition: winuser.h:510
#define BS_ICON
Definition: winuser.h:264
#define VK_SPACE
Definition: winuser.h:2255
#define BS_PUSHLIKE
Definition: winuser.h:272
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define BM_SETSTATE
Definition: winuser.h:1952
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define DT_SINGLELINE
Definition: winuser.h:540
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define BS_TYPEMASK
Definition: winuser.h:270
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
#define CS_HREDRAW
Definition: winuser.h:661
#define ODA_FOCUS
Definition: winuser.h:2580
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DLGC_UNDEFPUSHBUTTON
Definition: winuser.h:2658
#define IDC_ARROW
Definition: winuser.h:695
#define WM_NCHITTEST
Definition: winuser.h:1714
#define DFC_BUTTON
Definition: winuser.h:476
#define BS_BOTTOM
Definition: winuser.h:259
#define BN_KILLFOCUS
Definition: winuser.h:1959
#define WM_SETFOCUS
Definition: winuser.h:1641
#define EDGE_ETCHED
Definition: winuser.h:452
#define BN_HILITE
Definition: winuser.h:1958
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define DT_NOCLIP
Definition: winuser.h:536
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define BS_NOTIFY
Definition: winuser.h:268
#define DST_ICON
Definition: winuser.h:515
#define CS_DBLCLKS
Definition: winuser.h:659
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1654
#define DLGC_DEFPUSHBUTTON
Definition: winuser.h:2657
#define WM_GETFONT
Definition: winuser.h:1679
#define BF_FLAT
Definition: winuser.h:471
#define WM_DRAWITEM
Definition: winuser.h:1673
#define BM_SETCHECK
Definition: winuser.h:1950
#define BS_MULTILINE
Definition: winuser.h:267
#define BM_SETIMAGE
Definition: winuser.h:1951
#define BN_UNHILITE
Definition: winuser.h:1963
#define WM_CTLCOLORBTN
Definition: winuser.h:1797
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define WM_SETTEXT
Definition: winuser.h:1645
#define DFCS_MONO
Definition: winuser.h:511
HWND WINAPI GetNextDlgGroupItem(_In_ HWND, _In_opt_ HWND, _In_ BOOL)
#define DFCS_BUTTON3STATE
Definition: winuser.h:500
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_TOP
Definition: winuser.h:542
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define DLGC_RADIOBUTTON
Definition: winuser.h:2659
#define BS_FLAT
Definition: winuser.h:280
#define BS_LEFT
Definition: winuser.h:265
#define WM_SETFONT
Definition: winuser.h:1678
#define BM_CLICK
Definition: winuser.h:1946
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DST_BITMAP
Definition: winuser.h:516
#define DT_WORDBREAK
Definition: winuser.h:544
#define BST_PUSHED
Definition: winuser.h:201
#define BM_GETIMAGE
Definition: winuser.h:1948
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define DFCS_BUTTONRADIO
Definition: winuser.h:499
#define BM_SETSTYLE
Definition: winuser.h:1953
#define BST_FOCUS
Definition: winuser.h:200
#define BS_VCENTER
Definition: winuser.h:279
HDC WINAPI GetDC(_In_opt_ HWND)
#define BS_TOP
Definition: winuser.h:277
#define DLGC_STATIC
Definition: winuser.h:2661
#define WM_LBUTTONUP
Definition: winuser.h:1805
#define BS_TEXT
Definition: winuser.h:276
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define DT_VCENTER
Definition: winuser.h:543
HWND WINAPI GetParent(_In_ HWND)
#define DT_BOTTOM
Definition: winuser.h:525
#define WM_NCDESTROY
Definition: winuser.h:1712
#define ODA_SELECT
Definition: winuser.h:2579
#define HTTRANSPARENT
Definition: winuser.h:2509
#define DSS_NORMAL
Definition: winuser.h:517
#define GWLP_ID
Definition: winuser.h:871
#define DSS_HIDEPREFIX
Definition: winuser.h:522
#define MK_LBUTTON
Definition: winuser.h:2403
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define BN_CLICKED
Definition: winuser.h:1954
#define WM_DESTROY
Definition: winuser.h:1637
#define DFCS_CHECKED
Definition: winuser.h:504
#define ODT_BUTTON
Definition: winuser.h:2576
#define WM_KEYDOWN
Definition: winuser.h:1743
#define DT_RIGHT
Definition: winuser.h:538
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define BS_CENTER
Definition: winuser.h:260
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define DT_CALCRECT
Definition: winuser.h:526
#define DT_HIDEPREFIX
Definition: winuser.h:547
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
#define SetWindowLongPtrW
Definition: winuser.h:5512
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#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 BN_PAINT
Definition: winuser.h:1960
#define CS_PARENTDC
Definition: winuser.h:664
BOOL(CALLBACK * DRAWSTATEPROC)(HDC, LPARAM, WPARAM, int, int)
Definition: winuser.h:3015
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define DFCS_PUSHED
Definition: winuser.h:503
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define ODS_FOCUS
Definition: winuser.h:2585
#define WM_GETDLGCODE
Definition: winuser.h:1717
#define DSS_MONO
Definition: winuser.h:521
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define BST_CHECKED
Definition: winuser.h:197
#define COLOR_BTNFACE
Definition: winuser.h:939
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define BM_GETCHECK
Definition: winuser.h:1947
#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
#define WM_PRINTCLIENT
Definition: richedit.h:70
static FILE * client
Definition: client.c:37
#define TRACE(s)
Definition: solgame.cpp:4
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
HBITMAP hbmColor
Definition: winuser.h:3235
HBITMAP hbmMask
Definition: winuser.h:3234
WNDPROC pfnButtonWndProc
Definition: ntuser.h:807
Definition: ntuser.h:698
DWORD fnid
Definition: ntuser.h:713
Definition: tftpd.h:60
Definition: style.c:91
LONG bmHeight
Definition: wingdi.h:1869
LONG bmWidth
Definition: wingdi.h:1868
ULONG_PTR itemData
Definition: winuser.h:3201
const uint16_t * LPCWSTR
Definition: typedefs.h:57
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
#define ValidateHwnd(hwnd)
Definition: precomp.h:98
HBRUSH FASTCALL GetControlColor(PWND pwndParent, PWND pwnd, HDC hdc, UINT CtlMsg)
Definition: misc.c:153
#define STATE_GWL_OFFSET
Definition: button.c:71
static void set_button_state(HWND hwnd, LONG state)
Definition: button.c:159
static void set_button_font(HWND hwnd, HFONT font)
Definition: button.c:183
static const WCHAR buttonW[]
Definition: button.c:141
void(* pfButtonPaint)(HWND hwnd, HDC hdc, UINT action)
Definition: button.c:120
LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: button.c:239
#define BUTTON_HFONT_GWL_OFFSET
Definition: button.c:72
const struct builtin_class_descr BUTTON_builtin_class
Definition: button.c:142
static HFONT get_button_font(HWND hwnd)
Definition: button.c:178
static LONG get_button_state(HWND hwnd)
Definition: button.c:154
#define HIMAGE_GWL_OFFSET
Definition: button.c:73
#define BUTTON_UISTATE_GWL_OFFSET
Definition: button.c:74
#define NB_EXTRA_BYTES
Definition: button.c:75
ULONG WIN_SetStyle(HWND hwnd, ULONG set_bits, ULONG clear_bits)
Definition: win.c:164
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define WINAPI
Definition: msvc.h:6
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI GetCharWidthW(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)
#define LOGPIXELSY
Definition: wingdi.h:719
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define TRANSPARENT
Definition: wingdi.h:950
#define OPAQUE
Definition: wingdi.h:949
#define LOGPIXELSX
Definition: wingdi.h:718
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)