[COMCTL32] Button: Implement sending CDDS_PREERASE, CDDS_POSTERASE, CDDS_PREPAINT...
[reactos.git] / dll / win32 / comctl32 / theme_button.c
1 /*
2 * Theming - Button control
3 *
4 * Copyright (c) 2008 by Reece H. Dunn
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 */
21
22 #include "comctl32.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(theme_button);
24
25 #define BUTTON_TYPE 0x0f /* bit mask for the available button types */
26
27 /* These are indices into a states array to determine the theme state for a given theme part. */
28 typedef enum
29 {
30 STATE_NORMAL,
31 STATE_DISABLED,
32 STATE_HOT,
33 STATE_PRESSED,
34 STATE_DEFAULTED
35 } ButtonState;
36
37 #ifdef __REACTOS__ /* r73885 */
38 typedef void (*pfThemedPaint)(HTHEME theme, HWND hwnd, HDC hdc, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag);
39 #else
40 typedef void (*pfThemedPaint)(HTHEME theme, HWND hwnd, HDC hdc, ButtonState drawState, UINT dtFlags, BOOL focused);
41 #endif
42
43 #ifdef __REACTOS__ /* r73885 & r73907 */
44 static inline LONG get_button_state( HWND hwnd )
45 {
46 return _GetButtonData(hwnd)->state;
47 }
48
49 static inline HFONT get_button_font( HWND hwnd )
50 {
51 return (HFONT)_GetButtonData(hwnd)->font;
52 }
53
54 static inline LONG_PTR get_button_image(HWND hwnd)
55 {
56 return _GetButtonData(hwnd)->image;
57 }
58
59 BOOL BUTTON_DrawIml(HDC hdc, BUTTON_IMAGELIST *pimlData, RECT *prc, BOOL bOnlyCalc);
60 DWORD BUTTON_SendCustomDraw(HWND hwnd, HDC hDC, DWORD dwDrawStage, RECT* prc);
61 #endif
62
63 static UINT get_drawtext_flags(DWORD style, DWORD ex_style)
64 {
65 UINT flags = 0;
66
67 if (style & BS_PUSHLIKE)
68 style &= ~BUTTON_TYPE;
69
70 if (!(style & BS_MULTILINE))
71 flags |= DT_SINGLELINE;
72 else
73 flags |= DT_WORDBREAK;
74
75 switch (style & BS_CENTER)
76 {
77 case BS_LEFT: flags |= DT_LEFT; break;
78 case BS_RIGHT: flags |= DT_RIGHT; break;
79 case BS_CENTER: flags |= DT_CENTER; break;
80 default:
81 flags |= ((style & BUTTON_TYPE) <= BS_DEFPUSHBUTTON)
82 ? DT_CENTER : DT_LEFT;
83 }
84
85 if (ex_style & WS_EX_RIGHT)
86 flags = DT_RIGHT | (flags & ~(DT_LEFT | DT_CENTER));
87
88 if ((style & BUTTON_TYPE) != BS_GROUPBOX)
89 {
90 switch (style & BS_VCENTER)
91 {
92 case BS_TOP: flags |= DT_TOP; break;
93 case BS_BOTTOM: flags |= DT_BOTTOM; break;
94 case BS_VCENTER: /* fall through */
95 default: flags |= DT_VCENTER; break;
96 }
97 }
98 else
99 /* GroupBox's text is always single line and is top aligned. */
100 flags |= DT_SINGLELINE | DT_TOP;
101
102 return flags;
103 }
104
105 static inline WCHAR *get_button_text(HWND hwnd)
106 {
107 INT len = 512;
108 WCHAR *text;
109 text = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
110 if (text) InternalGetWindowText(hwnd, text, len + 1);
111 return text;
112 }
113
114 static void PB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
115 {
116 static const int states[] = { PBS_NORMAL, PBS_DISABLED, PBS_HOT, PBS_PRESSED, PBS_DEFAULTED };
117
118 RECT bgRect, textRect;
119 HFONT font = get_button_font(hwnd);
120 HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL;
121 int state = states[ drawState ];
122 WCHAR *text;
123 PBUTTON_DATA pdata = _GetButtonData(hwnd);
124 HWND parent;
125 DWORD cdrf;
126
127 GetClientRect(hwnd, &bgRect);
128 GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect);
129
130 if (prfFlag == 0)
131 {
132 if (IsThemeBackgroundPartiallyTransparent(theme, BP_PUSHBUTTON, state))
133 DrawThemeParentBackground(hwnd, hDC, NULL);
134 }
135
136 parent = GetParent(hwnd);
137 if (!parent) parent = hwnd;
138 SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
139
140 cdrf = BUTTON_SendCustomDraw(hwnd, hDC, CDDS_PREERASE, &bgRect);
141 if (cdrf == CDRF_SKIPDEFAULT)
142 goto cleanup;
143
144 DrawThemeBackground(theme, hDC, BP_PUSHBUTTON, state, &bgRect, NULL);
145
146 if (cdrf == CDRF_NOTIFYPOSTERASE)
147 BUTTON_SendCustomDraw(hwnd, hDC, CDDS_POSTERASE, &bgRect);
148
149 cdrf = BUTTON_SendCustomDraw(hwnd, hDC, CDDS_PREPAINT, &bgRect);
150 if (cdrf == CDRF_SKIPDEFAULT)
151 goto cleanup;
152
153 BUTTON_DrawIml(hDC, &pdata->imlData, &textRect, FALSE);
154
155 text = get_button_text(hwnd);
156 if (text)
157 {
158 DrawThemeText(theme, hDC, BP_PUSHBUTTON, state, text, lstrlenW(text), dtFlags, 0, &textRect);
159 HeapFree(GetProcessHeap(), 0, text);
160 }
161
162 if (focused)
163 {
164 MARGINS margins;
165 RECT focusRect = bgRect;
166
167 GetThemeMargins(theme, hDC, BP_PUSHBUTTON, state, TMT_CONTENTMARGINS, NULL, &margins);
168
169 focusRect.left += margins.cxLeftWidth;
170 focusRect.top += margins.cyTopHeight;
171 focusRect.right -= margins.cxRightWidth;
172 focusRect.bottom -= margins.cyBottomHeight;
173
174 DrawFocusRect( hDC, &focusRect );
175 }
176
177 if (cdrf == CDRF_NOTIFYPOSTPAINT)
178 BUTTON_SendCustomDraw(hwnd, hDC, CDDS_POSTPAINT, &bgRect);
179
180 cleanup:
181 if (hPrevFont) SelectObject(hDC, hPrevFont);
182 }
183
184 static void CB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
185 {
186 static const int cb_states[3][5] =
187 {
188 { CBS_UNCHECKEDNORMAL, CBS_UNCHECKEDDISABLED, CBS_UNCHECKEDHOT, CBS_UNCHECKEDPRESSED, CBS_UNCHECKEDNORMAL },
189 { CBS_CHECKEDNORMAL, CBS_CHECKEDDISABLED, CBS_CHECKEDHOT, CBS_CHECKEDPRESSED, CBS_CHECKEDNORMAL },
190 { CBS_MIXEDNORMAL, CBS_MIXEDDISABLED, CBS_MIXEDHOT, CBS_MIXEDPRESSED, CBS_MIXEDNORMAL }
191 };
192
193 static const int rb_states[2][5] =
194 {
195 { RBS_UNCHECKEDNORMAL, RBS_UNCHECKEDDISABLED, RBS_UNCHECKEDHOT, RBS_UNCHECKEDPRESSED, RBS_UNCHECKEDNORMAL },
196 { RBS_CHECKEDNORMAL, RBS_CHECKEDDISABLED, RBS_CHECKEDHOT, RBS_CHECKEDPRESSED, RBS_CHECKEDNORMAL }
197 };
198
199 SIZE sz;
200 RECT bgRect, textRect;
201 HFONT font, hPrevFont = NULL;
202 LRESULT checkState = get_button_state(hwnd) & 3;
203 DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
204 int part = ((dwStyle & BUTTON_TYPE) == BS_RADIOBUTTON) || ((dwStyle & BUTTON_TYPE) == BS_AUTORADIOBUTTON)
205 ? BP_RADIOBUTTON
206 : BP_CHECKBOX;
207 int state = (part == BP_CHECKBOX)
208 ? cb_states[ checkState ][ drawState ]
209 : rb_states[ checkState ][ drawState ];
210 WCHAR *text;
211 LOGFONTW lf;
212 BOOL created_font = FALSE;
213 HWND parent;
214 HBRUSH hBrush;
215 DWORD cdrf;
216
217 HRESULT hr = GetThemeFont(theme, hDC, part, state, TMT_FONT, &lf);
218 if (SUCCEEDED(hr)) {
219 font = CreateFontIndirectW(&lf);
220 if (!font)
221 TRACE("Failed to create font\n");
222 else {
223 TRACE("font = %s\n", debugstr_w(lf.lfFaceName));
224 hPrevFont = SelectObject(hDC, font);
225 created_font = TRUE;
226 }
227 } else {
228 font = get_button_font(hwnd);
229 hPrevFont = SelectObject(hDC, font);
230 }
231
232 if (FAILED(GetThemePartSize(theme, hDC, part, state, NULL, TS_DRAW, &sz)))
233 sz.cx = sz.cy = 13;
234
235 GetClientRect(hwnd, &bgRect);
236
237 if (prfFlag == 0)
238 {
239 DrawThemeParentBackground(hwnd, hDC, NULL);
240 }
241
242 parent = GetParent(hwnd);
243 if (!parent) parent = hwnd;
244 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
245 (WPARAM)hDC, (LPARAM)hwnd);
246 if (!hBrush) /* did the app forget to call defwindowproc ? */
247 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
248 (WPARAM)hDC, (LPARAM)hwnd );
249 FillRect( hDC, &bgRect, hBrush );
250
251 cdrf = BUTTON_SendCustomDraw(hwnd, hDC, CDDS_PREERASE, &bgRect);
252 if (cdrf == CDRF_SKIPDEFAULT)
253 goto cleanup;
254
255 GetThemeBackgroundContentRect(theme, hDC, part, state, &bgRect, &textRect);
256
257 if (dtFlags & DT_SINGLELINE) /* Center the checkbox / radio button to the text. */
258 bgRect.top = bgRect.top + (textRect.bottom - textRect.top - sz.cy) / 2;
259
260 /* adjust for the check/radio marker */
261 bgRect.bottom = bgRect.top + sz.cy;
262 bgRect.right = bgRect.left + sz.cx;
263 textRect.left = bgRect.right + 6;
264
265 DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL);
266
267 if (cdrf == CDRF_NOTIFYPOSTERASE)
268 BUTTON_SendCustomDraw(hwnd, hDC, CDDS_POSTERASE, &bgRect);
269
270 cdrf = BUTTON_SendCustomDraw(hwnd, hDC, CDDS_PREPAINT, &bgRect);
271 if (cdrf == CDRF_SKIPDEFAULT)
272 goto cleanup;
273
274 text = get_button_text(hwnd);
275 if (text)
276 {
277 DrawThemeText(theme, hDC, part, state, text, lstrlenW(text), dtFlags, 0, &textRect);
278
279 if (focused)
280 {
281 RECT focusRect;
282
283 focusRect = textRect;
284
285 DrawTextW(hDC, text, lstrlenW(text), &focusRect, dtFlags | DT_CALCRECT);
286
287 if (focusRect.right < textRect.right) focusRect.right++;
288 focusRect.bottom = textRect.bottom;
289
290 DrawFocusRect( hDC, &focusRect );
291 }
292
293 HeapFree(GetProcessHeap(), 0, text);
294 }
295
296 if (cdrf == CDRF_NOTIFYPOSTPAINT)
297 BUTTON_SendCustomDraw(hwnd, hDC, CDDS_POSTPAINT, &bgRect);
298
299 cleanup:
300 if (created_font) DeleteObject(font);
301 if (hPrevFont) SelectObject(hDC, hPrevFont);
302 }
303
304 #ifdef __REACTOS__ /* r73885 */
305 static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused, LPARAM prfFlag)
306 #else
307 static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, ButtonState drawState, UINT dtFlags, BOOL focused)
308 #endif
309 {
310 static const int states[] = { GBS_NORMAL, GBS_DISABLED, GBS_NORMAL, GBS_NORMAL, GBS_NORMAL };
311
312 RECT bgRect, textRect, contentRect;
313 int state = states[ drawState ];
314 WCHAR *text = get_button_text(hwnd);
315 LOGFONTW lf;
316 HFONT font, hPrevFont = NULL;
317 BOOL created_font = FALSE;
318 #ifdef __REACTOS__ /* r74406 */
319 HWND parent;
320 HBRUSH hBrush;
321 RECT clientRect;
322 #endif
323
324 HRESULT hr = GetThemeFont(theme, hDC, BP_GROUPBOX, state, TMT_FONT, &lf);
325 if (SUCCEEDED(hr)) {
326 font = CreateFontIndirectW(&lf);
327 if (!font)
328 TRACE("Failed to create font\n");
329 else {
330 hPrevFont = SelectObject(hDC, font);
331 created_font = TRUE;
332 }
333 } else {
334 #ifdef __REACTOS__ /* r73885 */
335 font = get_button_font(hwnd);
336 #else
337 font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0);
338 #endif
339 hPrevFont = SelectObject(hDC, font);
340 }
341
342 GetClientRect(hwnd, &bgRect);
343 textRect = bgRect;
344
345 if (text)
346 {
347 SIZE textExtent;
348 GetTextExtentPoint32W(hDC, text, lstrlenW(text), &textExtent);
349 bgRect.top += (textExtent.cy / 2);
350 textRect.left += 10;
351 textRect.bottom = textRect.top + textExtent.cy;
352 textRect.right = textRect.left + textExtent.cx + 4;
353
354 ExcludeClipRect(hDC, textRect.left, textRect.top, textRect.right, textRect.bottom);
355 }
356
357 GetThemeBackgroundContentRect(theme, hDC, BP_GROUPBOX, state, &bgRect, &contentRect);
358 ExcludeClipRect(hDC, contentRect.left, contentRect.top, contentRect.right, contentRect.bottom);
359
360 #ifdef __REACTOS__ /* r73885 & r74149 */
361 if (prfFlag == 0)
362 {
363 if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
364 DrawThemeParentBackground(hwnd, hDC, NULL);
365 }
366 #else
367 if (IsThemeBackgroundPartiallyTransparent(theme, BP_GROUPBOX, state))
368 DrawThemeParentBackground(hwnd, hDC, NULL);
369 #endif
370
371 #ifdef __REACTOS__ /* r74406 */
372 parent = GetParent(hwnd);
373 if (!parent) parent = hwnd;
374 hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
375 (WPARAM)hDC, (LPARAM)hwnd);
376 if (!hBrush) /* did the app forget to call defwindowproc ? */
377 hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
378 (WPARAM)hDC, (LPARAM)hwnd );
379 GetClientRect(hwnd, &clientRect);
380 FillRect( hDC, &clientRect, hBrush );
381 #endif
382
383 DrawThemeBackground(theme, hDC, BP_GROUPBOX, state, &bgRect, NULL);
384
385 SelectClipRgn(hDC, NULL);
386
387 if (text)
388 {
389 InflateRect(&textRect, -2, 0);
390 DrawThemeText(theme, hDC, BP_GROUPBOX, state, text, lstrlenW(text), 0, 0, &textRect);
391 HeapFree(GetProcessHeap(), 0, text);
392 }
393
394 if (created_font) DeleteObject(font);
395 if (hPrevFont) SelectObject(hDC, hPrevFont);
396 }
397
398 static const pfThemedPaint btnThemedPaintFunc[BUTTON_TYPE + 1] =
399 {
400 PB_draw, /* BS_PUSHBUTTON */
401 PB_draw, /* BS_DEFPUSHBUTTON */
402 CB_draw, /* BS_CHECKBOX */
403 CB_draw, /* BS_AUTOCHECKBOX */
404 CB_draw, /* BS_RADIOBUTTON */
405 CB_draw, /* BS_3STATE */
406 CB_draw, /* BS_AUTO3STATE */
407 GB_draw, /* BS_GROUPBOX */
408 NULL, /* BS_USERBUTTON */
409 CB_draw, /* BS_AUTORADIOBUTTON */
410 NULL, /* Not defined */
411 NULL, /* BS_OWNERDRAW */
412 NULL, /* Not defined */
413 NULL, /* Not defined */
414 NULL, /* Not defined */
415 NULL, /* Not defined */
416 };
417
418 #ifdef __REACTOS__ /* r73873 */
419 BOOL BUTTON_PaintWithTheme(HTHEME theme, HWND hwnd, HDC hParamDC, LPARAM prfFlag)
420 #else
421 static BOOL BUTTON_Paint(HTHEME theme, HWND hwnd, HDC hParamDC)
422 #endif
423 {
424 #ifdef __REACTOS__ /* r73873, r73897 and r74120 */
425 DWORD dwStyle;
426 DWORD dwStyleEx;
427 DWORD type;
428 UINT dtFlags;
429 int state;
430 #else
431 PAINTSTRUCT ps;
432 HDC hDC;
433 DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
434 DWORD dwStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
435 UINT dtFlags = get_drawtext_flags(dwStyle, dwStyleEx);
436 int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
437 #endif
438 ButtonState drawState;
439 #ifdef __REACTOS__ /* r73873, r73897, r73907 and r74120 */
440 pfThemedPaint paint;
441
442 dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
443 type = dwStyle & BUTTON_TYPE;
444
445 if (type != BS_PUSHBUTTON && type != BS_DEFPUSHBUTTON && (dwStyle & BS_PUSHLIKE))
446 type = BS_PUSHBUTTON;
447
448 paint = btnThemedPaintFunc[type];
449 if (!paint)
450 return FALSE;
451
452 if (get_button_image(hwnd) != 0)
453 return FALSE;
454
455 dwStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
456 dtFlags = get_drawtext_flags(dwStyle, dwStyleEx);
457 state = get_button_state(hwnd);
458 #else
459 pfThemedPaint paint = btnThemedPaintFunc[ dwStyle & BUTTON_TYPE ];
460 #endif
461
462 if(IsWindowEnabled(hwnd))
463 {
464 if(state & BST_PUSHED)
465 drawState = STATE_PRESSED;
466 else if ((dwStyle & BS_PUSHLIKE) && (state & (BST_CHECKED|BST_INDETERMINATE)))
467 drawState = STATE_PRESSED;
468 else if(state & BST_HOT)
469 drawState = STATE_HOT;
470 else if(state & BST_FOCUS)
471 drawState = STATE_DEFAULTED;
472 else
473 drawState = STATE_NORMAL;
474 }
475 else
476 drawState = STATE_DISABLED;
477
478 #ifndef __REACTOS__ /* r73873 */
479 hDC = hParamDC ? hParamDC : BeginPaint(hwnd, &ps);
480 if (paint) paint(theme, hwnd, hDC, drawState, dtFlags, state & BST_FOCUS);
481 if (!hParamDC) EndPaint(hwnd, &ps);
482 #endif
483
484 #ifdef __REACTOS__ /* r74074 & r74120 */
485 if (drawState == STATE_NORMAL && type == BS_DEFPUSHBUTTON)
486 {
487 drawState = STATE_DEFAULTED;
488 }
489 #endif
490
491 paint(theme, hwnd, hParamDC, drawState, dtFlags, state & BST_FOCUS, prfFlag);
492 return TRUE;
493 }
494
495 #ifndef __REACTOS__ /* r73873 */
496 /**********************************************************************
497 * The button control subclass window proc.
498 */
499 LRESULT CALLBACK THEMING_ButtonSubclassProc(HWND hwnd, UINT msg,
500 WPARAM wParam, LPARAM lParam,
501 ULONG_PTR dwRefData)
502 {
503 const WCHAR* themeClass = WC_BUTTONW;
504 HTHEME theme;
505 LRESULT result;
506
507 switch (msg)
508 {
509 case WM_CREATE:
510 result = THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
511 OpenThemeData(hwnd, themeClass);
512 return result;
513
514 case WM_DESTROY:
515 theme = GetWindowTheme(hwnd);
516 CloseThemeData (theme);
517 return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
518
519 case WM_THEMECHANGED:
520 theme = GetWindowTheme(hwnd);
521 CloseThemeData (theme);
522 OpenThemeData(hwnd, themeClass);
523 break;
524
525 case WM_SYSCOLORCHANGE:
526 theme = GetWindowTheme(hwnd);
527 if (!theme) return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
528 /* Do nothing. When themed, a WM_THEMECHANGED will be received, too,
529 * which will do the repaint. */
530 break;
531
532 case WM_PAINT:
533 theme = GetWindowTheme(hwnd);
534 if (theme && BUTTON_Paint(theme, hwnd, (HDC)wParam))
535 return 0;
536 else
537 return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
538
539 case WM_ENABLE:
540 theme = GetWindowTheme(hwnd);
541 if (theme) {
542 RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
543 return 0;
544 } else
545 return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
546
547 case WM_MOUSEMOVE:
548 {
549 TRACKMOUSEEVENT mouse_event;
550 mouse_event.cbSize = sizeof(TRACKMOUSEEVENT);
551 mouse_event.dwFlags = TME_QUERY;
552 if(!TrackMouseEvent(&mouse_event) || !(mouse_event.dwFlags&(TME_HOVER|TME_LEAVE)))
553 {
554 mouse_event.dwFlags = TME_HOVER|TME_LEAVE;
555 mouse_event.hwndTrack = hwnd;
556 mouse_event.dwHoverTime = 1;
557 TrackMouseEvent(&mouse_event);
558 }
559 break;
560 }
561
562 case WM_MOUSEHOVER:
563 {
564 int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
565 SetWindowLongW(hwnd, 0, state|BST_HOT);
566 InvalidateRect(hwnd, NULL, FALSE);
567 break;
568 }
569
570 case WM_MOUSELEAVE:
571 {
572 int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
573 SetWindowLongW(hwnd, 0, state&(~BST_HOT));
574 InvalidateRect(hwnd, NULL, FALSE);
575 break;
576 }
577
578 case BM_SETCHECK:
579 case BM_SETSTATE:
580 theme = GetWindowTheme(hwnd);
581 if (theme) {
582 InvalidateRect(hwnd, NULL, FALSE);
583 }
584 return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
585
586 default:
587 /* Call old proc */
588 return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
589 }
590 return 0;
591 }
592 #endif /* !__REACTOS__ */