opengl32: Correctly interpret glMapBuffer() access in wow64 mapping.
[wine.git] / dlls / comctl32 / tests / misc.c
blobd128c202c67397e6194ed030a1e344fb6e4f3dd1
1 /*
2 * Misc tests
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
21 #include <stdio.h>
22 #include <windows.h>
23 #include <commctrl.h>
25 #include "wine/test.h"
26 #include "v6util.h"
27 #include "msg.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 */
46 enum seq_index
48 CHILD_SEQ_INDEX,
49 PARENT_SEQ_INDEX,
50 NUM_MSG_SEQUENCES
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,
64 0x00, 0x00
67 #define COMCTL32_GET_PROC(ordinal, func) \
68 p ## func = (void*)GetProcAddress(hComctl32, (LPSTR)ordinal); \
69 if(!p ## func) { \
70 trace("GetProcAddress(%d)(%s) failed\n", ordinal, #func); \
71 FreeLibrary(hComctl32); \
74 static BOOL InitFunctionPtrs(void)
76 hComctl32 = LoadLibraryA("comctl32.dll");
78 if(!hComctl32)
80 trace("Could not load comctl32.dll\n");
81 return FALSE;
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)
94 return TRUE;
97 static BOOL init_functions_v6(void)
99 hComctl32 = LoadLibraryA("comctl32.dll");
100 if (!hComctl32)
102 trace("Could not load comctl32.dll version 6\n");
103 return FALSE;
106 COMCTL32_GET_PROC(410, SetWindowSubclass)
107 COMCTL32_GET_PROC(412, RemoveWindowSubclass)
108 COMCTL32_GET_PROC(413, DefSubclassProc)
110 return TRUE;
113 /* try to make sure pending X events have been processed before continuing */
114 static void flush_events(void)
116 MSG msg;
117 int diff = 200;
118 int min_timeout = 100;
119 DWORD time = GetTickCount() + diff;
121 while (diff > 0)
123 if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT)
124 break;
125 while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
126 DispatchMessageA(&msg);
127 diff = time - GetTickCount();
131 static void test_GetPtrAW(void)
133 if (pStr_GetPtrA)
135 static const char source[] = "Just a source string";
136 static const char desttest[] = "Just a destination string";
137 static char dest[MAX_PATH];
138 int sourcelen;
139 int destsize = MAX_PATH;
140 int count;
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);
147 if (0)
149 /* Crashes on W98, NT4, W2K, XP, W2K3
150 * Our implementation also crashes and we should probably leave
151 * it like that.
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");
187 destsize = 15;
188 count = pStr_GetPtrA(source, dest, destsize);
189 ok (count == 15 ||
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)
199 PCHAR p;
200 BOOL res;
201 DWORD size, min;
203 /* allocate size 0 */
204 p = pAlloc(0);
205 ok(p != NULL, "Expected non-NULL ptr\n");
207 /* get the minimum size */
208 min = pGetSize(p);
210 /* free the block */
211 res = pFree(p);
212 ok(res == TRUE, "Expected TRUE, got %d\n", res);
214 /* allocate size 1 */
215 p = pAlloc(1);
216 ok(p != NULL, "Expected non-NULL ptr\n");
218 /* get the allocated size */
219 size = pGetSize(p);
220 ok(size == 1 ||
221 broken(size == min), /* win9x */
222 "Expected 1, got %ld\n", size);
224 /* reallocate the block */
225 p = pReAlloc(p, 2);
226 ok(p != NULL, "Expected non-NULL ptr\n");
228 /* get the new size */
229 size = pGetSize(p);
230 ok(size == 2 ||
231 broken(size == min), /* win9x */
232 "Expected 2, got %ld\n", size);
234 /* free the block */
235 res = pFree(p);
236 ok(res == TRUE, "Expected TRUE, got %d\n", res);
238 /* free a NULL ptr */
239 res = pFree(NULL);
240 ok(res == TRUE ||
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");
248 res = pFree(p);
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];
257 ICONINFO info;
258 HMODULE hinst;
259 HANDLE handle;
260 DWORD written;
261 HRESULT hr;
262 BITMAP bmp;
263 HICON icon;
264 void *ptr;
265 int bytes;
266 BOOL res;
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");
274 FreeLibrary(hinst);
275 return;
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");
285 CloseHandle(handle);
287 /* test ordinals */
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);
318 todo_wine
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);
340 DestroyIcon(icon);
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);
350 DestroyIcon(icon);
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);
360 DestroyIcon(icon);
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);
371 DestroyIcon(icon);
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);
381 DestroyIcon(icon);
383 DeleteFileW(icon_path);
384 FreeLibrary(hinst);
387 static void check_class( const char *name, int must_exist, UINT style, UINT ignore, BOOL v6 )
389 WNDCLASSA wc;
391 if (GetClassInfoA( 0, name, &wc ))
393 char buff[64];
394 HWND hwnd;
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 );
412 DestroyWindow(hwnd);
414 else
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);
448 if (v6)
449 check_class(TOOLTIPS_CLASSA, 1, CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS | CS_DROPSHADOW, CS_SAVEBITS | CS_HREDRAW | CS_VREDRAW /* XP */, TRUE);
450 else
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
460 const char *class;
461 const struct message *expected_msg;
462 int ignored_msg_count;
463 DWORD ignored_msgs[16];
464 BOOL todo;
467 static BOOL ignore_message(UINT msg)
469 /* these are always ignored */
470 return (msg >= 0xc000 ||
471 msg == WM_GETICON ||
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};
487 LRESULT ret;
488 int i;
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;
504 msg.wParam = wParam;
505 msg.lParam = lParam;
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;
515 return ret;
518 static HWND create_control(const char *class, DWORD style, HWND parent, DWORD_PTR data)
520 HWND hwnd;
522 if (parent)
523 style |= WS_CHILD;
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);
527 return hwnd;
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},
536 {0},
539 static const struct message wm_themechanged_paint_seq[] =
541 {WM_THEMECHANGED, sent | wparam | lparam},
542 {WM_PAINT, sent | wparam | lparam},
543 {0},
546 static const struct message wm_themechanged_no_paint_seq[] =
548 {WM_THEMECHANGED, sent | wparam | lparam},
549 {0},
552 static void test_WM_THEMECHANGED(void)
554 HWND parent, child;
555 char buffer[64];
556 int i;
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]);
595 flush_events();
596 flush_sequences(sequences, NUM_MSG_SEQUENCES);
598 SendMessageW(child, WM_THEMECHANGED, 0, 0);
599 flush_events();
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},
612 {0},
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;
621 msg.wParam = wParam;
622 msg.lParam = lParam;
623 add_message(sequences, CHILD_SEQ_INDEX, &msg);
624 return FALSE;
627 static void test_WM_SYSCOLORCHANGE(void)
629 HWND parent, dialog;
630 struct
632 DLGTEMPLATE tmplate;
633 WORD menu;
634 WORD class;
635 WORD title;
636 } temp = {{0}};
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());
647 flush_events();
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};
796 HBRUSH brush;
797 RECT rect;
799 if (message == WM_ERASEBKGND || message == WM_PRINTCLIENT || (message >= WM_CTLCOLORMSGBOX
800 && message <= WM_CTLCOLORSTATIC))
802 msg.message = message;
803 msg.flags = sent;
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);
812 DeleteObject(brush);
813 return 1;
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);
828 HWND child, parent;
829 HMODULE uxtheme;
830 COLORREF color;
831 WNDCLASSA cls;
832 HDC hdc;
833 int i;
835 static const struct test
837 const CHAR *class_name;
838 DWORD style;
839 const struct message *seq;
840 BOOL todo;
842 tests[] =
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);
904 return;
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,
926 0, 0, 0, 0);
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());
936 flush_events();
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)
955 hdc = GetDC(child);
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},
1011 {WM_PAINT, sent},
1012 {WM_ERASEBKGND, sent | defwinproc},
1016 static const struct message wm_stylechanged_combox_seq[] =
1018 {WM_STYLECHANGED, sent},
1019 {WM_ERASEBKGND, sent | defwinproc},
1020 {WM_PAINT, sent},
1024 static const struct message wm_stylechanged_listview_report_seq[] =
1026 {WM_STYLECHANGED, sent},
1027 {WM_ERASEBKGND, sent | defwinproc},
1028 {WM_PAINT, sent},
1029 {WM_ERASEBKGND, sent | defwinproc},
1033 static const struct message wm_stylechanged_pager_seq[] =
1035 {WM_STYLECHANGED, sent},
1036 {WM_PAINT, sent},
1037 {WM_NCPAINT, sent | defwinproc},
1038 {WM_ERASEBKGND, sent | defwinproc},
1042 static const struct message wm_stylechanged_progress_seq[] =
1044 {WM_STYLECHANGED, sent},
1045 {WM_PAINT, sent | optional}, /* WM_PAINT and WM_ERASEBKGND are missing with comctl32 v5 */
1046 {WM_ERASEBKGND, sent | defwinproc | optional},
1050 static const struct message wm_stylechanged_trackbar_seq[] =
1052 {WM_STYLECHANGED, sent},
1053 {WM_PAINT, sent | defwinproc},
1054 {WM_PAINT, sent},
1058 static LRESULT WINAPI test_wm_stylechanged_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
1060 static int defwndproc_counter = 0;
1061 struct message msg = {0};
1062 LRESULT ret;
1064 if (message == WM_STYLECHANGED
1065 || message == WM_PAINT
1066 || message == WM_ERASEBKGND
1067 || message == WM_NCPAINT)
1069 msg.message = message;
1070 msg.flags = sent | wparam | lparam;
1071 if (defwndproc_counter)
1072 msg.flags |= defwinproc;
1073 msg.wParam = wp;
1074 msg.lParam = lp;
1075 add_message(sequences, CHILD_SEQ_INDEX, &msg);
1078 ++defwndproc_counter;
1079 ret = CallWindowProcA(old_proc, hwnd, message, wp, lp);
1080 --defwndproc_counter;
1081 return ret;
1084 static void test_WM_STYLECHANGED(void)
1086 HWND parent, hwnd;
1087 STYLESTRUCT style;
1088 unsigned int i;
1090 static const struct test
1092 const CHAR *class_name;
1093 DWORD add_style;
1094 const struct message *seq;
1095 BOOL todo;
1097 tests[] =
1099 {ANIMATE_CLASSA, WS_TABSTOP, wm_stylechanged_seq},
1100 {WC_BUTTONA, WS_TABSTOP, wm_stylechanged_seq},
1101 {WC_COMBOBOXA, WS_TABSTOP, wm_stylechanged_combox_seq, TRUE},
1102 {WC_COMBOBOXEXA, WS_TABSTOP, wm_stylechanged_seq},
1103 {DATETIMEPICK_CLASSA, WS_TABSTOP, wm_stylechanged_seq},
1104 {WC_EDITA, WS_TABSTOP, wm_stylechanged_seq},
1105 {WC_HEADERA, WS_TABSTOP, wm_stylechanged_repaint_seq, TRUE},
1106 {HOTKEY_CLASSA, WS_TABSTOP, wm_stylechanged_seq},
1107 {WC_IPADDRESSA, WS_TABSTOP, wm_stylechanged_seq},
1108 {WC_LISTBOXA, WS_TABSTOP, wm_stylechanged_repaint_seq, TRUE},
1109 {WC_LISTVIEWA, WS_TABSTOP, wm_stylechanged_seq},
1110 {WC_LISTVIEWA, LVS_REPORT, wm_stylechanged_listview_report_seq, TRUE},
1111 {MONTHCAL_CLASSA, WS_TABSTOP, wm_stylechanged_repaint_seq, TRUE},
1112 {WC_NATIVEFONTCTLA, WS_TABSTOP, wm_stylechanged_seq},
1113 {WC_PAGESCROLLERA, WS_TABSTOP, wm_stylechanged_pager_seq, TRUE},
1114 {PROGRESS_CLASSA, WS_TABSTOP, wm_stylechanged_progress_seq},
1115 {REBARCLASSNAMEA, WS_TABSTOP, wm_stylechanged_seq},
1116 {WC_STATICA, WS_TABSTOP, wm_stylechanged_seq},
1117 {STATUSCLASSNAMEA, WS_TABSTOP, wm_stylechanged_seq},
1118 {"SysLink", WS_TABSTOP, wm_stylechanged_seq},
1119 {WC_TABCONTROLA, WS_TABSTOP, wm_stylechanged_seq},
1120 {TOOLBARCLASSNAMEA, WS_TABSTOP, wm_stylechanged_seq},
1121 {TOOLTIPS_CLASSA, WS_TABSTOP, wm_stylechanged_seq},
1122 {TRACKBAR_CLASSA, WS_TABSTOP, wm_stylechanged_trackbar_seq, TRUE},
1123 {WC_TREEVIEWA, WS_TABSTOP, wm_stylechanged_seq},
1124 {UPDOWN_CLASSA, WS_TABSTOP, wm_stylechanged_seq},
1125 {WC_SCROLLBARA, WS_TABSTOP, wm_stylechanged_seq},
1128 parent = CreateWindowA(WC_STATICA, "parent", WS_POPUP | WS_VISIBLE, 100, 100, 100, 100,
1129 0, 0, 0, 0);
1130 ok(parent != NULL, "CreateWindowA failed, error %lu.\n", GetLastError());
1132 for (i = 0; i < ARRAY_SIZE(tests); ++i)
1134 winetest_push_context("%s", tests[i].class_name);
1136 hwnd = CreateWindowA(tests[i].class_name, "test", WS_CHILD | WS_VISIBLE, 0, 0, 50, 50,
1137 parent, 0, 0, 0);
1138 /* SysLink is unavailable in comctl32 v5 */
1139 if (!hwnd && !lstrcmpA(tests[i].class_name, "SysLink"))
1141 winetest_pop_context();
1142 continue;
1144 ok(hwnd != NULL, "CreateWindowA failed, error %lu.\n", GetLastError());
1145 old_proc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)test_wm_stylechanged_proc);
1146 ok(old_proc != NULL, "SetWindowLongPtrA failed, error %lu.\n", GetLastError());
1147 flush_events();
1148 flush_sequences(sequences, NUM_MSG_SEQUENCES);
1150 style.styleOld = GetWindowLongA(hwnd, GWL_STYLE);
1151 style.styleNew = style.styleOld | tests[i].add_style;
1152 SendMessageA(hwnd, WM_STYLECHANGED, GWL_STYLE, (LPARAM)&style);
1153 flush_events();
1154 ok_sequence(sequences, CHILD_SEQ_INDEX, tests[i].seq, "WM_STYLECHANGED", tests[i].todo);
1156 DestroyWindow(hwnd);
1157 winetest_pop_context();
1160 DestroyWindow(parent);
1163 START_TEST(misc)
1165 ULONG_PTR ctx_cookie;
1166 HANDLE hCtx;
1168 init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
1169 if(!InitFunctionPtrs())
1170 return;
1172 test_GetPtrAW();
1173 test_Alloc();
1174 test_comctl32_classes(FALSE);
1175 test_WM_STYLECHANGED();
1177 FreeLibrary(hComctl32);
1179 if (!load_v6_module(&ctx_cookie, &hCtx))
1180 return;
1181 if(!init_functions_v6())
1182 return;
1184 test_comctl32_classes(TRUE);
1185 test_builtin_classes();
1186 test_LoadIconWithScaleDown();
1187 test_themed_background();
1188 test_WM_THEMECHANGED();
1189 test_WM_SYSCOLORCHANGE();
1190 test_WM_STYLECHANGED();
1192 unload_v6_module(ctx_cookie, hCtx);
1193 FreeLibrary(hComctl32);