From 4893b157e215000ff76f358abbc912c4f4970a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Zalewski?= Date: Sun, 18 Mar 2007 13:02:04 +0100 Subject: [PATCH] user32: tests: Using DefWindowProcA with RegisterClassW works under Windows. --- dlls/user32/tests/class.c | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index aa7ef5a1d48..782f0ba94d5 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -556,6 +556,75 @@ static void test_instances(void) check_thread_instance( "EDIT", (HINSTANCE)0x12345678, (HINSTANCE)0x12345678, (HINSTANCE)0xdeadbeef ); } +static void test_defwndproc() +{ + char classA[] = "deftest"; + WCHAR classW[] = {'d','e','f','t','e','s','t',0}; + int i; + + for (i = 0; i < 4; i++) + { + WNDCLASSEXA cls; /* the memory layout of WNDCLASSEXA and WNDCLASSEXW is the same */ + ATOM atom; + HWND hwnd; + ZeroMemory(&cls, sizeof(cls)); + cls.cbSize = sizeof(cls); + cls.hInstance = GetModuleHandle(NULL); + cls.hbrBackground = GetStockObject (WHITE_BRUSH); + if (i & 1) + cls.lpfnWndProc = DefWindowProcA; + else + cls.lpfnWndProc = DefWindowProcW; + + if (i & 2) + { + cls.lpszClassName = classA; + atom = RegisterClassExA(&cls); + } + else + { + cls.lpszClassName = (LPSTR)classW; + atom = RegisterClassExW((WNDCLASSEXW *)&cls); + } + ok(atom != 0, "Couldn't register class, i=%d, %d\n", i, GetLastError()); + + hwnd = CreateWindowA(classA, NULL, 0, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), NULL); + ok(hwnd != NULL, "Couldn't create window i=%d\n", i); + if ((i & 1) && (i & 2)) + { + ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", + (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), DefWindowProcA); + ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", + (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), DefWindowProcA); + } + else + todo_wine { + ok(GetWindowLongPtrA(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", + (void *)GetWindowLongPtrA(hwnd, GWLP_WNDPROC), DefWindowProcA); + ok(GetClassLongPtrA(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcA, "Wrong ANSI wndproc: %p vs %p\n", + (void *)GetClassLongPtrA(hwnd, GCLP_WNDPROC), DefWindowProcA); + } + + if (!(i & 1) && !(i & 2)) + { + ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", + (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), DefWindowProcW); + ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", + (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), DefWindowProcW); + } + else + todo_wine { + ok(GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", + (void *)GetWindowLongPtrW(hwnd, GWLP_WNDPROC), DefWindowProcW); + ok(GetClassLongPtrW(hwnd, GCLP_WNDPROC) == (LONG_PTR)DefWindowProcW, "Wrong Unicode wndproc: %p vs %p\n", + (void *)GetClassLongPtrW(hwnd, GCLP_WNDPROC), DefWindowProcW); + } + + DestroyWindow(hwnd); + UnregisterClass((LPSTR)(DWORD_PTR)atom, GetModuleHandle(NULL)); + } +} + static LRESULT WINAPI TestDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd, uMsg, wParam, lParam); @@ -619,4 +688,5 @@ START_TEST(class) CreateDialogParamTest(hInstance); test_styles(); test_instances(); + test_defwndproc(); }