4 * Copyright 2006 Paul Vriens
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.
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.
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
25 #include "wine/test.h"
29 static PVOID (WINAPI
* pAlloc
)(LONG
);
30 static PVOID (WINAPI
* pReAlloc
)(PVOID
, LONG
);
31 static BOOL (WINAPI
* pFree
)(PVOID
);
32 static LONG (WINAPI
* pGetSize
)(PVOID
);
34 static INT (WINAPI
* pStr_GetPtrA
)(LPCSTR
, LPSTR
, INT
);
35 static BOOL (WINAPI
* pStr_SetPtrA
)(LPSTR
, LPCSTR
);
36 static INT (WINAPI
* pStr_GetPtrW
)(LPCWSTR
, LPWSTR
, INT
);
37 static BOOL (WINAPI
* pStr_SetPtrW
)(LPWSTR
, LPCWSTR
);
39 static BOOL (WINAPI
*pSetWindowSubclass
)(HWND
, SUBCLASSPROC
, UINT_PTR
, DWORD_PTR
);
40 static BOOL (WINAPI
*pRemoveWindowSubclass
)(HWND
, SUBCLASSPROC
, UINT_PTR
);
41 static LRESULT (WINAPI
*pDefSubclassProc
)(HWND
, UINT
, WPARAM
, LPARAM
);
43 static HMODULE hComctl32
;
45 /* For message tests */
53 static struct msg_sequence
*sequences
[NUM_MSG_SEQUENCES
];
55 static char testicon_data
[] =
57 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00,
58 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00,
59 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00,
60 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x12, 0x0b,
61 0x00, 0x00, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62 0x00, 0x00, 0xde, 0xde, 0xde, 0xff, 0xde, 0xde, 0xde, 0xff, 0xde, 0xde,
63 0xde, 0xff, 0xde, 0xde, 0xde, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67 #define COMCTL32_GET_PROC(ordinal, func) \
68 p ## func = (void*)GetProcAddress(hComctl32, (LPSTR)ordinal); \
70 trace("GetProcAddress(%d)(%s) failed\n", ordinal, #func); \
71 FreeLibrary(hComctl32); \
74 static BOOL
InitFunctionPtrs(void)
76 hComctl32
= LoadLibraryA("comctl32.dll");
80 trace("Could not load comctl32.dll\n");
84 COMCTL32_GET_PROC(71, Alloc
);
85 COMCTL32_GET_PROC(72, ReAlloc
);
86 COMCTL32_GET_PROC(73, Free
);
87 COMCTL32_GET_PROC(74, GetSize
);
89 COMCTL32_GET_PROC(233, Str_GetPtrA
)
90 COMCTL32_GET_PROC(234, Str_SetPtrA
)
91 COMCTL32_GET_PROC(235, Str_GetPtrW
)
92 COMCTL32_GET_PROC(236, Str_SetPtrW
)
97 static BOOL
init_functions_v6(void)
99 hComctl32
= LoadLibraryA("comctl32.dll");
102 trace("Could not load comctl32.dll version 6\n");
106 COMCTL32_GET_PROC(410, SetWindowSubclass
)
107 COMCTL32_GET_PROC(412, RemoveWindowSubclass
)
108 COMCTL32_GET_PROC(413, DefSubclassProc
)
113 /* try to make sure pending X events have been processed before continuing */
114 static void flush_events(void)
118 int min_timeout
= 100;
119 DWORD time
= GetTickCount() + diff
;
123 if (MsgWaitForMultipleObjects(0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
)
125 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
126 DispatchMessageA(&msg
);
127 diff
= time
- GetTickCount();
131 static void test_GetPtrAW(void)
135 static const char source
[] = "Just a source string";
136 static const char desttest
[] = "Just a destination string";
137 static char dest
[MAX_PATH
];
139 int destsize
= MAX_PATH
;
142 sourcelen
= strlen(source
) + 1;
144 count
= pStr_GetPtrA(NULL
, NULL
, 0);
145 ok (count
== 0, "Expected count to be 0, it was %d\n", count
);
149 /* Crashes on W98, NT4, W2K, XP, W2K3
150 * Our implementation also crashes and we should probably leave
153 count
= pStr_GetPtrA(NULL
, NULL
, destsize
);
154 trace("count : %d\n", count
);
157 count
= pStr_GetPtrA(source
, NULL
, 0);
158 ok (count
== sourcelen
||
159 broken(count
== sourcelen
- 1), /* win9x */
160 "Expected count to be %d, it was %d\n", sourcelen
, count
);
162 strcpy(dest
, desttest
);
163 count
= pStr_GetPtrA(source
, dest
, 0);
164 ok (count
== sourcelen
||
165 broken(count
== 0), /* win9x */
166 "Expected count to be %d, it was %d\n", sourcelen
, count
);
167 ok (!lstrcmpA(dest
, desttest
) ||
168 broken(!lstrcmpA(dest
, "")), /* Win7 */
169 "Expected destination to not have changed\n");
171 count
= pStr_GetPtrA(source
, NULL
, destsize
);
172 ok (count
== sourcelen
||
173 broken(count
== sourcelen
- 1), /* win9x */
174 "Expected count to be %d, it was %d\n", sourcelen
, count
);
176 count
= pStr_GetPtrA(source
, dest
, destsize
);
177 ok (count
== sourcelen
||
178 broken(count
== sourcelen
- 1), /* win9x */
179 "Expected count to be %d, it was %d\n", sourcelen
, count
);
180 ok (!lstrcmpA(source
, dest
), "Expected source and destination to be the same\n");
182 strcpy(dest
, desttest
);
183 count
= pStr_GetPtrA(NULL
, dest
, destsize
);
184 ok (count
== 0, "Expected count to be 0, it was %d\n", count
);
185 ok (dest
[0] == '\0', "Expected destination to be cut-off and 0 terminated\n");
188 count
= pStr_GetPtrA(source
, dest
, destsize
);
190 broken(count
== 14), /* win9x */
191 "Expected count to be 15, it was %d\n", count
);
192 ok (!memcmp(source
, dest
, 14), "Expected first part of source and destination to be the same\n");
193 ok (dest
[14] == '\0', "Expected destination to be cut-off and 0 terminated\n");
197 static void test_Alloc(void)
203 /* allocate size 0 */
205 ok(p
!= NULL
, "Expected non-NULL ptr\n");
207 /* get the minimum size */
212 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
214 /* allocate size 1 */
216 ok(p
!= NULL
, "Expected non-NULL ptr\n");
218 /* get the allocated size */
221 broken(size
== min
), /* win9x */
222 "Expected 1, got %ld\n", size
);
224 /* reallocate the block */
226 ok(p
!= NULL
, "Expected non-NULL ptr\n");
228 /* get the new size */
231 broken(size
== min
), /* win9x */
232 "Expected 2, got %ld\n", size
);
236 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
238 /* free a NULL ptr */
241 broken(res
== FALSE
), /* win9x */
242 "Expected TRUE, got %d\n", res
);
244 /* reallocate a NULL ptr */
245 p
= pReAlloc(NULL
, 2);
246 ok(p
!= NULL
, "Expected non-NULL ptr\n");
249 ok(res
== TRUE
, "Expected TRUE, got %d\n", res
);
252 static void test_LoadIconWithScaleDown(void)
254 HRESULT (WINAPI
*pLoadIconMetric
)(HINSTANCE
, const WCHAR
*, int, HICON
*);
255 HRESULT (WINAPI
*pLoadIconWithScaleDown
)(HINSTANCE
, const WCHAR
*, int, int, HICON
*);
256 WCHAR tmp_path
[MAX_PATH
], icon_path
[MAX_PATH
];
268 hinst
= LoadLibraryA("comctl32.dll");
269 pLoadIconMetric
= (void *)GetProcAddress(hinst
, "LoadIconMetric");
270 pLoadIconWithScaleDown
= (void *)GetProcAddress(hinst
, "LoadIconWithScaleDown");
271 if (!pLoadIconMetric
|| !pLoadIconWithScaleDown
)
273 win_skip("LoadIconMetric or pLoadIconWithScaleDown not exported by name\n");
278 GetTempPathW(MAX_PATH
, tmp_path
);
279 GetTempFileNameW(tmp_path
, L
"ICO", 0, icon_path
);
280 handle
= CreateFileW(icon_path
, GENERIC_READ
| GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
,
281 FILE_ATTRIBUTE_NORMAL
, NULL
);
282 ok(handle
!= INVALID_HANDLE_VALUE
, "CreateFileW failed with error %lu\n", GetLastError());
283 res
= WriteFile(handle
, testicon_data
, sizeof(testicon_data
), &written
, NULL
);
284 ok(res
&& written
== sizeof(testicon_data
), "Failed to write icon file\n");
288 ptr
= GetProcAddress(hinst
, (const char *)380);
289 ok(ptr
== pLoadIconMetric
,
290 "got wrong pointer for ordinal 380, %p expected %p\n", ptr
, pLoadIconMetric
);
292 ptr
= GetProcAddress(hinst
, (const char *)381);
293 ok(ptr
== pLoadIconWithScaleDown
,
294 "got wrong pointer for ordinal 381, %p expected %p\n", ptr
, pLoadIconWithScaleDown
);
296 /* invalid arguments */
297 icon
= (HICON
)0x1234;
298 hr
= pLoadIconMetric(NULL
, (LPWSTR
)IDI_APPLICATION
, 0x100, &icon
);
299 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %lx\n", hr
);
300 ok(icon
== NULL
, "Expected NULL, got %p\n", icon
);
302 icon
= (HICON
)0x1234;
303 hr
= pLoadIconMetric(NULL
, NULL
, LIM_LARGE
, &icon
);
304 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %lx\n", hr
);
305 ok(icon
== NULL
, "Expected NULL, got %p\n", icon
);
307 icon
= (HICON
)0x1234;
308 hr
= pLoadIconWithScaleDown(NULL
, NULL
, 32, 32, &icon
);
309 ok(hr
== E_INVALIDARG
, "Expected E_INVALIDARG, got %lx\n", hr
);
310 ok(icon
== NULL
, "Expected NULL, got %p\n", icon
);
312 /* non-existing filename */
313 hr
= pLoadIconMetric(NULL
, L
"nonexisting.ico", LIM_LARGE
, &icon
);
314 ok(hr
== HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
) || hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
) /* Win7 */,
315 "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %lx\n", hr
);
317 hr
= pLoadIconWithScaleDown(NULL
, L
"nonexisting.ico", 32, 32, &icon
);
319 ok(hr
== HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
),
320 "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %lx\n", hr
);
322 /* non-existing resource name */
323 hr
= pLoadIconMetric(hinst
, L
"Nonexisting", LIM_LARGE
, &icon
);
324 ok(hr
== HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
),
325 "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %lx\n", hr
);
327 hr
= pLoadIconWithScaleDown(hinst
, L
"Noneexisting", 32, 32, &icon
);
328 ok(hr
== HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND
),
329 "Expected HRESULT_FROM_WIN32(ERROR_RESOURCE_TYPE_NOT_FOUND), got %lx\n", hr
);
331 /* load icon using predefined identifier */
332 hr
= pLoadIconMetric(NULL
, (LPWSTR
)IDI_APPLICATION
, LIM_SMALL
, &icon
);
333 ok(hr
== S_OK
, "Expected S_OK, got %lx\n", hr
);
334 res
= GetIconInfo(icon
, &info
);
335 ok(res
, "Failed to get icon info, error %lu\n", GetLastError());
336 bytes
= GetObjectA(info
.hbmColor
, sizeof(bmp
), &bmp
);
337 ok(bytes
> 0, "Failed to get bitmap info for icon\n");
338 ok(bmp
.bmWidth
== GetSystemMetrics(SM_CXSMICON
), "Wrong icon width %d\n", bmp
.bmWidth
);
339 ok(bmp
.bmHeight
== GetSystemMetrics(SM_CYSMICON
), "Wrong icon height %d\n", bmp
.bmHeight
);
342 hr
= pLoadIconMetric(NULL
, (LPWSTR
)IDI_APPLICATION
, LIM_LARGE
, &icon
);
343 ok(hr
== S_OK
, "Expected S_OK, got %lx\n", hr
);
344 res
= GetIconInfo(icon
, &info
);
345 ok(res
, "Failed to get icon info, error %lu\n", GetLastError());
346 bytes
= GetObjectA(info
.hbmColor
, sizeof(bmp
), &bmp
);
347 ok(bytes
> 0, "Failed to get bitmap info for icon\n");
348 ok(bmp
.bmWidth
== GetSystemMetrics(SM_CXICON
), "Wrong icon width %d\n", bmp
.bmWidth
);
349 ok(bmp
.bmHeight
== GetSystemMetrics(SM_CYICON
), "Wrong icon height %d\n", bmp
.bmHeight
);
352 hr
= pLoadIconWithScaleDown(NULL
, (LPWSTR
)IDI_APPLICATION
, 42, 42, &icon
);
353 ok(hr
== S_OK
, "Expected S_OK, got %lx\n", hr
);
354 res
= GetIconInfo(icon
, &info
);
355 ok(res
, "Failed to get icon info, error %lu\n", GetLastError());
356 bytes
= GetObjectA(info
.hbmColor
, sizeof(bmp
), &bmp
);
357 ok(bytes
> 0, "Failed to get bitmap info for icon\n");
358 ok(bmp
.bmWidth
== 42, "Wrong icon width %d\n", bmp
.bmWidth
);
359 ok(bmp
.bmHeight
== 42, "Wrong icon height %d\n", bmp
.bmHeight
);
362 /* load icon from file */
363 hr
= pLoadIconMetric(NULL
, icon_path
, LIM_SMALL
, &icon
);
364 ok(hr
== S_OK
, "Expected S_OK, got %lx\n", hr
);
365 res
= GetIconInfo(icon
, &info
);
366 ok(res
, "Failed to get icon info, error %lu\n", GetLastError());
367 bytes
= GetObjectA(info
.hbmColor
, sizeof(bmp
), &bmp
);
368 ok(bytes
> 0, "Failed to get bitmap info for icon\n");
369 ok(bmp
.bmWidth
== GetSystemMetrics(SM_CXSMICON
), "Wrong icon width %d\n", bmp
.bmWidth
);
370 ok(bmp
.bmHeight
== GetSystemMetrics(SM_CYSMICON
), "Wrong icon height %d\n", bmp
.bmHeight
);
373 hr
= pLoadIconWithScaleDown(NULL
, icon_path
, 42, 42, &icon
);
374 ok(hr
== S_OK
, "Expected S_OK, got %lx\n", hr
);
375 res
= GetIconInfo(icon
, &info
);
376 ok(res
, "Failed to get icon info, error %lu\n", GetLastError());
377 bytes
= GetObjectA(info
.hbmColor
, sizeof(bmp
), &bmp
);
378 ok(bytes
> 0, "Failed to get bitmap info for icon\n");
379 ok(bmp
.bmWidth
== 42, "Wrong icon width %d\n", bmp
.bmWidth
);
380 ok(bmp
.bmHeight
== 42, "Wrong icon height %d\n", bmp
.bmHeight
);
383 DeleteFileW(icon_path
);
387 static void check_class( const char *name
, int must_exist
, UINT style
, UINT ignore
, BOOL v6
)
391 if (GetClassInfoA( 0, name
, &wc
))
396 todo_wine_if(!strcmp(name
, "SysLink") && !must_exist
&& !v6
)
397 ok( must_exist
, "System class %s should %sexist\n", name
, must_exist
? "" : "NOT " );
398 if (!must_exist
) return;
400 todo_wine_if(!strcmp(name
, "ScrollBar") || (!strcmp(name
, "tooltips_class32") && v6
))
401 ok( !(~wc
.style
& style
& ~ignore
), "System class %s is missing bits %x (%08x/%08x)\n",
402 name
, ~wc
.style
& style
, wc
.style
, style
);
403 todo_wine_if((!strcmp(name
, "tooltips_class32") && v6
) || !strcmp(name
, "SysLink"))
404 ok( !(wc
.style
& ~style
), "System class %s has extra bits %x (%08x/%08x)\n",
405 name
, wc
.style
& ~style
, wc
.style
, style
);
406 ok( !wc
.hInstance
, "System class %s has hInstance %p\n", name
, wc
.hInstance
);
408 hwnd
= CreateWindowA(name
, 0, 0, 0, 0, 0, 0, 0, NULL
, GetModuleHandleA(NULL
), 0);
409 ok( hwnd
!= NULL
, "Failed to create window for class %s.\n", name
);
410 GetClassNameA(hwnd
, buff
, ARRAY_SIZE(buff
));
411 ok( !strcmp(name
, buff
), "Unexpected class name %s, expected %s.\n", buff
, name
);
415 ok( !must_exist
, "System class %s does not exist\n", name
);
418 /* test styles of system classes */
419 static void test_builtin_classes(void)
421 /* check style bits */
422 check_class( "Button", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
423 check_class( "ComboBox", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
424 check_class( "Edit", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
425 check_class( "ListBox", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
426 check_class( "ScrollBar", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
427 check_class( "Static", 1, CS_PARENTDC
| CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
428 check_class( "ComboLBox", 1, CS_SAVEBITS
| CS_DBLCLKS
| CS_DROPSHADOW
| CS_GLOBALCLASS
, CS_DROPSHADOW
, FALSE
);
431 static void test_comctl32_classes(BOOL v6
)
433 check_class(ANIMATE_CLASSA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
434 check_class(WC_COMBOBOXEXA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
435 check_class(DATETIMEPICK_CLASSA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
436 check_class(WC_HEADERA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
437 check_class(HOTKEY_CLASSA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
438 check_class(WC_IPADDRESSA
, 1, CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
439 check_class(WC_LISTVIEWA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
440 check_class(MONTHCAL_CLASSA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
441 check_class(WC_NATIVEFONTCTLA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
442 check_class(WC_PAGESCROLLERA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
443 check_class(PROGRESS_CLASSA
, 1, CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
444 check_class(REBARCLASSNAMEA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
445 check_class(STATUSCLASSNAMEA
, 1, CS_DBLCLKS
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
446 check_class(WC_TABCONTROLA
, 1, CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
447 check_class(TOOLBARCLASSNAMEA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
449 check_class(TOOLTIPS_CLASSA
, 1, CS_DBLCLKS
| CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
| CS_DROPSHADOW
, CS_SAVEBITS
| CS_HREDRAW
| CS_VREDRAW
/* XP */, TRUE
);
451 check_class(TOOLTIPS_CLASSA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
| CS_SAVEBITS
, CS_HREDRAW
| CS_VREDRAW
/* XP */, FALSE
);
452 check_class(TRACKBAR_CLASSA
, 1, CS_GLOBALCLASS
, 0, FALSE
);
453 check_class(WC_TREEVIEWA
, 1, CS_DBLCLKS
| CS_GLOBALCLASS
, 0, FALSE
);
454 check_class(UPDOWN_CLASSA
, 1, CS_HREDRAW
| CS_VREDRAW
| CS_GLOBALCLASS
, 0, FALSE
);
455 check_class("SysLink", v6
, CS_GLOBALCLASS
, 0, FALSE
);
458 struct wm_themechanged_test
461 const struct message
*expected_msg
;
462 int ignored_msg_count
;
463 DWORD ignored_msgs
[16];
467 static BOOL
ignore_message(UINT msg
)
469 /* these are always ignored */
470 return (msg
>= 0xc000 ||
472 msg
== WM_GETOBJECT
||
473 msg
== WM_TIMECHANGE
||
474 msg
== WM_DISPLAYCHANGE
||
475 msg
== WM_DEVICECHANGE
||
476 msg
== WM_DWMNCRENDERINGCHANGED
||
477 msg
== WM_WININICHANGE
||
478 msg
== WM_CHILDACTIVATE
);
481 static LRESULT CALLBACK
test_wm_themechanged_proc(HWND hwnd
, UINT message
, WPARAM wParam
,
482 LPARAM lParam
, UINT_PTR id
, DWORD_PTR ref_data
)
484 const struct wm_themechanged_test
*test
= (const struct wm_themechanged_test
*)ref_data
;
485 static int defwndproc_counter
= 0;
486 struct message msg
= {0};
490 if (ignore_message(message
))
491 return pDefSubclassProc(hwnd
, message
, wParam
, lParam
);
493 /* Extra messages to be ignored for a test case */
494 for (i
= 0; i
< test
->ignored_msg_count
; ++i
)
496 if (message
== test
->ignored_msgs
[i
])
497 return pDefSubclassProc(hwnd
, message
, wParam
, lParam
);
500 msg
.message
= message
;
501 msg
.flags
= sent
| wparam
| lparam
;
502 if (defwndproc_counter
)
503 msg
.flags
|= defwinproc
;
506 add_message(sequences
, CHILD_SEQ_INDEX
, &msg
);
508 if (message
== WM_NCDESTROY
)
509 pRemoveWindowSubclass(hwnd
, test_wm_themechanged_proc
, 0);
511 ++defwndproc_counter
;
512 ret
= pDefSubclassProc(hwnd
, message
, wParam
, lParam
);
513 --defwndproc_counter
;
518 static HWND
create_control(const char *class, DWORD style
, HWND parent
, DWORD_PTR data
)
524 hwnd
= CreateWindowExA(0, class, "test", style
, 0, 0, 50, 20, parent
, 0, 0, NULL
);
525 ok(!!hwnd
, "Failed to create %s style %#lx parent %p\n", class, style
, parent
);
526 pSetWindowSubclass(hwnd
, test_wm_themechanged_proc
, 0, data
);
530 static const struct message wm_themechanged_paint_erase_seq
[] =
532 {WM_THEMECHANGED
, sent
| wparam
| lparam
},
533 {WM_PAINT
, sent
| wparam
| lparam
},
534 /* TestBot w7u_2qxl VM occasionally doesn't send WM_ERASEBKGND, hence the 'optional' */
535 {WM_ERASEBKGND
, sent
| defwinproc
| optional
},
539 static const struct message wm_themechanged_paint_seq
[] =
541 {WM_THEMECHANGED
, sent
| wparam
| lparam
},
542 {WM_PAINT
, sent
| wparam
| lparam
},
546 static const struct message wm_themechanged_no_paint_seq
[] =
548 {WM_THEMECHANGED
, sent
| wparam
| lparam
},
552 static void test_WM_THEMECHANGED(void)
558 static const struct wm_themechanged_test tests
[] =
560 {ANIMATE_CLASSA
, wm_themechanged_no_paint_seq
},
561 {WC_BUTTONA
, wm_themechanged_paint_erase_seq
, 2, {WM_GETTEXT
, WM_GETTEXTLENGTH
}},
562 {WC_COMBOBOXA
, wm_themechanged_paint_erase_seq
, 1, {WM_CTLCOLOREDIT
}},
563 {WC_COMBOBOXEXA
, wm_themechanged_no_paint_seq
},
564 {DATETIMEPICK_CLASSA
, wm_themechanged_paint_erase_seq
},
565 {WC_EDITA
, wm_themechanged_paint_erase_seq
, 7, {WM_GETTEXTLENGTH
, WM_GETFONT
, EM_GETSEL
, EM_GETRECT
, EM_CHARFROMPOS
, EM_LINEFROMCHAR
, EM_POSFROMCHAR
}},
566 {WC_HEADERA
, wm_themechanged_paint_erase_seq
},
567 {HOTKEY_CLASSA
, wm_themechanged_no_paint_seq
},
568 {WC_IPADDRESSA
, wm_themechanged_paint_erase_seq
, 1, {WM_CTLCOLOREDIT
}},
569 {WC_LISTBOXA
, wm_themechanged_paint_erase_seq
},
570 {WC_LISTVIEWA
, wm_themechanged_paint_erase_seq
},
571 {MONTHCAL_CLASSA
, wm_themechanged_paint_erase_seq
},
572 {WC_NATIVEFONTCTLA
, wm_themechanged_no_paint_seq
},
573 {WC_PAGESCROLLERA
, wm_themechanged_paint_erase_seq
},
574 {PROGRESS_CLASSA
, wm_themechanged_paint_erase_seq
, 3, {WM_STYLECHANGING
, WM_STYLECHANGED
, WM_NCPAINT
}},
575 {REBARCLASSNAMEA
, wm_themechanged_no_paint_seq
, 1, {WM_WINDOWPOSCHANGING
}},
576 {WC_STATICA
, wm_themechanged_paint_erase_seq
, 2, {WM_GETTEXT
, WM_GETTEXTLENGTH
}},
577 {STATUSCLASSNAMEA
, wm_themechanged_paint_erase_seq
},
578 {"SysLink", wm_themechanged_no_paint_seq
},
579 {WC_TABCONTROLA
, wm_themechanged_paint_erase_seq
},
580 {TOOLBARCLASSNAMEA
, wm_themechanged_paint_erase_seq
, 1, {WM_WINDOWPOSCHANGING
}},
581 {TOOLTIPS_CLASSA
, wm_themechanged_no_paint_seq
},
582 {TRACKBAR_CLASSA
, wm_themechanged_paint_seq
},
583 {WC_TREEVIEWA
, wm_themechanged_paint_erase_seq
, 1, {0x1128}},
584 {UPDOWN_CLASSA
, wm_themechanged_paint_erase_seq
, 1, {WM_NCPAINT
}},
585 {WC_SCROLLBARA
, wm_themechanged_paint_erase_seq
, 1, {SBM_GETSCROLLINFO
}},
588 parent
= CreateWindowExA(0, WC_STATICA
, "parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, 100, 100,
589 200, 200, 0, 0, 0, NULL
);
590 ok(!!parent
, "Failed to create parent window\n");
592 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
594 child
= create_control(tests
[i
].class, WS_VISIBLE
, parent
, (DWORD_PTR
)&tests
[i
]);
596 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
598 SendMessageW(child
, WM_THEMECHANGED
, 0, 0);
601 sprintf(buffer
, "Test %d class %s WM_THEMECHANGED", i
, tests
[i
].class);
602 ok_sequence(sequences
, CHILD_SEQ_INDEX
, tests
[i
].expected_msg
, buffer
, tests
[i
].todo
);
603 DestroyWindow(child
);
606 DestroyWindow(parent
);
609 static const struct message wm_syscolorchange_seq
[] =
611 {WM_SYSCOLORCHANGE
, sent
| wparam
| lparam
},
615 static INT_PTR CALLBACK
wm_syscolorchange_dlg_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
617 struct message msg
= {0};
619 msg
.message
= message
;
620 msg
.flags
= sent
| wparam
| lparam
;
623 add_message(sequences
, CHILD_SEQ_INDEX
, &msg
);
627 static void test_WM_SYSCOLORCHANGE(void)
638 parent
= CreateWindowExA(0, WC_STATICA
, "parent", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
, 100, 100,
639 200, 200, 0, 0, 0, NULL
);
640 ok(!!parent
, "CreateWindowExA failed, error %ld\n", GetLastError());
642 temp
.tmplate
.style
= WS_CHILD
| WS_VISIBLE
;
643 temp
.tmplate
.cx
= 50;
644 temp
.tmplate
.cy
= 50;
645 dialog
= CreateDialogIndirectParamA(NULL
, &temp
.tmplate
, parent
, wm_syscolorchange_dlg_proc
, 0);
646 ok(!!dialog
, "CreateDialogIndirectParamA failed, error %ld\n", GetLastError());
648 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
650 SendMessageW(dialog
, WM_SYSCOLORCHANGE
, 0, 0);
651 ok_sequence(sequences
, CHILD_SEQ_INDEX
, wm_syscolorchange_seq
, "test dialog WM_SYSCOLORCHANGE", FALSE
);
653 EndDialog(dialog
, 0);
654 DestroyWindow(parent
);
657 static const struct message empty_seq
[] =
662 static const struct message wm_erasebkgnd_seq
[] =
664 {WM_ERASEBKGND
, sent
},
668 static const struct message wm_ctlcolorstatic_seq
[] =
670 {WM_CTLCOLORSTATIC
, sent
},
674 static const struct message drawthemeparentbackground_seq
[] =
676 {WM_ERASEBKGND
, sent
},
677 {WM_PRINTCLIENT
, sent
},
681 static const struct message drawthemeparentbackground_optional_seq
[] =
683 {WM_ERASEBKGND
, sent
| optional
},
684 {WM_PRINTCLIENT
, sent
| optional
},
688 static const struct message pushbutton_seq
[] =
690 {WM_ERASEBKGND
, sent
},
691 {WM_PRINTCLIENT
, sent
},
692 {WM_CTLCOLORBTN
, sent
},
696 static const struct message defpushbutton_seq
[] =
698 {WM_ERASEBKGND
, sent
},
699 {WM_PRINTCLIENT
, sent
},
700 {WM_CTLCOLORBTN
, sent
},
701 {WM_ERASEBKGND
, sent
| optional
},
702 {WM_PRINTCLIENT
, sent
| optional
},
703 {WM_CTLCOLORBTN
, sent
| optional
},
707 static const struct message checkbox_seq
[] =
709 {WM_ERASEBKGND
, sent
| optional
},
710 {WM_PRINTCLIENT
, sent
| optional
},
711 {WM_CTLCOLORSTATIC
, sent
},
715 static const struct message radiobutton_seq
[] =
717 {WM_ERASEBKGND
, sent
},
718 {WM_PRINTCLIENT
, sent
},
719 {WM_CTLCOLORSTATIC
, sent
},
723 static const struct message groupbox_seq
[] =
725 {WM_CTLCOLORSTATIC
, sent
},
726 {WM_ERASEBKGND
, sent
},
727 {WM_PRINTCLIENT
, sent
},
731 static const struct message ownerdrawbutton_seq
[] =
733 {WM_CTLCOLORBTN
, sent
},
734 {WM_CTLCOLORBTN
, sent
},
738 static const struct message splitbutton_seq
[] =
740 {WM_ERASEBKGND
, sent
},
741 {WM_PRINTCLIENT
, sent
},
742 /* Either WM_CTLCOLORSTATIC or WM_CTLCOLORBTN */
743 {WM_CTLCOLORSTATIC
, sent
| optional
},
744 {WM_CTLCOLORBTN
, sent
| optional
},
745 /* BS_DEFSPLITBUTTON or BS_DEFCOMMANDLINK */
746 {WM_ERASEBKGND
, sent
| optional
},
747 {WM_PRINTCLIENT
, sent
| optional
},
748 {WM_CTLCOLORSTATIC
, sent
| optional
},
749 {WM_CTLCOLORBTN
, sent
| optional
},
753 static const struct message combobox_seq
[] =
755 {WM_ERASEBKGND
, sent
| optional
},
756 {WM_PRINTCLIENT
, sent
| optional
},
757 {WM_CTLCOLOREDIT
, sent
},
758 {WM_CTLCOLORLISTBOX
, sent
},
759 {WM_CTLCOLORLISTBOX
, sent
| optional
},
760 {WM_CTLCOLOREDIT
, sent
| optional
},
761 {WM_CTLCOLOREDIT
, sent
| optional
},
765 static const struct message edit_seq
[] =
767 {WM_CTLCOLOREDIT
, sent
},
768 {WM_CTLCOLOREDIT
, sent
| optional
},
772 static const struct message listbox_seq
[] =
774 {WM_CTLCOLORLISTBOX
, sent
},
775 {WM_CTLCOLORLISTBOX
, sent
},
779 static const struct message treeview_seq
[] =
781 {WM_CTLCOLOREDIT
, sent
| optional
},
782 {WM_CTLCOLOREDIT
, sent
| optional
},
786 static const struct message scrollbar_seq
[] =
788 {WM_CTLCOLORSCROLLBAR
, sent
},
789 {WM_CTLCOLORSCROLLBAR
, sent
| optional
},
793 static LRESULT WINAPI
test_themed_background_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
795 struct message msg
= {0};
799 if (message
== WM_ERASEBKGND
|| message
== WM_PRINTCLIENT
|| (message
>= WM_CTLCOLORMSGBOX
800 && message
<= WM_CTLCOLORSTATIC
))
802 msg
.message
= message
;
804 add_message(sequences
, PARENT_SEQ_INDEX
, &msg
);
807 if (message
== WM_ERASEBKGND
)
809 brush
= CreateSolidBrush(RGB(255, 0, 0));
810 GetClientRect(hwnd
, &rect
);
811 FillRect((HDC
)wp
, &rect
, brush
);
815 else if (message
>= WM_CTLCOLORMSGBOX
&& message
<= WM_CTLCOLORSTATIC
)
817 return (LRESULT
)GetStockObject(GRAY_BRUSH
);
820 return DefWindowProcA(hwnd
, message
, wp
, lp
);
823 static void test_themed_background(void)
825 DPI_AWARENESS_CONTEXT (WINAPI
*pSetThreadDpiAwarenessContext
)(DPI_AWARENESS_CONTEXT
);
826 DPI_AWARENESS_CONTEXT old_context
= NULL
;
827 BOOL (WINAPI
*pIsThemeActive
)(void);
835 static const struct test
837 const CHAR
*class_name
;
839 const struct message
*seq
;
844 {ANIMATE_CLASSA
, 0, empty_seq
, TRUE
},
845 {WC_BUTTONA
, BS_PUSHBUTTON
, pushbutton_seq
},
846 {WC_BUTTONA
, BS_DEFPUSHBUTTON
, defpushbutton_seq
},
847 {WC_BUTTONA
, BS_CHECKBOX
, checkbox_seq
},
848 {WC_BUTTONA
, BS_AUTOCHECKBOX
, checkbox_seq
},
849 {WC_BUTTONA
, BS_RADIOBUTTON
, radiobutton_seq
},
850 {WC_BUTTONA
, BS_3STATE
, checkbox_seq
},
851 {WC_BUTTONA
, BS_AUTO3STATE
, checkbox_seq
},
852 {WC_BUTTONA
, BS_GROUPBOX
, groupbox_seq
},
853 {WC_BUTTONA
, BS_USERBUTTON
, pushbutton_seq
},
854 {WC_BUTTONA
, BS_AUTORADIOBUTTON
, radiobutton_seq
},
855 {WC_BUTTONA
, BS_PUSHBOX
, radiobutton_seq
, TRUE
},
856 {WC_BUTTONA
, BS_OWNERDRAW
, ownerdrawbutton_seq
},
857 {WC_BUTTONA
, BS_SPLITBUTTON
, splitbutton_seq
},
858 {WC_BUTTONA
, BS_DEFSPLITBUTTON
, splitbutton_seq
},
859 {WC_BUTTONA
, BS_COMMANDLINK
, splitbutton_seq
},
860 {WC_BUTTONA
, BS_DEFCOMMANDLINK
, splitbutton_seq
},
861 {WC_COMBOBOXA
, 0, combobox_seq
, TRUE
},
862 {WC_COMBOBOXEXA
, 0, drawthemeparentbackground_optional_seq
},
863 {DATETIMEPICK_CLASSA
, 0, drawthemeparentbackground_optional_seq
, TRUE
},
864 {WC_EDITA
, 0, edit_seq
},
865 {WC_HEADERA
, 0, empty_seq
},
866 {HOTKEY_CLASSA
, 0, empty_seq
, TRUE
},
867 {WC_IPADDRESSA
, 0, empty_seq
},
868 {WC_LISTBOXA
, 0, listbox_seq
, TRUE
},
869 {WC_LISTVIEWA
, 0, empty_seq
},
870 {MONTHCAL_CLASSA
, 0, empty_seq
},
871 {WC_NATIVEFONTCTLA
, 0, empty_seq
},
872 {WC_PAGESCROLLERA
, 0, wm_erasebkgnd_seq
},
873 {PROGRESS_CLASSA
, 0, drawthemeparentbackground_optional_seq
},
874 {REBARCLASSNAMEA
, 0, empty_seq
},
875 {WC_STATICA
, SS_LEFT
, wm_ctlcolorstatic_seq
},
876 {WC_STATICA
, SS_ICON
, wm_ctlcolorstatic_seq
},
877 {WC_STATICA
, SS_BLACKRECT
, wm_ctlcolorstatic_seq
},
878 {WC_STATICA
, SS_OWNERDRAW
, wm_ctlcolorstatic_seq
},
879 {WC_STATICA
, SS_BITMAP
, wm_ctlcolorstatic_seq
},
880 {WC_STATICA
, SS_ENHMETAFILE
, wm_ctlcolorstatic_seq
},
881 {WC_STATICA
, SS_ETCHEDHORZ
, wm_ctlcolorstatic_seq
},
882 {STATUSCLASSNAMEA
, 0, empty_seq
},
883 {"SysLink", 0, wm_ctlcolorstatic_seq
},
884 {WC_TABCONTROLA
, 0, drawthemeparentbackground_seq
},
885 {TOOLBARCLASSNAMEA
, 0, empty_seq
, TRUE
},
886 {TOOLTIPS_CLASSA
, 0, empty_seq
},
887 {TRACKBAR_CLASSA
, 0, wm_ctlcolorstatic_seq
},
888 {WC_TREEVIEWA
, 0, treeview_seq
},
889 {UPDOWN_CLASSA
, 0, empty_seq
},
890 {WC_SCROLLBARA
, 0, scrollbar_seq
},
891 {WC_SCROLLBARA
, SBS_SIZEBOX
, empty_seq
},
892 {WC_SCROLLBARA
, SBS_SIZEGRIP
, empty_seq
},
893 /* Scrollbars in non-client area */
894 {"ChildClass", WS_HSCROLL
, empty_seq
},
895 {"ChildClass", WS_VSCROLL
, empty_seq
},
898 uxtheme
= LoadLibraryA("uxtheme.dll");
899 pIsThemeActive
= (void *)GetProcAddress(uxtheme
, "IsThemeActive");
900 if (!pIsThemeActive())
902 skip("Theming is inactive.\n");
903 FreeLibrary(uxtheme
);
906 FreeLibrary(uxtheme
);
908 pSetThreadDpiAwarenessContext
= (void *)GetProcAddress(GetModuleHandleA("user32.dll"),
909 "SetThreadDpiAwarenessContext");
910 if (pSetThreadDpiAwarenessContext
)
911 pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE
);
913 memset(&cls
, 0, sizeof(cls
));
914 cls
.hInstance
= GetModuleHandleA(0);
915 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
916 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
917 cls
.lpfnWndProc
= test_themed_background_proc
;
918 cls
.lpszClassName
= "ParentClass";
919 RegisterClassA(&cls
);
921 cls
.lpfnWndProc
= DefWindowProcA
;
922 cls
.lpszClassName
= "ChildClass";
923 RegisterClassA(&cls
);
925 parent
= CreateWindowA("ParentClass", "parent", WS_POPUP
| WS_VISIBLE
, 100, 100, 100, 100,
927 ok(parent
!= NULL
, "CreateWindowA failed, error %lu.\n", GetLastError());
929 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
931 winetest_push_context("%s %#lx", tests
[i
].class_name
, tests
[i
].style
);
933 child
= CreateWindowA(tests
[i
].class_name
, " ", WS_CHILD
| WS_VISIBLE
| tests
[i
].style
,
934 0, 0, 50, 100, parent
, 0, 0, 0);
935 ok(child
!= NULL
, "CreateWindowA failed, error %lu.\n", GetLastError());
937 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
939 RedrawWindow(child
, NULL
, NULL
, RDW_INVALIDATE
| RDW_ERASE
| RDW_UPDATENOW
| RDW_ERASENOW
| RDW_FRAME
);
940 ok_sequence(sequences
, PARENT_SEQ_INDEX
, tests
[i
].seq
, "paint background", tests
[i
].todo
);
942 /* For message sequences that contain both DrawThemeParentBackground() messages and
943 * WM_CTLCOLOR*, do a color test to check which is really in effect for controls that can be
944 * tested automatically. For WM_ERASEBKGND from DrawThemeParentBackground(), a red brush is
945 * used. For WM_CTLCOLOR*, a gray brush is returned. If there are only WM_CTLCOLOR* messages
946 * in the message sequence, then surely DrawThemeParentBackground() is not used.
948 * For tests that use pushbutton_seq and defpushbutton_seq, manual tests on XP show that
949 * a brush from WM_CTLCOLORBTN is used to fill background even after a successful
950 * DrawThemeParentBackground(). This behavior can be verified by returning a gray or hollow
951 * brush in test_themed_background_proc() when handling WM_CTLCOLORBTN. It can't be tested
952 * automatically here because stock Windows themes don't use transparent button bitmaps */
953 if (tests
[i
].seq
== radiobutton_seq
|| tests
[i
].seq
== groupbox_seq
)
957 if (tests
[i
].seq
== radiobutton_seq
)
959 /* WM_CTLCOLORSTATIC is used to fill background */
960 color
= GetPixel(hdc
, 40, 40);
961 /* BS_PUSHBOX is unimplemented on Wine */
962 todo_wine_if(i
== 11)
963 ok(color
== 0x808080, "Expected color %#x, got %#lx.\n", 0x808080, color
);
965 else if (tests
[i
].seq
== groupbox_seq
)
967 /* DrawThemeParentBackground() is used to fill content background */
968 color
= GetPixel(hdc
, 40, 40);
969 ok(color
== 0xff, "Expected color %#x, got %#lx.\n", 0xff, color
);
971 /* WM_CTLCOLORSTATIC is used to fill text background */
972 color
= GetPixel(hdc
, 10, 10);
973 ok(color
== 0x808080, "Expected color %#x, got %#lx.\n", 0x808080, color
);
975 else if (tests
[i
].seq
== scrollbar_seq
)
977 /* WM_CTLCOLORSCROLLBAR is used to fill tracks only */
978 color
= GetPixel(hdc
, 10, 10);
979 ok(color
!= RGB(255, 0, 0), "Got unexpected color %#08lx.\n", color
);
981 color
= GetPixel(hdc
, 10, 60);
982 ok(color
== RGB(255, 0, 0) || broken(color
== CLR_INVALID
), /* Win7 on TestBots */
983 "Got unexpected color %#08lx.\n", color
);
986 ReleaseDC(child
, hdc
);
989 DestroyWindow(child
);
990 winetest_pop_context();
993 DestroyWindow(parent
);
994 UnregisterClassA("ChildClass", GetModuleHandleA(0));
995 UnregisterClassA("ParentClass", GetModuleHandleA(0));
996 if (pSetThreadDpiAwarenessContext
)
997 pSetThreadDpiAwarenessContext(old_context
);
1000 static WNDPROC old_proc
;
1002 static const struct message wm_stylechanged_seq
[] =
1004 {WM_STYLECHANGED
, sent
},
1008 static const struct message wm_stylechanged_repaint_seq
[] =
1010 {WM_STYLECHANGED
, sent
},
1012 {WM_ERASEBKGND
, sent
| defwinproc
},
1016 static const struct message wm_stylechanged_combox_seq
[] =
1018 {WM_STYLECHANGED
, sent
},
1019 {WM_ERASEBKGND
, sent
| defwinproc
},
1024 static const struct message wm_stylechanged_pager_seq
[] =
1026 {WM_STYLECHANGED
, sent
},
1028 {WM_NCPAINT
, sent
| defwinproc
},
1029 {WM_ERASEBKGND
, sent
| defwinproc
},
1033 static const struct message wm_stylechanged_progress_seq
[] =
1035 {WM_STYLECHANGED
, sent
},
1036 {WM_PAINT
, sent
| optional
}, /* WM_PAINT and WM_ERASEBKGND are missing with comctl32 v5 */
1037 {WM_ERASEBKGND
, sent
| defwinproc
| optional
},
1041 static const struct message wm_stylechanged_trackbar_seq
[] =
1043 {WM_STYLECHANGED
, sent
},
1044 {WM_PAINT
, sent
| defwinproc
},
1049 static LRESULT WINAPI
test_wm_stylechanged_proc(HWND hwnd
, UINT message
, WPARAM wp
, LPARAM lp
)
1051 static int defwndproc_counter
= 0;
1052 struct message msg
= {0};
1055 if (message
== WM_STYLECHANGED
1056 || message
== WM_PAINT
1057 || message
== WM_ERASEBKGND
1058 || message
== WM_NCPAINT
)
1060 msg
.message
= message
;
1061 msg
.flags
= sent
| wparam
| lparam
;
1062 if (defwndproc_counter
)
1063 msg
.flags
|= defwinproc
;
1066 add_message(sequences
, CHILD_SEQ_INDEX
, &msg
);
1069 ++defwndproc_counter
;
1070 ret
= CallWindowProcA(old_proc
, hwnd
, message
, wp
, lp
);
1071 --defwndproc_counter
;
1075 static void test_WM_STYLECHANGED(void)
1081 static const struct test
1083 const CHAR
*class_name
;
1084 const struct message
*seq
;
1089 {ANIMATE_CLASSA
, wm_stylechanged_seq
, TRUE
},
1090 {WC_BUTTONA
, wm_stylechanged_seq
},
1091 {WC_COMBOBOXA
, wm_stylechanged_combox_seq
, TRUE
},
1092 {WC_COMBOBOXEXA
, wm_stylechanged_seq
},
1093 {DATETIMEPICK_CLASSA
, wm_stylechanged_seq
, TRUE
},
1094 {WC_EDITA
, wm_stylechanged_seq
},
1095 {WC_HEADERA
, wm_stylechanged_repaint_seq
, TRUE
},
1096 {HOTKEY_CLASSA
, wm_stylechanged_seq
},
1097 {WC_IPADDRESSA
, wm_stylechanged_seq
},
1098 {WC_LISTBOXA
, wm_stylechanged_repaint_seq
, TRUE
},
1099 {WC_LISTVIEWA
, wm_stylechanged_seq
, TRUE
},
1100 {MONTHCAL_CLASSA
, wm_stylechanged_repaint_seq
, TRUE
},
1101 {WC_NATIVEFONTCTLA
, wm_stylechanged_seq
},
1102 {WC_PAGESCROLLERA
, wm_stylechanged_pager_seq
, TRUE
},
1103 {PROGRESS_CLASSA
, wm_stylechanged_progress_seq
},
1104 {REBARCLASSNAMEA
, wm_stylechanged_seq
},
1105 {WC_STATICA
, wm_stylechanged_seq
},
1106 {STATUSCLASSNAMEA
, wm_stylechanged_seq
},
1107 {"SysLink", wm_stylechanged_seq
, TRUE
},
1108 {WC_TABCONTROLA
, wm_stylechanged_seq
, TRUE
},
1109 {TOOLBARCLASSNAMEA
, wm_stylechanged_seq
},
1110 {TOOLTIPS_CLASSA
, wm_stylechanged_seq
},
1111 {TRACKBAR_CLASSA
, wm_stylechanged_trackbar_seq
, TRUE
},
1112 {WC_TREEVIEWA
, wm_stylechanged_seq
},
1113 {UPDOWN_CLASSA
, wm_stylechanged_seq
, TRUE
},
1114 {WC_SCROLLBARA
, wm_stylechanged_seq
},
1117 parent
= CreateWindowA(WC_STATICA
, "parent", WS_POPUP
| WS_VISIBLE
, 100, 100, 100, 100,
1119 ok(parent
!= NULL
, "CreateWindowA failed, error %lu.\n", GetLastError());
1121 for (i
= 0; i
< ARRAY_SIZE(tests
); ++i
)
1123 winetest_push_context("%s", tests
[i
].class_name
);
1125 hwnd
= CreateWindowA(tests
[i
].class_name
, "test", WS_CHILD
| WS_VISIBLE
, 0, 0, 50, 50,
1127 /* SysLink is unavailable in comctl32 v5 */
1128 if (!hwnd
&& !lstrcmpA(tests
[i
].class_name
, "SysLink"))
1130 winetest_pop_context();
1133 ok(hwnd
!= NULL
, "CreateWindowA failed, error %lu.\n", GetLastError());
1134 old_proc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)test_wm_stylechanged_proc
);
1135 ok(old_proc
!= NULL
, "SetWindowLongPtrA failed, error %lu.\n", GetLastError());
1137 flush_sequences(sequences
, NUM_MSG_SEQUENCES
);
1139 style
.styleOld
= GetWindowLongA(hwnd
, GWL_STYLE
);
1140 style
.styleNew
= style
.styleOld
| WS_TABSTOP
;
1141 SendMessageA(hwnd
, WM_STYLECHANGED
, GWL_STYLE
, (LPARAM
)&style
);
1143 ok_sequence(sequences
, CHILD_SEQ_INDEX
, tests
[i
].seq
, "WM_STYLECHANGED", tests
[i
].todo
);
1145 DestroyWindow(hwnd
);
1146 winetest_pop_context();
1149 DestroyWindow(parent
);
1154 ULONG_PTR ctx_cookie
;
1157 init_msg_sequences(sequences
, NUM_MSG_SEQUENCES
);
1158 if(!InitFunctionPtrs())
1163 test_comctl32_classes(FALSE
);
1164 test_WM_STYLECHANGED();
1166 FreeLibrary(hComctl32
);
1168 if (!load_v6_module(&ctx_cookie
, &hCtx
))
1170 if(!init_functions_v6())
1173 test_comctl32_classes(TRUE
);
1174 test_builtin_classes();
1175 test_LoadIconWithScaleDown();
1176 test_themed_background();
1177 test_WM_THEMECHANGED();
1178 test_WM_SYSCOLORCHANGE();
1179 test_WM_STYLECHANGED();
1181 unload_v6_module(ctx_cookie
, hCtx
);
1182 FreeLibrary(hComctl32
);