From 08f60ee991916f3b4400574cb1096a6cc87d53e2 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 7 Oct 2021 16:34:04 +0200 Subject: [PATCH] user32/tests: Test window style in HCBT_CREATEWND hook. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/user32/tests/win.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index f9428fd3494..b9824422409 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -4432,6 +4432,35 @@ typedef struct DWORD exstyle; } test_style; +static LRESULT WINAPI cbt_proc(int ncode, WPARAM wparam, LPARAM lparam) +{ + CBT_CREATEWNDW* c = (CBT_CREATEWNDW*)lparam; + HWND hwnd = (HWND)wparam; + test_style *ts; + DWORD style; + + if (ncode != HCBT_CREATEWND) + return CallNextHookEx(NULL, ncode, wparam, lparam); + + ts = c->lpcs->lpCreateParams; + ok(ts != NULL, "lpCreateParams not set\n"); + todo_wine_if(!(ts->cs_style & WS_CHILD) || (ts->cs_style & WS_POPUP)) + ok(c->lpcs->style == ts->cs_style, "style = 0x%08x, expected 0x%08x\n", + c->lpcs->style, ts->cs_style); + ok(c->lpcs->dwExStyle == ts->cs_exstyle, "exstyle = 0x%08x, expected 0x%08x\n", + c->lpcs->dwExStyle, ts->cs_exstyle); + + style = GetWindowLongW(hwnd, GWL_STYLE); + todo_wine_if(!(ts->cs_style & WS_CHILD) || (ts->cs_style & WS_POPUP)) + ok(style == ts->cs_style, "style = 0x%08x, expected 0x%08x\n", + style, ts->cs_style); + style = GetWindowLongW(hwnd, GWL_EXSTYLE); + todo_wine_if(ts->exstyle != ts->cs_exstyle) + ok(style == (ts->cs_exstyle & ~WS_EX_LAYERED), + "exstyle = 0x%08x, expected 0x%08x\n", style, ts->cs_exstyle); + return CallNextHookEx(NULL, ncode, wparam, lparam); +} + static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { CREATESTRUCTA *cs; @@ -4491,6 +4520,7 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle test_style ts; HWND hwnd; HWND hwndParent = NULL; + HHOOK hook; ts.cs_style = dwStyleIn; ts.cs_exstyle = dwExStyleIn; @@ -4507,11 +4537,14 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle { hwndParent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL); + ok(hwndParent != NULL, "CreateWindowExA failed\n"); } + hook = SetWindowsHookExW(WH_CBT, cbt_proc, 0, GetCurrentThreadId()); hwnd = CreateWindowExA(dwExStyleIn, (LPCSTR)MAKEINTATOM(atomStyleCheckClass), NULL, dwStyleIn, 0, 0, 0, 0, hwndParent, NULL, NULL, &ts); - assert(hwnd); + ok(hwnd != NULL, "CreateWindowExA failed\n"); + UnhookWindowsHookEx(hook); flush_events( TRUE );