2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for Button window class v6
5 * PROGRAMMERS: Giannis Adamopoulos
13 #include <undocuser.h>
15 #include <user32testhelpers.h>
17 #define ok_rect(rc, l,r,t,b) ok((rc.left == (l)) && (rc.right == (r)) && (rc.top == (t)) && (rc.bottom == (b)), "Wrong rect. expected %d, %d, %d, %d got %ld, %ld, %ld, %ld\n", l,t,r,b, rc.left, rc.top, rc.right, rc.bottom)
18 #define ok_size(s, width, height) ok((s.cx == (width) && s.cy == (height)), "Expected size (%lu,%lu) got (%lu,%lu)\n", (LONG)width, (LONG)height, s.cx, s.cy)
20 void Test_TextMargin()
26 hwnd1
= CreateWindowW(L
"Button", L
"Test1", 0, 10, 10, 100, 100, 0, NULL
, NULL
, NULL
);
27 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
28 SetWindowTheme(hwnd1
, L
"", L
"");
30 ret
= SendMessageW(hwnd1
, BCM_GETTEXTMARGIN
, 0, (LPARAM
)&rc
);
31 ok (ret
== TRUE
, "Expected BCM_GETTEXTMARGIN to succeed\n");
32 ok_rect(rc
, 1, 1, 1, 1);
34 SetRect(&rc
, 0,0,0,0);
35 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
36 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
38 ret
= SendMessageW(hwnd1
, BCM_GETTEXTMARGIN
, 0, (LPARAM
)&rc
);
39 ok (ret
== TRUE
, "Expected BCM_GETTEXTMARGIN to succeed\n");
40 ok_rect(rc
, 0, 0, 0, 0);
42 SetRect(&rc
, -1,-1,-1,-1);
43 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
44 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
46 ret
= SendMessageW(hwnd1
, BCM_GETTEXTMARGIN
, 0, (LPARAM
)&rc
);
47 ok (ret
== TRUE
, "Expected BCM_GETTEXTMARGIN to succeed\n");
48 ok_rect(rc
, -1, -1, -1, -1);
50 SetRect(&rc
, 1000,1000,1000,1000);
51 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
52 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
54 ret
= SendMessageW(hwnd1
, BCM_GETTEXTMARGIN
, 0, (LPARAM
)&rc
);
55 ok (ret
== TRUE
, "Expected BCM_GETTEXTMARGIN to succeed\n");
56 ok_rect(rc
, 1000, 1000, 1000, 1000);
60 hwnd1
= CreateWindowW(L
"Button", L
"Test1", BS_DEFPUSHBUTTON
, 10, 10, 100, 100, 0, NULL
, NULL
, NULL
);
61 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
62 SetWindowTheme(hwnd1
, L
"", L
"");
64 ret
= SendMessageW(hwnd1
, BCM_GETTEXTMARGIN
, 0, (LPARAM
)&rc
);
65 ok (ret
== TRUE
, "Expected BCM_GETTEXTMARGIN to succeed\n");
66 ok_rect(rc
, 1, 1, 1, 1);
76 BUTTON_IMAGELIST imlData
;
78 hwnd1
= CreateWindowW(L
"Button", L
"Test2", 0, 10, 10, 100, 100, 0, NULL
, NULL
, NULL
);
79 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
81 ret
= SendMessageW(hwnd1
, BCM_GETIMAGELIST
, 0, (LPARAM
)&imlData
);
82 ok (ret
== TRUE
, "Expected BCM_GETIMAGELIST to succeed\n");
83 ok (imlData
.himl
== 0, "Expected 0 himl\n");
84 ok (imlData
.uAlign
== 0, "Expected 0 uAlign\n");
85 ok_rect(imlData
.margin
, 0, 0, 0, 0);
87 SetRect(&imlData
.margin
, 0,0,0,1);
88 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
89 ok (ret
== FALSE
, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */
91 imlData
.himl
= (HIMAGELIST
)0xdead;
92 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
93 ok (ret
== TRUE
, "Expected BCM_SETIMAGELIST to fail\n");
95 ret
= SendMessageW(hwnd1
, BCM_GETIMAGELIST
, 0, (LPARAM
)&imlData
);
96 ok (ret
== TRUE
, "Expected BCM_GETIMAGELIST to succeed\n");
97 ok (imlData
.himl
== (HIMAGELIST
)0xdead, "Expected 0 himl\n");
98 ok (imlData
.uAlign
== 0, "Expected 0 uAlign\n");
99 ok_rect(imlData
.margin
, 0, 0, 0, 1);
102 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
103 ok (ret
== FALSE
, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */
105 DestroyWindow(hwnd1
);
108 void Test_GetIdealSizeNoThemes()
117 BUTTON_IMAGELIST imlData
;
122 hwnd2
= CreateWindowW(L
"Static", L
"", 0, 0, 0, 100, 100, 0, NULL
, NULL
, NULL
);
123 ok (hwnd2
!= NULL
, "Expected CreateWindowW to succeed\n");
125 hwnd1
= CreateWindowW(L
"Button", L
" ", WS_CHILD
, 10, 10, 100, 100, hwnd2
, NULL
, NULL
, NULL
);
126 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
127 SetWindowTheme(hwnd1
, L
"", L
"");
129 font
= (HFONT
)SendMessageW(hwnd1
, WM_GETFONT
, 0, 0);
131 SelectObject(hdc
, font
);
132 GetTextExtentPoint32W(hdc
, L
" ", 1, &textent
);
134 memset(&s
, 0, sizeof(s
));
135 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
136 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
137 ok_size(s
, textent
.cx
+ 5 + 2,
138 textent
.cy
+ 7 + 2); /* the last +2 is the text margin */
140 DestroyWindow(hwnd1
);
143 hwnd1
= CreateWindowW(L
"Button", L
" ", BS_USERBUTTON
| WS_CHILD
, 10, 10, 100, 100, hwnd2
, NULL
, NULL
, NULL
);
144 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
145 SetWindowTheme(hwnd1
, L
"", L
"");
147 memset(&s
, 0, sizeof(s
));
148 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
149 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
150 ok_size(s
, textent
.cx
+ 5 + 2,
151 textent
.cy
+ 7 + 2); /* the last +2 is the text margin */
153 DestroyWindow(hwnd1
);
157 hwnd1
= CreateWindowW(L
"Button", L
"", WS_CHILD
, 10, 10, 100, 100, hwnd2
, NULL
, NULL
, NULL
);
158 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
159 SetWindowTheme(hwnd1
, L
"", L
"");
163 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
164 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
165 ok_size(s
, 100, 100);
167 hbmp
= LoadImage(GetModuleHandle(NULL
), MAKEINTRESOURCE(5), IMAGE_BITMAP
, 0, 0, 0);
168 ok (hbmp
!= 0, "Expected LoadImage to succeed\n");
170 SendMessageW(hwnd1
, BM_SETIMAGE
, IMAGE_BITMAP
, (LPARAM
)hbmp
);
172 memset(&s
, 0, sizeof(s
));
173 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
174 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
175 ok_size(s
, 100, 100);
177 himl
= ImageList_LoadImage(GetModuleHandle(NULL
), MAKEINTRESOURCE(5), 1, 1, 0, IMAGE_BITMAP
, 0);
178 ok (himl
!= 0, "Expected ImageList_LoadImage to succeed\n");
180 memset(&imlData
, 0, sizeof(imlData
));
182 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
183 ok (ret
== TRUE
, "Expected BCM_SETIMAGELIST to fail\n"); /* This works in win10 */
185 memset(&s
, 0, sizeof(s
));
186 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
187 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
188 ok_size(s
, 100, 100);
190 DestroyWindow(hwnd1
);
196 hwnd1
= CreateWindowW(L
"Button", L
"", WS_CHILD
, 10, 10, 5, 5, hwnd2
, NULL
, NULL
, NULL
);
197 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
198 SetWindowTheme(hwnd1
, L
"", L
"");
200 memset(&s
, 0, sizeof(s
));
201 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
202 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
205 DestroyWindow(hwnd1
);
210 hwnd1
= CreateWindowW(L
"Button", L
" ", BS_BITMAP
| WS_CHILD
, 10, 10, 100, 100, hwnd2
, NULL
, NULL
, NULL
);
211 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
212 SetWindowTheme(hwnd1
, L
"", L
"");
214 SendMessageW(hwnd1
, BM_SETIMAGE
, IMAGE_BITMAP
, (LPARAM
)hbmp
);
216 memset(&s
, 0, sizeof(s
));
217 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
218 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
220 /* In xp and 2k3 the image is ignored, in vista+ its width is added to the text width */
221 ok_size(s
, textent
.cx
+ 5 + 2,
222 textent
.cy
+ 7 + 2); /* the last +2 is the text margin */
224 DestroyWindow(hwnd1
);
228 hwnd1
= CreateWindowW(L
"Button", L
" ", WS_CHILD
, 10, 10, 100, 100, hwnd2
, NULL
, NULL
, NULL
);
229 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
230 SetWindowTheme(hwnd1
, L
"", L
"");
232 SetRect(&rc
, 0,0,0,0);
233 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
234 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
236 memset(&s
, 0, sizeof(s
));
237 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
238 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
239 ok_size(s
, textent
.cx
+ 5,
242 SetRect(&rc
, 50,50,50,50);
243 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
244 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
246 memset(&s
, 0, sizeof(s
));
247 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
248 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
249 ok_size(s
, textent
.cx
+ 5 + 100,
250 textent
.cy
+ 7 + 100);
252 SetRect(&rc
, 1,1,1,1);
253 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
254 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
256 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
257 ok (ret
== TRUE
, "Expected BCM_SETIMAGELIST to fail\n");
259 memset(&s
, 0, sizeof(s
));
260 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
261 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
262 ok_size(s
, textent
.cx
+ 5 + 2 + 1, /* we get an extra pixel due to the iml */
267 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
268 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
269 ok_size(s
, textent
.cx
+ 5 + 2 + 1,
274 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
275 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
276 ok_size(s
, textent
.cx
+ 5 + 2 + 1,
279 SetRect(&imlData
.margin
, 1,1,1,1);
280 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
281 ok (ret
== TRUE
, "Expected BCM_SETIMAGELIST to fail\n");
283 memset(&s
, 0, sizeof(s
));
284 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
285 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
286 /* expected width = text width + hardcoded value + text margins + image width + image margins */
287 ok_size(s
, textent
.cx
+ 5 + 2 + 1 + 2,
290 SetRect(&imlData
.margin
, 50,50,50,50);
291 ret
= SendMessageW(hwnd1
, BCM_SETIMAGELIST
, 0, (LPARAM
)&imlData
);
292 ok (ret
== TRUE
, "Expected BCM_SETIMAGELIST to fail\n");
294 memset(&s
, 0, sizeof(s
));
295 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
296 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
297 /* image + its margins is so big that the height is dictated by them */
298 ok_size(s
, textent
.cx
+ 5 + 2 + 1 + 100, (LONG
)101);
300 DestroyWindow(hwnd1
);
307 hwnd1
= CreateWindowW(L
"Button", L
"Start", BS_VCENTER
| WS_CHILD
, 0, 0, 0, 0, hwnd2
, NULL
, NULL
, NULL
);
308 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
309 SetWindowTheme(hwnd1
, L
"", L
"");
311 font
= (HFONT
)SendMessageW(hwnd1
, WM_GETFONT
, 0, 0);
313 SelectObject(hdc
, font
);
314 GetTextExtentPoint32W(hdc
, L
"Start", 5, &textent
);
316 SetRect(&rc
, 0,0,0,0);
317 ret
= SendMessageW(hwnd1
, BCM_SETTEXTMARGIN
, 0, (LPARAM
)&rc
);
318 ok (ret
== TRUE
, "Expected BCM_SETTEXTMARGIN to succeed\n");
320 memset(&s
, 0, sizeof(s
));
321 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
322 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
323 ok_size(s
, textent
.cx
+ 5, textent
.cy
+ 7);
325 DestroyWindow(hwnd1
);
330 /* Test again with some real text to see if the formula is correct */
331 hwnd1
= CreateWindowW(L
"Button", L
"Some test text", WS_CHILD
, 10, 10, 100, 100, hwnd2
, NULL
, NULL
, NULL
);
332 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
333 SetWindowTheme(hwnd1
, L
"", L
"");
335 font
= (HFONT
)SendMessageW(hwnd1
, WM_GETFONT
, 0, 0);
337 SelectObject(hdc
, font
);
338 GetTextExtentPoint32W(hdc
, L
"Some test text", 14, &textent
);
340 memset(&s
, 0, sizeof(s
));
341 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
342 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
343 ok_size(s
, textent
.cx
+ 5 + 2, /* the last +2 is the text margin */
346 /* The hardcoded values are independent of the margin */
349 lf
.lfWeight
= FW_BOLD
;
350 wcscpy(lf
.lfFaceName
, L
"Arial");
351 font
= CreateFontIndirectW(&lf
);
352 ok(font
!= NULL
, "\n");
353 SendMessageW(hwnd1
, WM_SETFONT
, (WPARAM
)font
, FALSE
);
355 SelectObject(hdc
, font
);
356 GetTextExtentPoint32W(hdc
, L
"Some test text", 14, &textent
);
358 memset(&s
, 0, sizeof(s
));
359 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
360 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
361 ok_size(s
, textent
.cx
+ 5 + 2, /* the last +2 is the text margin */
364 DestroyWindow(hwnd1
);
366 for (i
= BS_PUSHBUTTON
; i
<= BS_OWNERDRAW
; i
++)
368 if (i
== BS_USERBUTTON
)
371 if (i
>= BS_CHECKBOX
)
373 hwnd1
= CreateWindowW(L
"Button", L
" ", i
|WS_CHILD
, 0, 0, 72, 72, hwnd2
, NULL
, NULL
, NULL
);
374 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
375 memset(&s
, 0, sizeof(s
));
376 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
377 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
380 SetWindowTheme(hwnd1
, L
"", L
"");
381 memset(&s
, 0, sizeof(s
));
382 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
383 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
385 DestroyWindow(hwnd1
);
387 hwnd1
= CreateWindowW(L
"Button", L
" ", i
|WS_CHILD
, 0, 0, 12, 12, hwnd2
, NULL
, NULL
, NULL
);
388 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
389 memset(&s
, 0, sizeof(s
));
390 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
391 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
393 DestroyWindow(hwnd1
);
396 hwnd1
= CreateWindowW(L
"Button", L
"", i
|WS_CHILD
, 0, 0, 72, 72, hwnd2
, NULL
, NULL
, NULL
);
397 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
398 memset(&s
, 0, sizeof(s
));
399 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
400 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
402 DestroyWindow(hwnd1
);
404 hwnd1
= CreateWindowW(L
"Button", L
"", i
|WS_CHILD
, 0, 0, 150, 72, hwnd2
, NULL
, NULL
, NULL
);
405 ok (hwnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
406 memset(&s
, 0, sizeof(s
));
407 ret
= SendMessageW(hwnd1
, BCM_GETIDEALSIZE
, 0, (LPARAM
)&s
);
408 ok (ret
== TRUE
, "Expected BCM_GETIDEALSIZE to succeed\n");
410 DestroyWindow(hwnd1
);
412 DestroyWindow(hwnd2
);
418 #define MOVE_CURSOR(x,y) mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE , \
419 x*(65535/GetSystemMetrics(SM_CXVIRTUALSCREEN)), \
420 y*(65535/GetSystemMetrics(SM_CYVIRTUALSCREEN)) , 0,0);
422 static int get_iwnd(HWND hWnd
)
424 if(hWnd
== hWnd1
) return 1;
425 else if(hWnd
== hWnd2
) return 2;
429 static LRESULT CALLBACK
subclass_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
, UINT_PTR id
, DWORD_PTR ref_data
)
431 int iwnd
= get_iwnd(hwnd
);
433 if(message
> WM_USER
|| !iwnd
)
434 return DefSubclassProc(hwnd
, message
, wParam
, lParam
);
438 case WM_IME_SETCONTEXT
:
442 case WM_GETTEXTLENGTH
:
446 NMHDR
* pnmhdr
= (NMHDR
*)lParam
;
447 RECORD_MESSAGE(iwnd
, message
, SENT
, pnmhdr
->idFrom
,pnmhdr
->code
);
451 RECORD_MESSAGE(iwnd
, message
, SENT
, 0,0);
453 return DefSubclassProc(hwnd
, message
, wParam
, lParam
);
456 static LRESULT CALLBACK
TestProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
458 int iwnd
= get_iwnd(hwnd
);
460 if (iwnd
!= 0 && message
== WM_NOTIFY
)
462 NMHDR
* pnmhdr
= (NMHDR
*)lParam
;
463 RECORD_MESSAGE(iwnd
, message
, SENT
, pnmhdr
->idFrom
,pnmhdr
->code
);
465 else if (iwnd
!= 0 && message
< WM_USER
&& message
!= WM_GETICON
)
467 RECORD_MESSAGE(iwnd
, message
, SENT
, 0,0);
470 return DefWindowProc(hwnd
, message
, wParam
, lParam
);
473 static void FlushMessages()
477 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
))
479 int iwnd
= get_iwnd(msg
.hwnd
);
482 if(msg
.message
<= WM_USER
&& iwnd
!= 0)
483 RECORD_MESSAGE(iwnd
, msg
.message
, POST
,0,0);
485 DispatchMessageW( &msg
);
489 MSG_ENTRY erase_sequence
[]={
494 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
495 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
498 MSG_ENTRY erase_nonthemed_sequence
[]={
501 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
502 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
505 MSG_ENTRY printclnt_nonthemed_sequence
[]={
508 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
509 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
512 MSG_ENTRY printclnt_sequence
[]={
515 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
518 MSG_ENTRY pseudomove_sequence
[]={
520 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
521 {2, WM_MOUSELEAVE
, POST
},
522 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
528 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
529 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
532 MSG_ENTRY pseudomove_nonthemed_sequence
[]={
534 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
535 {2, WM_MOUSELEAVE
, POST
},
536 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
540 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
541 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
544 MSG_ENTRY pseudohover_sequence
[]={
548 MSG_ENTRY pseudoleave_sequence
[]={
552 MSG_ENTRY mouseenter_sequence
[]={
556 {2, WM_MOUSEMOVE
, POST
},
557 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
563 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
564 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
567 MSG_ENTRY mouseenter_nonthemed_sequence
[]={
571 {2, WM_MOUSEMOVE
, POST
},
572 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
576 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
577 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
580 MSG_ENTRY mousemove_sequence
[]={
584 {2, WM_MOUSEMOVE
, POST
},
587 MSG_ENTRY mouseleave_sequence
[]={
588 {2, WM_MOUSELEAVE
, POST
},
589 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
595 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
596 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
599 MSG_ENTRY mouseleave_nonthemed_sequence
[]={
600 {2, WM_MOUSELEAVE
, POST
},
601 {1, WM_NOTIFY
, SENT
, 0, BCN_HOTITEMCHANGE
},
605 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
606 {1, WM_NOTIFY
, SENT
, 0, NM_CUSTOMDRAW
},
609 void Test_MessagesNonThemed()
613 RegisterSimpleClass(TestProc
, L
"testClass");
614 hWnd1
= CreateWindowW(L
"testClass", L
"Test parent", WS_POPUP
| WS_VISIBLE
, 100, 100, 200, 200, 0, NULL
, NULL
, NULL
);
615 ok (hWnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
616 SetWindowTheme(hWnd1
, L
"", L
"");
619 hWnd2
= CreateWindowW(L
"Button", L
"test button", /*BS_RADIOBUTTON | */WS_CHILD
| WS_VISIBLE
, 0, 0, 100, 100, hWnd1
, NULL
, NULL
, NULL
);
620 ok (hWnd2
!= NULL
, "Expected CreateWindowW to succeed\n");
621 SetWindowTheme(hWnd2
, L
"", L
"");
622 SetWindowSubclass(hWnd2
, subclass_proc
, 0, 0);
628 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_ERASE
);
630 COMPARE_CACHE(empty_chain
);
632 COMPARE_CACHE(empty_chain
);
634 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_FRAME
);
636 COMPARE_CACHE(empty_chain
);
638 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_INTERNALPAINT
);
640 COMPARE_CACHE(erase_nonthemed_sequence
);
642 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_INVALIDATE
);
644 COMPARE_CACHE(erase_nonthemed_sequence
);
646 SendMessageW(hWnd2
, WM_PRINTCLIENT
, 0, PRF_ERASEBKGND
);
648 COMPARE_CACHE(printclnt_nonthemed_sequence
);
650 SendMessageW(hWnd2
, WM_MOUSEMOVE
, 0, 0);
652 COMPARE_CACHE(pseudomove_nonthemed_sequence
);
654 SendMessageW(hWnd2
, WM_MOUSEHOVER
, 0, 0);
656 COMPARE_CACHE(pseudohover_sequence
);
658 SendMessageW(hWnd2
, WM_MOUSELEAVE
, 0, 0);
660 COMPARE_CACHE(pseudoleave_sequence
);
662 MOVE_CURSOR(150,150);
664 COMPARE_CACHE(mouseenter_nonthemed_sequence
);
666 MOVE_CURSOR(151,151);
668 COMPARE_CACHE(mousemove_sequence
);
672 COMPARE_CACHE(empty_chain
);
674 COMPARE_CACHE(mouseleave_nonthemed_sequence
);
676 DestroyWindow(hWnd1
);
677 DestroyWindow(hWnd2
);
680 void Test_MessagesThemed()
684 RegisterSimpleClass(TestProc
, L
"testClass");
685 hWnd1
= CreateWindowW(L
"testClass", L
"Test parent", WS_POPUP
| WS_VISIBLE
, 100, 100, 200, 200, 0, NULL
, NULL
, NULL
);
686 ok (hWnd1
!= NULL
, "Expected CreateWindowW to succeed\n");
689 hWnd2
= CreateWindowW(L
"Button", L
"test button", /*BS_RADIOBUTTON | */WS_CHILD
| WS_VISIBLE
, 0, 0, 100, 100, hWnd1
, NULL
, NULL
, NULL
);
690 ok (hWnd2
!= NULL
, "Expected CreateWindowW to succeed\n");
691 SetWindowSubclass(hWnd2
, subclass_proc
, 0, 0);
697 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_ERASE
);
699 COMPARE_CACHE(empty_chain
);
701 COMPARE_CACHE(empty_chain
);
703 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_FRAME
);
705 COMPARE_CACHE(empty_chain
);
707 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_INTERNALPAINT
);
709 COMPARE_CACHE(erase_sequence
);
711 RedrawWindow(hWnd2
, NULL
, NULL
, RDW_INVALIDATE
);
713 COMPARE_CACHE(erase_sequence
);
715 SendMessageW(hWnd2
, WM_PRINTCLIENT
, 0, PRF_ERASEBKGND
);
717 COMPARE_CACHE(printclnt_sequence
);
719 SendMessageW(hWnd2
, WM_MOUSEMOVE
, 0, 0);
721 COMPARE_CACHE(pseudomove_sequence
);
723 SendMessageW(hWnd2
, WM_MOUSEHOVER
, 0, 0);
725 COMPARE_CACHE(pseudohover_sequence
);
727 SendMessageW(hWnd2
, WM_MOUSELEAVE
, 0, 0);
729 COMPARE_CACHE(pseudoleave_sequence
);
731 MOVE_CURSOR(150,150);
733 COMPARE_CACHE(mouseenter_sequence
);
735 MOVE_CURSOR(151,151);
737 COMPARE_CACHE(mousemove_sequence
);
741 COMPARE_CACHE(empty_chain
);
743 COMPARE_CACHE(mouseleave_sequence
);
745 DestroyWindow(hWnd1
);
746 DestroyWindow(hWnd2
);
751 LoadLibraryW(L
"comctl32.dll"); /* same as statically linking to comctl32 and doing InitCommonControls */
754 Test_GetIdealSizeNoThemes();
756 Test_MessagesNonThemed();
758 Test_MessagesThemed();
760 skip("No active theme, skipping Test_MessagesThemed\n");