ReactOS 0.4.15-dev-7953-g1f49173
button.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 1993 Johannes Ruscheinski
3 * Copyright (C) 1993 David Metcalfe
4 * Copyright (C) 1994 Alexandre Julliard
5 * Copyright (C) 2008 by Reece H. Dunn
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 * TODO
22 * Styles
23 * - BS_NOTIFY: is it complete?
24 * - BS_RIGHTBUTTON: same as BS_LEFTTEXT
25 *
26 * Messages
27 * - WM_CHAR: Checks a (manual or automatic) check box on '+' or '=', clears it on '-' key.
28 * - WM_SETFOCUS: For (manual or automatic) radio buttons, send the parent window BN_CLICKED
29 * - WM_NCCREATE: Turns any BS_OWNERDRAW button into a BS_PUSHBUTTON button.
30 * - WM_SYSKEYUP
31 * - BCM_GETIDEALSIZE
32 * - BCM_GETIMAGELIST
33 * - BCM_GETTEXTMARGIN
34 * - BCM_SETIMAGELIST
35 * - BCM_SETTEXTMARGIN
36 *
37 * Notifications
38 * - BCN_HOTITEMCHANGE
39 * - BN_DISABLE
40 * - BN_PUSHED/BN_HILITE
41 * + BN_KILLFOCUS: is it OK?
42 * - BN_PAINT
43 * + BN_SETFOCUS: is it OK?
44 * - BN_UNPUSHED/BN_UNHILITE
45 * - NM_CUSTOMDRAW
46 *
47 * Structures/Macros/Definitions
48 * - BUTTON_IMAGELIST
49 * - NMBCHOTITEM
50 * - Button_GetIdealSize
51 * - Button_GetImageList
52 * - Button_GetTextMargin
53 * - Button_SetImageList
54 * - Button_SetTextMargin
55 */
56
57#include <stdarg.h>
58#include <string.h>
59#include <stdlib.h>
60
61#define OEMRESOURCE
62
63#include "windef.h"
64#include "winbase.h"
65#include "wingdi.h"
66#include "winuser.h"
67#include "uxtheme.h"
68#include "vssym32.h"
69#include "wine/debug.h"
70#include "wine/heap.h"
71
72#include "comctl32.h"
73
75
76/* undocumented flags */
77#define BUTTON_NSTATES 0x0F
78#define BUTTON_BTNPRESSED 0x40
79#define BUTTON_UNKNOWN2 0x20
80#define BUTTON_UNKNOWN3 0x10
81#ifdef __REACTOS__
82#define BUTTON_BMCLICK 0x100 // ReactOS Need to up to wine!
83#endif
84
85#define BUTTON_NOTIFY_PARENT(hWnd, code) \
86 do { /* Notify parent which has created this button control */ \
87 TRACE("notification " #code " sent to hwnd=%p\n", GetParent(hWnd)); \
88 SendMessageW(GetParent(hWnd), WM_COMMAND, \
89 MAKEWPARAM(GetWindowLongPtrW((hWnd),GWLP_ID), (code)), \
90 (LPARAM)(hWnd)); \
91 } while(0)
92
93typedef struct _BUTTON_INFO
94{
98 union
99 {
103 } u;
104
105#ifdef __REACTOS__
106 DWORD ui_state;
107 RECT rcTextMargin;
108 BUTTON_IMAGELIST imlData;
109#endif
111
112static UINT BUTTON_CalcLabelRect( const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc );
113static void PB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
114static void CB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
115static void GB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
116static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
117static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action );
119
120#define MAX_BTN_TYPE 16
121
123{
124 BST_UNCHECKED, /* BS_PUSHBUTTON */
125 BST_UNCHECKED, /* BS_DEFPUSHBUTTON */
126 BST_CHECKED, /* BS_CHECKBOX */
127 BST_CHECKED, /* BS_AUTOCHECKBOX */
128 BST_CHECKED, /* BS_RADIOBUTTON */
129 BST_INDETERMINATE, /* BS_3STATE */
130 BST_INDETERMINATE, /* BS_AUTO3STATE */
131 BST_UNCHECKED, /* BS_GROUPBOX */
132 BST_UNCHECKED, /* BS_USERBUTTON */
133 BST_CHECKED, /* BS_AUTORADIOBUTTON */
134 BST_UNCHECKED, /* BS_PUSHBOX */
135 BST_UNCHECKED, /* BS_OWNERDRAW */
136 BST_UNCHECKED, /* BS_SPLITBUTTON */
137 BST_UNCHECKED, /* BS_DEFSPLITBUTTON */
138 BST_UNCHECKED, /* BS_COMMANDLINK */
139 BST_UNCHECKED /* BS_DEFCOMMANDLINK */
140};
141
142/* These are indices into a states array to determine the theme state for a given theme part. */
143typedef enum
144{
151
152typedef void (*pfPaint)( const BUTTON_INFO *infoPtr, HDC hdc, UINT action );
153
155{
156 PB_Paint, /* BS_PUSHBUTTON */
157 PB_Paint, /* BS_DEFPUSHBUTTON */
158 CB_Paint, /* BS_CHECKBOX */
159 CB_Paint, /* BS_AUTOCHECKBOX */
160 CB_Paint, /* BS_RADIOBUTTON */
161 CB_Paint, /* BS_3STATE */
162 CB_Paint, /* BS_AUTO3STATE */
163 GB_Paint, /* BS_GROUPBOX */
164 UB_Paint, /* BS_USERBUTTON */
165 CB_Paint, /* BS_AUTORADIOBUTTON */
166 NULL, /* BS_PUSHBOX */
167 OB_Paint, /* BS_OWNERDRAW */
168 PB_Paint, /* BS_SPLITBUTTON */
169 PB_Paint, /* BS_DEFSPLITBUTTON */
170 PB_Paint, /* BS_COMMANDLINK */
171 PB_Paint /* BS_DEFCOMMANDLINK */
172};
173
174
175#ifdef __REACTOS__ /* r73885 */
176typedef void (*pfThemedPaint)( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
177
178static void PB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
179static void CB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
180static void GB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused, LPARAM prfFlag);
181
182#else
183typedef void (*pfThemedPaint)( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
184
185static void PB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
186static void CB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
187static void GB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused);
188
189#endif
190
192{
193 PB_ThemedPaint, /* BS_PUSHBUTTON */
194 PB_ThemedPaint, /* BS_DEFPUSHBUTTON */
195 CB_ThemedPaint, /* BS_CHECKBOX */
196 CB_ThemedPaint, /* BS_AUTOCHECKBOX */
197 CB_ThemedPaint, /* BS_RADIOBUTTON */
198 CB_ThemedPaint, /* BS_3STATE */
199 CB_ThemedPaint, /* BS_AUTO3STATE */
200 GB_ThemedPaint, /* BS_GROUPBOX */
201 NULL, /* BS_USERBUTTON */
202 CB_ThemedPaint, /* BS_AUTORADIOBUTTON */
203 NULL, /* BS_PUSHBOX */
204 NULL, /* BS_OWNERDRAW */
205 NULL, /* BS_SPLITBUTTON */
206 NULL, /* BS_DEFSPLITBUTTON */
207 NULL, /* BS_COMMANDLINK */
208 NULL, /* BS_DEFCOMMANDLINK */
209};
210
211static inline UINT get_button_type( LONG window_style )
212{
213 return (window_style & BS_TYPEMASK);
214}
215
216#ifndef __REACTOS__
217/* paint a button of any type */
218static inline void paint_button( BUTTON_INFO *infoPtr, LONG style, UINT action )
219{
220 if (btnPaintFunc[style] && IsWindowVisible(infoPtr->hwnd))
221 {
222 HDC hdc = GetDC( infoPtr->hwnd );
223 btnPaintFunc[style]( infoPtr, hdc, action );
224 ReleaseDC( infoPtr->hwnd, hdc );
225 }
226}
227#endif
228
229/* retrieve the button text; returned buffer must be freed by caller */
230static inline WCHAR *get_button_text( const BUTTON_INFO *infoPtr )
231{
232 INT len = GetWindowTextLengthW( infoPtr->hwnd );
233 WCHAR *buffer = heap_alloc( (len + 1) * sizeof(WCHAR) );
234 if (buffer)
235 GetWindowTextW( infoPtr->hwnd, buffer, len + 1 );
236 return buffer;
237}
238
240{
241 RECT rc = *rect;
242 HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
243
244 if (GetClipRgn( hdc, hrgn ) != 1)
245 {
247 hrgn = 0;
248 }
249 DPtoLP( hdc, (POINT *)&rc, 2 );
250 if (GetLayout( hdc ) & LAYOUT_RTL) /* compensate for the shifting done by IntersectClipRect */
251 {
252 rc.left++;
253 rc.right++;
254 }
255 IntersectClipRect( hdc, rc.left, rc.top, rc.right, rc.bottom );
256 return hrgn;
257}
258
259/**********************************************************************
260 * Convert button styles to flags used by DrawText.
261 */
262static UINT BUTTON_BStoDT( DWORD style, DWORD ex_style )
263{
264 UINT dtStyle = DT_NOCLIP; /* We use SelectClipRgn to limit output */
265
266 /* "Convert" pushlike buttons to pushbuttons */
267 if (style & BS_PUSHLIKE)
268 style &= ~BS_TYPEMASK;
269
270 if (!(style & BS_MULTILINE))
271 dtStyle |= DT_SINGLELINE;
272 else
273 dtStyle |= DT_WORDBREAK;
274
275 switch (style & BS_CENTER)
276 {
277 case BS_LEFT: /* DT_LEFT is 0 */ break;
278 case BS_RIGHT: dtStyle |= DT_RIGHT; break;
279 case BS_CENTER: dtStyle |= DT_CENTER; break;
280 default:
281 /* Pushbutton's text is centered by default */
283 /* all other flavours have left aligned text */
284 }
285
286 if (ex_style & WS_EX_RIGHT) dtStyle = DT_RIGHT | (dtStyle & ~(DT_LEFT | DT_CENTER));
287
288 /* DrawText ignores vertical alignment for multiline text,
289 * but we use these flags to align label manually.
290 */
292 {
293 switch (style & BS_VCENTER)
294 {
295 case BS_TOP: /* DT_TOP is 0 */ break;
296 case BS_BOTTOM: dtStyle |= DT_BOTTOM; break;
297 case BS_VCENTER: /* fall through */
298 default: dtStyle |= DT_VCENTER; break;
299 }
300 }
301 else
302 /* GroupBox's text is always single line and is top aligned. */
303 dtStyle |= DT_SINGLELINE;
304
305 return dtStyle;
306}
307
308
309#ifdef __REACTOS__
310BOOL BUTTON_PaintWithTheme(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hParamDC, LPARAM prfFlag)
311{
312 DWORD dwStyle;
313 DWORD dwStyleEx;
314 DWORD type;
315 UINT dtFlags;
316 ButtonState drawState;
317 pfThemedPaint paint;
318
319 /* Don't draw with themes on a button with BS_ICON or BS_BITMAP */
320 if (infoPtr->u.image != 0)
321 return FALSE;
322
323 dwStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
324 type = get_button_type(dwStyle);
325
326 if (type != BS_PUSHBUTTON && type != BS_DEFPUSHBUTTON && (dwStyle & BS_PUSHLIKE))
328
329 paint = btnThemedPaintFunc[type];
330 if (!paint)
331 return FALSE;
332
333 dwStyleEx = GetWindowLongW(infoPtr->hwnd, GWL_EXSTYLE);
334 dtFlags = BUTTON_BStoDT(dwStyle, dwStyleEx);
335
336 if(dwStyle & WS_DISABLED)
337 drawState = STATE_DISABLED;
338 else if(infoPtr->state & BST_PUSHED)
339 drawState = STATE_PRESSED;
340 else if ((dwStyle & BS_PUSHLIKE) && (infoPtr->state & (BST_CHECKED|BST_INDETERMINATE)))
341 drawState = STATE_PRESSED;
342 else if(infoPtr->state & BST_HOT)
343 drawState = STATE_HOT;
344 else if((infoPtr->state & BST_FOCUS) || (dwStyle & BS_DEFPUSHBUTTON))
345 drawState = STATE_DEFAULTED;
346 else
347 drawState = STATE_NORMAL;
348
349 if (paint == PB_ThemedPaint || paint == CB_ThemedPaint)
350 {
351 HDC hdc;
353 RECT rc;
354
355 GetClientRect(infoPtr->hwnd, &rc);
356 hdc = CreateCompatibleDC(hParamDC);
357 hbmp = CreateCompatibleBitmap(hParamDC, rc.right, rc.bottom);
358 if (hdc && hbmp)
359 {
361
362 paint(theme, infoPtr, hdc, drawState, dtFlags, infoPtr->state & BST_FOCUS, prfFlag);
363
364 BitBlt(hParamDC, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY);
366 DeleteDC(hdc);
367 return TRUE;
368 }
369 else
370 {
371 ERR("Failed to create DC and bitmap for double buffering\n");
372 if (hbmp)
374 if (hdc)
375 DeleteDC(hdc);
376 }
377 }
378
379 paint(theme, infoPtr, hParamDC, drawState, dtFlags, infoPtr->state & BST_FOCUS, prfFlag);
380 return TRUE;
381}
382
383/* paint a button of any type */
384static inline void paint_button( BUTTON_INFO *infoPtr, LONG style, UINT action )
385{
386 HTHEME theme = GetWindowTheme(infoPtr->hwnd);
387 RECT rc;
388 HDC hdc = GetDC( infoPtr->hwnd );
389 /* GetDC appears to give a dc with a clip rect that includes the whoe parent, not sure if it is correct or not. */
390 GetClientRect(infoPtr->hwnd, &rc);
391 IntersectClipRect (hdc, rc.left, rc. top, rc.right, rc.bottom);
392 if (theme && BUTTON_PaintWithTheme(theme, infoPtr, hdc, 0))
393 {
394 ReleaseDC( infoPtr->hwnd, hdc );
395 return;
396 }
397 if (btnPaintFunc[style] && IsWindowVisible(infoPtr->hwnd))
398 {
399 btnPaintFunc[style]( infoPtr, hdc, action );
400 }
401 ReleaseDC( infoPtr->hwnd, hdc );
402}
403
404BOOL BUTTON_GetIdealSize(BUTTON_INFO *infoPtr, HTHEME theme, SIZE* psize)
405{
406 HDC hdc;
407 WCHAR *text;
408 HFONT hFont = 0, hPrevFont = 0;
409 SIZE TextSize, ImageSize, ButtonSize;
410 BOOL ret = FALSE;
411 LOGFONTW logfont = {0};
412
413 text = get_button_text(infoPtr);
414 hdc = GetDC(infoPtr->hwnd);
415 if (!text || !hdc || !text[0])
416 goto cleanup;
417
418 /* FIXME : Should use GetThemeTextExtent but unfortunately uses DrawTextW which is broken */
419 if (theme)
420 {
422 if(SUCCEEDED(hr))
423 {
424 hFont = CreateFontIndirectW(&logfont);
425 if(hFont)
426 hPrevFont = SelectObject( hdc, hFont );
427 }
428 }
429 else
430 {
431 if (infoPtr->font)
432 hPrevFont = SelectObject( hdc, infoPtr->font );
433 }
434
436
437 if (logfont.lfHeight == -1 && logfont.lfWidth == 0 && wcscmp(logfont.lfFaceName, L"Arial") == 0 && wcsicmp(text, L"Start") == 0)
438 {
439 TextSize.cx = 5;
440 TextSize.cy = 4;
441 }
442
443 if (hPrevFont)
444 SelectObject( hdc, hPrevFont );
445
446 TextSize.cy += infoPtr->rcTextMargin.top + infoPtr->rcTextMargin.bottom;
447 TextSize.cx += infoPtr->rcTextMargin.left + infoPtr->rcTextMargin.right;
448
449 if (infoPtr->imlData.himl && ImageList_GetIconSize(infoPtr->imlData.himl, &ImageSize.cx, &ImageSize.cy))
450 {
451 ImageSize.cx += infoPtr->imlData.margin.left + infoPtr->imlData.margin.right;
452 ImageSize.cy += infoPtr->imlData.margin.top + infoPtr->imlData.margin.bottom;
453 }
454 else
455 {
456 ImageSize.cx = ImageSize.cy = 0;
457 }
458
459 if (theme)
460 {
461 RECT rcContents = {0};
462 RECT rcButtonExtent = {0};
463 rcContents.right = ImageSize.cx + TextSize.cx;
464 rcContents.bottom = max(ImageSize.cy, TextSize.cy);
465 GetThemeBackgroundExtent(theme, hdc, BP_PUSHBUTTON, PBS_NORMAL, &rcContents, &rcButtonExtent);
466 ButtonSize.cx = rcButtonExtent.right - rcButtonExtent.left;
467 ButtonSize.cy = rcButtonExtent.bottom - rcButtonExtent.top;
468 }
469 else
470 {
471 ButtonSize.cx = ImageSize.cx + TextSize.cx + 5;
472 ButtonSize.cy = max(ImageSize.cy, TextSize.cy + 7);
473 }
474
475 *psize = ButtonSize;
476 ret = TRUE;
477
478cleanup:
479 if (hFont)
481 if (text)
483 if (hdc)
484 ReleaseDC(infoPtr->hwnd, hdc);
485
486 return ret;
487}
488
489BOOL BUTTON_DrawIml(HDC hDC, const BUTTON_IMAGELIST *pimlData, RECT *prc, BOOL bOnlyCalc, int index)
490{
491 SIZE ImageSize;
492 int left, top, count;
493
494 if (!pimlData->himl)
495 return FALSE;
496
497 if (!ImageList_GetIconSize(pimlData->himl, &ImageSize.cx, &ImageSize.cy))
498 return FALSE;
499
500 if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_LEFT)
501 {
502 left = prc->left + pimlData->margin.left;
503 top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
504 prc->left = left + pimlData->margin.right + ImageSize.cx;
505 }
506 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
507 {
508 left = prc->right - pimlData->margin.right - ImageSize.cx;
509 top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
510 prc->right = left - pimlData->margin.left;
511 }
512 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_TOP)
513 {
514 left = prc->left + (prc->right - prc->left - ImageSize.cx) / 2;
515 top = prc->top + pimlData->margin.top;
516 prc->top = top + ImageSize.cy + pimlData->margin.bottom;
517 }
518 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
519 {
520 left = prc->left + (prc->right - prc->left - ImageSize.cx) / 2;
521 top = prc->bottom - pimlData->margin.bottom - ImageSize.cy;
522 prc->bottom = top - pimlData->margin.top;
523 }
524 else if (pimlData->uAlign == BUTTON_IMAGELIST_ALIGN_CENTER)
525 {
526 left = prc->left + (prc->right - prc->left - ImageSize.cx) / 2;
527 top = prc->top + (prc->bottom - prc->top - ImageSize.cy) / 2;
528 }
529
530 if (bOnlyCalc)
531 return TRUE;
532
534
535 if (count == 1)
536 index = 0;
537 else if (index >= count)
538 return TRUE;
539
540 ImageList_Draw(pimlData->himl, index, hDC, left, top, 0);
541
542 return TRUE;
543}
544
545DWORD BUTTON_SendCustomDraw(const BUTTON_INFO *infoPtr, HDC hDC, DWORD dwDrawStage, RECT* prc)
546{
547 NMCUSTOMDRAW nmcs;
548
549 nmcs.hdr.hwndFrom = infoPtr->hwnd;
550 nmcs.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwnd, GWLP_ID);
551 nmcs.hdr.code = NM_CUSTOMDRAW ;
552 nmcs.dwDrawStage = dwDrawStage;
553 nmcs.hdc = hDC;
554 nmcs.rc = *prc;
555 nmcs.dwItemSpec = 0;
556 nmcs.uItemState = 0;
557 nmcs.lItemlParam = 0;
558 if(!IsWindowEnabled(infoPtr->hwnd))
560 if (infoPtr->state & (BST_CHECKED | BST_INDETERMINATE))
561 nmcs.uItemState |= CDIS_CHECKED;
562 if (infoPtr->state & BST_FOCUS)
563 nmcs.uItemState |= CDIS_FOCUS;
564 if (infoPtr->state & BST_PUSHED)
566 if (!(infoPtr->ui_state & UISF_HIDEACCEL))
568
569 return SendMessageW(GetParent(infoPtr->hwnd), WM_NOTIFY, nmcs.hdr.idFrom, (LPARAM)&nmcs);
570}
571
572/* Retrieve the UI state for the control */
573static BOOL button_update_uistate(BUTTON_INFO *infoPtr)
574{
575 LONG flags = DefWindowProcW(infoPtr->hwnd, WM_QUERYUISTATE, 0, 0);
576
577 if (infoPtr->ui_state != flags)
578 {
579 infoPtr->ui_state = flags;
580 return TRUE;
581 }
582
583 return FALSE;
584}
585#endif
586
588{
590 RECT rect;
591 POINT pt;
593 UINT btn_type = get_button_type( style );
594 LONG state, new_state;
595 HANDLE oldHbitmap;
596 HTHEME theme;
597
598 if (!IsWindow( hWnd )) return 0;
599
600 if (!infoPtr && (uMsg != WM_NCCREATE))
601 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
602
603 pt.x = (short)LOWORD(lParam);
604 pt.y = (short)HIWORD(lParam);
605
606 switch (uMsg)
607 {
608 case WM_GETDLGCODE:
609 switch(btn_type)
610 {
611 case BS_COMMANDLINK:
612 case BS_USERBUTTON:
616 case BS_RADIOBUTTON:
618 case BS_GROUPBOX: return DLGC_STATIC;
621 default: return DLGC_BUTTON;
622 }
623
624 case WM_ENABLE:
625#ifndef __REACTOS__
626 theme = GetWindowTheme( hWnd );
627 if (theme)
629 else
630#endif
631 paint_button( infoPtr, btn_type, ODA_DRAWENTIRE );
632 break;
633
634 case WM_NCCREATE:
635 infoPtr = heap_alloc_zero( sizeof(*infoPtr) );
636 SetWindowLongPtrW( hWnd, 0, (LONG_PTR)infoPtr );
637 infoPtr->hwnd = hWnd;
638#ifdef __REACTOS__
639 SetRect(&infoPtr->rcTextMargin, 1,1,1,1);
640#endif
641 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
642
643 case WM_NCDESTROY:
644 SetWindowLongPtrW( hWnd, 0, 0 );
645 heap_free(infoPtr);
646 break;
647
648 case WM_CREATE:
649 if (btn_type >= MAX_BTN_TYPE)
650 return -1; /* abort */
651
652 /* XP turns a BS_USERBUTTON into BS_PUSHBUTTON */
653 if (btn_type == BS_USERBUTTON )
654 {
655 style = (style & ~BS_TYPEMASK) | BS_PUSHBUTTON;
657 }
658 infoPtr->state = BST_UNCHECKED;
660 return 0;
661
662 case WM_DESTROY:
663 theme = GetWindowTheme( hWnd );
664 CloseThemeData( theme );
665 break;
666
667 case WM_THEMECHANGED:
668 theme = GetWindowTheme( hWnd );
669 CloseThemeData( theme );
671#ifdef __REACTOS__
673#endif
674 break;
675
676 case WM_ERASEBKGND:
677 if (btn_type == BS_OWNERDRAW)
678 {
679 HDC hdc = (HDC)wParam;
680 RECT rc;
681 HBRUSH hBrush;
683 if (!parent) parent = hWnd;
684 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
685 if (!hBrush) /* did the app forget to call defwindowproc ? */
686 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
687 (WPARAM)hdc, (LPARAM)hWnd);
688 GetClientRect(hWnd, &rc);
689 FillRect(hdc, &rc, hBrush);
690 }
691 return 1;
692
693 case WM_PRINTCLIENT:
694 case WM_PAINT:
695 {
696 PAINTSTRUCT ps;
697 HDC hdc;
698
699 theme = GetWindowTheme( hWnd );
700 hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
701
702#ifdef __REACTOS__
703 if (theme && BUTTON_PaintWithTheme(theme, infoPtr, hdc, uMsg == WM_PRINTCLIENT ? lParam : 0))
704 {
705 if ( !wParam ) EndPaint( hWnd, &ps );
706 return 0;
707 }
708#else
709 if (theme && btnThemedPaintFunc[btn_type])
710 {
711 ButtonState drawState;
712 UINT dtflags;
713
714 if (IsWindowEnabled( hWnd ))
715 {
716 if (infoPtr->state & BST_PUSHED) drawState = STATE_PRESSED;
717 else if (infoPtr->state & BST_HOT) drawState = STATE_HOT;
718 else if (infoPtr->state & BST_FOCUS) drawState = STATE_DEFAULTED;
719 else drawState = STATE_NORMAL;
720 }
721 else
722 drawState = STATE_DISABLED;
723
725 btnThemedPaintFunc[btn_type](theme, infoPtr, hdc, drawState, dtflags, infoPtr->state & BST_FOCUS);
726 }
727#endif
728 else if (btnPaintFunc[btn_type])
729 {
730 int nOldMode = SetBkMode( hdc, OPAQUE );
731 btnPaintFunc[btn_type]( infoPtr, hdc, ODA_DRAWENTIRE );
732 SetBkMode(hdc, nOldMode); /* reset painting mode */
733 }
734
735 if ( !wParam ) EndPaint( hWnd, &ps );
736 break;
737 }
738
739 case WM_KEYDOWN:
740 if (wParam == VK_SPACE)
741 {
743 infoPtr->state |= BUTTON_BTNPRESSED;
744 SetCapture( hWnd );
745 }
746 break;
747
748 case WM_LBUTTONDBLCLK:
749 if(style & BS_NOTIFY ||
750 btn_type == BS_RADIOBUTTON ||
751 btn_type == BS_USERBUTTON ||
752 btn_type == BS_OWNERDRAW)
753 {
755 break;
756 }
757 /* fall through */
758 case WM_LBUTTONDOWN:
759 SetCapture( hWnd );
760 SetFocus( hWnd );
761 infoPtr->state |= BUTTON_BTNPRESSED;
763 break;
764
765 case WM_KEYUP:
766 if (wParam != VK_SPACE)
767 break;
768 /* fall through */
769 case WM_LBUTTONUP:
770 state = infoPtr->state;
771 if (!(state & BUTTON_BTNPRESSED)) break;
772 infoPtr->state &= BUTTON_NSTATES;
773 if (!(state & BST_PUSHED))
774 {
776 break;
777 }
780 if (uMsg == WM_KEYUP || PtInRect( &rect, pt ))
781 {
782 switch(btn_type)
783 {
784 case BS_AUTOCHECKBOX:
785 SendMessageW( hWnd, BM_SETCHECK, !(infoPtr->state & BST_CHECKED), 0 );
786 break;
788#ifdef __REACTOS__
790#else
792#endif
793 break;
794 case BS_AUTO3STATE:
795 SendMessageW( hWnd, BM_SETCHECK, (infoPtr->state & BST_INDETERMINATE) ? 0 :
796 ((infoPtr->state & 3) + 1), 0 );
797 break;
798 }
799#ifdef __REACTOS__
800 // Fix CORE-10194, Notify parent after capture is released.
803#else
806#endif
807 }
808 else
809 {
811 }
812
813 break;
814
816 TRACE("WM_CAPTURECHANGED %p\n", hWnd);
817 if (hWnd == (HWND)lParam) break;
818 if (infoPtr->state & BUTTON_BTNPRESSED)
819 {
820 infoPtr->state &= BUTTON_NSTATES;
821 if (infoPtr->state & BST_PUSHED)
823 }
824 break;
825
826 case WM_MOUSEMOVE:
827 {
829 mouse_event.cbSize = sizeof(TRACKMOUSEEVENT);
830 mouse_event.dwFlags = TME_QUERY;
831
832#ifdef __REACTOS__
833 if ((infoPtr->state & BST_HOT) == 0)
834 {
835 NMBCHOTITEM nmhotitem;
836
837 infoPtr->state |= BST_HOT;
838
839 nmhotitem.hdr.hwndFrom = hWnd;
840 nmhotitem.hdr.idFrom = GetWindowLongPtrW (hWnd, GWLP_ID);
841 nmhotitem.hdr.code = BCN_HOTITEMCHANGE;
842 nmhotitem.dwFlags = HICF_ENTERING;
843 SendMessageW(GetParent(hWnd), WM_NOTIFY, nmhotitem.hdr.idFrom, (LPARAM)&nmhotitem);
844
845 theme = GetWindowTheme( hWnd );
846 if (theme)
848 }
849
851 {
852 mouse_event.dwFlags = TME_LEAVE;
853 mouse_event.hwndTrack = hWnd;
854 mouse_event.dwHoverTime = 1;
856 }
857#else
858
859 if (!TrackMouseEvent(&mouse_event) || !(mouse_event.dwFlags & (TME_HOVER | TME_LEAVE)))
860 {
861 mouse_event.dwFlags = TME_HOVER | TME_LEAVE;
862 mouse_event.hwndTrack = hWnd;
863 mouse_event.dwHoverTime = 1;
865 }
866#endif
867
868 if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
869 {
872 }
873 break;
874 }
875
876#ifndef __REACTOS__
877 case WM_MOUSEHOVER:
878 {
879 infoPtr->state |= BST_HOT;
881 break;
882 }
883#endif
884
885 case WM_MOUSELEAVE:
886 {
887#ifdef __REACTOS__
888 if (infoPtr->state & BST_HOT)
889 {
890 NMBCHOTITEM nmhotitem;
891
892 infoPtr->state &= ~BST_HOT;
893
894 nmhotitem.hdr.hwndFrom = hWnd;
895 nmhotitem.hdr.idFrom = GetWindowLongPtrW (hWnd, GWLP_ID);
896 nmhotitem.hdr.code = BCN_HOTITEMCHANGE;
897 nmhotitem.dwFlags = HICF_LEAVING;
898 SendMessageW(GetParent(hWnd), WM_NOTIFY, nmhotitem.hdr.idFrom, (LPARAM)&nmhotitem);
899
900 theme = GetWindowTheme( hWnd );
901 if (theme)
903 }
904 break;
905#else
906 infoPtr->state &= ~BST_HOT;
908 break;
909#endif
910 }
911
912#ifdef __REACTOS__
914 {
915 RECT* prc = (RECT*)lParam;
916 if (!prc)
917 return FALSE;
918 *prc = infoPtr->rcTextMargin;
919 return TRUE;
920 }
922 {
923 RECT* prc = (RECT*)lParam;
924 if (!prc)
925 return FALSE;
926 infoPtr->rcTextMargin = *prc;
927 return TRUE;
928 }
929 case BCM_SETIMAGELIST:
930 {
932 if (!pimldata || !pimldata->himl)
933 return FALSE;
934 infoPtr->imlData = *pimldata;
935 return TRUE;
936 }
937 case BCM_GETIMAGELIST:
938 {
940 if (!pimldata)
941 return FALSE;
942 *pimldata = infoPtr->imlData;
943 return TRUE;
944 }
945 case BCM_GETIDEALSIZE:
946 {
947 HTHEME theme = GetWindowTheme(hWnd);
948 BOOL ret = FALSE;
949 SIZE* pSize = (SIZE*)lParam;
950
951 if (!pSize)
952 {
953 return FALSE;
954 }
955
956 if (btn_type == BS_PUSHBUTTON ||
957 btn_type == BS_DEFPUSHBUTTON ||
958 btn_type == BS_USERBUTTON)
959 {
960 ret = BUTTON_GetIdealSize(infoPtr, theme, pSize);
961 }
962
963 if (!ret)
964 {
966 pSize->cx = rect.right;
967 pSize->cy = rect.bottom;
968 }
969
970 return TRUE;
971 }
972#endif
973
974 case WM_SETTEXT:
975 {
976 /* Clear an old text here as Windows does */
977#ifdef __REACTOS__
978//
979// ReactOS Note :
980// wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
981// Patch: http://source.winehq.org/patches/data/70889
982// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
983//
984 if (style & WS_VISIBLE)
985#else
987#endif
988 {
989 HDC hdc = GetDC(hWnd);
990 HBRUSH hbrush;
991 RECT client, rc;
993 UINT message = (btn_type == BS_PUSHBUTTON ||
994 btn_type == BS_DEFPUSHBUTTON ||
995 btn_type == BS_USERBUTTON ||
996 btn_type == BS_OWNERDRAW) ?
998
999 if (!parent) parent = hWnd;
1000 hbrush = (HBRUSH)SendMessageW(parent, message,
1001 (WPARAM)hdc, (LPARAM)hWnd);
1002 if (!hbrush) /* did the app forget to call DefWindowProc ? */
1004 (WPARAM)hdc, (LPARAM)hWnd);
1005
1007 rc = client;
1008 /* FIXME: check other BS_* handlers */
1009 if (btn_type == BS_GROUPBOX)
1010 InflateRect(&rc, -7, 1); /* GB_Paint does this */
1011 BUTTON_CalcLabelRect(infoPtr, hdc, &rc);
1012 /* Clip by client rect bounds */
1013 if (rc.right > client.right) rc.right = client.right;
1014 if (rc.bottom > client.bottom) rc.bottom = client.bottom;
1015 FillRect(hdc, &rc, hbrush);
1016 ReleaseDC(hWnd, hdc);
1017 }
1018
1020 if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */
1022 else
1023 paint_button( infoPtr, btn_type, ODA_DRAWENTIRE );
1024 return 1; /* success. FIXME: check text length */
1025 }
1026
1027 case WM_SETFONT:
1028 infoPtr->font = (HFONT)wParam;
1030 break;
1031
1032 case WM_GETFONT:
1033 return (LRESULT)infoPtr->font;
1034
1035 case WM_SETFOCUS:
1036 TRACE("WM_SETFOCUS %p\n",hWnd);
1037 infoPtr->state |= BST_FOCUS;
1038#ifdef __REACTOS__
1039 if (btn_type != BS_OWNERDRAW)
1041 else
1042#endif
1043 paint_button( infoPtr, btn_type, ODA_FOCUS );
1044 if (style & BS_NOTIFY)
1046#ifdef __REACTOS__
1047 if (((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON)) &&
1048 !(infoPtr->state & BST_CHECKED))
1049 {
1051 }
1052#endif
1053 break;
1054
1055 case WM_KILLFOCUS:
1056 TRACE("WM_KILLFOCUS %p\n",hWnd);
1057 infoPtr->state &= ~BST_FOCUS;
1058#ifndef __REACTOS__
1059 paint_button( infoPtr, btn_type, ODA_FOCUS );
1060#endif
1061
1062 if ((infoPtr->state & BUTTON_BTNPRESSED) && GetCapture() == hWnd)
1064 if (style & BS_NOTIFY)
1066
1068 break;
1069
1070 case WM_SYSCOLORCHANGE:
1072 break;
1073
1074 case BM_SETSTYLE:
1075 btn_type = wParam & BS_TYPEMASK;
1076 style = (style & ~BS_TYPEMASK) | btn_type;
1078
1079 /* Only redraw if lParam flag is set.*/
1080 if (lParam)
1082
1083 break;
1084
1085 case BM_CLICK:
1086#ifdef __REACTOS__
1087 /* Fix for core CORE-6024 */
1088 if (infoPtr->state & BUTTON_BMCLICK)
1089 break;
1090 infoPtr->state |= BUTTON_BMCLICK;
1091#endif
1093 SendMessageW( hWnd, WM_LBUTTONUP, 0, 0 );
1094#ifdef __REACTOS__
1095 infoPtr->state &= ~BUTTON_BMCLICK;
1096#endif
1097 break;
1098
1099 case BM_SETIMAGE:
1100 /* Check that image format matches button style */
1101 switch (style & (BS_BITMAP|BS_ICON))
1102 {
1103 case BS_BITMAP:
1104 if (wParam != IMAGE_BITMAP) return 0;
1105 break;
1106 case BS_ICON:
1107 if (wParam != IMAGE_ICON) return 0;
1108 break;
1109 default:
1110 return 0;
1111 }
1112 oldHbitmap = infoPtr->u.image;
1113 infoPtr->u.image = (HANDLE)lParam;
1115 return (LRESULT)oldHbitmap;
1116
1117 case BM_GETIMAGE:
1118 return (LRESULT)infoPtr->u.image;
1119
1120 case BM_GETCHECK:
1121 return infoPtr->state & 3;
1122
1123 case BM_SETCHECK:
1124 if (wParam > maxCheckState[btn_type]) wParam = maxCheckState[btn_type];
1125 if ((btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON))
1126 {
1127 style = wParam ? style | WS_TABSTOP : style & ~WS_TABSTOP;
1129 }
1130 if ((infoPtr->state & 3) != wParam)
1131 {
1132 infoPtr->state = (infoPtr->state & ~3) | wParam;
1134 }
1135#ifndef __REACTOS__
1136 if ((btn_type == BS_AUTORADIOBUTTON) && (wParam == BST_CHECKED) && (style & WS_CHILD))
1138#endif
1139 break;
1140
1141 case BM_GETSTATE:
1142 return infoPtr->state;
1143
1144 case BM_SETSTATE:
1145 state = infoPtr->state;
1146 new_state = wParam ? BST_PUSHED : 0;
1147
1148 if ((state ^ new_state) & BST_PUSHED)
1149 {
1150 if (wParam)
1151 state |= BST_PUSHED;
1152 else
1153 state &= ~BST_PUSHED;
1154
1155 if (btn_type == BS_USERBUTTON)
1157 infoPtr->state = state;
1158
1160 }
1161 break;
1162
1163#ifdef __REACTOS__
1164 case WM_UPDATEUISTATE:
1166
1167 if (button_update_uistate(infoPtr))
1168 paint_button( infoPtr, btn_type, ODA_DRAWENTIRE );
1169 break;
1170#endif
1171
1172 case WM_NCHITTEST:
1173 if(btn_type == BS_GROUPBOX) return HTTRANSPARENT;
1174 /* fall through */
1175 default:
1176 return DefWindowProcW(hWnd, uMsg, wParam, lParam);
1177 }
1178 return 0;
1179}
1180
1181/**********************************************************************
1182 * BUTTON_CalcLabelRect
1183 *
1184 * Calculates label's rectangle depending on button style.
1185 *
1186 * Returns flags to be passed to DrawText.
1187 * Calculated rectangle doesn't take into account button state
1188 * (pushed, etc.). If there is nothing to draw (no text/image) output
1189 * rectangle is empty, and return value is (UINT)-1.
1190 */
1191static UINT BUTTON_CalcLabelRect(const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc)
1192{
1193 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1194 LONG ex_style = GetWindowLongW( infoPtr->hwnd, GWL_EXSTYLE );
1195 WCHAR *text;
1196 ICONINFO iconInfo;
1197 BITMAP bm;
1198 UINT dtStyle = BUTTON_BStoDT( style, ex_style );
1199 RECT r = *rc;
1200 INT n;
1201#ifdef __REACTOS__
1202 BOOL bHasIml = BUTTON_DrawIml(hdc, &infoPtr->imlData, &r, TRUE, 0);
1203#endif
1204
1205 /* Calculate label rectangle according to label type */
1206 switch (style & (BS_ICON|BS_BITMAP))
1207 {
1208 case BS_TEXT:
1209 {
1210 HFONT hFont, hPrevFont = 0;
1211
1212 if (!(text = get_button_text( infoPtr ))) goto empty_rect;
1213 if (!text[0])
1214 {
1215 heap_free( text );
1216 goto empty_rect;
1217 }
1218
1219 if ((hFont = infoPtr->font)) hPrevFont = SelectObject( hdc, hFont );
1220#ifdef __REACTOS__
1221 DrawTextW(hdc, text, -1, &r, ((dtStyle | DT_CALCRECT) & ~(DT_VCENTER | DT_BOTTOM)));
1222#else
1223 DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
1224#endif
1225 if (hPrevFont) SelectObject( hdc, hPrevFont );
1226 heap_free( text );
1227#ifdef __REACTOS__
1228 if (infoPtr->ui_state & UISF_HIDEACCEL)
1229 dtStyle |= DT_HIDEPREFIX;
1230#endif
1231 break;
1232 }
1233
1234 case BS_ICON:
1235 if (!GetIconInfo(infoPtr->u.icon, &iconInfo))
1236 goto empty_rect;
1237
1238 GetObjectW (iconInfo.hbmColor, sizeof(BITMAP), &bm);
1239
1240 r.right = r.left + bm.bmWidth;
1241 r.bottom = r.top + bm.bmHeight;
1242
1243 DeleteObject(iconInfo.hbmColor);
1244 DeleteObject(iconInfo.hbmMask);
1245 break;
1246
1247 case BS_BITMAP:
1248 if (!GetObjectW( infoPtr->u.bitmap, sizeof(BITMAP), &bm))
1249 goto empty_rect;
1250
1251 r.right = r.left + bm.bmWidth;
1252 r.bottom = r.top + bm.bmHeight;
1253 break;
1254
1255 default:
1256 empty_rect:
1257#ifdef __REACTOS__
1258 if (bHasIml)
1259 break;
1260#endif
1261 rc->right = r.left;
1262 rc->bottom = r.top;
1263 return (UINT)-1;
1264 }
1265
1266#ifdef __REACTOS__
1267 if (bHasIml)
1268 {
1269 if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_LEFT)
1270 r.left = infoPtr->imlData.margin.left;
1271 else if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_RIGHT)
1272 r.right = infoPtr->imlData.margin.right;
1273 else if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_TOP)
1274 r.top = infoPtr->imlData.margin.top;
1275 else if (infoPtr->imlData.uAlign == BUTTON_IMAGELIST_ALIGN_BOTTOM)
1276 r.bottom = infoPtr->imlData.margin.bottom;
1277 }
1278#endif
1279
1280 /* Position label inside bounding rectangle according to
1281 * alignment flags. (calculated rect is always left-top aligned).
1282 * If label is aligned to any side - shift label in opposite
1283 * direction to leave extra space for focus rectangle.
1284 */
1285 switch (dtStyle & (DT_CENTER|DT_RIGHT))
1286 {
1287 case DT_LEFT: r.left++; r.right++; break;
1288 case DT_CENTER: n = r.right - r.left;
1289 r.left = rc->left + ((rc->right - rc->left) - n) / 2;
1290 r.right = r.left + n; break;
1291 case DT_RIGHT: n = r.right - r.left;
1292 r.right = rc->right - 1;
1293 r.left = r.right - n;
1294 break;
1295 }
1296
1297 switch (dtStyle & (DT_VCENTER|DT_BOTTOM))
1298 {
1299 case DT_TOP: r.top++; r.bottom++; break;
1300 case DT_VCENTER: n = r.bottom - r.top;
1301#ifdef __REACTOS__
1302 r.top = rc->top + ((rc->bottom - 1 - rc->top) - n) / 2;
1303#else
1304 r.top = rc->top + ((rc->bottom - rc->top) - n) / 2;
1305#endif
1306 r.bottom = r.top + n; break;
1307 case DT_BOTTOM: n = r.bottom - r.top;
1308 r.bottom = rc->bottom - 1;
1309 r.top = r.bottom - n;
1310 break;
1311 }
1312
1313 *rc = r;
1314 return dtStyle;
1315}
1316
1317
1318/**********************************************************************
1319 * BUTTON_DrawTextCallback
1320 *
1321 * Callback function used by DrawStateW function.
1322 */
1324{
1325 RECT rc;
1326
1327 SetRect(&rc, 0, 0, cx, cy);
1328 DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
1329 return TRUE;
1330}
1331
1332
1333/**********************************************************************
1334 * BUTTON_DrawLabel
1335 *
1336 * Common function for drawing button label.
1337 */
1338static void BUTTON_DrawLabel(const BUTTON_INFO *infoPtr, HDC hdc, UINT dtFlags, const RECT *rc)
1339{
1340 DRAWSTATEPROC lpOutputProc = NULL;
1341 LPARAM lp;
1342 WPARAM wp = 0;
1343 HBRUSH hbr = 0;
1345 LONG state = infoPtr->state;
1346 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1347 WCHAR *text = NULL;
1348
1349 /* FIXME: To draw disabled label in Win31 look-and-feel, we probably
1350 * must use DSS_MONO flag and COLOR_GRAYTEXT brush (or maybe DSS_UNION).
1351 * I don't have Win31 on hand to verify that, so I leave it as is.
1352 */
1353
1354#ifdef __REACTOS__
1355 RECT rcText = *rc;
1356 BUTTON_DrawIml(hdc, &infoPtr->imlData, &rcText, FALSE, 0);
1357#endif
1358
1360 {
1362 flags |= DSS_MONO;
1363 }
1364
1365 switch (style & (BS_ICON|BS_BITMAP))
1366 {
1367 case BS_TEXT:
1368 /* DST_COMPLEX -- is 0 */
1369 lpOutputProc = BUTTON_DrawTextCallback;
1370 if (!(text = get_button_text( infoPtr ))) return;
1371 lp = (LPARAM)text;
1372 wp = dtFlags;
1373#ifdef __REACTOS__
1374 if (dtFlags & DT_HIDEPREFIX)
1376#endif
1377 break;
1378
1379 case BS_ICON:
1380 flags |= DST_ICON;
1381 lp = (LPARAM)infoPtr->u.icon;
1382 break;
1383
1384 case BS_BITMAP:
1385 flags |= DST_BITMAP;
1386 lp = (LPARAM)infoPtr->u.bitmap;
1387 break;
1388
1389 default:
1390 return;
1391 }
1392
1393#ifdef __REACTOS__
1394 DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rcText.left, rcText.top,
1395 rcText.right - rcText.left, rcText.bottom - rcText.top, flags);
1396#else
1397 DrawStateW(hdc, hbr, lpOutputProc, lp, wp, rc->left, rc->top,
1398 rc->right - rc->left, rc->bottom - rc->top, flags);
1399#endif
1400 heap_free( text );
1401}
1402
1403/**********************************************************************
1404 * Push Button Functions
1405 */
1406static void PB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1407{
1408 RECT rc, r;
1409 UINT dtFlags, uState;
1410 HPEN hOldPen, hpen;
1411 HBRUSH hOldBrush;
1412 INT oldBkMode;
1413 COLORREF oldTxtColor;
1414 HFONT hFont;
1415 LONG state = infoPtr->state;
1416 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1417 BOOL pushedState = (state & BST_PUSHED);
1418 HWND parent;
1419 HRGN hrgn;
1420#ifdef __REACTOS__
1421 DWORD cdrf;
1422#endif
1423
1424 GetClientRect( infoPtr->hwnd, &rc );
1425
1426 /* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
1427 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1428 parent = GetParent(infoPtr->hwnd);
1429 if (!parent) parent = infoPtr->hwnd;
1431
1432 hrgn = set_control_clipping( hDC, &rc );
1433
1435 hOldPen = SelectObject(hDC, hpen);
1437 oldBkMode = SetBkMode(hDC, TRANSPARENT);
1438
1439#ifdef __REACTOS__
1440 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREERASE, &rc);
1441 if (cdrf == CDRF_SKIPDEFAULT)
1442 goto cleanup;
1443#endif
1444
1446 {
1447 if (action != ODA_FOCUS)
1448 Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
1449 InflateRect( &rc, -1, -1 );
1450 }
1451
1452 /* completely skip the drawing if only focus has changed */
1453 if (action == ODA_FOCUS) goto draw_focus;
1454
1455 uState = DFCS_BUTTONPUSH;
1456
1457 if (style & BS_FLAT)
1458 uState |= DFCS_MONO;
1459 else if (pushedState)
1460 {
1462 uState |= DFCS_FLAT;
1463 else
1464 uState |= DFCS_PUSHED;
1465 }
1466
1468 uState |= DFCS_CHECKED;
1469
1470 DrawFrameControl( hDC, &rc, DFC_BUTTON, uState );
1471
1472#ifdef __REACTOS__
1473 if (cdrf == CDRF_NOTIFYPOSTERASE)
1474 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTERASE, &rc);
1475
1476 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREPAINT, &rc);
1477 if (cdrf == CDRF_SKIPDEFAULT)
1478 goto cleanup;
1479#endif
1480
1481 /* draw button label */
1482 r = rc;
1483 dtFlags = BUTTON_CalcLabelRect(infoPtr, hDC, &r);
1484
1485 if (dtFlags == (UINT)-1L)
1486 goto cleanup;
1487
1488 if (pushedState)
1489 OffsetRect(&r, 1, 1);
1490
1491 oldTxtColor = SetTextColor( hDC, GetSysColor(COLOR_BTNTEXT) );
1492
1493 BUTTON_DrawLabel(infoPtr, hDC, dtFlags, &r);
1494
1495 SetTextColor( hDC, oldTxtColor );
1496
1497#ifdef __REACTOS__
1498 if (cdrf == CDRF_NOTIFYPOSTPAINT)
1499 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &rc);
1500#endif
1501
1502draw_focus:
1503 if (action == ODA_FOCUS || (state & BST_FOCUS))
1504 {
1505#ifdef __REACTOS__
1506 if (!(infoPtr->ui_state & UISF_HIDEFOCUS))
1507 {
1508#endif
1509 InflateRect( &rc, -2, -2 );
1510 DrawFocusRect( hDC, &rc );
1511#ifdef __REACTOS__
1512 }
1513#endif
1514 }
1515
1516 cleanup:
1517 SelectObject( hDC, hOldPen );
1518 SelectObject( hDC, hOldBrush );
1519 SetBkMode(hDC, oldBkMode);
1521 if (hrgn) DeleteObject( hrgn );
1522 DeleteObject( hpen );
1523}
1524
1525/**********************************************************************
1526 * Check Box & Radio Button Functions
1527 */
1528
1529static void CB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1530{
1531 RECT rbox, rtext, client;
1532 HBRUSH hBrush;
1533 int delta, text_offset, checkBoxWidth, checkBoxHeight;
1534 UINT dtFlags;
1535 HFONT hFont;
1536 LONG state = infoPtr->state;
1537 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1538 LONG ex_style = GetWindowLongW( infoPtr->hwnd, GWL_EXSTYLE );
1539 HWND parent;
1540 HRGN hrgn;
1541
1542 if (style & BS_PUSHLIKE)
1543 {
1544 PB_Paint( infoPtr, hDC, action );
1545 return;
1546 }
1547
1548 GetClientRect(infoPtr->hwnd, &client);
1549 rbox = rtext = client;
1550
1551 checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
1552 checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
1553
1554 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1555 GetCharWidthW( hDC, '0', '0', &text_offset );
1556 text_offset /= 2;
1557
1558 parent = GetParent(infoPtr->hwnd);
1559 if (!parent) parent = infoPtr->hwnd;
1560 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1561 if (!hBrush) /* did the app forget to call defwindowproc ? */
1562 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1564
1565 if (style & BS_LEFTTEXT || ex_style & WS_EX_RIGHT)
1566 {
1567 rtext.right -= checkBoxWidth + text_offset;
1568 rbox.left = rbox.right - checkBoxWidth;
1569 }
1570 else
1571 {
1572 rtext.left += checkBoxWidth + text_offset;
1573 rbox.right = checkBoxWidth;
1574 }
1575
1576 /* Since WM_ERASEBKGND does nothing, first prepare background */
1577 if (action == ODA_SELECT) FillRect( hDC, &rbox, hBrush );
1578 if (action == ODA_DRAWENTIRE) FillRect( hDC, &client, hBrush );
1579
1580 /* Draw label */
1581 client = rtext;
1582 dtFlags = BUTTON_CalcLabelRect(infoPtr, hDC, &rtext);
1583
1584 /* Only adjust rbox when rtext is valid */
1585 if (dtFlags != (UINT)-1L)
1586 {
1587 rbox.top = rtext.top;
1588 rbox.bottom = rtext.bottom;
1589 }
1590
1591 /* Draw the check-box bitmap */
1593 {
1594 UINT flags;
1595
1599 else flags = DFCS_BUTTONCHECK;
1600
1603
1605
1606 /* rbox must have the correct height */
1607 delta = rbox.bottom - rbox.top - checkBoxHeight;
1608
1609 if (style & BS_TOP) {
1610 if (delta > 0) {
1611 rbox.bottom = rbox.top + checkBoxHeight;
1612 } else {
1613 rbox.top -= -delta/2 + 1;
1614 rbox.bottom = rbox.top + checkBoxHeight;
1615 }
1616 } else if (style & BS_BOTTOM) {
1617 if (delta > 0) {
1618 rbox.top = rbox.bottom - checkBoxHeight;
1619 } else {
1620 rbox.bottom += -delta/2 + 1;
1621 rbox.top = rbox.bottom - checkBoxHeight;
1622 }
1623 } else { /* Default */
1624 if (delta > 0) {
1625 int ofs = (delta / 2);
1626 rbox.bottom -= ofs + 1;
1627 rbox.top = rbox.bottom - checkBoxHeight;
1628 } else if (delta < 0) {
1629 int ofs = (-delta / 2);
1630 rbox.top -= ofs + 1;
1631 rbox.bottom = rbox.top + checkBoxHeight;
1632 }
1633 }
1634
1636 }
1637
1638 if (dtFlags == (UINT)-1L) /* Noting to draw */
1639 return;
1640
1641 if (action == ODA_DRAWENTIRE)
1642 BUTTON_DrawLabel(infoPtr, hDC, dtFlags, &rtext);
1643
1644 /* ... and focus */
1645 if (action == ODA_FOCUS || (state & BST_FOCUS))
1646 {
1647 rtext.left--;
1648 rtext.right++;
1649 IntersectRect(&rtext, &rtext, &client);
1650 DrawFocusRect( hDC, &rtext );
1651 }
1653 if (hrgn) DeleteObject( hrgn );
1654}
1655
1656
1657/**********************************************************************
1658 * BUTTON_CheckAutoRadioButton
1659 *
1660 * hwnd is checked, uncheck every other auto radio button in group
1661 */
1663{
1664 HWND parent, sibling, start;
1665
1667 /* make sure that starting control is not disabled or invisible */
1668#ifdef __REACTOS__
1669 start = sibling = hwnd;
1670#else
1671 start = sibling = GetNextDlgGroupItem( parent, hwnd, TRUE );
1672#endif
1673 do
1674 {
1675 if (!sibling) break;
1676#ifdef __REACTOS__
1678 SendMessageW( sibling, BM_SETCHECK, sibling == hwnd ? BST_CHECKED : BST_UNCHECKED, 0 );
1679#else
1680 if ((hwnd != sibling) &&
1682 SendMessageW( sibling, BM_SETCHECK, BST_UNCHECKED, 0 );
1683#endif
1684 sibling = GetNextDlgGroupItem( parent, sibling, FALSE );
1685 } while (sibling != start);
1686}
1687
1688
1689/**********************************************************************
1690 * Group Box Functions
1691 */
1692
1693static void GB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1694{
1695 RECT rc, rcFrame;
1696 HBRUSH hbr;
1697 HFONT hFont;
1698 UINT dtFlags;
1700 LONG style = GetWindowLongW( infoPtr->hwnd, GWL_STYLE );
1701 HWND parent;
1702 HRGN hrgn;
1703
1704 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1705 /* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
1706 parent = GetParent(infoPtr->hwnd);
1707 if (!parent) parent = infoPtr->hwnd;
1708 hbr = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1709 if (!hbr) /* did the app forget to call defwindowproc ? */
1710 hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1711 GetClientRect( infoPtr->hwnd, &rc);
1712 rcFrame = rc;
1713 hrgn = set_control_clipping( hDC, &rc );
1714
1716 rcFrame.top += (tm.tmHeight / 2) - 1;
1717 DrawEdge (hDC, &rcFrame, EDGE_ETCHED, BF_RECT | ((style & BS_FLAT) ? BF_FLAT : 0));
1718
1719 InflateRect(&rc, -7, 1);
1720 dtFlags = BUTTON_CalcLabelRect(infoPtr, hDC, &rc);
1721
1722 if (dtFlags != (UINT)-1)
1723 {
1724 /* Because buttons have CS_PARENTDC class style, there is a chance
1725 * that label will be drawn out of client rect.
1726 * But Windows doesn't clip label's rect, so do I.
1727 */
1728
1729 /* There is 1-pixel margin at the left, right, and bottom */
1730 rc.left--; rc.right++; rc.bottom++;
1731 FillRect(hDC, &rc, hbr);
1732 rc.left++; rc.right--; rc.bottom--;
1733
1734 BUTTON_DrawLabel(infoPtr, hDC, dtFlags, &rc);
1735 }
1737 if (hrgn) DeleteObject( hrgn );
1738}
1739
1740
1741/**********************************************************************
1742 * User Button Functions
1743 */
1744
1745static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1746{
1747 RECT rc;
1748 HBRUSH hBrush;
1749 HFONT hFont;
1750 LONG state = infoPtr->state;
1751 HWND parent;
1752
1753 GetClientRect( infoPtr->hwnd, &rc);
1754
1755 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1756
1757 parent = GetParent(infoPtr->hwnd);
1758 if (!parent) parent = infoPtr->hwnd;
1759 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1760 if (!hBrush) /* did the app forget to call defwindowproc ? */
1761 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1762
1763 FillRect( hDC, &rc, hBrush );
1764 if (action == ODA_FOCUS || (state & BST_FOCUS))
1765 DrawFocusRect( hDC, &rc );
1766
1767 switch (action)
1768 {
1769 case ODA_FOCUS:
1771 break;
1772
1773 case ODA_SELECT:
1775 break;
1776
1777 default:
1778 break;
1779 }
1780}
1781
1782
1783/**********************************************************************
1784 * Ownerdrawn Button Functions
1785 */
1786
1787static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
1788{
1789 LONG state = infoPtr->state;
1790 DRAWITEMSTRUCT dis;
1791 LONG_PTR id = GetWindowLongPtrW( infoPtr->hwnd, GWLP_ID );
1792 HWND parent;
1793 HFONT hFont;
1794 HRGN hrgn;
1795
1796 dis.CtlType = ODT_BUTTON;
1797 dis.CtlID = id;
1798 dis.itemID = 0;
1799 dis.itemAction = action;
1800 dis.itemState = ((state & BST_FOCUS) ? ODS_FOCUS : 0) |
1801 ((state & BST_PUSHED) ? ODS_SELECTED : 0) |
1802 (IsWindowEnabled(infoPtr->hwnd) ? 0: ODS_DISABLED);
1803 dis.hwndItem = infoPtr->hwnd;
1804 dis.hDC = hDC;
1805 dis.itemData = 0;
1806 GetClientRect( infoPtr->hwnd, &dis.rcItem );
1807
1808 if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
1809 parent = GetParent(infoPtr->hwnd);
1810 if (!parent) parent = infoPtr->hwnd;
1812
1814
1815 SendMessageW( GetParent(infoPtr->hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
1817 if (hrgn) DeleteObject( hrgn );
1818}
1819
1820#ifdef __REACTOS__ /* r73885 */
1821static void PB_ThemedPaint( HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
1822#else
1823static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
1824#endif
1825{
1826 static const int states[] = { PBS_NORMAL, PBS_DISABLED, PBS_HOT, PBS_PRESSED, PBS_DEFAULTED };
1827
1828 RECT bgRect, textRect;
1829 HFONT font = infoPtr->font;
1830 HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL;
1831 int state = states[ drawState ];
1832 WCHAR *text = get_button_text(infoPtr);
1833#ifdef __REACTOS__
1834 HWND parent;
1835 DWORD cdrf;
1836
1837 GetClientRect(infoPtr->hwnd, &bgRect);
1839
1840 if (prfFlag == 0)
1841 {
1844 }
1845
1846 parent = GetParent(infoPtr->hwnd);
1847 if (!parent) parent = infoPtr->hwnd;
1849
1850 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREERASE, &bgRect);
1851 if (cdrf == CDRF_SKIPDEFAULT)
1852 goto cleanup;
1853
1854 DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
1855
1856 if (cdrf == CDRF_NOTIFYPOSTERASE)
1857 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTERASE, &bgRect);
1858
1859 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREPAINT, &bgRect);
1860 if (cdrf == CDRF_SKIPDEFAULT)
1861 goto cleanup;
1862
1863 BUTTON_DrawIml(hDC, &infoPtr->imlData, &textRect, FALSE, drawState);
1864#else
1865 GetClientRect(infoPtr->hwnd, &bgRect);
1867
1870
1871 DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
1872#endif
1873
1874 if (text)
1875 {
1876 DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect);
1877 heap_free(text);
1878#ifdef __REACTOS__
1879 text = NULL;
1880#endif
1881 }
1882
1883 if (focused)
1884 {
1886 RECT focusRect = bgRect;
1887
1889
1890 focusRect.left += margins.cxLeftWidth;
1891 focusRect.top += margins.cyTopHeight;
1892 focusRect.right -= margins.cxRightWidth;
1893 focusRect.bottom -= margins.cyBottomHeight;
1894
1895 DrawFocusRect( hDC, &focusRect );
1896 }
1897
1898#ifdef __REACTOS__
1899 if (cdrf == CDRF_NOTIFYPOSTPAINT)
1900 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &bgRect);
1901cleanup:
1902 if (text) heap_free(text);
1903#endif
1904 if (hPrevFont) SelectObject(hDC, hPrevFont);
1905}
1906
1907#ifdef __REACTOS__ /* r73885 */
1908static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
1909#else
1910static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
1911#endif
1912{
1913 static const int cb_states[3][5] =
1914 {
1918 };
1919
1920 static const int rb_states[2][5] =
1921 {
1924 };
1925
1926 SIZE sz;
1927 RECT bgRect, textRect;
1928 HFONT font, hPrevFont = NULL;
1929 int checkState = infoPtr->state & 3;
1930 DWORD dwStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE);
1931 UINT btn_type = get_button_type( dwStyle );
1932 int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX;
1933 int state = (part == BP_CHECKBOX)
1934 ? cb_states[ checkState ][ drawState ]
1935 : rb_states[ checkState ][ drawState ];
1936 WCHAR *text = get_button_text(infoPtr);
1937 LOGFONTW lf;
1938 BOOL created_font = FALSE;
1939#ifdef __REACTOS__
1940 HWND parent;
1941 HBRUSH hBrush;
1942 DWORD cdrf;
1943#endif
1944
1945 HRESULT hr = GetThemeFont(theme, hDC, part, state, TMT_FONT, &lf);
1946 if (SUCCEEDED(hr)) {
1948 if (!font)
1949 TRACE("Failed to create font\n");
1950 else {
1951 TRACE("font = %s\n", debugstr_w(lf.lfFaceName));
1952 hPrevFont = SelectObject(hDC, font);
1953 created_font = TRUE;
1954 }
1955 } else {
1956#ifdef __REACTOS__ /* r73885 */
1957 font = infoPtr->font;
1958#else
1959 font = (HFONT)SendMessageW(infoPtr->hwnd, WM_GETFONT, 0, 0);
1960#endif
1961 hPrevFont = SelectObject(hDC, font);
1962 }
1963
1964 if (FAILED(GetThemePartSize(theme, hDC, part, state, NULL, TS_DRAW, &sz)))
1965 sz.cx = sz.cy = 13;
1966
1967 GetClientRect(infoPtr->hwnd, &bgRect);
1968
1969#ifdef __REACTOS__
1970 if (prfFlag == 0)
1971 {
1973 }
1974
1975 parent = GetParent(infoPtr->hwnd);
1976 if (!parent) parent = infoPtr->hwnd;
1977 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
1978 (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
1979 if (!hBrush) /* did the app forget to call defwindowproc ? */
1980 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
1981 (WPARAM)hDC, (LPARAM)infoPtr->hwnd );
1982 FillRect( hDC, &bgRect, hBrush );
1983
1984 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREERASE, &bgRect);
1985 if (cdrf == CDRF_SKIPDEFAULT)
1986 goto cleanup;
1987#endif
1988
1989 GetThemeBackgroundContentRect(theme, hDC, part, state, &bgRect, &textRect);
1990
1991 if (dtFlags & DT_SINGLELINE) /* Center the checkbox / radio button to the text. */
1992 bgRect.top = bgRect.top + (textRect.bottom - textRect.top - sz.cy) / 2;
1993
1994 /* adjust for the check/radio marker */
1995 bgRect.bottom = bgRect.top + sz.cy;
1996 bgRect.right = bgRect.left + sz.cx;
1997 textRect.left = bgRect.right + 6;
1998
1999#ifdef __REACTOS__
2000 DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL);
2001
2002 if (cdrf == CDRF_NOTIFYPOSTERASE)
2003 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTERASE, &bgRect);
2004
2005 cdrf = BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_PREPAINT, &bgRect);
2006 if (cdrf == CDRF_SKIPDEFAULT)
2007 goto cleanup;
2008
2009#else
2011 DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL);
2012#endif
2013 if (text)
2014 {
2015 DrawThemeText(theme, hDC, part, state, text, lstrlenW(text), dtFlags, 0, &textRect);
2016
2017 if (focused)
2018 {
2019 RECT focusRect;
2020
2021 focusRect = textRect;
2022
2023 DrawTextW(hDC, text, lstrlenW(text), &focusRect, dtFlags | DT_CALCRECT);
2024
2025 if (focusRect.right < textRect.right) focusRect.right++;
2026 focusRect.bottom = textRect.bottom;
2027
2028 DrawFocusRect( hDC, &focusRect );
2029 }
2030
2031 heap_free(text);
2032#ifdef __REACTOS__
2033 text = NULL;
2034#endif
2035 }
2036
2037#ifdef __REACTOS__
2038 if (cdrf == CDRF_NOTIFYPOSTPAINT)
2039 BUTTON_SendCustomDraw(infoPtr, hDC, CDDS_POSTPAINT, &bgRect);
2040cleanup:
2041 if (text) heap_free(text);
2042#endif
2043 if (created_font) DeleteObject(font);
2044 if (hPrevFont) SelectObject(hDC, hPrevFont);
2045}
2046
2047#ifdef __REACTOS__ /* r73885 */
2048static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
2049#else
2050static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
2051#endif
2052{
2053 static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL };
2054
2055 RECT bgRect, textRect, contentRect;
2056 int state = states[ drawState ];
2057 WCHAR *text = get_button_text(infoPtr);
2058 LOGFONTW lf;
2059 HFONT font, hPrevFont = NULL;
2060 BOOL created_font = FALSE;
2061#ifdef __REACTOS__ /* r74406 */
2062 HWND parent;
2063 HBRUSH hBrush;
2064 RECT clientRect;
2065#endif
2066
2068 if (SUCCEEDED(hr)) {
2070 if (!font)
2071 TRACE("Failed to create font\n");
2072 else {
2073 hPrevFont = SelectObject(hDC, font);
2074 created_font = TRUE;
2075 }
2076 } else {
2077#ifdef __REACTOS__ /* r73885 */
2078 font = infoPtr->font;
2079#else
2080 font = (HFONT)SendMessageW(infoPtr->hwnd, WM_GETFONT, 0, 0);
2081#endif
2082 hPrevFont = SelectObject(hDC, font);
2083 }
2084
2085 GetClientRect(infoPtr->hwnd, &bgRect);
2086 textRect = bgRect;
2087
2088 if (text)
2089 {
2090 SIZE textExtent;
2091 GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
2092 bgRect.top += (textExtent.cy / 2);
2093 textRect.left += 10;
2094 textRect.bottom = textRect.top + textExtent.cy;
2095 textRect.right = textRect.left + textExtent.cx + 4;
2096
2098 }
2099
2100 GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
2101 ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);
2102
2103#ifdef __REACTOS__ /* r73885 & r74149 */
2104 if (prfFlag == 0)
2105#endif
2108
2109#ifdef __REACTOS__ /* r74406 */
2110 parent = GetParent(infoPtr->hwnd);
2111 if (!parent) parent = infoPtr->hwnd;
2112 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
2113 (WPARAM)hDC, (LPARAM)infoPtr->hwnd);
2114 if (!hBrush) /* did the app forget to call defwindowproc ? */
2115 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
2116 (WPARAM)hDC, (LPARAM)infoPtr->hwnd );
2117 GetClientRect(infoPtr->hwnd, &clientRect);
2118 FillRect( hDC, &clientRect, hBrush );
2119#endif
2120
2121 DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);
2122
2124
2125 if (text)
2126 {
2127 InflateRect(&textRect, -2, 0);
2129 heap_free(text);
2130 }
2131
2132 if (created_font) DeleteObject(font);
2133 if (hPrevFont) SelectObject(hDC, hPrevFont);
2134}
2135
2137{
2138 WNDCLASSW wndClass;
2139
2140 memset(&wndClass, 0, sizeof(wndClass));
2142 wndClass.lpfnWndProc = BUTTON_WindowProc;
2143 wndClass.cbClsExtra = 0;
2144 wndClass.cbWndExtra = sizeof(BUTTON_INFO *);
2145 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
2146 wndClass.hbrBackground = NULL;
2147 wndClass.lpszClassName = WC_BUTTONW;
2148 RegisterClassW(&wndClass);
2149}
2150
2151
2152#ifdef __REACTOS__
2153void BUTTON_Unregister(void)
2154{
2156}
2157#endif
static HDC hDC
Definition: 3dtext.c:33
static HRGN hrgn
static HBRUSH hbrush
static HPEN hpen
Arabic default style
Definition: afstyles.h:94
static int state
Definition: maze.c:121
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
HFONT hFont
Definition: main.c:53
static RECT margins
Definition: print.c:55
#define ERR(fmt,...)
Definition: debug.h:110
HBITMAP hbmp
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
void BUTTON_Register(void)
Definition: button.c:2136
static const pfThemedPaint btnThemedPaintFunc[MAX_BTN_TYPE]
Definition: button.c:191
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:239
static void GB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:2050
static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: button.c:587
#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:1338
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
Definition: button.c:1323
static void GB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1693
#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:1529
static const pfPaint btnPaintFunc[MAX_BTN_TYPE]
Definition: button.c:154
struct _BUTTON_INFO BUTTON_INFO
static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:1910
static UINT BUTTON_CalcLabelRect(const BUTTON_INFO *infoPtr, HDC hdc, RECT *rc)
Definition: button.c:1191
static void paint_button(BUTTON_INFO *infoPtr, LONG style, UINT action)
Definition: button.c:218
static UINT BUTTON_BStoDT(DWORD style, DWORD ex_style)
Definition: button.c:262
ButtonState
Definition: button.c:144
@ STATE_PRESSED
Definition: button.c:148
@ STATE_DEFAULTED
Definition: button.c:149
@ STATE_DISABLED
Definition: button.c:146
@ STATE_NORMAL
Definition: button.c:145
@ STATE_HOT
Definition: button.c:147
#define BUTTON_BTNPRESSED
Definition: button.c:78
static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:1823
static UINT get_button_type(LONG window_style)
Definition: button.c:211
static void PB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1406
static WCHAR * get_button_text(const BUTTON_INFO *infoPtr)
Definition: button.c:230
static const WORD maxCheckState[MAX_BTN_TYPE]
Definition: button.c:122
static void UB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1745
#define MAX_BTN_TYPE
Definition: button.c:120
void(* pfThemedPaint)(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hdc, ButtonState drawState, UINT dtflags, BOOL focused)
Definition: button.c:183
static void OB_Paint(const BUTTON_INFO *infoPtr, HDC hDC, UINT action)
Definition: button.c:1787
void(* pfPaint)(const BUTTON_INFO *infoPtr, HDC hdc, UINT action)
Definition: button.c:152
static void BUTTON_CheckAutoRadioButton(HWND hwnd)
Definition: button.c:1662
BOOL WINAPI ImageList_Draw(HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle)
Definition: imagelist.c:1228
INT WINAPI ImageList_GetImageCount(HIMAGELIST himl)
Definition: imagelist.c:2063
BOOL WINAPI ImageList_GetIconSize(HIMAGELIST himl, INT *cx, INT *cy)
Definition: imagelist.c:2037
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
#define CALLBACK
Definition: compat.h:35
#define wcsicmp
Definition: compat.h:15
#define lstrlenW
Definition: compat.h:750
static void cleanup(void)
Definition: main.c:1335
const WCHAR * action
Definition: action.c:7479
const WCHAR * text
Definition: package.c:1799
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1883
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
HRESULT WINAPI GetThemeBackgroundExtent(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pContentRect, RECT *pExtentRect)
Definition: draw.c:1528
HRESULT WINAPI DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect)
Definition: draw.c:1377
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
HRESULT WINAPI GetThemeBackgroundContentRect(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pBoundingRect, RECT *pContentRect)
Definition: draw.c:1479
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *pFont)
Definition: property.c:108
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
Definition: property.c:216
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
r parent
Definition: btrfs.c:3010
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
pKey DeleteObject()
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_w
Definition: kernel32.h:32
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
DWORD button
Definition: button.c:166
static HDC
Definition: imagelist.c:92
static HICON
Definition: imagelist.c:84
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
Definition: mk_font.cpp:20
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
_Must_inspect_result_ _Out_ LPSIZE psize
Definition: ntgdi.h:1569
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
#define BS_AUTORADIOBUTTON
Definition: pedump.c:660
#define WS_CHILD
Definition: pedump.c:617
#define BS_USERBUTTON
Definition: pedump.c:659
#define BS_LEFTTEXT
Definition: pedump.c:662
#define WS_TABSTOP
Definition: pedump.c:634
#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
#define BST_HOT
Definition: commctrl.h:4668
#define WC_BUTTONW
Definition: commctrl.h:4623
#define CDIS_DISABLED
Definition: commctrl.h:293
#define CDRF_NOTIFYPOSTERASE
Definition: commctrl.h:277
#define CDIS_SHOWKEYBOARDCUES
Definition: commctrl.h:300
#define TME_LEAVE
Definition: commctrl.h:4981
#define BS_SPLITBUTTON
Definition: commctrl.h:4670
#define BUTTON_IMAGELIST_ALIGN_CENTER
Definition: commctrl.h:4631
#define BS_DEFCOMMANDLINK
Definition: commctrl.h:4673
#define BUTTON_IMAGELIST_ALIGN_TOP
Definition: commctrl.h:4629
#define BUTTON_IMAGELIST_ALIGN_LEFT
Definition: commctrl.h:4627
_Out_opt_ int * cx
Definition: commctrl.h:585
#define CDIS_SELECTED
Definition: commctrl.h:291
#define CDRF_NOTIFYPOSTPAINT
Definition: commctrl.h:274
#define BCM_GETIDEALSIZE
Definition: commctrl.h:4639
#define CDDS_POSTERASE
Definition: commctrl.h:283
#define NM_CUSTOMDRAW
Definition: commctrl.h:137
#define BCM_SETIMAGELIST
Definition: commctrl.h:4642
#define CDIS_FOCUS
Definition: commctrl.h:295
#define BCN_HOTITEMCHANGE
Definition: commctrl.h:260
#define CDIS_CHECKED
Definition: commctrl.h:294
#define BCM_SETTEXTMARGIN
Definition: commctrl.h:4648
#define WM_MOUSELEAVE
Definition: commctrl.h:4975
#define BS_DEFSPLITBUTTON
Definition: commctrl.h:4671
#define HICF_ENTERING
Definition: commctrl.h:1330
#define CDDS_PREPAINT
Definition: commctrl.h:280
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define HICF_LEAVING
Definition: commctrl.h:1331
#define BUTTON_IMAGELIST_ALIGN_RIGHT
Definition: commctrl.h:4628
#define WM_MOUSEHOVER
Definition: commctrl.h:4974
#define CDDS_POSTPAINT
Definition: commctrl.h:281
#define TME_QUERY
Definition: commctrl.h:4983
#define CDRF_SKIPDEFAULT
Definition: commctrl.h:270
#define BUTTON_IMAGELIST_ALIGN_BOTTOM
Definition: commctrl.h:4630
#define BS_COMMANDLINK
Definition: commctrl.h:4672
#define TME_HOVER
Definition: commctrl.h:4980
#define CDDS_PREERASE
Definition: commctrl.h:282
#define BCM_GETTEXTMARGIN
Definition: commctrl.h:4650
#define BCM_GETIMAGELIST
Definition: commctrl.h:4645
#define WM_PRINTCLIENT
Definition: richedit.h:70
#define WM_NOTIFY
Definition: richedit.h:61
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define memset(x, y, z)
Definition: compat.h:39
static FILE * client
Definition: client.c:41
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
RECT textRect
Definition: startmenu.cpp:1392
& rect
Definition: startmenu.cpp:1413
HIMAGELIST himl
Definition: commctrl.h:4634
LONG lfHeight
Definition: dimm.idl:59
WCHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:72
LONG lfWidth
Definition: dimm.idl:60
Definition: bl.h:1331
HBITMAP bitmap
Definition: button.c:101
HANDLE image
Definition: button.c:102
union _BUTTON_INFO::@337 u
HWND hwnd
Definition: button.c:95
HICON icon
Definition: button.c:100
HFONT font
Definition: button.c:97
LONG state
Definition: button.c:96
HBITMAP hbmColor
Definition: winuser.h:3127
HBITMAP hbmMask
Definition: winuser.h:3126
Definition: misc.c:279
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
LPCWSTR lpszClassName
Definition: winuser.h:3185
HBRUSH hbrBackground
Definition: winuser.h:3183
int cbClsExtra
Definition: winuser.h:3178
UINT style
Definition: winuser.h:3176
WNDPROC lpfnWndProc
Definition: winuser.h:3177
int cbWndExtra
Definition: winuser.h:3179
HCURSOR hCursor
Definition: winuser.h:3182
Definition: tftpd.h:60
ULONG_PTR itemData
Definition: winuser.h:3093
DWORD_PTR dwItemSpec
Definition: commctrl.h:307
UINT_PTR idFrom
Definition: winuser.h:3158
UINT code
Definition: winuser.h:3159
HWND hwndFrom
Definition: winuser.h:3157
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
Definition: time.h:68
#define max(a, b)
Definition: svc.c:63
#define CBS_UNCHECKEDNORMAL
Definition: treelist.c:148
#define CBS_CHECKEDNORMAL
Definition: treelist.c:151
#define BP_CHECKBOX
Definition: treelist.c:145
PVOID HANDLE
Definition: typedefs.h:73
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
@ CBS_CHECKEDDISABLED
Definition: vsstyle.h:113
@ CBS_UNCHECKEDDISABLED
Definition: vsstyle.h:109
@ CBS_UNCHECKEDHOT
Definition: vsstyle.h:107
@ CBS_MIXEDPRESSED
Definition: vsstyle.h:116
@ CBS_MIXEDNORMAL
Definition: vsstyle.h:114
@ CBS_UNCHECKEDPRESSED
Definition: vsstyle.h:108
@ CBS_CHECKEDPRESSED
Definition: vsstyle.h:112
@ CBS_CHECKEDHOT
Definition: vsstyle.h:111
@ CBS_MIXEDDISABLED
Definition: vsstyle.h:117
@ CBS_MIXEDHOT
Definition: vsstyle.h:115
@ PBS_DISABLED
Definition: vsstyle.h:89
@ PBS_PRESSED
Definition: vsstyle.h:88
@ PBS_NORMAL
Definition: vsstyle.h:86
@ PBS_HOT
Definition: vsstyle.h:87
@ PBS_DEFAULTED
Definition: vsstyle.h:90
@ BP_RADIOBUTTON
Definition: vsstyle.h:75
@ BP_PUSHBUTTON
Definition: vsstyle.h:74
@ BP_GROUPBOX
Definition: vsstyle.h:77
@ RBS_UNCHECKEDHOT
Definition: vsstyle.h:96
@ RBS_CHECKEDPRESSED
Definition: vsstyle.h:101
@ RBS_CHECKEDHOT
Definition: vsstyle.h:100
@ RBS_UNCHECKEDNORMAL
Definition: vsstyle.h:95
@ RBS_CHECKEDDISABLED
Definition: vsstyle.h:102
@ RBS_UNCHECKEDDISABLED
Definition: vsstyle.h:98
@ RBS_CHECKEDNORMAL
Definition: vsstyle.h:99
@ RBS_UNCHECKEDPRESSED
Definition: vsstyle.h:97
@ GBS_NORMAL
Definition: vsstyle.h:129
@ GBS_DISABLED
Definition: vsstyle.h:130
#define TMT_CONTENTMARGINS
Definition: vssym32.h:324
#define TMT_FONT
Definition: vssym32.h:144
int ret
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
DWORD COLORREF
Definition: windef.h:300
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _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
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define TRANSPARENT
Definition: wingdi.h:950
#define SRCCOPY
Definition: wingdi.h:333
#define LAYOUT_RTL
Definition: wingdi.h:1371
#define OPAQUE
Definition: wingdi.h:949
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#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)
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
BOOL WINAPI DeleteDC(_In_ HDC)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define PS_SOLID
Definition: wingdi.h:586
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)
#define WM_PAINT
Definition: winuser.h:1620
#define ODS_DISABLED
Definition: winuser.h:2547
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:1625
#define CS_VREDRAW
Definition: winuser.h:658
DWORD WINAPI GetSysColor(_In_ int)
#define BS_BITMAP
Definition: winuser.h:258
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CTLCOLORSTATIC
Definition: winuser.h:1772
#define ODS_SELECTED
Definition: winuser.h:2545
#define BM_GETSTATE
Definition: winuser.h:1920
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
#define COLOR_BTNTEXT
Definition: winuser.h:933
#define IMAGE_BITMAP
Definition: winuser.h:211
#define GetWindowLongPtrW
Definition: winuser.h:4829
#define WM_ENABLE
Definition: winuser.h:1615
#define WM_KEYUP
Definition: winuser.h:1716
#define COLOR_GRAYTEXT
Definition: winuser.h:932
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define COLOR_WINDOWFRAME
Definition: winuser.h:919
#define DT_CENTER
Definition: winuser.h:527
#define ODA_DRAWENTIRE
Definition: winuser.h:2542
#define BS_RIGHT
Definition: winuser.h:274
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define DLGC_BUTTON
Definition: winuser.h:2620
#define BST_UNCHECKED
Definition: winuser.h:199
#define BN_DOUBLECLICKED
Definition: winuser.h:1928
#define IMAGE_ICON
Definition: winuser.h:212
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
#define BN_SETFOCUS
Definition: winuser.h:1933
BOOL WINAPI GetIconInfo(_In_ HICON, _Out_ PICONINFO)
Definition: cursoricon.c:2045
#define WM_CAPTURECHANGED
Definition: winuser.h:1808
#define DSS_DISABLED
Definition: winuser.h:519
#define WM_CREATE
Definition: winuser.h:1608
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:2219
#define BS_PUSHLIKE
Definition: winuser.h:272
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define BM_SETSTATE
Definition: winuser.h:1923
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:1778
#define BS_TYPEMASK
Definition: winuser.h:270
#define DFCS_BUTTONCHECK
Definition: winuser.h:496
#define CS_HREDRAW
Definition: winuser.h:653
#define ODA_FOCUS
Definition: winuser.h:2544
#define DFCS_INACTIVE
Definition: winuser.h:502
#define DLGC_UNDEFPUSHBUTTON
Definition: winuser.h:2616
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define WM_NCHITTEST
Definition: winuser.h:1686
#define DFC_BUTTON
Definition: winuser.h:476
#define BS_BOTTOM
Definition: winuser.h:259
#define BN_KILLFOCUS
Definition: winuser.h:1930
#define WM_SETFOCUS
Definition: winuser.h:1613
#define EDGE_ETCHED
Definition: winuser.h:452
#define BN_HILITE
Definition: winuser.h:1929
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define DT_NOCLIP
Definition: winuser.h:536
#define RDW_UPDATENOW
Definition: winuser.h:1220
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define BS_NOTIFY
Definition: winuser.h:268
#define DST_ICON
Definition: winuser.h:515
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define CS_DBLCLKS
Definition: winuser.h:651
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1626
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
#define DLGC_DEFPUSHBUTTON
Definition: winuser.h:2615
#define WM_GETFONT
Definition: winuser.h:1651
#define BF_FLAT
Definition: winuser.h:471
#define WM_DRAWITEM
Definition: winuser.h:1645
#define WM_NCCREATE
Definition: winuser.h:1683
#define BM_SETCHECK
Definition: winuser.h:1921
#define BS_MULTILINE
Definition: winuser.h:267
#define BM_SETIMAGE
Definition: winuser.h:1922
#define BN_UNHILITE
Definition: winuser.h:1934
#define WM_CTLCOLORBTN
Definition: winuser.h:1769
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define WM_SETTEXT
Definition: winuser.h:1617
#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:2617
#define BS_FLAT
Definition: winuser.h:280
#define BS_LEFT
Definition: winuser.h:265
#define WM_SETFONT
Definition: winuser.h:1650
#define BM_CLICK
Definition: winuser.h:1917
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define DLGC_WANTARROWS
Definition: winuser.h:2610
#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:1919
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
#define RDW_FRAME
Definition: winuser.h:1212
#define DFCS_BUTTONRADIO
Definition: winuser.h:499
#define BM_SETSTYLE
Definition: winuser.h:1924
#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:2619
int WINAPI GetWindowTextLengthW(_In_ HWND)
#define WM_LBUTTONUP
Definition: winuser.h:1777
#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 CS_GLOBALCLASS
Definition: winuser.h:652
#define WM_NCDESTROY
Definition: winuser.h:1684
#define ODA_SELECT
Definition: winuser.h:2543
#define HTTRANSPARENT
Definition: winuser.h:2473
#define DSS_NORMAL
Definition: winuser.h:517
#define GWLP_ID
Definition: winuser.h:860
#define DSS_HIDEPREFIX
Definition: winuser.h:522
#define MK_LBUTTON
Definition: winuser.h:2367
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define BN_CLICKED
Definition: winuser.h:1925
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define DFCS_CHECKED
Definition: winuser.h:504
#define ODT_BUTTON
Definition: winuser.h:2540
#define WM_KEYDOWN
Definition: winuser.h:1715
#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)
#define SetWindowLongPtrW
Definition: winuser.h:5346
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:852
#define CS_PARENTDC
Definition: winuser.h:656
BOOL(CALLBACK * DRAWSTATEPROC)(HDC, LPARAM, WPARAM, int, int)
Definition: winuser.h:2907
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define DFCS_PUSHED
Definition: winuser.h:503
#define WM_KILLFOCUS
Definition: winuser.h:1614
#define ODS_FOCUS
Definition: winuser.h:2549
#define RDW_INVALIDATE
Definition: winuser.h:1214
#define WM_GETDLGCODE
Definition: winuser.h:1689
#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:928
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define BM_GETCHECK
Definition: winuser.h:1918
#define WS_EX_RIGHT
Definition: winuser.h:400
#define GWL_EXSTYLE
Definition: winuser.h:851
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185