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