From: Amine Khaldi Date: Fri, 18 Apr 2014 22:26:13 +0000 (+0000) Subject: [USER32_WINETEST] X-Git-Tag: backups/0.3.17@66124~1702 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5f7347300befe5f1e8d77b07ea522369c24f0dec [USER32_WINETEST] * Sync with Wine 1.7.17. CORE-8080 svn path=/trunk/; revision=62785 --- diff --git a/rostests/winetests/user32/broadcast.c b/rostests/winetests/user32/broadcast.c index f15bb375139..a18f11a9203 100644 --- a/rostests/winetests/user32/broadcast.c +++ b/rostests/winetests/user32/broadcast.c @@ -59,7 +59,7 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR static BOOL init_procs(void) { WNDCLASSA cls; - HANDLE user32 = GetModuleHandle("user32"); + HANDLE user32 = GetModuleHandleA("user32.dll"); pBroadcastA = (PBROADCAST)GetProcAddress(user32, "BroadcastSystemMessageA"); if (!pBroadcastA) pBroadcastA = (PBROADCAST)GetProcAddress(user32, "BroadcastSystemMessage"); @@ -82,7 +82,7 @@ static BOOL init_procs(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "MainWindowClass"; @@ -92,7 +92,7 @@ static BOOL init_procs(void) if (!CreateWindowExA(0, "MainWindowClass", "Main window", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP, 100, 100, 200, - 200, 0, 0, GetModuleHandle(0), NULL)) + 200, 0, 0, GetModuleHandleA(NULL), NULL)) return FALSE; return TRUE; } @@ -119,7 +119,8 @@ static void test_parameters(PBROADCAST broadcast, const char *functionname) ok(!ret || broken(ret), "Returned: %d\n", ret); if (!ret) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError()); -#if 0 /* TODO: Check the hang flags */ +if (0) /* TODO: Check the hang flags */ +{ SetLastError(0xcafebabe); recips = BSM_APPLICATIONS; ret = broadcast( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0 ); @@ -143,7 +144,7 @@ static void test_parameters(PBROADCAST broadcast, const char *functionname) ret = broadcast( BSF_POSTMESSAGE|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0 ); ok(0, "Last error: %08x\n", GetLastError()); ok(0, "Returned: %d\n", ret); -#endif +} recips = BSM_APPLICATIONS; ResetEvent(hevent); @@ -204,31 +205,32 @@ static void test_parametersEx(PBROADCASTEX broadcastex) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Last error: %08x\n", GetLastError()); ok(!ret, "Returned: %d\n", ret); -#if 0 /* TODO: Check the hang flags */ +if (0) /* TODO: Check the hang flags */ +{ SetLastError(0xcafebabe); recips = BSM_APPLICATIONS; - ret = broadcast( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL ); + ret = broadcastex( BSF_QUERY|(BSF_NOHANG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL ); ok(0, "Last error: %08x\n", GetLastError()); ok(0, "Returned: %d\n", ret); SetLastError(0xcafebabe); recips = BSM_APPLICATIONS; - ret = broadcast( BSF_QUERY|(BSF_NOHANG|BSF_NOTIMEOUTIFNOTHUNG), &recips, WM_NULL, 30000, 0, NULL ); + ret = broadcastex( BSF_QUERY|(BSF_NOHANG|BSF_NOTIMEOUTIFNOTHUNG), &recips, WM_NULL, 30000, 0, NULL ); ok(0, "Last error: %08x\n", GetLastError()); ok(0, "Returned: %d\n", ret); SetLastError(0xcafebabe); recips = BSM_APPLICATIONS; - ret = broadcast( BSF_QUERY|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL ); + ret = broadcastex( BSF_QUERY|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL ); ok(0, "Last error: %08x\n", GetLastError()); ok(0, "Returned: %d\n", ret); SetLastError(0xcafebabe); recips = BSM_APPLICATIONS; - ret = broadcast( BSF_POSTMESSAGE|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL ); + ret = broadcastex( BSF_POSTMESSAGE|(BSF_NOTIMEOUTIFNOTHUNG|BSF_FORCEIFHUNG), &recips, WM_NULL, 30000, 0, NULL ); ok(0, "Last error: %08x\n", GetLastError()); ok(0, "Returned: %d\n", ret); -#endif +} recips = BSM_APPLICATIONS; ResetEvent(hevent); diff --git a/rostests/winetests/user32/clipboard.c b/rostests/winetests/user32/clipboard.c index e2e727c557d..40218be4c7a 100755 --- a/rostests/winetests/user32/clipboard.c +++ b/rostests/winetests/user32/clipboard.c @@ -270,6 +270,7 @@ static void test_synthesized(void) } static CRITICAL_SECTION clipboard_cs; +static HWND next_wnd; static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { switch(msg) { @@ -277,12 +278,19 @@ static LRESULT CALLBACK clipboard_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARA EnterCriticalSection(&clipboard_cs); LeaveCriticalSection(&clipboard_cs); break; + case WM_CHANGECBCHAIN: + if (next_wnd == (HWND)wp) + next_wnd = (HWND)lp; + else if (next_wnd) + SendMessageA(next_wnd, msg, wp, lp); + break; case WM_USER: + ChangeClipboardChain(hwnd, next_wnd); PostQuitMessage(0); break; } - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } static DWORD WINAPI clipboard_thread(void *param) @@ -292,7 +300,7 @@ static DWORD WINAPI clipboard_thread(void *param) EnterCriticalSection(&clipboard_cs); SetLastError(0xdeadbeef); - SetClipboardViewer(win); + next_wnd = SetClipboardViewer(win); ok(GetLastError() == 0xdeadbeef, "GetLastError = %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs); @@ -307,14 +315,14 @@ static DWORD WINAPI clipboard_thread(void *param) ok(r, "CloseClipboard failed: %d\n", GetLastError()); LeaveCriticalSection(&clipboard_cs); - r = PostMessage(win, WM_USER, 0, 0); + r = PostMessageA(win, WM_USER, 0, 0); ok(r, "PostMessage failed: %d\n", GetLastError()); return 0; } static void test_messages(void) { - WNDCLASS cls; + WNDCLASSA cls; HWND win; MSG msg; HANDLE thread; @@ -324,25 +332,25 @@ static void test_messages(void) memset(&cls, 0, sizeof(cls)); cls.lpfnWndProc = clipboard_wnd_proc; - cls.hInstance = GetModuleHandle(0); + cls.hInstance = GetModuleHandleA(NULL); cls.lpszClassName = "clipboard_test"; - RegisterClass(&cls); + RegisterClassA(&cls); - win = CreateWindow("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0); + win = CreateWindowA("clipboard_test", NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0); ok(win != NULL, "CreateWindow failed: %d\n", GetLastError()); thread = CreateThread(NULL, 0, clipboard_thread, (void*)win, 0, &tid); ok(thread != NULL, "CreateThread failed: %d\n", GetLastError()); - while(GetMessage(&msg, NULL, 0, 0)) { + while(GetMessageA(&msg, NULL, 0, 0)) { TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessageA(&msg); } ok(WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0, "WaitForSingleObject failed\n"); CloseHandle(thread); - UnregisterClass("clipboard_test", GetModuleHandle(0)); + UnregisterClassA("clipboard_test", GetModuleHandleA(NULL)); DeleteCriticalSection(&clipboard_cs); } diff --git a/rostests/winetests/user32/combo.c b/rostests/winetests/user32/combo.c index 3d3b945fcd0..d9875ea466c 100644 --- a/rostests/winetests/user32/combo.c +++ b/rostests/winetests/user32/combo.c @@ -60,7 +60,7 @@ static INT CALLBACK is_font_installed_proc(const LOGFONTA *elf, const TEXTMETRIC return 0; } -static int is_font_installed(const char *name) +static BOOL is_font_installed(const char *name) { HDC hdc = GetDC(NULL); BOOL ret = !EnumFontFamiliesA(hdc, name, is_font_installed_proc, 0); diff --git a/rostests/winetests/user32/cursoricon.c b/rostests/winetests/user32/cursoricon.c index 61937e8d0f6..a7c3ca47599 100644 --- a/rostests/winetests/user32/cursoricon.c +++ b/rostests/winetests/user32/cursoricon.c @@ -304,7 +304,7 @@ static BOOL (WINAPI *pGetCursorInfo)(CURSORINFO *); static BOOL (WINAPI *pGetIconInfoExA)(HICON,ICONINFOEXA *); static BOOL (WINAPI *pGetIconInfoExW)(HICON,ICONINFOEXW *); -static const int is_win64 = (sizeof(void *) > sizeof(int)); +static const BOOL is_win64 = (sizeof(void *) > sizeof(int)); static LRESULT CALLBACK callback_child(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -328,7 +328,7 @@ static LRESULT CALLBACK callback_child(HWND hwnd, UINT msg, WPARAM wParam, LPARA return 0; } - return DefWindowProc(hwnd, msg, wParam, lParam); + return DefWindowProcA(hwnd, msg, wParam, lParam); } static LRESULT CALLBACK callback_parent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -339,12 +339,12 @@ static LRESULT CALLBACK callback_parent(HWND hwnd, UINT msg, WPARAM wParam, LPAR return TRUE; } - return DefWindowProc(hwnd, msg, wParam, lParam); + return DefWindowProcA(hwnd, msg, wParam, lParam); } static void do_child(void) { - WNDCLASS class; + WNDCLASSA class; MSG msg; BOOL ret; @@ -353,7 +353,7 @@ static void do_child(void) class.lpfnWndProc = callback_child; class.cbClsExtra = 0; class.cbWndExtra = 0; - class.hInstance = GetModuleHandle(NULL); + class.hInstance = GetModuleHandleA(NULL); class.hIcon = NULL; class.hCursor = NULL; class.hbrBackground = NULL; @@ -361,7 +361,7 @@ static void do_child(void) class.lpszClassName = "cursor_child"; SetLastError(0xdeadbeef); - ret = RegisterClass(&class); + ret = RegisterClassA(&class); ok(ret, "Failed to register window class. Error: %u\n", GetLastError()); /* Create a window. */ @@ -370,14 +370,14 @@ static void do_child(void) ok(child != 0, "CreateWindowA failed. Error: %u\n", GetLastError()); /* Let the parent know our HWND. */ - PostMessage(parent, PROC_INIT, (WPARAM) child, 0); + PostMessageA(parent, PROC_INIT, (WPARAM) child, 0); /* Receive messages. */ - while ((ret = GetMessage(&msg, 0, 0, 0))) + while ((ret = GetMessageA(&msg, 0, 0, 0))) { ok(ret != -1, "GetMessage failed. Error: %u\n", GetLastError()); TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessageA(&msg); } } @@ -386,7 +386,7 @@ static void do_parent(void) char path_name[MAX_PATH]; PROCESS_INFORMATION info; STARTUPINFOA startup; - WNDCLASS class; + WNDCLASSA class; MSG msg; BOOL ret; @@ -395,7 +395,7 @@ static void do_parent(void) class.lpfnWndProc = callback_parent; class.cbClsExtra = 0; class.cbWndExtra = 0; - class.hInstance = GetModuleHandle(NULL); + class.hInstance = GetModuleHandleA(NULL); class.hIcon = NULL; class.hCursor = NULL; class.hbrBackground = NULL; @@ -403,7 +403,7 @@ static void do_parent(void) class.lpszClassName = "cursor_parent"; SetLastError(0xdeadbeef); - ret = RegisterClass(&class); + ret = RegisterClassA(&class); ok(ret, "Failed to register window class. Error: %u\n", GetLastError()); /* Create a window. */ @@ -422,17 +422,17 @@ static void do_parent(void) child_process = info.hProcess; /* Wait for child window handle. */ - while ((child == 0) && (ret = GetMessage(&msg, parent, 0, 0))) + while ((child == 0) && (ret = GetMessageA(&msg, parent, 0, 0))) { ok(ret != -1, "GetMessage failed. Error: %u\n", GetLastError()); TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessageA(&msg); } } static void finish_child_process(void) { - SendMessage(child, WM_CLOSE, 0, 0); + SendMessageA(child, WM_CLOSE, 0, 0); winetest_wait_child_process( child_process ); CloseHandle(child_process); } @@ -462,7 +462,7 @@ static void test_child_process(void) SetCursor(cursor); /* Destroy the cursor. */ - SendMessage(child, WM_USER+1, 0, (LPARAM) cursor); + SendMessageA(child, WM_USER+1, 0, (LPARAM) cursor); } static BOOL color_match(COLORREF a, COLORREF b) @@ -486,8 +486,8 @@ static void test_CopyImage_Check(HBITMAP bitmap, UINT flags, INT copyWidth, INT ok(copy != NULL, "CopyImage() failed\n"); if (copy != NULL) { - GetObject(bitmap, sizeof(origBitmap), &origBitmap); - GetObject(copy, sizeof(copyBitmap), ©Bitmap); + GetObjectA(bitmap, sizeof(origBitmap), &origBitmap); + GetObjectA(copy, sizeof(copyBitmap), ©Bitmap); orig_is_dib = (origBitmap.bmBits != NULL); copy_is_dib = (copyBitmap.bmBits != NULL); @@ -688,7 +688,7 @@ static void test_initial_cursor(void) /* Check what handle GetCursor() returns if a cursor is not set yet. */ SetLastError(0xdeadbeef); - cursor2 = LoadCursor(NULL, IDC_WAIT); + cursor2 = LoadCursorA(NULL, (LPCSTR)IDC_WAIT); todo_wine { ok(cursor == cursor2, "cursor (%p) is not IDC_WAIT (%p).\n", cursor, cursor2); } @@ -710,7 +710,7 @@ static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_m ok_(__FILE__, line)(info.yHotspot == exp_cy/2, "info.yHotspot = %u\n", info.yHotspot); ok_(__FILE__, line)(info.hbmMask != 0, "info.hbmMask is NULL\n"); - ret = GetObject(info.hbmMask, sizeof(bmMask), &bmMask); + ret = GetObjectA(info.hbmMask, sizeof(bmMask), &bmMask); ok_(__FILE__, line)(ret == sizeof(bmMask), "GetObject(info.hbmMask) failed, ret %u\n", ret); if (exp_bpp == 1) @@ -725,7 +725,7 @@ static void test_icon_info_dbg(HICON hIcon, UINT exp_cx, UINT exp_cy, UINT exp_m display_bpp = GetDeviceCaps(hdc, BITSPIXEL); ReleaseDC(0, hdc); - ret = GetObject(info.hbmColor, sizeof(bmColor), &bmColor); + ret = GetObjectA(info.hbmColor, sizeof(bmColor), &bmColor); ok_(__FILE__, line)(ret == sizeof(bmColor), "GetObject(info.hbmColor) failed, ret %u\n", ret); ok_(__FILE__, line)(bmColor.bmBitsPixel == display_bpp /* XP */ || @@ -1043,7 +1043,7 @@ static void test_LoadImageBitmap(const char * test_desc, HBITMAP hbm) DWORD ret, pixel = 0; HDC hdc = GetDC(NULL); - ret = GetObject(hbm, sizeof(bm), &bm); + ret = GetObjectA(hbm, sizeof(bm), &bm); ok(ret == sizeof(bm), "GetObject returned %d\n", ret); memset(&bmi, 0, sizeof(bmi)); @@ -1219,7 +1219,7 @@ static void test_LoadImage(void) DeleteFileA("icon.ico"); /* Test a system icon */ - handle = LoadIcon( 0, IDI_HAND ); + handle = LoadIconA( 0, (LPCSTR)IDI_HAND ); ok(handle != NULL, "LoadImage() failed.\n"); if (pGetIconInfoExA) { @@ -1976,7 +1976,7 @@ static void check_DrawState_Size(HDC hdc, BOOL maskvalue, UINT32 color, int bpp, SetPixelV(hdc, 2, 2, background); /* Let DrawState calculate the size of the icon (it's 1x1) */ - DrawState(hdc, hbr, NULL, (LPARAM) hicon, 0, 1, 1, 0, 0, (DST_ICON | flags )); + DrawStateA(hdc, hbr, NULL, (LPARAM) hicon, 0, 1, 1, 0, 0, (DST_ICON | flags )); result = GetPixel(hdc, 0, 0); passed[0] = color_match(result, background); @@ -1990,7 +1990,7 @@ static void check_DrawState_Size(HDC hdc, BOOL maskvalue, UINT32 color, int bpp, * width/height 2x2 if the icon is only 1x1 pixels in size should * result in drawing it with size 1x1. The size parameters must be * ignored if a Icon has to be drawn! */ - DrawState(hdc, hbr, NULL, (LPARAM) hicon, 0, 1, 1, 2, 2, (DST_ICON | flags )); + DrawStateA(hdc, hbr, NULL, (LPARAM) hicon, 0, 1, 1, 2, 2, (DST_ICON | flags )); result = GetPixel(hdc, 0, 0); passed[1] = color_match(result, background); @@ -2026,7 +2026,7 @@ static void check_DrawState_Color(HDC hdc, BOOL maskvalue, UINT32 color, int bpp /* Set color of the pixel that will be checked afterwards */ SetPixelV(hdc, 1, 1, background); - DrawState(hdc, hbr, NULL, (LPARAM) hicon, 0, 1, 1, 0, 0, ( DST_ICON | flags )); + DrawStateA(hdc, hbr, NULL, (LPARAM) hicon, 0, 1, 1, 0, 0, ( DST_ICON | flags )); /* Check the color of the pixel is correct */ result = GetPixel(hdc, 1, 1); @@ -2095,7 +2095,7 @@ static DWORD CALLBACK set_cursor_thread( void *arg ) { HCURSOR ret; - PeekMessage( 0, 0, 0, 0, PM_NOREMOVE ); /* create a msg queue */ + PeekMessageA( 0, 0, 0, 0, PM_NOREMOVE ); /* create a msg queue */ if (parent_id) { BOOL ret = AttachThreadInput( GetCurrentThreadId(), parent_id, TRUE ); @@ -2214,7 +2214,7 @@ static DWORD CALLBACK show_cursor_thread( void *arg ) DWORD count = (DWORD_PTR)arg; int ret; - PeekMessage( 0, 0, 0, 0, PM_NOREMOVE ); /* create a msg queue */ + PeekMessageA( 0, 0, 0, 0, PM_NOREMOVE ); /* create a msg queue */ if (parent_id) { BOOL ret = AttachThreadInput( GetCurrentThreadId(), parent_id, TRUE ); @@ -2242,8 +2242,8 @@ static void test_ShowCursor(void) ok( info.flags & CURSOR_SHOWING, "cursor not shown in info\n" ); } - event_start = CreateEvent( NULL, FALSE, FALSE, NULL ); - event_next = CreateEvent( NULL, FALSE, FALSE, NULL ); + event_start = CreateEventW( NULL, FALSE, FALSE, NULL ); + event_next = CreateEventW( NULL, FALSE, FALSE, NULL ); count = ShowCursor( TRUE ); ok( count == 1, "wrong count %d\n", count ); @@ -2448,7 +2448,7 @@ static void test_DestroyCursor(void) DeleteObject(cursorInfo.hbmColor); /* Try testing DestroyCursor() now using LoadCursor() cursors. */ - cursor = LoadCursor(NULL, IDC_ARROW); + cursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); SetLastError(0xdeadbeef); ret = DestroyCursor(cursor); @@ -2463,11 +2463,11 @@ static void test_DestroyCursor(void) ok(error == 0xdeadbeef, "Last error: 0x%08x\n", error); /* Check if LoadCursor() returns the same handle with the same icon. */ - cursor2 = LoadCursor(NULL, IDC_ARROW); + cursor2 = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); ok(cursor2 == cursor, "cursor == %p, cursor2 == %p\n", cursor, cursor2); /* Check if LoadCursor() returns the same handle with a different icon. */ - cursor2 = LoadCursor(NULL, IDC_WAIT); + cursor2 = LoadCursorA(NULL, (LPCSTR)IDC_WAIT); ok(cursor2 != cursor, "cursor == %p, cursor2 == %p\n", cursor, cursor2); } diff --git a/rostests/winetests/user32/dce.c b/rostests/winetests/user32/dce.c index f75e6b30e58..dc78caf9759 100755 --- a/rostests/winetests/user32/dce.c +++ b/rostests/winetests/user32/dce.c @@ -40,7 +40,8 @@ static void test_dc_attributes(void) { HDC hdc, old_hdc; HDC hdcs[20]; - INT i, rop, def_rop, found_dc; + INT i, rop, def_rop; + BOOL found_dc; /* test cache DC */ @@ -59,7 +60,7 @@ static void test_dc_attributes(void) ReleaseDC( hwnd_cache, hdc ); old_hdc = hdc; - found_dc = 0; + found_dc = FALSE; for (i = 0; i < 20; i++) { hdc = hdcs[i] = GetDCEx( hwnd_cache, 0, DCX_USESTYLE | DCX_NORESETATTRS ); @@ -68,7 +69,7 @@ static void test_dc_attributes(void) ok( rop == def_rop, "wrong ROP2 %d after release %p/%p\n", rop, old_hdc, hdc ); if (hdc == old_hdc) { - found_dc = 1; + found_dc = TRUE; SetROP2( hdc, R2_WHITE ); } } @@ -581,7 +582,7 @@ START_TEST(dce) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "cache_class"; diff --git a/rostests/winetests/user32/dde.c b/rostests/winetests/user32/dde.c index 4a50c39f66e..38240812a51 100755 --- a/rostests/winetests/user32/dde.c +++ b/rostests/winetests/user32/dde.c @@ -2397,8 +2397,8 @@ static HDDEDATA CALLBACK server_end_to_end_callback(UINT uType, UINT uFmt, HCONV char str[MAX_PATH]; static int msg_index = 0; static HCONV conversation = 0; - static char test_service [] = "TestDDEService"; - static char test_topic [] = "TestDDETopic"; + static const char test_service [] = "TestDDEService"; + static const char test_topic [] = "TestDDETopic"; msg_index++; @@ -2586,10 +2586,10 @@ static void test_end_to_end_client(BOOL type_a) HSZ server, topic; HCONV hconv; HDDEDATA hdata; - static char test_service[] = "TestDDEService"; - static WCHAR test_service_w[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0}; - static char test_topic[] = "TestDDETopic"; - static WCHAR test_topic_w[] = {'T','e','s','t','D','D','E','T','o','p','i','c',0}; + static const char test_service[] = "TestDDEService"; + static const WCHAR test_service_w[] = {'T','e','s','t','D','D','E','S','e','r','v','i','c','e',0}; + static const char test_topic[] = "TestDDETopic"; + static const WCHAR test_topic_w[] = {'T','e','s','t','D','D','E','T','o','p','i','c',0}; trace("Start end to end client %s\n", type_a ? "ASCII" : "UNICODE"); @@ -2651,7 +2651,7 @@ static void test_end_to_end_server(HANDLE hproc, HANDLE hthread, BOOL type_a) BOOL ret; DWORD res; HDDEDATA hdata; - static CHAR test_service[] = "TestDDEService"; + static const char test_service[] = "TestDDEService"; trace("start end to end server %s\n", type_a ? "ASCII" : "UNICODE"); server_pid = 0; diff --git a/rostests/winetests/user32/dialog.c b/rostests/winetests/user32/dialog.c index 537bb4523bb..403b9a48356 100755 --- a/rostests/winetests/user32/dialog.c +++ b/rostests/winetests/user32/dialog.c @@ -54,7 +54,7 @@ static HWND g_hwndInitialFocusT1, g_hwndInitialFocusT2, g_hwndInitialFocusGroupB static LONG g_styleInitialFocusT1, g_styleInitialFocusT2; static BOOL g_bInitialFocusInitDlgResult, g_bReceivedCommand; -static int g_terminated; +static BOOL g_terminated; typedef struct { INT_PTR id; diff --git a/rostests/winetests/user32/input.c b/rostests/winetests/user32/input.c index a8de5c8226b..7d039e00889 100755 --- a/rostests/winetests/user32/input.c +++ b/rostests/winetests/user32/input.c @@ -246,7 +246,7 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) if (winetest_debug > 1) trace("======== key stroke sequence #%d: %s =============\n", seqnr + 1, buf); - while( PeekMessage(&msg,hwnd,WM_KEYFIRST,WM_KEYLAST,PM_REMOVE) ) { + while( PeekMessageA(&msg,hwnd,WM_KEYFIRST,WM_KEYLAST,PM_REMOVE) ) { if (winetest_debug > 1) trace("message[%d] %-15s wParam %04lx lParam %08lx time %x\n", i, MSGNAME[msg.message - WM_KEYFIRST], msg.wParam, msg.lParam, msg.time); @@ -344,8 +344,8 @@ static void test_Input_whitebox(void) wclass.style = CS_HREDRAW | CS_VREDRAW; wclass.lpfnWndProc = WndProc; wclass.hInstance = hInstance; - wclass.hIcon = LoadIconA( 0, IDI_APPLICATION ); - wclass.hCursor = LoadCursorA( NULL, IDC_ARROW ); + wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION ); + wclass.hCursor = LoadCursorA( NULL, (LPCSTR)IDC_ARROW ); wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; @@ -362,7 +362,7 @@ static void test_Input_whitebox(void) UpdateWindow( hWndTest); /* flush pending messages */ - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); SetFocus( hWndTest ); TestSysKeys( hWndTest ); @@ -390,13 +390,13 @@ static void empty_message_queue(void) while (diff > 0) { if (MsgWaitForMultipleObjects(0, NULL, FALSE, min_timeout, QS_ALLINPUT) == WAIT_TIMEOUT) break; - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) { if (is_keyboard_message(msg.message) || is_mouse_message(msg.message)) ok(msg.time != 0, "message %#x has time set to 0\n", msg.message); TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessageA(&msg); } diff = time - GetTickCount(); } @@ -437,83 +437,83 @@ static const struct sendinput_test_s { } sendinput_test[] = { /* test ALT+F */ /* 0 */ - {VK_LMENU, 0, 0, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}}, + {VK_LMENU, 0, FALSE, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}}, {{WM_SYSKEYDOWN, hook|wparam, VK_LMENU}, {WM_SYSKEYDOWN}, {0}}}, - {'F', 0, 0, {{'F', 0x00}, {0}}, + {'F', 0, FALSE, {{'F', 0x00}, {0}}, {{WM_SYSKEYDOWN, hook}, {WM_SYSKEYDOWN}, {WM_SYSCHAR}, {WM_SYSCOMMAND}, {0}}}, - {'F', KEYEVENTF_KEYUP, 0, {{'F', 0x80}, {0}}, + {'F', KEYEVENTF_KEYUP, FALSE, {{'F', 0x80}, {0}}, {{WM_SYSKEYUP, hook}, {WM_SYSKEYUP}, {0}}}, - {VK_LMENU, KEYEVENTF_KEYUP, 0, {{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {0}}, + {VK_LMENU, KEYEVENTF_KEYUP, FALSE, {{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, /* test CTRL+O */ /* 4 */ - {VK_LCONTROL, 0, 0, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}}, + {VK_LCONTROL, 0, FALSE, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {0}}}, - {'O', 0, 0, {{'O', 0x00}, {0}}, + {'O', 0, FALSE, {{'O', 0x00}, {0}}, {{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {WM_CHAR}, {0}}}, - {'O', KEYEVENTF_KEYUP, 0, {{'O', 0x80}, {0}}, + {'O', KEYEVENTF_KEYUP, FALSE, {{'O', 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, - {VK_LCONTROL, KEYEVENTF_KEYUP, 0, {{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}}, + {VK_LCONTROL, KEYEVENTF_KEYUP, FALSE, {{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, /* test ALT+CTRL+X */ /* 8 */ - {VK_LMENU, 0, 0, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}}, + {VK_LMENU, 0, FALSE, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}}, {{WM_SYSKEYDOWN, hook}, {WM_SYSKEYDOWN}, {0}}}, - {VK_LCONTROL, 0, 0, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}}, + {VK_LCONTROL, 0, FALSE, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {0}}}, - {'X', 0, 0, {{'X', 0x00}, {0}}, + {'X', 0, FALSE, {{'X', 0x00}, {0}}, {{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {0}}}, - {'X', KEYEVENTF_KEYUP, 0, {{'X', 0x80}, {0}}, + {'X', KEYEVENTF_KEYUP, FALSE, {{'X', 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, - {VK_LCONTROL, KEYEVENTF_KEYUP, 0, {{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}}, + {VK_LCONTROL, KEYEVENTF_KEYUP, FALSE, {{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}}, {{WM_SYSKEYUP, hook}, {WM_SYSKEYUP}, {0}}}, - {VK_LMENU, KEYEVENTF_KEYUP, 0, {{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {0}}, + {VK_LMENU, KEYEVENTF_KEYUP, FALSE, {{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, /* test SHIFT+A */ /* 14 */ - {VK_LSHIFT, 0, 0, {{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}}, + {VK_LSHIFT, 0, FALSE, {{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {0}}}, - {'A', 0, 0, {{'A', 0x00}, {0}}, + {'A', 0, FALSE, {{'A', 0x00}, {0}}, {{WM_KEYDOWN, hook}, {WM_KEYDOWN}, {WM_CHAR}, {0}}}, - {'A', KEYEVENTF_KEYUP, 0, {{'A', 0x80}, {0}}, + {'A', KEYEVENTF_KEYUP, FALSE, {{'A', 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, - {VK_LSHIFT, KEYEVENTF_KEYUP, 0, {{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80}, {0}}, + {VK_LSHIFT, KEYEVENTF_KEYUP, FALSE, {{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook}, {WM_KEYUP}, {0}}}, /* test L-SHIFT & R-SHIFT: */ /* RSHIFT == LSHIFT */ /* 18 */ - {VK_RSHIFT, 0, 0, + {VK_RSHIFT, 0, FALSE, /* recent windows versions (>= w2k3) correctly report an RSHIFT transition */ {{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00, TRUE}, {VK_RSHIFT, 0x00, TRUE}, {0}}, {{WM_KEYDOWN, hook|wparam, VK_RSHIFT}, {WM_KEYDOWN}, {0}}}, - {VK_RSHIFT, KEYEVENTF_KEYUP, 0, + {VK_RSHIFT, KEYEVENTF_KEYUP, FALSE, {{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80, TRUE}, {VK_RSHIFT, 0x80, TRUE}, {0}}, {{WM_KEYUP, hook, hook|wparam, VK_RSHIFT}, {WM_KEYUP}, {0}}}, /* LSHIFT | KEYEVENTF_EXTENDEDKEY == RSHIFT */ /* 20 */ - {VK_LSHIFT, KEYEVENTF_EXTENDEDKEY, 0, + {VK_LSHIFT, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_SHIFT, 0x00}, {VK_RSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam|lparam, VK_LSHIFT, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}}, - {VK_LSHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_LSHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_SHIFT, 0x80}, {VK_RSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook|wparam|lparam, VK_LSHIFT, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}}, /* RSHIFT | KEYEVENTF_EXTENDEDKEY == RSHIFT */ /* 22 */ - {VK_RSHIFT, KEYEVENTF_EXTENDEDKEY, 0, + {VK_RSHIFT, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_SHIFT, 0x00}, {VK_RSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam|lparam, VK_RSHIFT, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}}, - {VK_RSHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_RSHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_SHIFT, 0x80}, {VK_RSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook|wparam|lparam, VK_RSHIFT, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}}, @@ -524,21 +524,21 @@ static const struct sendinput_test_s { */ /* SHIFT == LSHIFT */ /* 24 */ - {VK_SHIFT, 0, 0, + {VK_SHIFT, 0, FALSE, {{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook/* |wparam */|lparam, VK_SHIFT, 0}, {WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}}, - {VK_SHIFT, KEYEVENTF_KEYUP, 0, + {VK_SHIFT, KEYEVENTF_KEYUP, FALSE, {{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook/*|wparam*/|lparam, VK_SHIFT, LLKHF_UP}, {WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}}, /* SHIFT | KEYEVENTF_EXTENDEDKEY == RSHIFT */ /* 26 */ - {VK_SHIFT, KEYEVENTF_EXTENDEDKEY, 0, + {VK_SHIFT, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_SHIFT, 0x00}, {VK_RSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook/*|wparam*/|lparam, VK_SHIFT, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}}, - {VK_SHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_SHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_SHIFT, 0x80}, {VK_RSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook/*|wparam*/|lparam, VK_SHIFT, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}}, @@ -546,51 +546,51 @@ static const struct sendinput_test_s { /* test L-CONTROL & R-CONTROL: */ /* RCONTROL == LCONTROL */ /* 28 */ - {VK_RCONTROL, 0, 0, + {VK_RCONTROL, 0, FALSE, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam, VK_RCONTROL}, {WM_KEYDOWN, wparam|lparam, VK_CONTROL, 0}, {0}}}, - {VK_RCONTROL, KEYEVENTF_KEYUP, 0, + {VK_RCONTROL, KEYEVENTF_KEYUP, FALSE, {{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}}, {{WM_KEYUP, hook|wparam, VK_RCONTROL}, {WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP}, {0}}}, /* LCONTROL | KEYEVENTF_EXTENDEDKEY == RCONTROL */ /* 30 */ - {VK_LCONTROL, KEYEVENTF_EXTENDEDKEY, 0, + {VK_LCONTROL, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_CONTROL, 0x00}, {VK_RCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam|lparam, VK_LCONTROL, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_CONTROL, KF_EXTENDED}, {0}}}, - {VK_LCONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_LCONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_CONTROL, 0x80}, {VK_RCONTROL, 0x80}, {0}}, {{WM_KEYUP, hook|wparam|lparam, VK_LCONTROL, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP|KF_EXTENDED}, {0}}}, /* RCONTROL | KEYEVENTF_EXTENDEDKEY == RCONTROL */ /* 32 */ - {VK_RCONTROL, KEYEVENTF_EXTENDEDKEY, 0, + {VK_RCONTROL, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_CONTROL, 0x00}, {VK_RCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam|lparam, VK_RCONTROL, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_CONTROL, KF_EXTENDED}, {0}}}, - {VK_RCONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_RCONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_CONTROL, 0x80}, {VK_RCONTROL, 0x80}, {0}}, {{WM_KEYUP, hook|wparam|lparam, VK_RCONTROL, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP|KF_EXTENDED}, {0}}}, /* CONTROL == LCONTROL */ /* 34 */ - {VK_CONTROL, 0, 0, + {VK_CONTROL, 0, FALSE, {{VK_CONTROL, 0x00}, {VK_LCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook/*|wparam, VK_CONTROL*/}, {WM_KEYDOWN, wparam|lparam, VK_CONTROL, 0}, {0}}}, - {VK_CONTROL, KEYEVENTF_KEYUP, 0, + {VK_CONTROL, KEYEVENTF_KEYUP, FALSE, {{VK_CONTROL, 0x80}, {VK_LCONTROL, 0x80}, {0}}, {{WM_KEYUP, hook/*|wparam, VK_CONTROL*/}, {WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP}, {0}}}, /* CONTROL | KEYEVENTF_EXTENDEDKEY == RCONTROL */ /* 36 */ - {VK_CONTROL, KEYEVENTF_EXTENDEDKEY, 0, + {VK_CONTROL, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_CONTROL, 0x00}, {VK_RCONTROL, 0x00}, {0}}, {{WM_KEYDOWN, hook/*|wparam*/|lparam, VK_CONTROL, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_CONTROL, KF_EXTENDED}, {0}}}, - {VK_CONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_CONTROL, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_CONTROL, 0x80}, {VK_RCONTROL, 0x80}, {0}}, {{WM_KEYUP, hook/*|wparam*/|lparam, VK_CONTROL, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, wparam|lparam, VK_CONTROL, KF_UP|KF_EXTENDED}, {0}}}, @@ -598,13 +598,13 @@ static const struct sendinput_test_s { /* test L-MENU & R-MENU: */ /* RMENU == LMENU */ /* 38 */ - {VK_RMENU, 0, 0, + {VK_RMENU, 0, FALSE, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {VK_CONTROL, 0x00, 1}, {VK_LCONTROL, 0x01, 1}, {0}}, {{WM_SYSKEYDOWN, hook|wparam|optional, VK_LCONTROL}, {WM_SYSKEYDOWN, hook|wparam, VK_RMENU}, {WM_KEYDOWN, wparam|lparam|optional, VK_CONTROL, 0}, {WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0}, {0}}}, - {VK_RMENU, KEYEVENTF_KEYUP, 1, + {VK_RMENU, KEYEVENTF_KEYUP, TRUE, {{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {VK_CONTROL, 0x81, 1}, {VK_LCONTROL, 0x80, 1}, {0}}, {{WM_KEYUP, hook|wparam|optional, VK_LCONTROL}, {WM_KEYUP, hook|wparam, VK_RMENU}, @@ -613,24 +613,24 @@ static const struct sendinput_test_s { {WM_SYSCOMMAND, optional}, {0}}}, /* LMENU | KEYEVENTF_EXTENDEDKEY == RMENU */ /* 40 */ - {VK_LMENU, KEYEVENTF_EXTENDEDKEY, 0, + {VK_LMENU, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_MENU, 0x00}, {VK_RMENU, 0x00}, {0}}, {{WM_SYSKEYDOWN, hook|wparam|lparam, VK_LMENU, LLKHF_EXTENDED}, {WM_SYSKEYDOWN, wparam|lparam, VK_MENU, KF_EXTENDED}, {0}}}, - {VK_LMENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 1, + {VK_LMENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, TRUE, {{VK_MENU, 0x80}, {VK_RMENU, 0x80}, {0}}, {{WM_KEYUP, hook|wparam|lparam, VK_LMENU, LLKHF_UP|LLKHF_EXTENDED}, {WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP|KF_EXTENDED}, {WM_SYSCOMMAND}, {0}}}, /* RMENU | KEYEVENTF_EXTENDEDKEY == RMENU */ /* 42 */ - {VK_RMENU, KEYEVENTF_EXTENDEDKEY, 0, + {VK_RMENU, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_MENU, 0x00}, {VK_RMENU, 0x00}, {VK_CONTROL, 0x00, 1}, {VK_LCONTROL, 0x01, 1}, {0}}, {{WM_SYSKEYDOWN, hook|wparam|lparam|optional, VK_LCONTROL, 0}, {WM_SYSKEYDOWN, hook|wparam|lparam, VK_RMENU, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam|optional, VK_CONTROL, 0}, {WM_SYSKEYDOWN, wparam|lparam, VK_MENU, KF_EXTENDED}, {0}}}, - {VK_RMENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 1, + {VK_RMENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, TRUE, {{VK_MENU, 0x80}, {VK_RMENU, 0x80}, {VK_CONTROL, 0x81, 1}, {VK_LCONTROL, 0x80, 1}, {0}}, {{WM_KEYUP, hook|wparam|lparam|optional, VK_LCONTROL, LLKHF_UP}, {WM_KEYUP, hook|wparam|lparam, VK_RMENU, LLKHF_UP|LLKHF_EXTENDED}, @@ -639,23 +639,23 @@ static const struct sendinput_test_s { {WM_SYSCOMMAND, optional}, {0}}}, /* MENU == LMENU */ /* 44 */ - {VK_MENU, 0, 0, + {VK_MENU, 0, FALSE, {{VK_MENU, 0x00}, {VK_LMENU, 0x00}, {0}}, {{WM_SYSKEYDOWN, hook/*|wparam, VK_MENU*/}, {WM_SYSKEYDOWN, wparam|lparam, VK_MENU, 0}, {0}}}, - {VK_MENU, KEYEVENTF_KEYUP, 1, + {VK_MENU, KEYEVENTF_KEYUP, TRUE, {{VK_MENU, 0x80}, {VK_LMENU, 0x80}, {0}}, {{WM_KEYUP, hook/*|wparam, VK_MENU*/}, {WM_SYSKEYUP, wparam|lparam, VK_MENU, KF_UP}, {WM_SYSCOMMAND}, {0}}}, /* MENU | KEYEVENTF_EXTENDEDKEY == RMENU */ /* 46 */ - {VK_MENU, KEYEVENTF_EXTENDEDKEY, 0, + {VK_MENU, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_MENU, 0x00}, {VK_RMENU, 0x00}, {VK_CONTROL, 0x00, 1}, {VK_LCONTROL, 0x01, 1}, {0}}, {{WM_SYSKEYDOWN, hook|wparam|lparam|optional, VK_CONTROL, 0}, {WM_SYSKEYDOWN, hook/*|wparam*/|lparam, VK_MENU, LLKHF_EXTENDED}, {WM_SYSKEYDOWN, wparam|lparam, VK_MENU, KF_EXTENDED}, {0}}}, - {VK_MENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 1, + {VK_MENU, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, TRUE, {{VK_MENU, 0x80}, {VK_RMENU, 0x80}, {VK_CONTROL, 0x81, 1}, {VK_LCONTROL, 0x80, 1}, {0}}, {{WM_KEYUP, hook|wparam|lparam|optional, VK_CONTROL, LLKHF_UP}, {WM_KEYUP, hook/*|wparam*/|lparam, VK_MENU, LLKHF_UP|LLKHF_EXTENDED}, @@ -664,24 +664,24 @@ static const struct sendinput_test_s { /* test LSHIFT & RSHIFT */ /* 48 */ - {VK_LSHIFT, 0, 0, + {VK_LSHIFT, 0, FALSE, {{VK_SHIFT, 0x00}, {VK_LSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam|lparam, VK_LSHIFT, 0}, {WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}}, - {VK_RSHIFT, KEYEVENTF_EXTENDEDKEY, 0, + {VK_RSHIFT, KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_RSHIFT, 0x00}, {0}}, {{WM_KEYDOWN, hook|wparam|lparam, VK_RSHIFT, LLKHF_EXTENDED}, {WM_KEYDOWN, wparam|lparam, VK_SHIFT, 0}, {0}}}, - {VK_RSHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, 0, + {VK_RSHIFT, KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY, FALSE, {{VK_RSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook|wparam|lparam, VK_RSHIFT, LLKHF_UP|LLKHF_EXTENDED}, {WM_KEYUP, optional}, {0}}}, - {VK_LSHIFT, KEYEVENTF_KEYUP, 0, + {VK_LSHIFT, KEYEVENTF_KEYUP, FALSE, {{VK_SHIFT, 0x80}, {VK_LSHIFT, 0x80}, {0}}, {{WM_KEYUP, hook|wparam, VK_LSHIFT}, {WM_KEYUP, wparam|lparam, VK_SHIFT, KF_UP}, {0}}}, - {0, 0, 0, {{0}}, {{0}}} /* end */ + {0, 0, FALSE, {{0}}, {{0}}} /* end */ }; static struct message sent_messages[MAXKEYMESSAGES]; @@ -696,7 +696,7 @@ static void compare_and_check(int id, BYTE *ks1, BYTE *ks2, const struct sendinp const struct message *expected = test->expected_messages; while (t->wVk) { - int matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80) + BOOL matched = ((ks1[t->wVk]&0x80) == (t->before_state&0x80) && (ks2[t->wVk]&0x80) == (~t->before_state&0x80)); if (!matched && !t->optional && test->_todo_wine) @@ -865,7 +865,7 @@ static LRESULT CALLBACK WndProc2(HWND hWnd, UINT Msg, WPARAM wParam, sent_messages[sent_messages_cnt++].lParam = HIWORD(lParam) & (KF_UP|KF_EXTENDED); } } - return DefWindowProc(hWnd, Msg, wParam, lParam); + return DefWindowProcA(hWnd, Msg, wParam, lParam); } static LRESULT CALLBACK hook_proc(int code, WPARAM wparam, LPARAM lparam) @@ -911,7 +911,7 @@ static void test_Input_blackbox(void) skip("Skipping Input_blackbox test on non-US keyboard\n"); return; } - window = CreateWindow("Static", NULL, WS_POPUP|WS_HSCROLL|WS_VSCROLL + window = CreateWindowA("Static", NULL, WS_POPUP|WS_HSCROLL|WS_VSCROLL |WS_VISIBLE, 0, 0, 200, 60, NULL, NULL, NULL, NULL); ok(window != NULL, "error: %d\n", (int) GetLastError()); @@ -929,7 +929,7 @@ static void test_Input_blackbox(void) * key state set by SendInput(). */ empty_message_queue(); - prevWndProc = SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR) WndProc2); + prevWndProc = SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR) WndProc2); ok(prevWndProc != 0 || (prevWndProc == 0 && GetLastError() == 0), "error: %d\n", (int) GetLastError()); @@ -1160,8 +1160,8 @@ static void test_Input_unicode(void) wclass.style = CS_HREDRAW | CS_VREDRAW; wclass.lpfnWndProc = unicode_wnd_proc; wclass.hInstance = hInstance; - wclass.hIcon = LoadIcon(0, IDI_APPLICATION); - wclass.hCursor = LoadCursor( NULL, IDC_ARROW); + wclass.hIcon = LoadIconW(0, (LPCWSTR)IDI_APPLICATION); + wclass.hCursor = LoadCursorW( NULL, (LPCWSTR)IDC_ARROW); wclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; @@ -1171,7 +1171,7 @@ static void test_Input_unicode(void) return; } - hModuleImm32 = LoadLibrary("imm32.dll"); + hModuleImm32 = LoadLibraryA("imm32.dll"); if (hModuleImm32) { pImmDisableIME = (void *)GetProcAddress(hModuleImm32, "ImmDisableIME"); if (pImmDisableIME) @@ -1280,7 +1280,7 @@ static void test_mouse_ll_hook(void) RECT rc; GetCursorPos(&pt_org); - hwnd = CreateWindow("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + hwnd = CreateWindowA("static", "Title", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 10, 10, 200, 200, NULL, NULL, NULL, NULL); SetCursorPos(100, 100); @@ -1503,34 +1503,34 @@ static void test_key_map(void) { VK_NUMPAD9, VK_PRIOR }, }; - s = MapVirtualKeyEx(VK_SHIFT, MAPVK_VK_TO_VSC, kl); + s = MapVirtualKeyExA(VK_SHIFT, MAPVK_VK_TO_VSC, kl); ok(s != 0, "MapVirtualKeyEx(VK_SHIFT) should return non-zero\n"); - sL = MapVirtualKeyEx(VK_LSHIFT, MAPVK_VK_TO_VSC, kl); + sL = MapVirtualKeyExA(VK_LSHIFT, MAPVK_VK_TO_VSC, kl); ok(s == sL || broken(sL == 0), /* win9x */ "%x != %x\n", s, sL); - kL = MapVirtualKeyEx(0x2a, MAPVK_VSC_TO_VK, kl); + kL = MapVirtualKeyExA(0x2a, MAPVK_VSC_TO_VK, kl); ok(kL == VK_SHIFT, "Scan code -> vKey = %x (not VK_SHIFT)\n", kL); - kR = MapVirtualKeyEx(0x36, MAPVK_VSC_TO_VK, kl); + kR = MapVirtualKeyExA(0x36, MAPVK_VSC_TO_VK, kl); ok(kR == VK_SHIFT, "Scan code -> vKey = %x (not VK_SHIFT)\n", kR); - kL = MapVirtualKeyEx(0x2a, MAPVK_VSC_TO_VK_EX, kl); + kL = MapVirtualKeyExA(0x2a, MAPVK_VSC_TO_VK_EX, kl); ok(kL == VK_LSHIFT || broken(kL == 0), /* win9x */ "Scan code -> vKey = %x (not VK_LSHIFT)\n", kL); - kR = MapVirtualKeyEx(0x36, MAPVK_VSC_TO_VK_EX, kl); + kR = MapVirtualKeyExA(0x36, MAPVK_VSC_TO_VK_EX, kl); ok(kR == VK_RSHIFT || broken(kR == 0), /* win9x */ "Scan code -> vKey = %x (not VK_RSHIFT)\n", kR); /* test that MAPVK_VSC_TO_VK prefers the non-numpad vkey if there's ambiguity */ for (i = 0; i < sizeof(numpad_collisions)/sizeof(numpad_collisions[0]); i++) { - UINT numpad_scan = MapVirtualKeyEx(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl); - UINT other_scan = MapVirtualKeyEx(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl); + UINT numpad_scan = MapVirtualKeyExA(numpad_collisions[i][0], MAPVK_VK_TO_VSC, kl); + UINT other_scan = MapVirtualKeyExA(numpad_collisions[i][1], MAPVK_VK_TO_VSC, kl); /* do they really collide for this layout? */ if (numpad_scan && other_scan == numpad_scan) { - UINT vkey = MapVirtualKeyEx(numpad_scan, MAPVK_VSC_TO_VK, kl); + UINT vkey = MapVirtualKeyExA(numpad_scan, MAPVK_VSC_TO_VK, kl); ok(vkey != numpad_collisions[i][0], "Got numpad vKey %x for scan code %x when there was another choice\n", vkey, numpad_scan); diff --git a/rostests/winetests/user32/menu.c b/rostests/winetests/user32/menu.c index e8f2d0f75b7..23922053b08 100755 --- a/rostests/winetests/user32/menu.c +++ b/rostests/winetests/user32/menu.c @@ -64,15 +64,15 @@ static void init_function_pointers(void) static BOOL correct_behavior(void) { HMENU hmenu; - MENUITEMINFO info; + MENUITEMINFOA info; BOOL rc; hmenu = CreateMenu(); - memset(&info, 0, sizeof(MENUITEMINFO)); - info.cbSize= sizeof(MENUITEMINFO); + memset(&info, 0, sizeof(MENUITEMINFOA)); + info.cbSize= sizeof(MENUITEMINFOA); SetLastError(0xdeadbeef); - rc = GetMenuItemInfo(hmenu, 0, TRUE, &info); + rc = GetMenuItemInfoA(hmenu, 0, TRUE, &info); /* Win9x : 0xdeadbeef * NT4 : ERROR_INVALID_PARAMETER * >= W2K : ERROR_MENU_ITEM_NOT_FOUND @@ -94,12 +94,12 @@ static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LP { case WM_ENTERMENULOOP: /* mark window as having entered menu loop */ - SetWindowLongPtr(hwnd, GWLP_USERDATA, TRUE); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, TRUE); /* exit menu modal loop * ( A SendMessage does not work on NT3.51 here ) */ - return PostMessage(hwnd, WM_CANCELMODE, 0, 0); + return PostMessageA(hwnd, WM_CANCELMODE, 0, 0); } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } /* The MSVC headers ignore our NONAMELESSUNION requests so we have to define @@ -144,10 +144,13 @@ static int MOD_avec, MOD_hic; static int MOD_odheight; static SIZE MODsizes[MOD_NRMENUS]= { {MOD_SIZE, MOD_SIZE},{MOD_SIZE, MOD_SIZE}, {MOD_SIZE, MOD_SIZE},{MOD_SIZE, MOD_SIZE}}; -static int MOD_GotDrawItemMsg = FALSE; +static BOOL MOD_GotDrawItemMsg = FALSE; static int gflag_initmenupopup, gflag_entermenuloop, - gflag_initmenu; + gflag_initmenu, + gflag_enteridle; +static WPARAM selectitem_wp; +static LPARAM selectitem_lp; /* wndproc used by test_menu_ownerdraw() */ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, @@ -182,7 +185,7 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, case WM_DRAWITEM: { DRAWITEMSTRUCT * pdis; - TEXTMETRIC tm; + TEXTMETRICA tm; HPEN oldpen; char chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; SIZE sz; @@ -212,12 +215,12 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, strcpy( buf, MOD_txtsizes[i].text); if( ( p = strchr( buf, '\t'))) { *p = '\0'; - DrawText( pdis->hDC, p + 1, -1, &rc, + DrawTextA( pdis->hDC, p + 1, -1, &rc, DT_SINGLELINE|DT_CALCRECT); MOD_txtsizes[i].sc_size.cx= rc.right - rc.left; MOD_txtsizes[i].sc_size.cy= rc.bottom - rc.top; } - DrawText( pdis->hDC, buf, -1, &rc, + DrawTextA( pdis->hDC, buf, -1, &rc, DT_SINGLELINE|DT_CALCRECT); MOD_txtsizes[i].size.cx= rc.right - rc.left; MOD_txtsizes[i].size.cy= rc.bottom - rc.top; @@ -227,15 +230,16 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, /* store the rectangle */ MOD_rc[pdis->itemData] = pdis->rcItem; /* calculate average character width */ - GetTextExtentPoint( pdis->hDC, chrs, 52, &sz ); + GetTextExtentPointA( pdis->hDC, chrs, 52, &sz ); MOD_avec = (sz.cx + 26)/52; - GetTextMetrics( pdis->hDC, &tm); + GetTextMetricsA( pdis->hDC, &tm); MOD_hic = tm.tmHeight; MOD_GotDrawItemMsg = TRUE; return TRUE; } case WM_ENTERIDLE: { + gflag_enteridle++; ok( lparam || broken(!lparam), /* win9x, nt4 */ "Menu window handle is NULL!\n"); if( lparam) { @@ -243,31 +247,34 @@ static LRESULT WINAPI menu_ownerdraw_wnd_proc(HWND hwnd, UINT msg, ok( hmenupopup == hmenu, "MN_GETHMENU returns %p expected %p\n", hmenu, hmenupopup); } - PostMessage(hwnd, WM_CANCELMODE, 0, 0); + PostMessageA(hwnd, WM_CANCELMODE, 0, 0); return TRUE; } - + case WM_MENUSELECT: + selectitem_wp = wparam; + selectitem_lp = lparam; + break; } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } static void register_menu_check_class(void) { - WNDCLASS wc = + WNDCLASSA wc = { 0, menu_check_wnd_proc, 0, 0, - GetModuleHandle(NULL), + GetModuleHandleA(NULL), NULL, - LoadCursor(NULL, IDC_ARROW), + LoadCursorA(NULL, (LPCSTR)IDC_ARROW), (HBRUSH)(COLOR_BTNFACE+1), NULL, - TEXT("WineMenuCheck"), + "WineMenuCheck", }; - - atomMenuCheckClass = RegisterClass(&wc); + + atomMenuCheckClass = RegisterClassA(&wc); } static void test_getmenubarinfo(void) @@ -286,7 +293,7 @@ static void test_getmenubarinfo(void) mbi.cbSize = sizeof(MENUBARINFO); - hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_SYSMENU | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); @@ -350,9 +357,9 @@ static void test_getmenubarinfo(void) ok(mbi.fFocused == 0, "fFocused: Got %d instead of 0.\n", mbi.fFocused); /* add some items */ - ret = AppendMenu(hmenu, MF_STRING , 100, "item 1"); + ret = AppendMenuA(hmenu, MF_STRING , 100, "item 1"); ok(ret, "AppendMenu failed.\n"); - ret = AppendMenu(hmenu, MF_STRING , 101, "item 2"); + ret = AppendMenuA(hmenu, MF_STRING , 101, "item 2"); ok(ret, "AppendMenu failed.\n"); ret = SetMenu(hwnd, hmenu); ok(ret, "SetMenu failed with error %d\n", GetLastError()); @@ -404,13 +411,13 @@ static void test_menu_locked_by_window(void) { BOOL ret; HMENU hmenu; - HWND hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + HWND hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); hmenu = CreateMenu(); ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); - ret = InsertMenu(hmenu, 0, MF_STRING, 0, TEXT("&Test")); + ret = InsertMenuA(hmenu, 0, MF_STRING, 0, "&Test"); ok(ret, "InsertMenu failed with error %d\n", GetLastError()); ret = SetMenu(hwnd, hmenu); ok(ret, "SetMenu failed with error %d\n", GetLastError()); @@ -418,15 +425,13 @@ static void test_menu_locked_by_window(void) ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); ret = DrawMenuBar(hwnd); - todo_wine { ok(ret, "DrawMenuBar failed with error %d\n", GetLastError()); - } ret = IsMenu(GetMenu(hwnd)); ok(!ret || broken(ret) /* nt4 */, "Menu handle should have been destroyed\n"); - SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0); + SendMessageA(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0); /* did we process the WM_INITMENU message? */ - ret = GetWindowLongPtr(hwnd, GWLP_USERDATA); + ret = GetWindowLongPtrA(hwnd, GWLP_USERDATA); todo_wine { ok(ret, "WM_INITMENU should have been sent\n"); } @@ -444,12 +449,12 @@ static LRESULT WINAPI subpopuplocked_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam case WM_ENTERIDLE: hwndmenu = GetCapture(); if( hwndmenu) { - PostMessage( hwndmenu, WM_KEYDOWN, VK_DOWN, 0); - PostMessage( hwndmenu, WM_KEYDOWN, VK_RIGHT, 0); - PostMessage( hwndmenu, WM_KEYDOWN, VK_RETURN, 0); + PostMessageA( hwndmenu, WM_KEYDOWN, VK_DOWN, 0); + PostMessageA( hwndmenu, WM_KEYDOWN, VK_RIGHT, 0); + PostMessageA( hwndmenu, WM_KEYDOWN, VK_RETURN, 0); } } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } static void test_subpopup_locked_by_menu(void) @@ -458,7 +463,7 @@ static void test_subpopup_locked_by_menu(void) BOOL ret; HMENU hmenu, hsubmenu; MENUINFO mi = { sizeof( MENUINFO)}; - MENUITEMINFO mii = { sizeof( MENUITEMINFO)}; + MENUITEMINFOA mii = { sizeof( MENUITEMINFOA)}; HWND hwnd; const int itemid = 0x1234567; if( !pGetMenuInfo) @@ -467,23 +472,23 @@ static void test_subpopup_locked_by_menu(void) return; } /* create window, popupmenu with one subpopup */ - hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); - SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR) subpopuplocked_wnd_proc); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR) subpopuplocked_wnd_proc); hmenu = CreatePopupMenu(); ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); hsubmenu = CreatePopupMenu(); ok(hsubmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); - ret = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hsubmenu, - TEXT("PopUpLockTest")); + ret = InsertMenuA(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hsubmenu, + "PopUpLockTest"); ok(ret, "InsertMenu failed with error %d\n", GetLastError()); - ret = InsertMenu(hsubmenu, 0, MF_BYPOSITION | MF_STRING, itemid, TEXT("PopUpMenu")); + ret = InsertMenuA(hsubmenu, 0, MF_BYPOSITION | MF_STRING, itemid, "PopUpMenu"); ok(ret, "InsertMenu failed with error %d\n", GetLastError()); /* first some tests that all this functions properly */ mii.fMask = MIIM_SUBMENU; - ret = GetMenuItemInfo( hmenu, 0, TRUE, &mii); + ret = GetMenuItemInfoA( hmenu, 0, TRUE, &mii); ok( ret, "GetMenuItemInfo failed error %d\n", GetLastError()); ok( mii.hSubMenu == hsubmenu, "submenu is %p\n", mii.hSubMenu); mi.fMask |= MIM_STYLE; @@ -507,7 +512,7 @@ static void test_subpopup_locked_by_menu(void) ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); /* and repeat the tests */ mii.fMask = MIIM_SUBMENU; - ret = GetMenuItemInfo( hmenu, 0, TRUE, &mii); + ret = GetMenuItemInfoA( hmenu, 0, TRUE, &mii); ok( ret, "GetMenuItemInfo failed error %d\n", GetLastError()); /* GetMenuInfo fails now */ ok( mii.hSubMenu == hsubmenu, "submenu is %p\n", mii.hSubMenu); @@ -539,22 +544,22 @@ static void test_menu_ownerdraw(void) int i,j,k; BOOL ret; HMENU hmenu; - MENUITEMINFO mii; + MENUITEMINFOA mii; LONG leftcol; - HWND hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + HWND hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); if( !hwnd) return; - SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); hmenu = CreatePopupMenu(); ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); if( !hmenu) { DestroyWindow(hwnd);return;} k=0; for( j=0;j<2;j++) /* create columns */ for(i=0;i<2;i++) { /* create rows */ - ret = AppendMenu( hmenu, MF_OWNERDRAW | - (i==0 ? MF_MENUBREAK : 0), k, MAKEINTRESOURCE(k)); + ret = AppendMenuA( hmenu, MF_OWNERDRAW | + (i==0 ? MF_MENUBREAK : 0), k, (LPCSTR)MAKEINTRESOURCE(k)); k++; ok( ret, "AppendMenu failed for %d\n", k-1); } @@ -583,7 +588,7 @@ static void test_menu_ownerdraw(void) /* test what MF_MENUBREAK did at the first position. Also show * that an MF_SEPARATOR is ignored in the height calculation. */ leftcol= MOD_rc[0].left; - ModifyMenu( hmenu, 0, MF_BYCOMMAND| MF_OWNERDRAW| MF_SEPARATOR, 0, 0); + ModifyMenuA( hmenu, 0, MF_BYCOMMAND| MF_OWNERDRAW| MF_SEPARATOR, 0, 0); /* display the menu */ TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); /* left should be 4 pixels less now */ @@ -600,7 +605,7 @@ static void test_menu_ownerdraw(void) MOD_rc[0].bottom - MOD_rc[0].top, MOD_SIZE); /* test owner-drawn callback bitmap */ - ModifyMenu( hmenu, 1, MF_BYPOSITION | MFT_BITMAP, 1, (LPCSTR)HBMMENU_CALLBACK ); + ModifyMenuA( hmenu, 1, MF_BYPOSITION | MFT_BITMAP, 1, (LPCSTR)HBMMENU_CALLBACK ); mii.cbSize = sizeof(mii); mii.fMask = MIIM_BITMAP | MIIM_FTYPE | MIIM_ID; if (GetMenuItemInfoA( hmenu, 1, TRUE, &mii )) @@ -619,7 +624,7 @@ static void test_menu_ownerdraw(void) if( !hmenu) { DestroyWindow(hwnd);return;} MOD_maxid=1; for(i=0;i<2;i++) { - ret = AppendMenu( hmenu, MF_OWNERDRAW , i, 0); + ret = AppendMenuA( hmenu, MF_OWNERDRAW, i, 0 ); ok( ret, "AppendMenu failed for %d\n", i); } ret = SetMenu( hwnd, hmenu); @@ -647,12 +652,12 @@ static void test_mbs_help( int ispop, int hassub, int mnuopt, { BOOL ret; HMENU hmenu, submenu; - MENUITEMINFO mii={ sizeof( MENUITEMINFO )}; + MENUITEMINFOA mii={ sizeof( MENUITEMINFOA )}; MENUINFO mi; RECT rc; CHAR text_copy[16]; int hastab, expect; - int failed = 0; + BOOL failed = FALSE; MOD_GotDrawItemMsg = FALSE; mii.fMask = MIIM_FTYPE | MIIM_DATA | MIIM_STATE; @@ -696,7 +701,7 @@ static void test_mbs_help( int ispop, int hassub, int mnuopt, ret = pSetMenuInfo( hmenu, &mi); ok( ret, "SetMenuInfo failed with error %d\n", GetLastError()); } - ret = InsertMenuItem( hmenu, 0, FALSE, &mii); + ret = InsertMenuItemA( hmenu, 0, FALSE, &mii); ok( ret, "InsertMenuItem failed with error %d\n", GetLastError()); failed = !ret; if( winetest_debug) { @@ -706,7 +711,7 @@ static void test_mbs_help( int ispop, int hassub, int mnuopt, sprintf( buf,"%d text \"%s\" mnuopt %d", count, text ? text: "(nil)", mnuopt); FillRect( hdc, &rc, (HBRUSH) COLOR_WINDOW); - TextOut( hdc, 10, 50, buf, strlen( buf)); + TextOutA( hdc, 10, 50, buf, strlen( buf)); ReleaseDC( hwnd, hdc); } if(ispop) @@ -819,11 +824,11 @@ static void test_menu_bmp_and_string(void) } memset( bmfill, 0xcc, sizeof( bmfill)); - hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, WS_SYSMENU | + hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_SYSMENU | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); - hbm_arrow=LoadBitmap( 0, (CHAR*)OBM_MNARROW); - GetObject( hbm_arrow, sizeof(bm), &bm); + hbm_arrow = LoadBitmapA( 0, (LPCSTR)OBM_MNARROW); + GetObjectA( hbm_arrow, sizeof(bm), &bm); arrowwidth = bm.bmWidth; ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); if( !hwnd) return; @@ -843,7 +848,7 @@ static void test_menu_bmp_and_string(void) ok( HBMMENU_POPUP_CLOSE == mii.hbmpItem, "Item info did not get the right hbitmap: got %p expected %p\n", mii.hbmpItem, HBMMENU_POPUP_CLOSE); - SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); if( winetest_debug) trace(" check %d,%d arrow %d avechar %d\n", @@ -890,7 +895,7 @@ static void test_menu_bmp_and_string(void) static void test_menu_add_string( void ) { HMENU hmenu; - MENUITEMINFO info; + MENUITEMINFOA info; BOOL rc; int ret; @@ -912,7 +917,7 @@ static void test_menu_add_string( void ) info.dwItemData = 0; info.wID = 1; info.fState = 0; - InsertMenuItem(hmenu, 0, TRUE, &info ); + InsertMenuItemA(hmenu, 0, TRUE, &info ); memset( &info, 0, sizeof info ); info.cbSize = sizeof info; @@ -920,22 +925,22 @@ static void test_menu_add_string( void ) info.dwTypeData = string; info.cch = sizeof string; string[0] = 0; - GetMenuItemInfo( hmenu, 0, TRUE, &info ); + GetMenuItemInfoA( hmenu, 0, TRUE, &info ); ok( !strcmp( string, "blah" ), "menu item name differed\n"); /* Test combination of ownerdraw and strings with GetMenuItemString(A/W) */ strcpy(string, "Dummy string"); memset(&info, 0x00, sizeof(info)); - info.cbSize= sizeof(MENUITEMINFO); + info.cbSize= sizeof(MENUITEMINFOA); info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */ info.fType= MFT_OWNERDRAW; info.dwTypeData= string; - rc = InsertMenuItem( hmenu, 0, TRUE, &info ); + rc = InsertMenuItemA( hmenu, 0, TRUE, &info ); ok (rc, "InsertMenuItem failed\n"); strcpy(string,"Garbage"); - ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); SetLastError(0xdeadbeef); @@ -948,58 +953,71 @@ static void test_menu_add_string( void ) ok (!lstrcmpW( strbackW, expectedString ), "Menu text from Unicode version incorrect\n"); } + /* Just try some invalid parameter tests */ + SetLastError(0xdeadbeef); + rc = SetMenuItemInfoA( hmenu, 0, TRUE, NULL ); + ret = GetLastError(); + ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n"); + ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret); + + SetLastError(0xdeadbeef); + rc = SetMenuItemInfoA( hmenu, 0, FALSE, NULL ); + ret = GetLastError(); + ok (!rc, "SetMenuItemInfoA succeeded unexpectedly\n"); + ok (ret == ERROR_INVALID_PARAMETER, "Expected 87, got %d\n", ret); + /* Just change ftype to string and see what text is stored */ memset(&info, 0x00, sizeof(info)); - info.cbSize= sizeof(MENUITEMINFO); + info.cbSize= sizeof(MENUITEMINFOA); info.fMask= MIIM_FTYPE; /* Set string type */ info.fType= MFT_STRING; - info.dwTypeData= (char *)0xdeadbeef; - rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + info.dwTypeData= (char *)0xdeadbeef; + rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info ); ok (rc, "SetMenuItemInfo failed\n"); /* Did we keep the old dwTypeData? */ - ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); /* Ensure change to bitmap type fails */ memset(&info, 0x00, sizeof(info)); - info.cbSize= sizeof(MENUITEMINFO); + info.cbSize= sizeof(MENUITEMINFOA); info.fMask= MIIM_FTYPE; /* Set as bitmap type */ info.fType= MFT_BITMAP; info.dwTypeData= (char *)0xdeadbee2; - rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info ); ok (!rc, "SetMenuItemInfo unexpectedly worked\n"); /* Just change ftype back and ensure data hasn't been freed */ info.fType= MFT_OWNERDRAW; /* Set as ownerdraw type */ info.dwTypeData= (char *)0xdeadbee3; - rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info ); ok (rc, "SetMenuItemInfo failed\n"); - + /* Did we keep the old dwTypeData? */ - ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); ok (!strcmp( strback, "Dummy string" ), "Menu text from Ansi version incorrect\n"); /* Just change string value (not type) */ memset(&info, 0x00, sizeof(info)); - info.cbSize= sizeof(MENUITEMINFO); + info.cbSize= sizeof(MENUITEMINFOA); info.fMask= MIIM_STRING; /* Set typeData */ strcpy(string2, "string2"); - info.dwTypeData= string2; - rc = SetMenuItemInfo( hmenu, 0, TRUE, &info ); + info.dwTypeData= string2; + rc = SetMenuItemInfoA( hmenu, 0, TRUE, &info ); ok (rc, "SetMenuItemInfo failed\n"); - ok (GetMenuString( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); + ok (GetMenuStringA( hmenu, 0, strback, 99, MF_BYPOSITION), "GetMenuString on ownerdraw entry failed\n"); ok (!strcmp( strback, "string2" ), "Menu text from Ansi version incorrect\n"); /* crashes with wine 0.9.5 */ memset(&info, 0x00, sizeof(info)); - info.cbSize= sizeof(MENUITEMINFO); + info.cbSize= sizeof(MENUITEMINFOA); info.fMask= MIIM_FTYPE | MIIM_STRING; /* Set OwnerDraw + typeData */ info.fType= MFT_OWNERDRAW; - rc = InsertMenuItem( hmenu, 0, TRUE, &info ); + rc = InsertMenuItemA( hmenu, 0, TRUE, &info ); ok (rc, "InsertMenuItem failed\n"); - ok (!GetMenuString( hmenu, 0, NULL, 0, MF_BYPOSITION), + ok (!GetMenuStringA( hmenu, 0, NULL, 0, MF_BYPOSITION), "GetMenuString on ownerdraw entry succeeded.\n"); SetLastError(0xdeadbeef); ret = GetMenuStringW( hmenu, 0, NULL, 0, MF_BYPOSITION); @@ -1203,7 +1221,7 @@ static void set_menu_item_info( int line, HMENU hmenu, BOOL ansi, UINT mask, UIN static void test_menu_iteminfo( void ) { - int ansi = TRUE; + BOOL ansi = TRUE; char txtA[]="wine"; char initA[]="XYZ"; char emptyA[]=""; @@ -1693,7 +1711,7 @@ static void test_menu_iteminfo( void ) static void test_menu_search_bycommand( void ) { HMENU hmenu, hmenuSub, hmenuSub2; - MENUITEMINFO info; + MENUITEMINFOA info; BOOL rc; UINT id; char strback[0x80]; @@ -1703,7 +1721,7 @@ static void test_menu_search_bycommand( void ) /* Case 1: Menu containing a menu item */ hmenu = CreateMenu(); - + memset( &info, 0, sizeof info ); info.cbSize = sizeof info; info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_ID; @@ -1711,8 +1729,8 @@ static void test_menu_search_bycommand( void ) strcpy(strIn, "Case 1 MenuItem"); info.dwTypeData = strIn; info.wID = (UINT) 0x1234; - - rc = InsertMenuItem(hmenu, 0, TRUE, &info ); + + rc = InsertMenuItemA(hmenu, 0, TRUE, &info ); ok (rc, "Inserting the menuitem failed\n"); id = GetMenuItemID(hmenu, 0); @@ -1721,12 +1739,12 @@ static void test_menu_search_bycommand( void ) /* Confirm the menuitem was given the id supplied (getting by position) */ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, 0, TRUE, &info); /* Get by position */ + rc = GetMenuItemInfoA(hmenu, 0, TRUE, &info); /* Get by position */ ok (rc, "Getting the menu items info failed\n"); ok (info.wID == 0x1234, "IDs differ for the menuitem\n"); ok (!strcmp(info.dwTypeData, "Case 1 MenuItem"), "Returned item has wrong label\n"); @@ -1734,11 +1752,11 @@ static void test_menu_search_bycommand( void ) /* Search by id - Should return the item */ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, 0x1234, FALSE, &info); /* Get by ID */ + rc = GetMenuItemInfoA(hmenu, 0x1234, FALSE, &info); /* Get by ID */ ok (rc, "Getting the menu items info failed\n"); ok (info.wID == 0x1234, "IDs differ for the menuitem\n"); @@ -1749,9 +1767,9 @@ static void test_menu_search_bycommand( void ) /* Case 2: Menu containing a popup menu */ hmenu = CreateMenu(); hmenuSub = CreateMenu(); - + strcpy(strIn, "Case 2 SubMenu"); - rc = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, strIn); + rc = InsertMenuA(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, strIn); ok (rc, "Inserting the popup menu into the main menu failed\n"); id = GetMenuItemID(hmenu, 0); @@ -1760,13 +1778,13 @@ static void test_menu_search_bycommand( void ) /* Confirm the menuitem itself was given an id the same as the HMENU, (getting by position) */ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; info.dwTypeData = strback; info.cch = sizeof(strback); info.wID = 0xdeadbeef; - rc = GetMenuItemInfo(hmenu, 0, TRUE, &info); /* Get by position */ + rc = GetMenuItemInfoA(hmenu, 0, TRUE, &info); /* Get by position */ ok (rc, "Getting the menu items info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the menuitem\n"); ok (!strcmp(info.dwTypeData, "Case 2 SubMenu"), "Returned item has wrong label\n"); @@ -1774,11 +1792,11 @@ static void test_menu_search_bycommand( void ) /* Search by id - returns the popup menu itself */ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ + rc = GetMenuItemInfoA(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ ok (rc, "Getting the menu items info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the popup menu\n"); @@ -1794,17 +1812,17 @@ static void test_menu_search_bycommand( void ) strcpy(strIn, "Case 2 MenuItem 1"); info.dwTypeData = strIn; info.wID = (UINT_PTR) hmenuSub; - rc = InsertMenuItem(hmenu, -1, TRUE, &info ); + rc = InsertMenuItemA(hmenu, -1, TRUE, &info ); ok (rc, "Inserting the menuitem failed\n"); /* Search by id - returns the item which follows the popup menu */ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ + rc = GetMenuItemInfoA(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ ok (rc, "Getting the menu items info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the popup menu\n"); @@ -1820,17 +1838,17 @@ static void test_menu_search_bycommand( void ) strcpy(strIn, "Case 2 MenuItem 2"); info.dwTypeData = strIn; info.wID = (UINT_PTR) hmenuSub; - rc = InsertMenuItem(hmenu, 0, TRUE, &info ); + rc = InsertMenuItemA(hmenu, 0, TRUE, &info ); ok (rc, "Inserting the menuitem failed\n"); /* Search by id - returns the item which precedes the popup menu */ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ + rc = GetMenuItemInfoA(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); /* Get by ID */ ok (rc, "Getting the menu items info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for the popup menu\n"); @@ -1854,10 +1872,10 @@ static void test_menu_search_bycommand( void ) info.dwTypeData = menuitem; info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ - rc = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); + rc = InsertMenuA(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); ok (rc, "Inserting the popup menu into the main menu failed\n"); - rc = InsertMenuItem(hmenuSub, 0, TRUE, &info ); + rc = InsertMenuItemA(hmenuSub, 0, TRUE, &info ); ok (rc, "Inserting the sub menu menuitem failed\n"); memset( &info, 0, sizeof info ); @@ -1867,40 +1885,40 @@ static void test_menu_search_bycommand( void ) info.dwTypeData = menuitem2; info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ - rc = InsertMenuItem(hmenuSub, 1, TRUE, &info ); + rc = InsertMenuItemA(hmenuSub, 1, TRUE, &info ); ok (rc, "Inserting the sub menu menuitem 2 failed\n"); /* Prove that you can't query the id of a popup directly (By position) */ id = GetMenuItemID(hmenu, 0); - ok (id == -1, "Getting the sub menu id should have failed because its a popup (gave %x)\n", id); + ok (id == -1, "Getting the sub menu id should have failed because it's a popup (gave %x)\n", id); /* Prove getting the item info via ID returns the first item (not the popup or 2nd item)*/ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_STRING | MIIM_ID; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); + rc = GetMenuItemInfoA(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); ok (rc, "Getting the menus info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for popup menu\n"); ok (!strcmp(info.dwTypeData, "MenuItem"), "Returned item has wrong label (%s)\n", info.dwTypeData); DestroyMenu( hmenu ); DestroyMenu( hmenuSub ); - /* + /* Case 4: Menu containing 2 popup menus, the second contains 2 items with the same id as the first popup menu */ hmenu = CreateMenu(); hmenuSub = CreateMenu(); hmenuSub2 = CreateMenu(); - - rc = InsertMenu(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); + + rc = InsertMenuA(hmenu, 0, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); ok (rc, "Inserting the popup menu into the main menu failed\n"); - - rc = InsertMenu(hmenu, 1, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub2, "Submenu2"); + + rc = InsertMenuA(hmenu, 1, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub2, "Submenu2"); ok (rc, "Inserting the popup menu into the main menu failed\n"); memset( &info, 0, sizeof info ); @@ -1910,7 +1928,7 @@ static void test_menu_search_bycommand( void ) info.dwTypeData = menuitem; info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ - rc = InsertMenuItem(hmenuSub2, 0, TRUE, &info ); + rc = InsertMenuItemA(hmenuSub2, 0, TRUE, &info ); ok (rc, "Inserting the sub menu menuitem failed\n"); memset( &info, 0, sizeof info ); @@ -1920,30 +1938,30 @@ static void test_menu_search_bycommand( void ) info.dwTypeData = menuitem2; info.wID = (UINT_PTR) hmenuSub; /* Enforce id collisions with the hmenu of the popup submenu*/ - rc = InsertMenuItem(hmenuSub2, 1, TRUE, &info ); + rc = InsertMenuItemA(hmenuSub2, 1, TRUE, &info ); ok (rc, "Inserting the sub menu menuitem 2 failed\n"); /* Prove getting the item info via ID returns the first item (not the popup or 2nd item)*/ memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_STRING | MIIM_ID; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); + rc = GetMenuItemInfoA(hmenu, (UINT_PTR)hmenuSub, FALSE, &info); ok (rc, "Getting the menus info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub, "IDs differ for popup menu\n"); ok (!strcmp(info.dwTypeData, "MenuItem"), "Returned item has wrong label (%s)\n", info.dwTypeData); memset( &info, 0, sizeof info ); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_STRING | MIIM_ID; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, (UINT_PTR)hmenuSub2, FALSE, &info); + rc = GetMenuItemInfoA(hmenu, (UINT_PTR)hmenuSub2, FALSE, &info); ok (rc, "Getting the menus info failed\n"); ok (info.wID == (UINT_PTR)hmenuSub2, "IDs differ for popup menu\n"); ok (!strcmp(info.dwTypeData, "Submenu2"), "Returned item has wrong label (%s)\n", info.dwTypeData); @@ -1953,7 +1971,7 @@ static void test_menu_search_bycommand( void ) DestroyMenu( hmenuSub2 ); - /* + /* Case 5: Menu containing a popup menu which in turn contains an item with a different id than the popup menu. This tests the fallback to a popup menu ID. @@ -1962,10 +1980,10 @@ static void test_menu_search_bycommand( void ) hmenu = CreateMenu(); hmenuSub = CreateMenu(); - rc = AppendMenu(hmenu, MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); + rc = AppendMenuA(hmenu, MF_POPUP | MF_STRING, (UINT_PTR)hmenuSub, "Submenu"); ok (rc, "Appending the popup menu to the main menu failed\n"); - rc = AppendMenu(hmenuSub, MF_STRING, 102, "Item"); + rc = AppendMenuA(hmenuSub, MF_STRING, 102, "Item"); ok (rc, "Appending the item to the popup menu failed\n"); /* Set the ID for hmenuSub */ @@ -1973,24 +1991,24 @@ static void test_menu_search_bycommand( void ) info.fMask = MIIM_ID; info.wID = 101; - rc = SetMenuItemInfo(hmenu, 0, TRUE, &info); + rc = SetMenuItemInfoA(hmenu, 0, TRUE, &info); ok(rc, "Setting the ID for the popup menu failed\n"); /* Check if the ID has been set */ info.wID = 0; - rc = GetMenuItemInfo(hmenu, 0, TRUE, &info); + rc = GetMenuItemInfoA(hmenu, 0, TRUE, &info); ok(rc, "Getting the ID for the popup menu failed\n"); ok(info.wID == 101, "The ID for the popup menu has not been set\n"); /* Prove getting the item info via ID returns the popup menu */ memset( &info, 0, sizeof(info)); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_STRING | MIIM_ID; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, 101, FALSE, &info); + rc = GetMenuItemInfoA(hmenu, 101, FALSE, &info); ok (rc, "Getting the menu info failed\n"); ok (info.wID == 101, "IDs differ\n"); ok (!strcmp(info.dwTypeData, "Submenu"), "Returned item has wrong label (%s)\n", info.dwTypeData); @@ -1998,12 +2016,12 @@ static void test_menu_search_bycommand( void ) /* Also look for the menu item */ memset( &info, 0, sizeof(info)); strback[0] = 0x00; - info.cbSize = sizeof(MENUITEMINFO); + info.cbSize = sizeof(MENUITEMINFOA); info.fMask = MIIM_STRING | MIIM_ID; info.dwTypeData = strback; info.cch = sizeof(strback); - rc = GetMenuItemInfo(hmenu, 102, FALSE, &info); + rc = GetMenuItemInfoA(hmenu, 102, FALSE, &info); ok (rc, "Getting the menu info failed\n"); ok (info.wID == 102, "IDs differ\n"); ok (!strcmp(info.dwTypeData, "Item"), "Returned item has wrong label (%s)\n", info.dwTypeData); @@ -2097,7 +2115,7 @@ static BOOL click_menu(HANDLE hWnd, struct menu_item_pair_s *mi) ret = pSendInput(3, (INPUT *) i, sizeof(INPUT)); /* hack to prevent mouse message buildup in Wine */ - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); return ret; } @@ -2110,7 +2128,8 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter) /* mixed keyboard/mouse test */ for (i = 0; menu_tests[i].type != -1; i++) { - int ret = TRUE, elapsed = 0; + BOOL ret = TRUE; + int elapsed = 0; got_input = i && menu_tests[i-1].bMenuVisible; @@ -2124,7 +2143,7 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter) if (!ret) { skip( "test %u: failed to send input\n", i ); - PostMessage( hWnd, WM_CANCELMODE, 0, 0 ); + PostMessageA( hWnd, WM_CANCELMODE, 0, 0 ); return 0; } while (menu_tests[i].bMenuVisible != bMenuVisible) @@ -2138,7 +2157,7 @@ static DWORD WINAPI test_menu_input_thread(LPVOID lpParameter) if (!got_input) { skip( "test %u: didn't receive input\n", i ); - PostMessage( hWnd, WM_CANCELMODE, 0, 0 ); + PostMessageA( hWnd, WM_CANCELMODE, 0, 0 ); return 0; } @@ -2180,7 +2199,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, default: return( DefWindowProcA( hWnd, msg, wParam, lParam ) ); } -#if 0 + if(pGetMenuBarInfo) { MENUBARINFO mbi; @@ -2226,7 +2245,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, ok(!(bMenuVisible && (state & MF_HILITE)) == !mbi.fFocused, "msg %x: GetMenuBarInfo.fFocused (%d) is wrong\n", msg, mbi.fFocused != 0); } -#endif + if (msg == WM_EXITMENULOOP) bMenuVisible = FALSE; else if (msg == WM_INITMENUPOPUP) @@ -2254,8 +2273,8 @@ static void test_menu_input(void) { wclass.style = CS_HREDRAW | CS_VREDRAW; wclass.lpfnWndProc = WndProc; wclass.hInstance = hInstance; - wclass.hIcon = LoadIconA( 0, IDI_APPLICATION ); - wclass.hCursor = LoadCursorA( NULL, IDC_ARROW ); + wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION ); + wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW ); wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; @@ -2270,18 +2289,18 @@ static void test_menu_input(void) { if (!hWnd) return; /* fixed menus */ hMenus[3] = CreatePopupMenu(); - AppendMenu(hMenus[3], MF_STRING, 0, "&Enabled"); - AppendMenu(hMenus[3], MF_STRING|MF_DISABLED, 0, "&Disabled"); + AppendMenuA(hMenus[3], MF_STRING, 0, "&Enabled"); + AppendMenuA(hMenus[3], MF_STRING|MF_DISABLED, 0, "&Disabled"); hMenus[2] = CreatePopupMenu(); - AppendMenu(hMenus[2], MF_STRING|MF_POPUP, (UINT_PTR) hMenus[3], "&Popup"); - AppendMenu(hMenus[2], MF_STRING, 0, "&Enabled"); - AppendMenu(hMenus[2], MF_STRING|MF_DISABLED, 0, "&Disabled"); + AppendMenuA(hMenus[2], MF_STRING|MF_POPUP, (UINT_PTR) hMenus[3], "&Popup"); + AppendMenuA(hMenus[2], MF_STRING, 0, "&Enabled"); + AppendMenuA(hMenus[2], MF_STRING|MF_DISABLED, 0, "&Disabled"); hMenus[1] = CreateMenu(); - AppendMenu(hMenus[1], MF_STRING|MF_POPUP, (UINT_PTR) hMenus[2], "&Menu"); - AppendMenu(hMenus[1], MF_STRING, 0, "&Enabled"); - AppendMenu(hMenus[1], MF_STRING|MF_DISABLED, 0, "&Disabled"); + AppendMenuA(hMenus[1], MF_STRING|MF_POPUP, (UINT_PTR) hMenus[2], "&Menu"); + AppendMenuA(hMenus[1], MF_STRING, 0, "&Enabled"); + AppendMenuA(hMenus[1], MF_STRING|MF_DISABLED, 0, "&Disabled"); SetMenu(hWnd, hMenus[1]); ShowWindow(hWnd, SW_SHOW); @@ -2292,7 +2311,7 @@ static void test_menu_input(void) { { if (WAIT_TIMEOUT != WaitForSingleObject(hThread, 50)) break; - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); } DestroyWindow(hWnd); } @@ -2304,12 +2323,12 @@ static void test_menu_flags( void ) hMenu = CreateMenu(); hPopupMenu = CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hPopupMenu, "Popup"); + AppendMenuA(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hPopupMenu, "Popup"); - AppendMenu(hPopupMenu, MF_STRING | MF_HILITE | MF_DEFAULT, 101, "Item 1"); - InsertMenu(hPopupMenu, 1, MF_BYPOSITION | MF_STRING | MF_HILITE | MF_DEFAULT, 102, "Item 2"); - AppendMenu(hPopupMenu, MF_STRING, 103, "Item 3"); - ModifyMenu(hPopupMenu, 2, MF_BYPOSITION | MF_STRING | MF_HILITE | MF_DEFAULT, 103, "Item 3"); + AppendMenuA(hPopupMenu, MF_STRING | MF_HILITE | MF_DEFAULT, 101, "Item 1"); + InsertMenuA(hPopupMenu, 1, MF_BYPOSITION | MF_STRING | MF_HILITE | MF_DEFAULT, 102, "Item 2"); + AppendMenuA(hPopupMenu, MF_STRING, 103, "Item 3"); + ModifyMenuA(hPopupMenu, 2, MF_BYPOSITION | MF_STRING | MF_HILITE | MF_DEFAULT, 103, "Item 3"); ok(GetMenuState(hPopupMenu, 0, MF_BYPOSITION) & MF_HILITE, "AppendMenu should accept MF_HILITE\n"); @@ -2339,8 +2358,8 @@ static void test_menu_hilitemenuitem( void ) wclass.style = CS_HREDRAW | CS_VREDRAW; wclass.lpfnWndProc = WndProc; wclass.hInstance = GetModuleHandleA( NULL ); - wclass.hIcon = LoadIconA( 0, IDI_APPLICATION ); - wclass.hCursor = LoadCursorA( NULL, IDC_ARROW ); + wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION ); + wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW ); wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; @@ -2357,11 +2376,11 @@ static void test_menu_hilitemenuitem( void ) hMenu = CreateMenu(); hPopupMenu = CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hPopupMenu, "Popup"); + AppendMenuA(hMenu, MF_POPUP | MF_STRING, (UINT_PTR)hPopupMenu, "Popup"); - AppendMenu(hPopupMenu, MF_STRING, 101, "Item 1"); - AppendMenu(hPopupMenu, MF_STRING, 102, "Item 2"); - AppendMenu(hPopupMenu, MF_STRING, 103, "Item 3"); + AppendMenuA(hPopupMenu, MF_STRING, 101, "Item 1"); + AppendMenuA(hPopupMenu, MF_STRING, 102, "Item 2"); + AppendMenuA(hPopupMenu, MF_STRING, 103, "Item 3"); SetMenu(hWnd, hMenu); @@ -2477,17 +2496,17 @@ static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, for (i = 0; i < count; i++) { BOOL ret; - MENUITEMINFO mii; + MENUITEMINFOA mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_ID | MIIM_SUBMENU; - ret = GetMenuItemInfo(hmenu, i, TRUE, &mii); + ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii); ok(ret, "GetMenuItemInfo(%u) failed\n", i); -#if 0 +if (0) trace("item #%u: fType %04x, fState %04x, wID %u, hSubMenu %p\n", i, mii.fType, mii.fState, mii.wID, mii.hSubMenu); -#endif + if (mii.hSubMenu) { ok(mii.wID == (UINT_PTR)mii.hSubMenu, "id %u: wID should be equal to hSubMenu\n", checked_cmd); @@ -2523,12 +2542,12 @@ static void check_menu_items(HMENU hmenu, UINT checked_cmd, UINT checked_type, static void clear_ftype_and_state(HMENU hmenu, UINT id, UINT flags) { BOOL ret; - MENUITEMINFO mii; + MENUITEMINFOA mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_FTYPE | MIIM_STATE; - ret = SetMenuItemInfo(hmenu, id, (flags & MF_BYPOSITION) != 0, &mii); + ret = SetMenuItemInfoA(hmenu, id, (flags & MF_BYPOSITION) != 0, &mii); ok(ret, "SetMenuItemInfo(%u) failed\n", id); } @@ -2537,7 +2556,7 @@ static void test_CheckMenuRadioItem(void) BOOL ret; HMENU hmenu; - hmenu = LoadMenu(GetModuleHandle(0), MAKEINTRESOURCE(1)); + hmenu = LoadMenuA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(1)); assert(hmenu != 0); check_menu_items(hmenu, -1, 0, 0); @@ -2616,14 +2635,14 @@ static void test_menu_resource_layout(void) INT count, i; BOOL ret; - hmenu = LoadMenuIndirect(&menu_template); + hmenu = LoadMenuIndirectA(&menu_template); ok(hmenu != 0, "LoadMenuIndirect error %u\n", GetLastError()); - ret = AppendMenu(hmenu, MF_STRING, 6, NULL); + ret = AppendMenuA(hmenu, MF_STRING, 6, NULL); ok(ret, "AppendMenu failed\n"); - ret = AppendMenu(hmenu, MF_STRING, 7, "\0"); + ret = AppendMenuA(hmenu, MF_STRING, 7, "\0"); ok(ret, "AppendMenu failed\n"); - ret = AppendMenu(hmenu, MF_SEPARATOR, 8, "separator"); + ret = AppendMenuA(hmenu, MF_SEPARATOR, 8, "separator"); ok(ret, "AppendMenu failed\n"); count = GetMenuItemCount(hmenu); @@ -2634,19 +2653,19 @@ static void test_menu_resource_layout(void) for (i = 0; i < count; i++) { char buf[20]; - MENUITEMINFO mii; + MENUITEMINFOA mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); mii.dwTypeData = buf; mii.cch = sizeof(buf); mii.fMask = MIIM_FTYPE | MIIM_STATE | MIIM_ID | MIIM_STRING; - ret = GetMenuItemInfo(hmenu, i, TRUE, &mii); + ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii); ok(ret, "GetMenuItemInfo(%u) failed\n", i); -#if 0 +if (0) trace("item #%u: fType %04x, fState %04x, wID %u, dwTypeData %s\n", i, mii.fType, mii.fState, mii.wID, (LPCSTR)mii.dwTypeData); -#endif + ok(mii.fType == menu_data[i].type, "%u: expected fType %04x, got %04x\n", i, menu_data[i].type, mii.fType); ok(mii.fState == menu_data[i].state, @@ -2680,7 +2699,7 @@ static HMENU create_menu_from_data(const struct menu_data *item, INT item_count) for (i = 0; i < item_count; i++) { SetLastError(0xdeadbeef); - ret = AppendMenu(hmenu, item[i].type, item[i].id, item[i].str); + ret = AppendMenuA(hmenu, item[i].type, item[i].id, item[i].str); ok(ret, "%d: AppendMenu(%04x, %04x, %p) error %u\n", i, item[i].type, item[i].id, item[i].str, GetLastError()); } @@ -2695,7 +2714,7 @@ static HMENU create_menuitem_from_data(const struct menu_data *item, INT item_co HMENU hmenu; INT i; BOOL ret; - MENUITEMINFO mii = { sizeof( MENUITEMINFO)}; + MENUITEMINFOA mii = { sizeof( MENUITEMINFOA) }; hmenu = CreateMenu(); assert(hmenu != 0); @@ -2722,7 +2741,7 @@ static HMENU create_menuitem_from_data(const struct menu_data *item, INT item_co mii.fState = 0; if( item[i].type & MF_HELP) mii.fType |= MF_HELP; mii.wID = item[i].id; - ret = InsertMenuItem( hmenu, -1, TRUE, &mii); + ret = InsertMenuItemA( hmenu, -1, TRUE, &mii); ok(ret, "%d: InsertMenuItem(%04x, %04x, %p) error %u\n", i, item[i].type, item[i].id, item[i].str, GetLastError()); } @@ -2740,19 +2759,19 @@ static void compare_menu_data(HMENU hmenu, const struct menu_data *item, INT ite for (i = 0; i < count; i++) { char buf[20]; - MENUITEMINFO mii; + MENUITEMINFOA mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); mii.dwTypeData = buf; mii.cch = sizeof(buf); mii.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_BITMAP; - ret = GetMenuItemInfo(hmenu, i, TRUE, &mii); + ret = GetMenuItemInfoA(hmenu, i, TRUE, &mii); ok(ret, "GetMenuItemInfo(%u) failed\n", i); -#if 0 +if (0) trace("item #%u: fType %04x, fState %04x, wID %04x, hbmp %p\n", i, mii.fType, mii.fState, mii.wID, mii.hbmpItem); -#endif + ok(mii.fType == item[i].type, "%u: expected fType %04x, got %04x\n", i, item[i].type, mii.fType); ok(mii.wID == item[i].id, @@ -2782,20 +2801,20 @@ static void test_InsertMenu(void) static const struct menu_data in1[] = { { MF_STRING, 1, "File" }, - { MF_BITMAP|MF_HELP, SC_CLOSE, MAKEINTRESOURCE(1) }, + { MF_BITMAP|MF_HELP, SC_CLOSE, MAKEINTRESOURCEA(1) }, { MF_STRING|MF_HELP, 2, "Help" } }; static const struct menu_data out1[] = { { MF_STRING, 1, "File" }, { MF_STRING|MF_HELP, 2, "Help" }, - { MF_BITMAP|MF_HELP, SC_CLOSE, MAKEINTRESOURCE(1) } + { MF_BITMAP|MF_HELP, SC_CLOSE, MAKEINTRESOURCEA(1) } }; static const struct menu_data out1a[] = { { MF_STRING, 1, "File" }, { MF_STRING|MF_HELP, 2, "Help" }, - { MF_HELP, SC_CLOSE, MAKEINTRESOURCE(1) } + { MF_HELP, SC_CLOSE, MAKEINTRESOURCEA(1) } }; const struct menu_data in2[] = { @@ -2818,32 +2837,32 @@ static void test_InsertMenu(void) static const struct menu_data in3[] = { { MF_STRING, 1, "File" }, - { MF_SEPARATOR|MF_HELP, SC_CLOSE, MAKEINTRESOURCE(1) }, + { MF_SEPARATOR|MF_HELP, SC_CLOSE, MAKEINTRESOURCEA(1) }, { MF_STRING|MF_HELP, 2, "Help" } }; static const struct menu_data out3[] = { { MF_STRING, 1, "File" }, - { MF_SEPARATOR|MF_HELP, SC_CLOSE, MAKEINTRESOURCE(0) }, + { MF_SEPARATOR|MF_HELP, SC_CLOSE, MAKEINTRESOURCEA(0) }, { MF_STRING|MF_HELP, 2, "Help" }, }; static const struct menu_data in4[] = { { MF_STRING, 1, "File" }, - { MF_BITMAP|MF_HELP, 1, MAKEINTRESOURCE(1) }, + { MF_BITMAP|MF_HELP, 1, MAKEINTRESOURCEA(1) }, { MF_STRING|MF_HELP, 2, "Help" } }; static const struct menu_data out4[] = { { MF_STRING, 1, "File" }, { MF_STRING|MF_HELP, 2, "Help" }, - { MF_BITMAP|MF_HELP, 1, MAKEINTRESOURCE(1) } + { MF_BITMAP|MF_HELP, 1, MAKEINTRESOURCEA(1) } }; static const struct menu_data out4a[] = { { MF_STRING, 1, "File" }, { MF_STRING|MF_HELP, 2, "Help" }, - { MF_HELP, 1, MAKEINTRESOURCE(1) } + { MF_HELP, 1, MAKEINTRESOURCEA(1) } }; HMENU hmenu; @@ -2944,7 +2963,7 @@ static void test_menu_setmenuinfo(void) { HMENU hmenu, hsubmenu; MENUINFO mi = {0}; - MENUITEMINFOA mii = {sizeof( MENUITEMINFOA)}; + MENUITEMINFOA mii = { sizeof(MENUITEMINFOA) }; BOOL ret; DWORD gle; @@ -2960,7 +2979,7 @@ static void test_menu_setmenuinfo(void) assert( hmenu && hsubmenu); mii.fMask = MIIM_SUBMENU; mii.hSubMenu = hsubmenu; - ret = InsertMenuItem( hmenu, 0, FALSE, &mii); + ret = InsertMenuItemA( hmenu, 0, FALSE, &mii); ok( ret, "InsertMenuItem failed with error %d\n", GetLastError()); /* test some parameter errors */ SetLastError(0xdeadbeef); @@ -3087,12 +3106,12 @@ static void test_menu_trackpopupmenu(void) HMENU hmenu; DWORD gle; int Ex; - HWND hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + HWND hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); if (!hwnd) return; - SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); for( Ex = 0; Ex < 2; Ex++) { hmenu = CreatePopupMenu(); @@ -3209,10 +3228,10 @@ static LRESULT WINAPI menu_track_again_wnd_proc(HWND hwnd, UINT msg, WPARAM wpar /* exit menu modal loop * ( A SendMessage does not work on NT3.51 here ) */ - return PostMessage(hwnd, WM_CANCELMODE, 0, 0); + return PostMessageA(hwnd, WM_CANCELMODE, 0, 0); } } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } static void test_menu_trackagain(void) @@ -3220,18 +3239,23 @@ static void test_menu_trackagain(void) HWND hwnd; BOOL ret; - hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL, + hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); if (!hwnd) return; - SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_track_again_wnd_proc); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_track_again_wnd_proc); g_hmenu = CreatePopupMenu(); ok(g_hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); + ret = AppendMenuA(g_hmenu, MF_STRING , 100, "item 1"); + ok(ret, "AppendMenu failed.\n"); + ret = AppendMenuA(g_hmenu, MF_STRING , 101, "item 2"); + ok(ret, "AppendMenu failed.\n"); + ret = TrackPopupMenu( g_hmenu, 0, 100, 100, 0, hwnd, NULL); - todo_wine ok(ret == FALSE, "got %d\n", ret); + ok(ret == TRUE, "got %d\n", ret); DestroyMenu(g_hmenu); DestroyWindow(hwnd); @@ -3247,19 +3271,19 @@ static LRESULT WINAPI menu_cancelmode_wnd_proc(HWND hwnd, UINT msg, { case WM_ENTERMENULOOP: g_got_enteridle = 0; - return SendMessage( g_hwndtosend, WM_CANCELMODE, 0, 0); + return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0); case WM_ENTERIDLE: { if( g_got_enteridle++ == 0) { /* little hack to get another WM_ENTERIDLE message */ - PostMessage( hwnd, WM_MOUSEMOVE, 0, 0); - return SendMessage( g_hwndtosend, WM_CANCELMODE, 0, 0); + PostMessageA( hwnd, WM_MOUSEMOVE, 0, 0); + return SendMessageA( g_hwndtosend, WM_CANCELMODE, 0, 0); } pEndMenu(); return TRUE; } } - return DefWindowProc( hwnd, msg, wparam, lparam); + return DefWindowProcA( hwnd, msg, wparam, lparam); } static void test_menu_cancelmode(void) @@ -3272,24 +3296,24 @@ static void test_menu_cancelmode(void) win_skip( "EndMenu is not available\n"); return; } - hwnd = CreateWindowEx( 0, MAKEINTATOM(atomMenuCheckClass), NULL, + hwnd = CreateWindowExA( 0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, NULL, NULL); - hwndchild = CreateWindowEx( 0, MAKEINTATOM(atomMenuCheckClass), NULL, + hwndchild = CreateWindowExA( 0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, WS_VISIBLE | WS_CHILD, 10, 10, 20, 20, hwnd, NULL, NULL, NULL); ok( hwnd != NULL && hwndchild != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); g_hwndtosend = hwnd; - SetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_cancelmode_wnd_proc); - SetWindowLongPtr( hwndchild, GWLP_WNDPROC, (LONG_PTR)menu_cancelmode_wnd_proc); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_cancelmode_wnd_proc); + SetWindowLongPtrA( hwndchild, GWLP_WNDPROC, (LONG_PTR)menu_cancelmode_wnd_proc); menu = CreatePopupMenu(); ok( menu != NULL, "CreatePopupMenu failed with error %d\n", GetLastError()); ret = AppendMenuA( menu, MF_STRING, 1, "winetest"); ok( ret, "Functie failed lasterror is %u\n", GetLastError()); /* seems to be needed only on wine :( */ - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - DispatchMessage(&msg); + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); /* test the effect of sending a WM_CANCELMODE message in the WM_INITMENULOOP * handler of the menu owner */ /* test results is extracted from variable g_got_enteridle. Possible values: @@ -3300,17 +3324,11 @@ static void test_menu_cancelmode(void) /* menu owner is top level window */ g_hwndtosend = hwnd; TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); - todo_wine { - ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); - } - ok( g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + ok( g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); /* menu owner is child window */ g_hwndtosend = hwndchild; TrackPopupMenu( menu, TPM_RETURNCMD, 100,100, 0, hwndchild, NULL); - todo_wine { - ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); - } - ok(g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); /* now send the WM_CANCELMODE messages to the WRONG window */ /* those should fail ( to have any effect) */ g_hwndtosend = hwnd; @@ -3326,14 +3344,11 @@ static void test_menu_cancelmode(void) ok( ret, "SetMenu failed lasterror is %u\n", GetLastError()); /* initiate tracking */ g_hwndtosend = hwnd; - ret = SendMessage( hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0 ); + ret = SendMessageA( hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0 ); ok( ret == 0, "Sending WM_SYSCOMMAND/SC_KEYMENU failed lasterror is %u\n", GetLastError()); - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) - DispatchMessage(&msg); - todo_wine { - ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); - } - ok(g_got_enteridle < 2, "received %d WM_ENTERIDLE messages, should be less than 2\n", g_got_enteridle); + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) + DispatchMessageA(&msg); + ok(g_got_enteridle == 0, "received %d WM_ENTERIDLE messages, none expected\n", g_got_enteridle); /* cleanup */ DestroyMenu( menubar ); @@ -3406,7 +3421,7 @@ static void test_menualign(void) BYTE bmfill[300]; HMENU menu; HBITMAP hbm1, hbm2, hbm3; - MENUITEMINFO mii = { sizeof(MENUITEMINFO)}; + MENUITEMINFOA mii = { sizeof(MENUITEMINFOA) }; DWORD ret; HWND hwnd; MENUINFO mi = { sizeof( MENUINFO)}; @@ -3415,7 +3430,7 @@ static void test_menualign(void) skip( "interactive alignment tests.\n"); return; } - hwnd = CreateWindowEx(0, + hwnd = CreateWindowExA(0, "STATIC", "Menu text alignment Test\nPlease make a selection.", WS_OVERLAPPEDWINDOW, @@ -3443,13 +3458,13 @@ static void test_menualign(void) mii.wID = 1; mii.hbmpItem = hbm1; mii.dwTypeData = (LPSTR) " OK: menu texts are correctly left-aligned."; - ret = InsertMenuItem( menu, -1, TRUE, &mii); + ret = InsertMenuItemA( menu, -1, TRUE, &mii); ok( ret, "InsertMenuItem() failed\n"); mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_ID ; mii.wID = 2; mii.hbmpItem = hbm2; mii.dwTypeData = (LPSTR) " FAIL: menu texts are NOT left-aligned."; - ret = InsertMenuItem( menu, -1, TRUE, &mii); + ret = InsertMenuItemA( menu, -1, TRUE, &mii); ok( ret, "InsertMenuItem() failed\n"); ret = TrackPopupMenu( menu, TPM_RETURNCMD, 110, 200, 0, hwnd, NULL); ok( ret != 2, "User indicated that menu text alignment test 1 failed %d\n", ret); @@ -3458,7 +3473,7 @@ static void test_menualign(void) mii.wID = 3; mii.hbmpItem = hbm3; mii.dwTypeData = NULL; - ret = InsertMenuItem( menu, 0, TRUE, &mii); + ret = InsertMenuItemA( menu, 0, TRUE, &mii); ok( ret, "InsertMenuItem() failed\n"); mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_ID; mii.wID = 1; @@ -3466,12 +3481,12 @@ static void test_menualign(void) /* make the text a bit longer, to keep it readable */ /* this bug is on winXP and reproduced on wine */ mii.dwTypeData = (LPSTR) " OK: menu texts are to the right of the bitmaps........"; - ret = SetMenuItemInfo( menu, 1, TRUE, &mii); + ret = SetMenuItemInfoA( menu, 1, TRUE, &mii); ok( ret, "SetMenuItemInfo() failed\n"); mii.wID = 2; mii.hbmpItem = hbm2; mii.dwTypeData = (LPSTR) " FAIL: menu texts are below the first bitmap. "; - ret = SetMenuItemInfo( menu, 2, TRUE, &mii); + ret = SetMenuItemInfoA( menu, 2, TRUE, &mii); ok( ret, "SetMenuItemInfo() failed\n"); ret = TrackPopupMenu( menu, TPM_RETURNCMD, 110, 200, 0, hwnd, NULL); ok( ret != 2, "User indicated that menu text alignment test 2 failed %d\n", ret); @@ -3480,18 +3495,18 @@ static void test_menualign(void) mii.wID = 3; mii.fType = MFT_BITMAP; mii.dwTypeData = (LPSTR) hbm3; - ret = SetMenuItemInfo( menu, 0, TRUE, &mii); + ret = SetMenuItemInfoA( menu, 0, TRUE, &mii); ok( ret, "SetMenuItemInfo() failed\n"); mii.fMask = MIIM_BITMAP | MIIM_STRING | MIIM_ID; mii.wID = 1; mii.hbmpItem = NULL; mii.dwTypeData = (LPSTR) " OK: menu texts are below the bitmap."; - ret = SetMenuItemInfo( menu, 1, TRUE, &mii); + ret = SetMenuItemInfoA( menu, 1, TRUE, &mii); ok( ret, "SetMenuItemInfo() failed\n"); mii.wID = 2; mii.hbmpItem = NULL; mii.dwTypeData = (LPSTR) " FAIL: menu texts are NOT below the bitmap."; - ret = SetMenuItemInfo( menu, 2, TRUE, &mii); + ret = SetMenuItemInfoA( menu, 2, TRUE, &mii); ok( ret, "SetMenuItemInfo() failed\n"); ret = TrackPopupMenu( menu, TPM_RETURNCMD, 110, 200, 0, hwnd, NULL); ok( ret != 2, "User indicated that menu text alignment test 3 failed %d\n", ret); @@ -3503,6 +3518,106 @@ static void test_menualign(void) DestroyWindow( hwnd); } +static LRESULT WINAPI menu_fill_in_init(HWND hwnd, UINT msg, + WPARAM wparam, LPARAM lparam) +{ + HMENU hmenupopup; + BOOL ret; + switch (msg) + { + case WM_INITMENUPOPUP: + gflag_initmenupopup++; + hmenupopup = (HMENU) wparam; + ret = AppendMenuA(hmenupopup, MF_STRING , 100, "item 1"); + ok(ret, "AppendMenu failed.\n"); + ret = AppendMenuA(hmenupopup, MF_STRING , 101, "item 2"); + ok(ret, "AppendMenu failed.\n"); + break; + case WM_ENTERMENULOOP: + gflag_entermenuloop++; + break; + case WM_INITMENU: + gflag_initmenu++; + break; + case WM_ENTERIDLE: + gflag_enteridle++; + PostMessageA(hwnd, WM_CANCELMODE, 0, 0); + return TRUE; + case WM_MENUSELECT: + selectitem_wp = wparam; + selectitem_lp = lparam; + break; + } + return DefWindowProcA(hwnd, msg, wparam, lparam); +} + +static void test_emptypopup(void) +{ + BOOL ret; + HMENU hmenu; + + HWND hwnd = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomMenuCheckClass), NULL, + WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, + NULL, NULL, NULL, NULL); + ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_ownerdraw_wnd_proc); + + hmenu = CreatePopupMenu(); + ok(hmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); + + gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = gflag_enteridle = 0; + selectitem_wp = 0xdeadbeef; + selectitem_lp = 0xdeadbeef; + + ret = TrackPopupMenu( hmenu, TPM_RETURNCMD, 100,100, 0, hwnd, NULL); + ok(ret == 0, "got %i\n", ret); + + ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup); + ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop); + ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu); + todo_wine ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu); + + todo_wine ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp); + todo_wine ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp); + + gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = gflag_enteridle = 0; + selectitem_wp = 0xdeadbeef; + selectitem_lp = 0xdeadbeef; + + ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL); + todo_wine ok(ret == 0, "got %i\n", ret); + + ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup); + ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop); + ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu); + todo_wine ok(gflag_enteridle == 0, "got %i\n", gflag_initmenu); + + todo_wine ok(selectitem_wp == 0xdeadbeef, "got %lx\n", selectitem_wp); + todo_wine ok(selectitem_lp == 0xdeadbeef, "got %lx\n", selectitem_lp); + + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)menu_fill_in_init); + + gflag_initmenupopup = gflag_entermenuloop = gflag_initmenu = gflag_enteridle = 0; + selectitem_wp = 0xdeadbeef; + selectitem_lp = 0xdeadbeef; + + ret = TrackPopupMenu( hmenu, 0, 100,100, 0, hwnd, NULL); + ok(ret == 1, "got %i\n", ret); + + ok(gflag_initmenupopup == 1, "got %i\n", gflag_initmenupopup); + ok(gflag_entermenuloop == 1, "got %i\n", gflag_entermenuloop); + ok(gflag_initmenu == 1, "got %i\n", gflag_initmenu); + ok(gflag_enteridle == 1, "got %i\n", gflag_initmenu); + + ok(selectitem_wp == 0xffff0000, "got %lx\n", selectitem_wp); + ok(selectitem_lp == 0, "got %lx\n", selectitem_lp); + + DestroyWindow(hwnd); + + ret = DestroyMenu(hmenu); + ok(ret, "DestroyMenu failed with error %d\n", GetLastError()); +} + START_TEST(menu) { init_function_pointers(); @@ -3539,4 +3654,5 @@ START_TEST(menu) test_menu_cancelmode(); test_menu_maxdepth(); test_menu_circref(); + test_emptypopup(); } diff --git a/rostests/winetests/user32/monitor.c b/rostests/winetests/user32/monitor.c index b5098604bf0..a2df20eba9d 100644 --- a/rostests/winetests/user32/monitor.c +++ b/rostests/winetests/user32/monitor.c @@ -31,6 +31,7 @@ static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,LPDISPLAY_DEVICEA,DWORD) static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM); static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO); static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD); +static HMONITOR (WINAPI *pMonitorFromRect)(LPCRECT,DWORD); static HMONITOR (WINAPI *pMonitorFromWindow)(HWND,DWORD); static void init_function_pointers(void) @@ -48,6 +49,7 @@ static void init_function_pointers(void) GET_PROC(EnumDisplayMonitors) GET_PROC(GetMonitorInfoA) GET_PROC(MonitorFromPoint) + GET_PROC(MonitorFromRect) GET_PROC(MonitorFromWindow) #undef GET_PROC @@ -161,7 +163,7 @@ static void test_ChangeDisplaySettingsEx(void) } SetLastError(0xdeadbeef); - res = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm); + res = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dm); ok(res, "EnumDisplaySettings error %u\n", GetLastError()); width = dm.dmPelsWidth; @@ -291,12 +293,13 @@ static void test_ChangeDisplaySettingsEx(void) static void test_monitors(void) { - HMONITOR monitor, primary; + HMONITOR monitor, primary, nearest; POINT pt; + RECT rc; - if (!pMonitorFromPoint || !pMonitorFromWindow) + if (!pMonitorFromPoint || !pMonitorFromWindow || !pMonitorFromRect) { - win_skip("MonitorFromPoint or MonitorFromWindow are not available\n"); + win_skip("MonitorFromPoint, MonitorFromWindow, or MonitorFromRect is not available\n"); return; } @@ -310,6 +313,65 @@ static void test_monitors(void) ok( monitor == primary, "got %p, should get primary %p for MONITOR_DEFAULTTOPRIMARY\n", monitor, primary ); monitor = pMonitorFromWindow( 0, MONITOR_DEFAULTTONEAREST ); ok( monitor == primary, "got %p, should get primary %p for MONITOR_DEFAULTTONEAREST\n", monitor, primary ); + + SetRect( &rc, 0, 0, 1, 1 ); + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary ); + + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY ); + ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary ); + + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST ); + ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary ); + + /* Empty rect at 0,0 is considered inside the primary monitor */ + SetRect( &rc, 0, 0, -1, -1 ); + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary ); + + /* Even if there is a monitor left of the primary, the primary will have the most overlapping area */ + SetRect( &rc, -1, 0, 2, 1 ); + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary ); + + /* But the width of the rect doesn't matter if it's empty. */ + SetRect( &rc, -1, 0, 2, -1 ); + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + ok( monitor != primary, "got primary %p\n", monitor ); + + if (!pGetMonitorInfoA) + { + win_skip("GetMonitorInfoA is not available\n"); + return; + } + + /* Search for a monitor that has no others equally near to (left, top-1) */ + SetRect( &rc, -1, -2, 2, 0 ); + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + nearest = primary; + while (monitor != NULL) + { + MONITORINFO mi; + BOOL ret; + ok( monitor != primary, "got primary %p\n", monitor ); + nearest = monitor; + mi.cbSize = sizeof(mi); + ret = pGetMonitorInfoA( monitor, &mi ); + ok( ret, "GetMonitorInfo failed\n" ); + SetRect( &rc, mi.rcMonitor.left-1, mi.rcMonitor.top-2, mi.rcMonitor.left+2, mi.rcMonitor.top ); + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + } + + SetRect( &rc, rc.left+1, rc.top+1, rc.left+2, rc.top+2 ); + + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONULL ); + ok( monitor == NULL, "got %p\n", monitor ); + + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTOPRIMARY ); + ok( monitor == primary, "got %p, should get primary %p\n", monitor, primary ); + + monitor = pMonitorFromRect( &rc, MONITOR_DEFAULTTONEAREST ); + ok( monitor == nearest, "got %p, should get nearest %p\n", monitor, nearest ); } static BOOL CALLBACK find_primary_mon(HMONITOR hmon, HDC hdc, LPRECT rc, LPARAM lp) @@ -356,12 +418,12 @@ static void test_work_area(void) mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom); SetLastError(0xdeadbeef); - ret = SystemParametersInfo(SPI_GETWORKAREA, 0, &rc_work, 0); + ret = SystemParametersInfoA(SPI_GETWORKAREA, 0, &rc_work, 0); ok(ret, "SystemParametersInfo error %u\n", GetLastError()); trace("work area (%d,%d-%d,%d)\n", rc_work.left, rc_work.top, rc_work.right, rc_work.bottom); ok(EqualRect(&rc_work, &mi.rcWork), "work area is different\n"); - hwnd = CreateWindowEx(0, "static", NULL, WS_OVERLAPPEDWINDOW|WS_VISIBLE,100,100,10,10,0,0,0,NULL); + hwnd = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW|WS_VISIBLE,100,100,10,10,0,0,0,NULL); ok(hwnd != 0, "CreateWindowEx failed\n"); ret = GetWindowRect(hwnd, &rc_normal); @@ -383,7 +445,7 @@ static void test_work_area(void) else ok(EqualRect(&rc_normal, &wp.rcNormalPosition), "normal pos is different\n"); - SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); + SetWindowLongA(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW); wp.length = sizeof(wp); ret = GetWindowPlacement(hwnd, &wp); diff --git a/rostests/winetests/user32/msg.c b/rostests/winetests/user32/msg.c index a0c610b8c3f..9ed7e2ef2ce 100755 --- a/rostests/winetests/user32/msg.c +++ b/rostests/winetests/user32/msg.c @@ -444,20 +444,20 @@ static const struct message WmShowOverlappedSeq[] = { { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, { WM_ERASEBKGND, sent|optional }, - { HCBT_ACTIVATE, hook }, + { HCBT_ACTIVATE, hook|optional }, { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 }, { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, { WM_NCPAINT, sent|wparam|optional, 1 }, - { WM_ACTIVATEAPP, sent|wparam, 1 }, - { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, + { WM_NCACTIVATE, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, - { WM_ACTIVATE, sent|wparam, 1 }, - { HCBT_SETFOCUS, hook }, + { WM_ACTIVATE, sent|wparam|optional, 1 }, + { HCBT_SETFOCUS, hook|optional }, { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 }, { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, - { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_SETFOCUS, sent|wparam|defwinproc|optional, 0 }, { WM_GETTEXT, sent|optional }, { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, @@ -488,19 +488,19 @@ static const struct message WmShowMaxOverlappedSeq[] = { { WM_GETMINMAXINFO, sent|defwinproc }, { WM_NCCALCSIZE, sent|wparam, TRUE }, { EVENT_OBJECT_SHOW, winevent_hook|wparam|lparam, 0, 0 }, - { HCBT_ACTIVATE, hook }, + { HCBT_ACTIVATE, hook|optional }, { EVENT_SYSTEM_FOREGROUND, winevent_hook|wparam|lparam, 0, 0 }, { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, - { WM_ACTIVATEAPP, sent|wparam, 1 }, - { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, + { WM_NCACTIVATE, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, - { WM_ACTIVATE, sent|wparam, 1 }, - { HCBT_SETFOCUS, hook }, + { WM_ACTIVATE, sent|wparam|optional, 1 }, + { HCBT_SETFOCUS, hook|optional }, { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 }, { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, - { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_SETFOCUS, sent|wparam|defwinproc|optional, 0 }, { WM_GETTEXT, sent|optional }, { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, @@ -549,20 +549,27 @@ static const struct message WmShowRestoreMinOverlappedSeq[] = { { HCBT_MINMAX, hook|lparam, 0, SW_RESTORE }, { WM_QUERYOPEN, sent|optional }, { WM_GETTEXT, sent|optional }, - { WM_WINDOWPOSCHANGING, sent|wparam, SWP_FRAMECHANGED|SWP_STATECHANGED|SWP_NOCOPYBITS }, - { WM_GETMINMAXINFO, sent|defwinproc }, - { WM_NCCALCSIZE, sent|wparam, TRUE }, - { HCBT_ACTIVATE, hook }, + { WM_NCACTIVATE, sent|wparam|optional, 1 }, + { WM_WINDOWPOSCHANGING, sent|optional }, /* SWP_NOSIZE|SWP_NOMOVE */ + { WM_WINDOWPOSCHANGED, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|SWP_NOCLIENTMOVE }, + { WM_NCCALCSIZE, sent|wparam|optional, TRUE }, + { WM_MOVE, sent|optional }, + { WM_SIZE, sent|wparam|optional, SIZE_RESTORED }, + { WM_GETTEXT, sent|optional }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_FRAMECHANGED|SWP_STATECHANGED|SWP_NOCOPYBITS }, + { WM_GETMINMAXINFO, sent|defwinproc|optional }, + { WM_NCCALCSIZE, sent|wparam|optional, TRUE }, + { HCBT_ACTIVATE, hook|optional }, { WM_QUERYNEWPALETTE, sent|wparam|lparam|optional, 0, 0 }, { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, - { WM_ACTIVATEAPP, sent|wparam, 1 }, - { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATEAPP, sent|wparam|optional, 1 }, + { WM_NCACTIVATE, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, - { WM_ACTIVATE, sent|wparam, 1 }, - { HCBT_SETFOCUS, hook }, + { WM_ACTIVATE, sent|wparam|optional, 1 }, + { HCBT_SETFOCUS, hook|optional }, { WM_IME_SETCONTEXT, sent|wparam|defwinproc|optional, 1 }, { WM_IME_NOTIFY, sent|wparam|defwinproc|optional, 2 }, - { WM_SETFOCUS, sent|wparam|defwinproc, 0 }, + { WM_SETFOCUS, sent|wparam|defwinproc|optional, 0 }, { WM_GETTEXT, sent|optional }, { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_GETTEXT, sent|defwinproc|optional }, @@ -570,9 +577,13 @@ static const struct message WmShowRestoreMinOverlappedSeq[] = { { WM_WINDOWPOSCHANGED, sent|wparam, SWP_STATECHANGED|SWP_FRAMECHANGED|SWP_NOCOPYBITS }, { WM_MOVE, sent|defwinproc }, { WM_SIZE, sent|defwinproc|wparam, SIZE_RESTORED }, + { HCBT_SETFOCUS, hook|optional }, + { WM_SETFOCUS, sent|wparam|optional, 0 }, { WM_NCCALCSIZE, sent|wparam|optional, TRUE }, { WM_NCPAINT, sent|wparam|optional, 1 }, { WM_ERASEBKGND, sent|optional }, + { HCBT_SETFOCUS, hook|optional }, + { WM_SETFOCUS, sent|wparam|optional, 0 }, { WM_ACTIVATE, sent|wparam, 1 }, { WM_GETTEXT, sent|optional }, { WM_PAINT, sent|optional }, @@ -584,9 +595,9 @@ static const struct message WmShowRestoreMinOverlappedSeq[] = { /* ShowWindow(SW_SHOWMINIMIZED) for a not visible overlapped window */ static const struct message WmShowMinOverlappedSeq[] = { { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE }, - { HCBT_SETFOCUS, hook }, + { HCBT_SETFOCUS, hook|optional }, { EVENT_OBJECT_FOCUS, winevent_hook|wparam|lparam, OBJID_CLIENT, 0 }, - { WM_KILLFOCUS, sent }, + { WM_KILLFOCUS, sent|optional }, { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 }, { WM_GETTEXT, sent|optional }, @@ -603,10 +614,10 @@ static const struct message WmShowMinOverlappedSeq[] = { { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { EVENT_OBJECT_LOCATIONCHANGE, winevent_hook|wparam|lparam, 0, 0 }, { EVENT_SYSTEM_MINIMIZESTART, winevent_hook|wparam|lparam, 0, 0 }, - { WM_NCACTIVATE, sent|wparam, 0 }, + { WM_NCACTIVATE, sent|wparam|optional, 0 }, { WM_GETTEXT, sent|defwinproc|optional }, - { WM_ACTIVATE, sent }, - { WM_ACTIVATEAPP, sent|wparam, 0 }, + { WM_ACTIVATE, sent|optional }, + { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, /* Vista sometimes restores the window right away... */ { WM_SYSCOMMAND, sent|optional|wparam, SC_RESTORE }, @@ -652,7 +663,7 @@ static const struct message WmHideOverlappedSeq[] = { { WM_ACTIVATE, sent|wparam|optional, 0 }, { WM_ACTIVATEAPP, sent|wparam|optional, 0 }, { HCBT_SETFOCUS, hook|optional }, - { WM_KILLFOCUS, sent|wparam, 0 }, + { WM_KILLFOCUS, sent|wparam|optional, 0 }, { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 }, { 0 } @@ -1719,6 +1730,38 @@ static const struct message WmSHOWNATopInvisible[] = { { 0 } }; +static const struct message WmTrackPopupMenu[] = { + { HCBT_CREATEWND, hook }, + { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, + { WM_INITMENU, sent|lparam, 0, 0 }, + { WM_INITMENUPOPUP, sent|lparam, 0, 0 }, + { 0x0093, sent|optional }, + { 0x0094, sent|optional }, + { 0x0094, sent|optional }, + { WM_ENTERIDLE, sent|wparam, 2 }, + { WM_CAPTURECHANGED, sent }, + { HCBT_DESTROYWND, hook }, + { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, + { WM_MENUSELECT, sent|wparam|lparam, 0xffff0000, 0 }, + { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 }, + { 0 } +}; + +static const struct message WmTrackPopupMenuEmpty[] = { + { HCBT_CREATEWND, hook }, + { WM_ENTERMENULOOP, sent|wparam|lparam, TRUE, 0 }, + { WM_INITMENU, sent|lparam, 0, 0 }, + { WM_INITMENUPOPUP, sent|lparam, 0, 0 }, + { 0x0093, sent|optional }, + { 0x0094, sent|optional }, + { 0x0094, sent|optional }, + { WM_CAPTURECHANGED, sent }, + { WM_EXITMENULOOP, sent|wparam|lparam, 1, 0 }, + { HCBT_DESTROYWND, hook }, + { WM_UNINITMENUPOPUP, sent|lparam, 0, 0 }, + { 0 } +}; + static BOOL after_end_dialog, test_def_id, paint_loop_done; static int sequence_cnt, sequence_size; static struct recvd_message* sequence; @@ -4516,6 +4559,7 @@ static void test_messages(void) HMENU hmenu; MSG msg; LRESULT res; + POINT pos; flush_sequence(); @@ -4776,13 +4820,23 @@ static void test_messages(void) after_end_dialog = FALSE; test_def_id = FALSE; - hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP, + ok(GetCursorPos(&pos), "GetCursorPos failed\n"); + ok(SetCursorPos(109, 109), "SetCursorPos failed\n"); + + hwnd = CreateWindowExA(0, "TestDialogClass", NULL, WS_POPUP|WS_CHILD, 0, 0, 100, 100, 0, 0, GetModuleHandleA(0), NULL); ok(hwnd != 0, "Failed to create custom dialog window\n"); flush_sequence(); trace("call ShowWindow(%p, SW_SHOW)\n", hwnd); ShowWindow(hwnd, SW_SHOW); ok_sequence(WmShowCustomDialogSeq, "ShowCustomDialog", TRUE); + + flush_events(); + flush_sequence(); + ok(DrawMenuBar(hwnd), "DrawMenuBar failed: %d\n", GetLastError()); + flush_events(); + ok_sequence(WmDrawMenuBarSeq, "DrawMenuBar", FALSE); + ok(SetCursorPos(pos.x, pos.y), "SetCursorPos failed\n"); DestroyWindow(hwnd); flush_sequence(); @@ -4793,7 +4847,8 @@ static void test_messages(void) flush_sequence(); /* Message sequence for SetMenu */ - ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a window without a menu\n"); + ok(!DrawMenuBar(hwnd), "DrawMenuBar should return FALSE for a destroyed window\n"); + ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "last error is %d\n", GetLastError()); ok_sequence(WmEmptySeq, "DrawMenuBar for a window without a menu", FALSE); hmenu = CreateMenu(); @@ -10816,8 +10871,11 @@ static const struct message WmShowNoActivate_1[] = { }; static const struct message WmShowNoActivate_2[] = { { HCBT_MINMAX, hook|lparam, 0, SW_SHOWNOACTIVATE }, - { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, - { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE }, + { HCBT_ACTIVATE, hook|optional }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { HCBT_SETFOCUS, hook|optional }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE }, { WM_MOVE, sent|defwinproc }, { WM_SIZE, sent|wparam|defwinproc, SIZE_RESTORED }, { HCBT_SETFOCUS, hook|optional }, @@ -10937,16 +10995,18 @@ static const struct message WmMinimize_1[] = { static const struct message WmMinimize_2[] = { { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE }, { HCBT_SETFOCUS, hook|optional }, - { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, - { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE }, { WM_MOVE, sent|defwinproc }, { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 }, { 0 } }; static const struct message WmMinimize_3[] = { { HCBT_MINMAX, hook|lparam, 0, SW_MINIMIZE }, - { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, - { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE }, + { HCBT_ACTIVATE, hook|optional }, + { WM_WINDOWPOSCHANGING, sent|wparam|optional, SWP_NOSIZE|SWP_NOMOVE }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOCOPYBITS|SWP_STATECHANGED, 0, SWP_NOACTIVATE }, { WM_MOVE, sent|defwinproc }, { WM_SIZE, sent|wparam|lparam|defwinproc, SIZE_MINIMIZED, 0 }, { 0 } @@ -11284,12 +11344,9 @@ if (0) /* FIXME: Wine behaves completely different here */ win_rc.left, win_rc.top, win_rc.right, win_rc.bottom, wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom); - - flush_events(); - flush_sequence(); } - DestroyWindow(hwnd); + flush_events(); } static INT_PTR WINAPI test_dlg_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -12084,7 +12141,11 @@ static void test_unicode_wm_char(void) PostMessageW( hwnd, WM_CHAR, 0x3b1, 0 ); - ok( GetMessageW( &msg, hwnd, 0, 0 ), "no message\n" ); + while (GetMessageW( &msg, hwnd, 0, 0 )) + { + if (!ignore_message( msg.message )) break; + } + ok( msg.hwnd == hwnd, "unexpected hwnd %p\n", msg.hwnd ); ok( msg.message == WM_CHAR, "unexpected message %x\n", msg.message ); ok( msg.wParam == 0x3b1, "bad wparam %lx\n", msg.wParam ); @@ -14260,6 +14321,80 @@ static void test_layered_window(void) DeleteObject( bmp ); } +static HMENU hpopupmenu; + +static LRESULT WINAPI cancel_popup_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if (ignore_message( message )) return 0; + + switch (message) { + case WM_ENTERIDLE: + todo_wine ok(GetCapture() == hwnd, "expected %p, got %p\n", hwnd, GetCapture()); + EndMenu(); + break; + case WM_INITMENU: + case WM_INITMENUPOPUP: + case WM_UNINITMENUPOPUP: + ok((HMENU)wParam == hpopupmenu, "expected %p, got %lx\n", hpopupmenu, wParam); + break; + } + + return MsgCheckProc (FALSE, hwnd, message, wParam, lParam); +} + +static void test_TrackPopupMenu(void) +{ + HWND hwnd; + BOOL ret; + + hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0, + 0, 0, 1, 1, 0, + NULL, NULL, 0); + ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); + + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_popup_proc); + + hpopupmenu = CreatePopupMenu(); + ok(hpopupmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); + + AppendMenuA(hpopupmenu, MF_STRING, 100, "item 1"); + AppendMenuA(hpopupmenu, MF_STRING, 100, "item 2"); + + flush_events(); + flush_sequence(); + ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL); + ok_sequence(WmTrackPopupMenu, "TrackPopupMenu", TRUE); + ok(ret == 1, "TrackPopupMenu failed with error %i\n", GetLastError()); + + DestroyMenu(hpopupmenu); + DestroyWindow(hwnd); +} + +static void test_TrackPopupMenuEmpty(void) +{ + HWND hwnd; + BOOL ret; + + hwnd = CreateWindowExA(0, "TestWindowClass", NULL, 0, + 0, 0, 1, 1, 0, + NULL, NULL, 0); + ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError()); + + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (LONG_PTR)cancel_popup_proc); + + hpopupmenu = CreatePopupMenu(); + ok(hpopupmenu != NULL, "CreateMenu failed with error %d\n", GetLastError()); + + flush_events(); + flush_sequence(); + ret = TrackPopupMenu(hpopupmenu, 0, 100,100, 0, hwnd, NULL); + ok_sequence(WmTrackPopupMenuEmpty, "TrackPopupMenuEmpty", TRUE); + todo_wine ok(ret == 0, "TrackPopupMenu succeeded\n"); + + DestroyMenu(hpopupmenu); + DestroyWindow(hwnd); +} + static void init_funcs(void) { HMODULE hKernel32 = GetModuleHandleA("kernel32.dll"); @@ -14337,7 +14472,6 @@ START_TEST(msg) pUnhookWinEvent = 0; } hEvent_hook = 0; - test_SetFocus(); test_SetParent(); test_PostMessage(); @@ -14357,9 +14491,6 @@ START_TEST(msg) test_combobox_messages(); test_wmime_keydown_message(); test_paint_messages(); - if(!winetest_interactive) - skip("ReactOS ActivateActCtx seems to be broken.\n"); - else test_interthread_messages(); test_message_conversion(); test_accelerators(); @@ -14392,6 +14523,8 @@ START_TEST(msg) test_keyflags(); test_hotkey(); test_layered_window(); + test_TrackPopupMenu(); + test_TrackPopupMenuEmpty(); /* keep it the last test, under Windows it tends to break the tests * which rely on active/foreground windows being correct. */ diff --git a/rostests/winetests/user32/resource.c b/rostests/winetests/user32/resource.c index 346cc2a8944..9cb73807641 100755 --- a/rostests/winetests/user32/resource.c +++ b/rostests/winetests/user32/resource.c @@ -23,7 +23,7 @@ #include "wine/test.h" -static UINT (WINAPI *pPrivateExtractIconsA)(LPCTSTR, int, int, int, HICON *, UINT *, UINT, UINT) = NULL; +static UINT (WINAPI *pPrivateExtractIconsA)(LPCSTR, int, int, int, HICON *, UINT *, UINT, UINT) = NULL; static void init_function_pointers(void) { @@ -33,7 +33,7 @@ static void init_function_pointers(void) static void test_LoadStringW(void) { - HINSTANCE hInst = GetModuleHandle(NULL); + HINSTANCE hInst = GetModuleHandleA(NULL); WCHAR copiedstringw[128], returnedstringw[128], *resourcepointer = NULL; char copiedstring[128], returnedstring[128]; int length1, length2, retvalue; @@ -79,7 +79,7 @@ static void test_LoadStringW(void) static void test_LoadStringA (void) { - HINSTANCE hInst = GetModuleHandle (NULL); + HINSTANCE hInst = GetModuleHandleA(NULL); static const char str[] = "String resource"; /* same in resource.rc */ char buf[128]; struct string_test { @@ -148,7 +148,7 @@ static void test_accel1(void) ac[n].key = 0; ac[n++].fVirt = 0; - hAccel = CreateAcceleratorTable( &ac[0], n ); + hAccel = CreateAcceleratorTableA( &ac[0], n ); ok( hAccel != NULL, "create accelerator table\n"); r = DestroyAcceleratorTable( hAccel ); @@ -176,13 +176,13 @@ static void test_accel1(void) ac[n].key = 0xffff; ac[n++].fVirt = 0x0001; - hAccel = CreateAcceleratorTable( &ac[0], n ); + hAccel = CreateAcceleratorTableA( &ac[0], n ); ok( hAccel != NULL, "create accelerator table\n"); - r = CopyAcceleratorTable( hAccel, NULL, 0 ); + r = CopyAcceleratorTableA( hAccel, NULL, 0 ); ok( r == n, "two entries in table %u/%u\n", r, n); - r = CopyAcceleratorTable( hAccel, &ac[0], n ); + r = CopyAcceleratorTableA( hAccel, &ac[0], n ); ok( r == n, "still should be two entries in table %u/%u\n", r, n); n=0; @@ -213,7 +213,7 @@ done: r = DestroyAcceleratorTable( hAccel ); ok( r, "destroy accelerator table\n"); - hAccel = CreateAcceleratorTable( &ac[0], 0 ); + hAccel = CreateAcceleratorTableA( &ac[0], 0 ); ok( !hAccel || broken(hAccel != NULL), /* nt4 */ "zero elements should fail\n"); /* these will on crash win2k @@ -246,36 +246,36 @@ static void test_accel2(void) */ /* try a zero count */ - hac = CreateAcceleratorTable( &ac[0], 0 ); + hac = CreateAcceleratorTableA( &ac[0], 0 ); ok( !hac || broken(hac != NULL), /* nt4 */ "fail\n"); if (!hac) ok( !DestroyAcceleratorTable( hac ), "destroy failed\n"); /* creating one accelerator should work */ - hac = CreateAcceleratorTable( &ac[0], 1 ); + hac = CreateAcceleratorTableA( &ac[0], 1 ); ok( hac != NULL , "fail\n"); - ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy failed\n"); + ok( 1 == CopyAcceleratorTableA( hac, out, 1 ), "copy failed\n"); ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); /* how about two of the same type? */ - hac = CreateAcceleratorTable( &ac[0], 2); + hac = CreateAcceleratorTableA( &ac[0], 2); ok( hac != NULL , "fail\n"); - res = CopyAcceleratorTable( hac, NULL, 100 ); + res = CopyAcceleratorTableA( hac, NULL, 100 ); ok( res == 2, "copy null failed %d\n", res); - res = CopyAcceleratorTable( hac, NULL, 0 ); + res = CopyAcceleratorTableA( hac, NULL, 0 ); ok( res == 2, "copy null failed %d\n", res); - res = CopyAcceleratorTable( hac, NULL, 1 ); + res = CopyAcceleratorTableA( hac, NULL, 1 ); ok( res == 2, "copy null failed %d\n", res); - ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy 1 failed\n"); - ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n"); + ok( 1 == CopyAcceleratorTableA( hac, out, 1 ), "copy 1 failed\n"); + ok( 2 == CopyAcceleratorTableA( hac, out, 2 ), "copy 2 failed\n"); ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); /* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */ /* how about two of the same type with a non-zero key? */ ac[0].key = 0x20; ac[1].key = 0x20; - hac = CreateAcceleratorTable( &ac[0], 2); + hac = CreateAcceleratorTableA( &ac[0], 2); ok( hac != NULL , "fail\n"); - ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n"); + ok( 2 == CopyAcceleratorTableA( hac, out, 2 ), "copy 2 failed\n"); ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); /* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */ @@ -284,17 +284,17 @@ static void test_accel2(void) ac[0].key = 0x40; ac[1].fVirt = FVIRTKEY; ac[1].key = 0x40; - hac = CreateAcceleratorTable( &ac[0], 2); + hac = CreateAcceleratorTableA( &ac[0], 2); ok( hac != NULL , "fail\n"); - ok( 2 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n"); + ok( 2 == CopyAcceleratorTableA( hac, out, 2 ), "copy 2 failed\n"); /* ok( !memcmp( ac, out, sizeof ac ), "tables different\n"); */ ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); /* how virtual key codes */ ac[0].fVirt = FVIRTKEY; - hac = CreateAcceleratorTable( &ac[0], 1); + hac = CreateAcceleratorTableA( &ac[0], 1); ok( hac != NULL , "fail\n"); - ok( 1 == CopyAcceleratorTable( hac, out, 2 ), "copy 2 failed\n"); + ok( 1 == CopyAcceleratorTableA( hac, out, 2 ), "copy 2 failed\n"); /* ok( !memcmp( ac, out, sizeof ac/2 ), "tables different\n"); */ ok( DestroyAcceleratorTable( hac ), "destroy failed\n"); @@ -302,9 +302,9 @@ static void test_accel2(void) ac[0].cmd = 0xffff; ac[0].fVirt = 0xff; ac[0].key = 0xffff; - hac = CreateAcceleratorTable( &ac[0], 1); + hac = CreateAcceleratorTableA( &ac[0], 1); ok( hac != NULL , "fail\n"); - ok( 1 == CopyAcceleratorTable( hac, out, 1 ), "copy 1 failed\n"); + ok( 1 == CopyAcceleratorTableA( hac, out, 1 ), "copy 1 failed\n"); /* ok( memcmp( ac, out, sizeof ac/2 ), "tables not different\n"); */ ok( out[0].cmd == ac[0].cmd, "cmd modified\n"); ok( out[0].fVirt == (ac[0].fVirt&0x7f), "fVirt not modified\n"); @@ -313,9 +313,9 @@ static void test_accel2(void) /* how turning on all bits? */ memset( ac, 0xff, sizeof ac ); - hac = CreateAcceleratorTable( &ac[0], 2); + hac = CreateAcceleratorTableA( &ac[0], 2); ok( hac != NULL , "fail\n"); - res = CopyAcceleratorTable( hac, out, 2 ); + res = CopyAcceleratorTableA( hac, out, 2 ); ok( res == 2, "copy 2 failed %d\n", res); /* ok( memcmp( ac, out, sizeof ac ), "tables not different\n"); */ ok( out[0].cmd == ac[0].cmd, "cmd modified\n"); @@ -331,13 +331,32 @@ static void test_accel2(void) } static void test_PrivateExtractIcons(void) { - CONST CHAR szShell32Dll[] = "shell32.dll"; + const CHAR szShell32Dll[] = "shell32.dll"; HICON ahIcon[256]; - UINT aIconId[256]; - UINT cIcons, cIcons2; + UINT i, aIconId[256], cIcons, cIcons2; if (!pPrivateExtractIconsA) return; - + + cIcons = pPrivateExtractIconsA("", 0, 16, 16, ahIcon, aIconId, 1, 0); + ok(cIcons == ~0u, "got %u\n", cIcons); + + cIcons = pPrivateExtractIconsA("notepad.exe", 0, 16, 16, NULL, NULL, 1, 0); + ok(cIcons == 1 || broken(cIcons == 2) /* win2k */, "got %u\n", cIcons); + + ahIcon[0] = (HICON)0xdeadbeef; + cIcons = pPrivateExtractIconsA("notepad.exe", 0, 16, 16, ahIcon, NULL, 1, 0); + ok(cIcons == 1, "got %u\n", cIcons); + ok(ahIcon[0] != (HICON)0xdeadbeef, "icon not set\n"); + DestroyIcon(ahIcon[0]); + + ahIcon[0] = (HICON)0xdeadbeef; + aIconId[0] = 0xdeadbeef; + cIcons = pPrivateExtractIconsA("notepad.exe", 0, 16, 16, ahIcon, aIconId, 1, 0); + ok(cIcons == 1, "got %u\n", cIcons); + ok(ahIcon[0] != (HICON)0xdeadbeef, "icon not set\n"); + ok(aIconId[0] != 0xdeadbeef, "id not set\n"); + DestroyIcon(ahIcon[0]); + cIcons = pPrivateExtractIconsA(szShell32Dll, 0, 16, 16, NULL, NULL, 0, 0); cIcons2 = pPrivateExtractIconsA(szShell32Dll, 4, MAKELONG(32,16), MAKELONG(32,16), NULL, NULL, 256, 0); @@ -350,14 +369,18 @@ static void test_PrivateExtractIcons(void) { cIcons = pPrivateExtractIconsA(szShell32Dll, 0, 16, 16, ahIcon, aIconId, 3, 0); ok(cIcons == 3, "Three icons requested got cIcons=%d\n", cIcons); + for (i = 0; i < cIcons; i++) DestroyIcon(ahIcon[i]); /* count must be a multiple of two when getting two sizes */ cIcons = pPrivateExtractIconsA(szShell32Dll, 0, MAKELONG(16,32), MAKELONG(16,32), ahIcon, aIconId, 3, 0); ok(cIcons == 0 /* vista */ || cIcons == 4, "Three icons requested got cIcons=%d\n", cIcons); + for (i = 0; i < cIcons; i++) DestroyIcon(ahIcon[i]); + cIcons = pPrivateExtractIconsA(szShell32Dll, 0, MAKELONG(16,32), MAKELONG(16,32), ahIcon, aIconId, 4, 0); ok(cIcons == 4, "Four icons requested got cIcons=%d\n", cIcons); + for (i = 0; i < cIcons; i++) DestroyIcon(ahIcon[i]); } static void test_LoadImage(void) @@ -365,14 +388,14 @@ static void test_LoadImage(void) HBITMAP bmp; HRSRC hres; - bmp = LoadBitmapA(GetModuleHandle(NULL), MAKEINTRESOURCE(100)); + bmp = LoadBitmapA(GetModuleHandleA(NULL), MAKEINTRESOURCEA(100)); ok(bmp != NULL, "Could not load a bitmap resource\n"); if (bmp) DeleteObject(bmp); - hres = FindResource(GetModuleHandle(NULL), "#100", RT_BITMAP); + hres = FindResourceA(GetModuleHandleA(NULL), "#100", (LPCSTR)RT_BITMAP); ok(hres != NULL, "Could not find a bitmap resource with a numeric string\n"); - bmp = LoadBitmapA(GetModuleHandle(NULL), "#100"); + bmp = LoadBitmapA(GetModuleHandleA(NULL), "#100"); ok(bmp != NULL, "Could not load a bitmap resource with a numeric string\n"); if (bmp) DeleteObject(bmp); } diff --git a/rostests/winetests/user32/scroll.c b/rostests/winetests/user32/scroll.c index 0f0ede23fed..df37534806e 100644 --- a/rostests/winetests/user32/scroll.c +++ b/rostests/winetests/user32/scroll.c @@ -56,7 +56,7 @@ static void scrollbar_test_track(void) { /* test that scrollbar tracking is terminated when * the control looses mouse capture */ - SendMessage( hScroll, WM_LBUTTONDOWN, 0, MAKELPARAM( 1, 1)); + SendMessageA( hScroll, WM_LBUTTONDOWN, 0, MAKELPARAM( 1, 1)); /* a normal return from the sendmessage */ /* not normal for instance by closing the windws */ ok( IsWindow( hScroll), "Scrollbar has gone!\n"); @@ -467,7 +467,7 @@ static void scrollbar_test_init(void) wc.cbSize = sizeof wc; wc.style = CS_VREDRAW | CS_HREDRAW; wc.hInstance = GetModuleHandleA(0); - wc.hCursor = LoadCursorA(NULL, IDC_ARROW); + wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); wc.hbrBackground = GetStockObject(WHITE_BRUSH); wc.lpszClassName = cls_name; wc.lpfnWndProc = scroll_init_proc; @@ -495,7 +495,7 @@ START_TEST ( scroll ) wc.cbWndExtra = 0; wc.hInstance = GetModuleHandleA(NULL); wc.hIcon = NULL; - wc.hCursor = LoadCursorA(NULL, IDC_IBEAM); + wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_IBEAM); wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW); wc.lpszMenuName = NULL; wc.lpszClassName = "MyTestWnd"; diff --git a/rostests/winetests/user32/static.c b/rostests/winetests/user32/static.c index 13955aa4cb7..d4aa9b1f674 100644 --- a/rostests/winetests/user32/static.c +++ b/rostests/winetests/user32/static.c @@ -50,14 +50,14 @@ static void flush_events(void) while (diff > 0) { if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); diff = time - GetTickCount(); } } static HWND build_static(DWORD style) { - return CreateWindow("static", "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0); + return CreateWindowA("static", "Test", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)CTRL_ID, NULL, 0); } static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) @@ -76,7 +76,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara break; } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } static void test_updates(int style, int flags) @@ -119,24 +119,24 @@ static void test_updates(int style, int flags) START_TEST(static) { - static char szClassName[] = "testclass"; - WNDCLASSEX wndclass; + static const char szClassName[] = "testclass"; + WNDCLASSEXA wndclass; wndclass.cbSize = sizeof(wndclass); wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = WndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; - wndclass.hInstance = GetModuleHandle(NULL); - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hInstance = GetModuleHandleA(NULL); + wndclass.hIcon = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION); + wndclass.hIconSm = LoadIconA(NULL, (LPCSTR)IDI_APPLICATION); + wndclass.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW); wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); wndclass.lpszClassName = szClassName; wndclass.lpszMenuName = NULL; - RegisterClassEx(&wndclass); + RegisterClassExA(&wndclass); - hMainWnd = CreateWindow(szClassName, "Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, GetModuleHandle(NULL), NULL); + hMainWnd = CreateWindowA(szClassName, "Test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, GetModuleHandleA(NULL), NULL); ShowWindow(hMainWnd, SW_SHOW); test_updates(0, 0); diff --git a/rostests/winetests/user32/sysparams.c b/rostests/winetests/user32/sysparams.c index d705e78d874..6c3489fc847 100755 --- a/rostests/winetests/user32/sysparams.c +++ b/rostests/winetests/user32/sysparams.c @@ -2869,8 +2869,9 @@ static void test_EnumDisplaySettings(void) if (!EnumDisplaySettingsA(NULL, num, &devmode)) { DWORD le = GetLastError(); ok(le == ERROR_NO_MORE_FILES || + le == ERROR_MOD_NOT_FOUND /* Win8 */ || le == 0xdeadbeef, /* XP, 2003 */ - "Expected ERROR_NO_MORE_FILES or 0xdeadbeef, got %d for %d\n", le, num); + "Expected ERROR_NO_MORE_FILES, ERROR_MOD_NOT_FOUND or 0xdeadbeef, got %d for %d\n", le, num); break; } num++; diff --git a/rostests/winetests/user32/uitools.c b/rostests/winetests/user32/uitools.c index c3f55083c05..5f10b0088ad 100644 --- a/rostests/winetests/user32/uitools.c +++ b/rostests/winetests/user32/uitools.c @@ -63,7 +63,57 @@ static void test_FillRect(void) ReleaseDC(0, hdc); } +static void test_SubtractRect(void) +{ + RECT rect1; + RECT rect2; + RECT rectr; + BOOL result; + + /* source rectangles don't intersect */ + SetRect(&rect1, 50, 50, 150, 100); + SetRect(&rect2, 250, 200, 1500, 1000); + result = SubtractRect(&rectr, &rect1, &rect2); + ok(result, "SubtractRect returned FALSE but subtraction should not be empty\n"); + ok(result && rectr.left == 50 && rectr.top == 50 && rectr.right ==150 + && rectr.bottom == 100, "wrong rect subtraction of SubtractRect " + "(dest rect={%d, %d, %d, %d})\n", rectr.left, rectr.top, rectr.right, rectr.bottom); + + /* source rect 2 partially overlaps rect 1 */ + SetRect(&rect1, 2431, 626, 3427, 1608); + SetRect(&rect2, 2499, 626, 3427, 1608); + result = SubtractRect(&rectr, &rect1, &rect2); + ok(result, "SubtractRect returned FALSE but subtraction should not be empty\n"); + ok(result && rectr.left == 2431 && rectr.top == 626 && rectr.right == 2499 + && rectr.bottom == 1608, "wrong rect subtraction of SubtractRect " + "(dest rect={%d, %d, %d, %d})\n", rectr.left, rectr.top, rectr.right, rectr.bottom); + + /* source rect 2 partially overlaps rect 1 - dest is src rect 2 */ + SetRect(&rect1, 2431, 626, 3427, 1608); + SetRect(&rect2, 2499, 626, 3427, 1608); + result = SubtractRect(&rect2, &rect1, &rect2); + ok(result, "SubtractRect returned FALSE but subtraction should not be empty\n"); + ok(result && rectr.left == 2431 && rectr.top == 626 && rectr.right == 2499 + && rectr.bottom == 1608, "wrong rect subtraction of SubtractRect " + "(dest rect={%d, %d, %d, %d})\n", rectr.left, rectr.top, rectr.right, rectr.bottom); + + /* source rect 2 completely overlaps rect 1 */ + SetRect(&rect1, 250, 250, 400, 500); + SetRect(&rect2, 50, 50, 1500, 1000); + result = SubtractRect(&rectr, &rect1, &rect2); + ok(!result, "SubtractRect returned TRUE but subtraction should be empty " + "(dest rect={%d, %d, %d, %d})\n", rectr.left, rectr.top, rectr.right, rectr.bottom); + + /* source rect 2 completely overlaps rect 1 - dest is src rect 2 */ + SetRect(&rect1, 250, 250, 400, 500); + SetRect(&rect2, 50, 50, 1500, 1000); + result = SubtractRect(&rect2, &rect1, &rect2); + ok(!result, "SubtractRect returned TRUE but subtraction should be empty " + "(dest rect={%d, %d, %d, %d})\n", rect2.left, rect2.top, rect2.right, rect2.bottom); +} + START_TEST(uitools) { test_FillRect(); + test_SubtractRect(); } diff --git a/rostests/winetests/user32/win.c b/rostests/winetests/user32/win.c index 0dc610fb158..7b5007b0720 100644 --- a/rostests/winetests/user32/win.c +++ b/rostests/winetests/user32/win.c @@ -97,7 +97,7 @@ static void flush_events( BOOL remove_messages ) { if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break; if (remove_messages) - while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg ); + while (PeekMessageA( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg ); diff = time - GetTickCount(); min_timeout = 50; } @@ -657,7 +657,7 @@ static DWORD CALLBACK enum_thread( void *arg ) "wrong error %u\n", GetLastError() ); } - PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */ + PeekMessageA( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */ count = 0; ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count ); @@ -840,7 +840,7 @@ static BOOL RegisterWindowClasses(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "MainWindowClass"; @@ -853,7 +853,7 @@ static BOOL RegisterWindowClasses(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "ToolWindowClass"; @@ -895,14 +895,15 @@ static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *in /* win2k and XP return broken border info in GetWindowInfo most of * the time, so there is no point in testing it. */ -#if 0 +if (0) +{ UINT border; ok(info->cxWindowBorders == (unsigned)(rcClient.left - rcWindow.left), "wrong cxWindowBorders %d != %d\n", info->cxWindowBorders, rcClient.left - rcWindow.left); border = min(rcWindow.bottom - rcClient.bottom, rcClient.top - rcWindow.top); ok(info->cyWindowBorders == border, "wrong cyWindowBorders %d != %d\n", info->cyWindowBorders, border); -#endif +} ok(info->atomWindowType == GetClassLongA(hwnd, GCW_ATOM), "wrong atomWindowType for %p in hook %s\n", hwnd, hook); ok(info->wCreatorVersion == 0x0400 /* NT4, Win2000, XP, Win2003 */ || @@ -1116,7 +1117,7 @@ static void test_shell_window(void) } shellWindow = GetShellWindow(); - hinst = GetModuleHandle(0); + hinst = GetModuleHandleA(NULL); hUser32 = GetModuleHandleA("user32"); SetShellWindow = (void *)GetProcAddress(hUser32, "SetShellWindow"); @@ -1151,7 +1152,7 @@ static void test_shell_window(void) CloseHandle(hProcess); } - hwnd1 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst, 0); + hwnd1 = CreateWindowExA(0, "#32770", "TEST1", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst, 0); trace("created window 1: %p\n", hwnd1); ret = SetShellWindow(hwnd1); @@ -1172,22 +1173,22 @@ static void test_shell_window(void) /* passes on Win XP, but not on Win98 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */ - SetWindowLong(hwnd1, GWL_EXSTYLE, GetWindowLong(hwnd1,GWL_EXSTYLE)|WS_EX_TOPMOST); - ret = (GetWindowLong(hwnd1,GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; + SetWindowLongA(hwnd1, GWL_EXSTYLE, GetWindowLongA(hwnd1,GWL_EXSTYLE)|WS_EX_TOPMOST); + ret = (GetWindowLongA(hwnd1,GWL_EXSTYLE) & WS_EX_TOPMOST) != 0; ok(!ret, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n"); ret = DestroyWindow(hwnd1); ok(ret, "DestroyWindow(hwnd1)\n"); - hwnd2 = CreateWindowEx(WS_EX_TOPMOST, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst, 0); + hwnd2 = CreateWindowExA(WS_EX_TOPMOST, "#32770", "TEST2", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst, 0); trace("created window 2: %p\n", hwnd2); ret = SetShellWindow(hwnd2); ok(!ret, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n"); - hwnd3 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst, 0); + hwnd3 = CreateWindowExA(0, "#32770", "TEST3", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst, 0); trace("created window 3: %p\n", hwnd3); - hwnd4 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst, 0); + hwnd4 = CreateWindowExA(0, "#32770", "TEST4", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst, 0); trace("created window 4: %p\n", hwnd4); nextWnd = GetWindow(hwnd4, GW_HWNDNEXT); @@ -1212,7 +1213,7 @@ static void test_shell_window(void) shellWindow = GetShellWindow(); ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow); - hwnd5 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst, 0); + hwnd5 = CreateWindowExA(0, "#32770", "TEST5", WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst, 0); trace("created window 5: %p\n", hwnd5); ret = SetWindowPos(hwnd4, hwnd5, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); ok(ret, "SetWindowPos(hwnd4, hwnd5)\n"); @@ -1245,7 +1246,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) mdi_cs.szClass = "MDI_child_Class_1"; mdi_cs.szTitle = "MDI child"; - mdi_cs.hOwner = GetModuleHandle(0); + mdi_cs.hOwner = GetModuleHandleA(NULL); mdi_cs.x = CW_USEDEFAULT; mdi_cs.y = CW_USEDEFAULT; mdi_cs.cx = CW_USEDEFAULT; @@ -1308,7 +1309,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, GetModuleHandle(0), + mdi_client, GetModuleHandleA(NULL), (LPARAM)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1320,7 +1321,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0x7fffffff, /* without WS_POPUP */ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, GetModuleHandle(0), + mdi_client, GetModuleHandleA(NULL), (LPARAM)mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1332,7 +1333,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0xffffffff, /* with WS_POPUP */ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, GetModuleHandle(0), + mdi_client, GetModuleHandleA(NULL), (LPARAM)mdi_lParam_test_message); if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES) { @@ -1353,7 +1354,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, GetModuleHandle(0), + mdi_client, GetModuleHandleA(NULL), (LPARAM)mdi_lParam_test_message); if (!mdi_child) { @@ -1374,7 +1375,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1386,7 +1387,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0x7fffffff, /* without WS_POPUP */ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1398,7 +1399,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0xffffffff, /* with WS_POPUP */ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES) { @@ -1419,7 +1420,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); if (!mdi_child) { @@ -1443,7 +1444,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) WS_CHILD, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - parent, 0, GetModuleHandle(0), + parent, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(!mdi_child, "WS_EX_MDICHILD with a not MDIClient parent should fail\n"); } @@ -1452,7 +1453,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) WS_CHILD, /* without WS_POPUP */ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1463,7 +1464,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) WS_CHILD | WS_POPUP, /* with WS_POPUP */ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1475,7 +1476,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) WS_CHILD | WS_MAXIMIZE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1487,7 +1488,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) WS_CHILD | WS_MAXIMIZE | WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1499,7 +1500,7 @@ static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id) WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - mdi_client, 0, GetModuleHandle(0), + mdi_client, 0, GetModuleHandleA(NULL), mdi_lParam_test_message); ok(mdi_child != 0, "MDI child creation failed\n"); id = GetWindowLongPtrA(mdi_child, GWLP_ID); @@ -1543,7 +1544,7 @@ static void test_MDI_child_stack(HWND mdi_client) child_4, child_3, child_2, child_1); trace("Activate child next to %p\n", child_3); - SendMessage(mdi_client, WM_MDINEXT, (WPARAM)child_3, 0); + SendMessageA(mdi_client, WM_MDINEXT, (WPARAM)child_3, 0); stack[0] = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0); stack[1] = GetWindow(stack[0], GW_HWNDNEXT); @@ -1555,7 +1556,7 @@ static void test_MDI_child_stack(HWND mdi_client) child_2, child_4, child_1, child_3, stack[0], stack[1], stack[2], stack[3]); trace("Activate child previous to %p\n", child_1); - SendMessage(mdi_client, WM_MDINEXT, (WPARAM)child_1, 1); + SendMessageA(mdi_client, WM_MDINEXT, (WPARAM)child_1, 1); stack[0] = (HWND)SendMessageA(mdi_client, WM_MDIGETACTIVE, 0, 0); stack[1] = GetWindow(stack[0], GW_HWNDNEXT); @@ -1836,7 +1837,7 @@ static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPA WS_CHILD /*| WS_VISIBLE*/, /* tests depend on a not zero MDIClient size */ 0, 0, rc.right, rc.bottom, - hwnd, 0, GetModuleHandle(0), + hwnd, 0, GetModuleHandleA(NULL), &client_cs); assert(mdi_client); test_MDI_create(hwnd, mdi_client, client_cs.idFirstChild); @@ -1848,7 +1849,7 @@ static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPA WS_CHILD | MDIS_ALLCHILDSTYLES /*| WS_VISIBLE*/, /* tests depend on a not zero MDIClient size */ 0, 0, rc.right, rc.bottom, - hwnd, 0, GetModuleHandle(0), + hwnd, 0, GetModuleHandleA(NULL), &client_cs); assert(mdi_client); test_MDI_create(hwnd, mdi_client, client_cs.idFirstChild); @@ -1859,7 +1860,7 @@ static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPA NULL, WS_CHILD, 0, 0, rc.right, rc.bottom, - hwnd, 0, GetModuleHandle(0), + hwnd, 0, GetModuleHandleA(NULL), &client_cs); assert(mdi_client); test_MDI_child_stack(mdi_client); @@ -1926,7 +1927,7 @@ static BOOL mdi_RegisterWindowClasses(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "MDI_parent_Class"; @@ -1955,7 +1956,7 @@ static void test_mdi(void) WS_MAXIMIZEBOX /*| WS_VISIBLE*/, 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, GetDesktopWindow(), 0, - GetModuleHandle(0), NULL); + GetModuleHandleA(NULL), NULL); assert(mdi_hwndMain); /* while(GetMessage(&msg, 0, 0, 0)) @@ -1971,9 +1972,9 @@ static void test_icons(void) { WNDCLASSEXA cls; HWND hwnd; - HICON icon = LoadIconA(0, IDI_APPLICATION); - HICON icon2 = LoadIconA(0, IDI_QUESTION); - HICON small_icon = LoadImageA(0, IDI_APPLICATION, IMAGE_ICON, + HICON icon = LoadIconA(0, (LPCSTR)IDI_APPLICATION); + HICON icon2 = LoadIconA(0, (LPCSTR)IDI_QUESTION); + HICON small_icon = LoadImageA(0, (LPCSTR)IDI_APPLICATION, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED ); HICON res; @@ -1983,9 +1984,9 @@ static void test_icons(void) cls.cbClsExtra = 0; cls.cbWndExtra = 0; cls.hInstance = 0; - cls.hIcon = LoadIconA(0, IDI_HAND); + cls.hIcon = LoadIconA(0, (LPCSTR)IDI_HAND); cls.hIconSm = small_icon; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "IconWindowClass"; @@ -2044,7 +2045,7 @@ static LRESULT WINAPI nccalcsize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM else InflateRect( rect, -10, -10 ); return 0; } - return DefWindowProc( hwnd, msg, wparam, lparam ); + return DefWindowProcA( hwnd, msg, wparam, lparam ); } static void test_SetWindowPos(HWND hwnd, HWND hwnd2) @@ -2068,7 +2069,7 @@ static void test_SetWindowPos(HWND hwnd, HWND hwnd2) GetWindowRect(hwnd, &orig_win_rc); - old_proc = SetWindowLongPtr( hwnd, GWLP_WNDPROC, (ULONG_PTR)nccalcsize_proc ); + old_proc = SetWindowLongPtrA( hwnd, GWLP_WNDPROC, (ULONG_PTR)nccalcsize_proc ); ret = SetWindowPos(hwnd, 0, 100, 100, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED); ok(ret, "Got %d\n", ret); GetWindowRect( hwnd, &rect ); @@ -2092,7 +2093,7 @@ static void test_SetWindowPos(HWND hwnd, HWND hwnd2) ret = SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top, orig_win_rc.right, orig_win_rc.bottom, 0); ok(ret, "Got %d\n", ret); - SetWindowLongPtr( hwnd, GWLP_WNDPROC, old_proc ); + SetWindowLongPtrA( hwnd, GWLP_WNDPROC, old_proc ); /* Win9x truncates coordinates to 16-bit irrespectively */ if (!is_win9x) @@ -2112,16 +2113,16 @@ static void test_SetWindowPos(HWND hwnd, HWND hwnd2) orig_win_rc.right, orig_win_rc.bottom, 0); ok(ret, "Got %d\n", ret); - ok(!(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n"); + ok(!(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n"); ret = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); ok(ret, "Got %d\n", ret); - ok(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n"); + ok(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n"); ret = SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); ok(ret, "Got %d\n", ret); - ok(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n"); + ok(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n"); ret = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE); ok(ret, "Got %d\n", ret); - ok(!(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n"); + ok(!(GetWindowLongA(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n"); hwnd_desktop = GetDesktopWindow(); ok(!!hwnd_desktop, "Failed to get hwnd_desktop window (%d).\n", GetLastError()); @@ -2322,15 +2323,15 @@ static void test_SetMenu(HWND parent) ret = GetMenu(child); ok(ret == (HMENU)10, "unexpected menu id %p\n", ret); - style = GetWindowLong(child, GWL_STYLE); - SetWindowLong(child, GWL_STYLE, style | WS_POPUP); + style = GetWindowLongA(child, GWL_STYLE); + SetWindowLongA(child, GWL_STYLE, style | WS_POPUP); ok(SetMenu(child, hMenu), "SetMenu on a popup child window should not fail\n"); ok(SetMenu(child, 0), "SetMenu on a popup child window should not fail\n"); - SetWindowLong(child, GWL_STYLE, style); + SetWindowLongA(child, GWL_STYLE, style); - SetWindowLong(child, GWL_STYLE, style | WS_OVERLAPPED); - ok(!SetMenu(child, hMenu), "SetMenu on a overlapped child window should fail\n"); - SetWindowLong(child, GWL_STYLE, style); + SetWindowLongA(child, GWL_STYLE, style | WS_OVERLAPPED); + ok(!SetMenu(child, hMenu), "SetMenu on an overlapped child window should fail\n"); + SetWindowLongA(child, GWL_STYLE, style); DestroyWindow(child); DestroyMenu(hMenu); @@ -2350,7 +2351,7 @@ static void test_window_tree(HWND parent, const DWORD *style, const int *order, { if (style[i] & DS_CONTROL) { - child[i] = CreateWindowExA(0, MAKEINTATOM(32770), "", style[i] & ~WS_VISIBLE, + child[i] = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(32770), "", style[i] & ~WS_VISIBLE, 0,0,0,0, parent, (HMENU)i, 0, NULL); if (style[i] & WS_VISIBLE) ShowWindow(child[i], SW_SHOW); @@ -2428,7 +2429,7 @@ static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner, /* skip foreign windows */ while (test && test != next && (GetWindowThreadProcessId(test, NULL) != our_pid || - UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)) != GetModuleHandle(0) || + UlongToHandle(GetWindowLongPtrA(test, GWLP_HINSTANCE)) != GetModuleHandleA(NULL) || GetWindow(test, GW_OWNER) == next)) { /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/ @@ -2440,7 +2441,7 @@ static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner, /* skip foreign windows */ while (test && test != prev && (GetWindowThreadProcessId(test, NULL) != our_pid || - UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)) != GetModuleHandle(0) || + UlongToHandle(GetWindowLongPtrA(test, GWLP_HINSTANCE)) != GetModuleHandleA(NULL) || GetWindow(test, GW_OWNER) == hwnd)) { /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/ @@ -2451,7 +2452,7 @@ static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner, test = GetWindow(hwnd, GW_OWNER); ok_(file, line)(owner == test, "%p: expected owner %p, got %p\n", hwnd, owner, test); - ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); + ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE); ok_(file, line)(!(ex_style & WS_EX_TOPMOST) == !topmost, "%p: expected %stopmost\n", hwnd, topmost ? "" : "NOT "); } @@ -2467,10 +2468,10 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style) check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE); check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE); - hwnd_F = CreateWindowEx(0, "MainWindowClass", "Owner window", + hwnd_F = CreateWindowExA(0, "MainWindowClass", "Owner window", WS_OVERLAPPED | WS_CAPTION, 100, 100, 100, 100, - 0, 0, GetModuleHandle(0), NULL); + 0, 0, GetModuleHandleA(NULL), NULL); trace("hwnd_F %p\n", hwnd_F); check_z_order(hwnd_F, hwnd_D, 0, 0, FALSE); @@ -2479,20 +2480,20 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style) check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE); check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE); - hwnd_C = CreateWindowEx(0, "MainWindowClass", NULL, + hwnd_C = CreateWindowExA(0, "MainWindowClass", NULL, style, 100, 100, 100, 100, - hwnd_F, 0, GetModuleHandle(0), NULL); + hwnd_F, 0, GetModuleHandleA(NULL), NULL); trace("hwnd_C %p\n", hwnd_C); check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE); check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE); check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE); check_z_order(hwnd_C, hwnd_D, 0, hwnd_F, FALSE); - hwnd_B = CreateWindowEx(WS_EX_TOPMOST, "MainWindowClass", NULL, + hwnd_B = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", NULL, style, 100, 100, 100, 100, - hwnd_F, 0, GetModuleHandle(0), NULL); + hwnd_F, 0, GetModuleHandleA(NULL), NULL); trace("hwnd_B %p\n", hwnd_B); check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE); check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE); @@ -2500,10 +2501,10 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style) check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE); check_z_order(hwnd_B, hwnd_C, 0, hwnd_F, TRUE); - hwnd_A = CreateWindowEx(WS_EX_TOPMOST, "MainWindowClass", NULL, + hwnd_A = CreateWindowExA(WS_EX_TOPMOST, "MainWindowClass", NULL, style, 100, 100, 100, 100, - 0, 0, GetModuleHandle(0), NULL); + 0, 0, GetModuleHandleA(NULL), NULL); trace("hwnd_A %p\n", hwnd_A); check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE); check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE); @@ -2536,10 +2537,10 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style) /* make hwnd_C owned by a topmost window */ DestroyWindow( hwnd_C ); - hwnd_C = CreateWindowEx(0, "MainWindowClass", NULL, + hwnd_C = CreateWindowExA(0, "MainWindowClass", NULL, style, 100, 100, 100, 100, - hwnd_A, 0, GetModuleHandle(0), NULL); + hwnd_A, 0, GetModuleHandleA(NULL), NULL); trace("hwnd_C %p\n", hwnd_C); check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE); check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE); @@ -2593,7 +2594,7 @@ static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, ok(GetFocus() == child, "Focus should be on child %p\n", child); return 0; } - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } static void test_SetFocus(HWND hwnd) @@ -2607,22 +2608,22 @@ static void test_SetFocus(HWND hwnd) SetFocus(0); SetFocus(hwnd); ok( GetFocus() == hwnd, "Failed to set focus to visible window %p\n", hwnd ); - ok( GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE, "Window %p not visible\n", hwnd ); + ok( GetWindowLongA(hwnd,GWL_STYLE) & WS_VISIBLE, "Window %p not visible\n", hwnd ); ShowWindow(hwnd, SW_HIDE); SetFocus(0); SetFocus(hwnd); ok( GetFocus() == hwnd, "Failed to set focus to invisible window %p\n", hwnd ); - ok( !(GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE), "Window %p still visible\n", hwnd ); + ok( !(GetWindowLongA(hwnd,GWL_STYLE) & WS_VISIBLE), "Window %p still visible\n", hwnd ); child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, NULL); assert(child); SetFocus(child); ok( GetFocus() == child, "Failed to set focus to invisible child %p\n", child ); - ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); + ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); ShowWindow(child, SW_SHOW); - ok( GetWindowLong(child,GWL_STYLE) & WS_VISIBLE, "Child %p is not visible\n", child ); + ok( GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE, "Child %p is not visible\n", child ); ok( GetFocus() == child, "Focus no longer on child %p\n", child ); ShowWindow(child, SW_HIDE); - ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); + ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() ); ShowWindow(child, SW_SHOW); child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, 0, 0, NULL); @@ -2630,7 +2631,7 @@ static void test_SetFocus(HWND hwnd) ShowWindow(child2, SW_SHOW); SetFocus(child2); ShowWindow(child, SW_HIDE); - ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); + ok( !(GetWindowLongA(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); ok( GetFocus() == child2, "Focus should be on %p, not %p\n", child2, GetFocus() ); ShowWindow(child, SW_SHOW); SetFocus(child); @@ -2668,12 +2669,12 @@ todo_wine ok( GetFocus() != child, "Focus should not be on child %p\n", child ); todo_wine ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd ); - old_wnd_proc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)set_focus_on_activate_proc); + old_wnd_proc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)set_focus_on_activate_proc); ShowWindow(hwnd, SW_RESTORE); ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd); todo_wine ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() ); - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc); + SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc); SetFocus( hwnd ); SetParent( child, GetDesktopWindow()); @@ -2793,6 +2794,7 @@ static void test_SetForegroundWindow(HWND hwnd) BOOL ret; HWND hwnd2; MSG msg; + LONG style; flush_events( TRUE ); ShowWindow(hwnd, SW_HIDE); @@ -2870,9 +2872,9 @@ static void test_SetForegroundWindow(HWND hwnd) hwnd2 = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0); check_wnd_state(hwnd2, hwnd2, hwnd2, 0); - thread_params.window_created = CreateEvent(NULL, FALSE, FALSE, NULL); + thread_params.window_created = CreateEventW(NULL, FALSE, FALSE, NULL); ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError()); - thread_params.test_finished = CreateEvent(NULL, FALSE, FALSE, NULL); + thread_params.test_finished = CreateEventW(NULL, FALSE, FALSE, NULL); ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError()); thread = CreateThread(NULL, 0, create_window_thread, &thread_params, 0, &tid); ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError()); @@ -2883,11 +2885,24 @@ static void test_SetForegroundWindow(HWND hwnd) SetForegroundWindow(hwnd2); check_wnd_state(hwnd2, hwnd2, hwnd2, 0); - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg); + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); if (0) check_wnd_state(hwnd2, hwnd2, hwnd2, 0); todo_wine ok(GetActiveWindow() == hwnd2, "Expected active window %p, got %p.\n", hwnd2, GetActiveWindow()); todo_wine ok(GetFocus() == hwnd2, "Expected focus window %p, got %p.\n", hwnd2, GetFocus()); + SetForegroundWindow(hwnd); + check_wnd_state(hwnd, hwnd, hwnd, 0); + style = GetWindowLongA(hwnd2, GWL_STYLE) | WS_CHILD; + ok(SetWindowLongA(hwnd2, GWL_STYLE, style), "SetWindowLong failed\n"); + ok(SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n"); + check_wnd_state(hwnd2, hwnd2, hwnd2, 0); + + SetForegroundWindow(hwnd); + check_wnd_state(hwnd, hwnd, hwnd, 0); + ok(SetWindowLongA(hwnd2, GWL_STYLE, style & (~WS_POPUP)), "SetWindowLong failed\n"); + ok(!SetForegroundWindow(hwnd2), "SetForegroundWindow failed\n"); + check_wnd_state(hwnd, hwnd, hwnd, 0); + SetEvent(thread_params.test_finished); WaitForSingleObject(thread, INFINITE); CloseHandle(thread_params.test_finished); @@ -2935,7 +2950,7 @@ static LRESULT WINAPI button_hook_proc(HWND button, UINT msg, WPARAM wparam, LPA /* button wnd proc should release capture on WM_KILLFOCUS if it does * match internal button state. */ - SendMessage(button, WM_KILLFOCUS, 0, 0); + SendMessageA(button, WM_KILLFOCUS, 0, 0); check_wnd_state(button, button, button, 0); ShowWindow(hwnd, SW_SHOW); @@ -3001,7 +3016,7 @@ static void test_capture_2(void) /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match * internal button state. */ - SendMessage(button, WM_KILLFOCUS, 0, 0); + SendMessageA(button, WM_KILLFOCUS, 0, 0); check_wnd_state(button, button, button, button); hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL); @@ -3144,8 +3159,8 @@ static void test_capture_4(void) wclass.style = CS_HREDRAW | CS_VREDRAW; wclass.lpfnWndProc = test_capture_4_proc; wclass.hInstance = hInstance; - wclass.hIcon = LoadIconA( 0, IDI_APPLICATION ); - wclass.hCursor = LoadCursorA( NULL, IDC_ARROW ); + wclass.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION ); + wclass.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW ); wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); wclass.lpszMenuName = 0; wclass.cbClsExtra = 0; @@ -3277,7 +3292,7 @@ static BOOL wait_for_message( MSG *msg ) ret = peek_message(msg); if (ret) { - if (msg->message == WM_PAINT) DispatchMessage(msg); + if (msg->message == WM_PAINT) DispatchMessageA(msg); else break; } else if (MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT ) == WAIT_TIMEOUT) break; @@ -3355,7 +3370,7 @@ static void test_mouse_input(HWND hwnd) if (msg.message == WM_TIMER || ignore_message(msg.message)) continue; ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message); - DispatchMessage(&msg); + DispatchMessageA(&msg); } ret = peek_message(&msg); ok( !ret, "message %04x available\n", msg.message); @@ -3570,7 +3585,7 @@ static void test_nccalcscroll(HWND parent) 0, rc1.left, rc1.top, rc1.right, rc1.bottom); /* same test, but with client edge: not enough width */ - SetWindowLong( hwnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE | GetWindowLong( hwnd, GWL_EXSTYLE)); + SetWindowLongA( hwnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE | GetWindowLongA( hwnd, GWL_EXSTYLE)); nccalchelper( hwnd, sbwidth, 100, &rc1); ok( rc1.right - rc1.left == sbwidth - 2 * GetSystemMetrics(SM_CXEDGE), "Width should be %d size is %d,%d - %d,%d\n", @@ -3674,6 +3689,19 @@ static void test_SetParent(void) ok(SetParent(sibling, parent) != 0, "SetParent should not fail\n"); ok(GetMenu(sibling) == hMenu, "SetParent should not remove menu\n"); + ok(SetParent(parent, desktop) != 0, "SetParent should not fail\n"); + ok(SetParent(child4, child3) != 0, "SetParent should not fail\n"); + ok(SetParent(child3, child2) != 0, "SetParent should not fail\n"); + ok(SetParent(child2, child1) != 0, "SetParent should not fail\n"); + ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4); + SetWindowLongW(child4, GWL_STYLE, WS_CHILD); + ok(IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4); + ok(IsChild(child2, child4), "wrong parent/child %p/%p\n", child2, child4); + ok(!IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4); + SetWindowLongW(child2, GWL_STYLE, WS_CHILD); + ok(IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4); + ok(IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4); + ok(DestroyWindow(parent), "DestroyWindow() failed\n"); ok(!IsWindow(parent), "parent still exists\n"); @@ -3706,21 +3734,34 @@ static void test_SetParent(void) ret = SetParent(popup, child1); ok(ret == desktop, "expected %p, got %p\n", desktop, ret); check_parents(popup, child1, child1, 0, 0, parent, popup); -todo_wine check_active_state(popup, 0, popup); + SetActiveWindow(parent); + SetFocus(popup); + check_active_state(popup, 0, popup); + + EnableWindow(child1, FALSE); + check_active_state(popup, 0, popup); + SetFocus(parent); + check_active_state(parent, 0, parent); + SetFocus(popup); + check_active_state(popup, 0, popup); + EnableWindow(child1, TRUE); + + ShowWindow(child1, SW_MINIMIZE); + SetFocus(parent); + check_active_state(parent, 0, parent); + SetFocus(popup); + check_active_state(popup, 0, popup); + ShowWindow(child1, SW_HIDE); + SetActiveWindow(parent); SetFocus(parent); check_active_state(parent, 0, parent); bret = SetForegroundWindow(popup); -todo_wine { - ok(bret || broken(!bret), "SetForegroundWindow() failed\n"); - if (!bret) - check_active_state(popup, 0, popup); - else - check_active_state(popup, popup, popup); - } + ok(bret, "SetForegroundWindow() failed\n"); + check_active_state(popup, popup, popup); ok(DestroyWindow(parent), "DestroyWindow() failed\n"); @@ -3731,14 +3772,14 @@ todo_wine { static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { - LPCREATESTRUCT lpcs; + LPCREATESTRUCTA lpcs; LPSTYLESTRUCT lpss; switch (msg) { case WM_NCCREATE: case WM_CREATE: - lpcs = (LPCREATESTRUCT)lparam; + lpcs = (LPCREATESTRUCTA)lparam; lpss = lpcs->lpCreateParams; if (lpss) { @@ -3759,28 +3800,28 @@ static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM } break; } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } static ATOM atomStyleCheckClass; static void register_style_check_class(void) { - WNDCLASS wc = + WNDCLASSA wc = { 0, StyleCheckProc, 0, 0, - GetModuleHandle(NULL), + GetModuleHandleA(NULL), NULL, - LoadCursor(NULL, IDC_ARROW), + LoadCursorA(0, (LPCSTR)IDC_ARROW), (HBRUSH)(COLOR_BTNFACE+1), NULL, - TEXT("WineStyleCheck"), + "WineStyleCheck", }; - - atomStyleCheckClass = RegisterClass(&wc); + + atomStyleCheckClass = RegisterClassA(&wc); assert(atomStyleCheckClass); } @@ -3797,25 +3838,25 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle if (dwStyleIn & WS_CHILD) { - hwndParent = CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass), NULL, + hwndParent = CreateWindowExA(0, (LPCSTR)MAKEINTATOM(atomStyleCheckClass), NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL); } - hwnd = CreateWindowEx(dwExStyleIn, MAKEINTATOM(atomStyleCheckClass), NULL, + hwnd = CreateWindowExA(dwExStyleIn, (LPCSTR)MAKEINTATOM(atomStyleCheckClass), NULL, dwStyleIn, 0, 0, 0, 0, hwndParent, NULL, NULL, &ss); assert(hwnd); flush_events( TRUE ); - dwActualStyle = GetWindowLong(hwnd, GWL_STYLE); - dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE); + dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE); ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle); ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle); /* try setting the styles explicitly */ - SetWindowLong( hwnd, GWL_EXSTYLE, dwExStyleIn ); - dwActualStyle = GetWindowLong(hwnd, GWL_STYLE); - dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLongA( hwnd, GWL_EXSTYLE, dwExStyleIn ); + dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE); + dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE); /* WS_EX_WINDOWEDGE can't always be changed */ if (dwExStyleIn & WS_EX_DLGMODALFRAME) dwExStyleOut = dwExStyleIn | WS_EX_WINDOWEDGE; @@ -3826,9 +3867,9 @@ static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyle ok(dwActualStyle == dwStyleOut, "expected style %#x, got %#x\n", dwStyleOut, dwActualStyle); ok(dwActualExStyle == dwExStyleOut, "expected ex_style %#x, got %#x\n", dwExStyleOut, dwActualExStyle); - SetWindowLong( hwnd, GWL_STYLE, dwStyleIn ); - dwActualStyle = GetWindowLong(hwnd, GWL_STYLE); - dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLongA( hwnd, GWL_STYLE, dwStyleIn ); + dwActualStyle = GetWindowLongA(hwnd, GWL_STYLE); + dwActualExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE); /* WS_CLIPSIBLINGS can't be reset on top-level windows */ if ((dwStyleIn & (WS_CHILD|WS_POPUP)) == WS_CHILD) dwStyleOut = dwStyleIn; else dwStyleOut = dwStyleIn | WS_CLIPSIBLINGS; @@ -3917,7 +3958,7 @@ static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_ou HWND hwnd, parent = 0; if (style_in & WS_CHILD) - parent = CreateWindowEx(0, "static", NULL, WS_OVERLAPPEDWINDOW, + parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL); dlg_data.dt.style = style_in; @@ -3932,20 +3973,20 @@ static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_ou dlg_data.class_atom = 0; dlg_data.caption[0] = 0; - hwnd = CreateDialogIndirectParam(GetModuleHandle(0), &dlg_data.dt, parent, empty_dlg_proc, 0); + hwnd = CreateDialogIndirectParamA(GetModuleHandleA(NULL), &dlg_data.dt, parent, empty_dlg_proc, 0); ok(hwnd != 0, "dialog creation failed, style %#x, exstyle %#x\n", style_in, ex_style_in); flush_events( TRUE ); - style = GetWindowLong(hwnd, GWL_STYLE); - ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); + ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE); ok(style == (style_out | DS_3DLOOK), "expected style %#x, got %#x\n", style_out | DS_3DLOOK, style); ok(ex_style == ex_style_out, "expected ex_style %#x, got %#x\n", ex_style_out, ex_style); /* try setting the styles explicitly */ - SetWindowLong(hwnd, GWL_EXSTYLE, ex_style_in); - style = GetWindowLong(hwnd, GWL_STYLE); - ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLongA(hwnd, GWL_EXSTYLE, ex_style_in); + style = GetWindowLongA(hwnd, GWL_STYLE); + ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE); ok(style == (style_out | DS_3DLOOK), "expected style %#x, got %#x\n", style_out|DS_3DLOOK, style); /* WS_EX_WINDOWEDGE can't always be changed */ if (ex_style_in & WS_EX_DLGMODALFRAME) @@ -3956,9 +3997,9 @@ static void check_dialog_style(DWORD style_in, DWORD ex_style_in, DWORD style_ou ex_style_out = ex_style_in & ~WS_EX_WINDOWEDGE; ok(ex_style == ex_style_out, "expected ex_style %#x, got %#x\n", ex_style_out, ex_style); - SetWindowLong(hwnd, GWL_STYLE, style_in); - style = GetWindowLong(hwnd, GWL_STYLE); - ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); + SetWindowLongA(hwnd, GWL_STYLE, style_in); + style = GetWindowLongA(hwnd, GWL_STYLE); + ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE); /* WS_CLIPSIBLINGS can't be reset on top-level windows */ if ((style_in & (WS_CHILD | WS_POPUP)) == WS_CHILD) style_out = style_in; else style_out = style_in | WS_CLIPSIBLINGS; @@ -4147,7 +4188,7 @@ static void test_scrollvalidate( HWND parent) SetRectRgn( clipping, 10, 10, 90, 90); hdc = GetDC( hwnd1); /* for a visual touch */ - TextOut( hdc, 0,10, "0123456789", 10); + TextOutA( hdc, 0,10, "0123456789", 10); ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu); if (winetest_debug > 0) dump_region(hrgn); /* create a region with what is expected */ @@ -4205,12 +4246,12 @@ static void test_scrollvalidate( HWND parent) hwnd2 = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE | WS_BORDER , 50, 50, 100, 100, hwnd1, 0, 0, NULL); - SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) & ~WS_CLIPSIBLINGS); + SetWindowLongA( hwnd1, GWL_STYLE, GetWindowLongA( hwnd1, GWL_STYLE) & ~WS_CLIPSIBLINGS); GetClientRect( hwnd1, &rc); cliprc=rc; /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */ - SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) | WS_CLIPCHILDREN ); + SetWindowLongA( hwnd1, GWL_STYLE, GetWindowLongA( hwnd1, GWL_STYLE) | WS_CLIPCHILDREN ); ValidateRect( hwnd1, NULL); ValidateRect( hwnd2, NULL); ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, @@ -4222,7 +4263,7 @@ static void test_scrollvalidate( HWND parent) ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); /* SW_SCROLLCHILDREN */ - SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) & ~WS_CLIPCHILDREN ); + SetWindowLongA( hwnd1, GWL_STYLE, GetWindowLongA( hwnd1, GWL_STYLE) & ~WS_CLIPCHILDREN ); ValidateRect( hwnd1, NULL); ValidateRect( hwnd2, NULL); ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_SCROLLCHILDREN | SW_INVALIDATE); @@ -4231,7 +4272,7 @@ static void test_scrollvalidate( HWND parent) ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); /* no SW_SCROLLCHILDREN */ - SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) & ~WS_CLIPCHILDREN ); + SetWindowLongA( hwnd1, GWL_STYLE, GetWindowLongA( hwnd1, GWL_STYLE) & ~WS_CLIPCHILDREN ); ValidateRect( hwnd1, NULL); ValidateRect( hwnd2, NULL); ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE); @@ -4240,7 +4281,7 @@ static void test_scrollvalidate( HWND parent) ok( EqualRgn( exprgn, hrgn), "wrong update region\n"); /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */ - SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) | WS_CLIPCHILDREN ); + SetWindowLongA( hwnd1, GWL_STYLE, GetWindowLongA( hwnd1, GWL_STYLE) | WS_CLIPCHILDREN ); ValidateRect( hwnd1, NULL); ValidateRect( hwnd2, NULL); ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE); @@ -4386,7 +4427,7 @@ static void test_params(void) if (pGetMonitorInfoA) { SetLastError(0xdeadbeef); - rc = GetWindowText(hwndMain2, NULL, 1024); + rc = GetWindowTextA(hwndMain2, NULL, 1024); ok( rc==0, "GetWindowText: rc=%d err=%d\n",rc,GetLastError()); } else @@ -4396,7 +4437,7 @@ static void test_params(void) } SetLastError(0xdeadbeef); - hwnd=CreateWindow("LISTBOX", "TestList", + hwnd=CreateWindowA("LISTBOX", "TestList", (LBS_STANDARD & ~LBS_SORT), 0, 0, 100, 100, NULL, (HMENU)1, NULL, 0); @@ -4413,7 +4454,7 @@ static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu) { HWND hwnd = 0; - hwnd = CreateWindowEx(exStyle, class, class, style, + hwnd = CreateWindowExA(exStyle, class, class, style, 110, 100, 225, 200, 0, @@ -4433,20 +4474,20 @@ static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu) static BOOL AWR_init(void) { - WNDCLASS class; + WNDCLASSA class; class.style = CS_HREDRAW | CS_VREDRAW; class.lpfnWndProc = DefWindowProcA; class.cbClsExtra = 0; class.cbWndExtra = 0; class.hInstance = 0; - class.hIcon = LoadIcon (0, IDI_APPLICATION); - class.hCursor = LoadCursor (0, IDC_ARROW); + class.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION); + class.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); class.hbrBackground = 0; class.lpszMenuName = 0; class.lpszClassName = szAWRClass; - - if (!RegisterClass (&class)) { + + if (!RegisterClassA(&class)) { ok(FALSE, "RegisterClass failed\n"); return FALSE; } @@ -4455,8 +4496,8 @@ static BOOL AWR_init(void) if (!hmenu) return FALSE; ok(hmenu != 0, "Failed to create menu\n"); - ok(AppendMenu(hmenu, MF_STRING, 1, "Test!"), "Failed to create menu item\n"); - + ok(AppendMenuA(hmenu, MF_STRING, 1, "Test!"), "Failed to create menu item\n"); + return TRUE; } @@ -4543,7 +4584,7 @@ static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LP } return 0; } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } /* Ensure we exit from RedrawNow regardless of invalidated area */ @@ -4558,7 +4599,7 @@ static void test_redrawnow(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "RedrawWindowClass"; @@ -4622,7 +4663,7 @@ static LRESULT WINAPI parentdc_window_procA(HWND hwnd, UINT msg, WPARAM wparam, EndPaint(hwnd, &ps); return 0; } - return DefWindowProc(hwnd, msg, wparam, lparam); + return DefWindowProcA(hwnd, msg, wparam, lparam); } static void zero_parentdc_stat(struct parentdc_stat *t) @@ -4729,7 +4770,7 @@ static void test_csparentdc(void) clsMain.cbWndExtra = 0; clsMain.hInstance = GetModuleHandleA(0); clsMain.hIcon = 0; - clsMain.hCursor = LoadCursorA(0, IDC_ARROW); + clsMain.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); clsMain.hbrBackground = GetStockObject(WHITE_BRUSH); clsMain.lpszMenuName = NULL; clsMain.lpszClassName = "ParentDcMainWindowClass"; @@ -4745,7 +4786,7 @@ static void test_csparentdc(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "ParentDcWindowClass"; @@ -4950,11 +4991,11 @@ static LRESULT CALLBACK minmax_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM l MINMAXINFO *minmax; if (msg != WM_GETMINMAXINFO) - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); minmax = (MINMAXINFO *)lp; - if ((GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD)) + if ((GetWindowLongA(hwnd, GWL_STYLE) & WS_CHILD)) { minmax->ptReserved.x = 0; minmax->ptReserved.y = 0; @@ -4968,7 +5009,7 @@ static LRESULT CALLBACK minmax_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM l minmax->ptMinTrackSize.y = 100; } else - DefWindowProc(hwnd, msg, wp, lp); + DefWindowProcA(hwnd, msg, wp, lp); return 1; } @@ -4985,7 +5026,7 @@ static LRESULT CALLBACK winsizes_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM GetWindowRect( hwnd, &rect ); ok( !rect.left && !rect.top && !rect.right && !rect.bottom, "wrong rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } case WM_NCCREATE: case WM_CREATE: @@ -5010,7 +5051,7 @@ static LRESULT CALLBACK winsizes_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM "wrong rect %d,%d-%d,%d / %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom, expected_rect.left, expected_rect.top, expected_rect.right, expected_rect.bottom ); - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } case WM_NCCALCSIZE: { @@ -5019,16 +5060,16 @@ static LRESULT CALLBACK winsizes_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM ok( !memcmp( &rect, r, sizeof(rect) ), "passed rect %d,%d-%d,%d doesn't match window rect %d,%d-%d,%d\n", r->left, r->top, r->right, r->bottom, rect.left, rect.top, rect.right, rect.bottom ); - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } default: - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } } static void test_CreateWindow(void) { - WNDCLASS cls; + WNDCLASSA cls; HWND hwnd, parent; HMENU hmenu; RECT rc, rc_minmax; @@ -5041,10 +5082,10 @@ static void test_CreateWindow(void) ok(res, "GetMenu error %d\n", GetLastError()) #define expect_style(window, style)\ - ok((ULONG)GetWindowLong(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLong(window, GWL_STYLE)) + ok((ULONG)GetWindowLongA(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLongA(window, GWL_STYLE)) #define expect_ex_style(window, ex_style)\ - ok((ULONG)GetWindowLong(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLong(window, GWL_EXSTYLE)) + ok((ULONG)GetWindowLongA(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLongA(window, GWL_EXSTYLE)) #define expect_gle_broken_9x(gle)\ ok(GetLastError() == gle ||\ @@ -5062,7 +5103,7 @@ static void test_CreateWindow(void) /* WS_CHILD */ SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_CHILD, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, 1); @@ -5071,7 +5112,7 @@ static void test_CreateWindow(void) DestroyWindow(hwnd); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_CAPTION, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_CAPTION, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, 1); @@ -5080,7 +5121,7 @@ static void test_CreateWindow(void) DestroyWindow(hwnd); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD, + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, 1); @@ -5089,7 +5130,7 @@ static void test_CreateWindow(void) DestroyWindow(hwnd); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_CAPTION, + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_CAPTION, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, 1); @@ -5099,7 +5140,7 @@ static void test_CreateWindow(void) /* WS_POPUP */ SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5113,7 +5154,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP | WS_CAPTION, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP | WS_CAPTION, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5127,7 +5168,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP, + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5141,7 +5182,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP | WS_CAPTION, + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP | WS_CAPTION, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5154,7 +5195,7 @@ static void test_CreateWindow(void) /* WS_CHILD | WS_POPUP */ SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n"); expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); @@ -5164,7 +5205,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5176,7 +5217,7 @@ static void test_CreateWindow(void) expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n"); expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); @@ -5186,7 +5227,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5198,7 +5239,7 @@ static void test_CreateWindow(void) expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP, + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n"); expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); @@ -5208,7 +5249,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP, + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5220,7 +5261,7 @@ static void test_CreateWindow(void) expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, 0, 0, 100, 100, parent, (HMENU)1, 0, NULL); ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n"); expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE); @@ -5230,7 +5271,7 @@ static void test_CreateWindow(void) hmenu = CreateMenu(); assert(hmenu != 0); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION, 0, 0, 100, 100, parent, hmenu, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(hwnd, hmenu); @@ -5246,16 +5287,16 @@ static void test_CreateWindow(void) cls.lpfnWndProc = minmax_wnd_proc; cls.cbClsExtra = 0; cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandle(0); + cls.hInstance = GetModuleHandleA(NULL); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "MinMax_WndClass"; - RegisterClass(&cls); + RegisterClassA(&cls); SetLastError(0xdeadbeef); - parent = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, + parent = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, 0, 0, 100, 100, 0, 0, 0, NULL); ok(parent != 0, "CreateWindowEx error %d\n", GetLastError()); expect_menu(parent, 0); @@ -5263,7 +5304,7 @@ static void test_CreateWindow(void) expect_ex_style(parent, WS_EX_WINDOWEDGE); memset(&minmax, 0, sizeof(minmax)); - SendMessage(parent, WM_GETMINMAXINFO, 0, (LPARAM)&minmax); + SendMessageA(parent, WM_GETMINMAXINFO, 0, (LPARAM)&minmax); SetRect(&rc_minmax, 0, 0, minmax.ptMaxSize.x, minmax.ptMaxSize.y); ok(IsRectEmpty(&rc_minmax), "ptMaxSize is not empty\n"); SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y); @@ -5278,7 +5319,7 @@ static void test_CreateWindow(void) trace("creating child with rect (%d,%d-%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom); SetLastError(0xdeadbeef); - hwnd = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, + hwnd = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, parent, (HMENU)1, 0, NULL); ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError()); @@ -5287,7 +5328,7 @@ static void test_CreateWindow(void) expect_ex_style(hwnd, WS_EX_WINDOWEDGE); memset(&minmax, 0, sizeof(minmax)); - SendMessage(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax); + SendMessageA(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax); SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y); GetWindowRect(hwnd, &rc); @@ -5299,7 +5340,7 @@ static void test_CreateWindow(void) cls.lpfnWndProc = winsizes_wnd_proc; cls.lpszClassName = "Sizes_WndClass"; - RegisterClass(&cls); + RegisterClassA(&cls); expected_cx = expected_cy = 200000; SetRect( &expected_rect, 0, 0, 200000, 200000 ); @@ -5335,7 +5376,7 @@ static void test_CreateWindow(void) /* we need a parent at 0,0 so that child coordinates match */ DestroyWindow(parent); - parent = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL); + parent = CreateWindowExA(0, "MinMax_WndClass", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL); ok(parent != 0, "CreateWindowEx error %d\n", GetLastError()); expected_cx = 100; @@ -5382,7 +5423,7 @@ static void test_CreateWindow(void) ReleaseDC( parent, hdc ); DestroyWindow( parent ); SetLastError( 0xdeadbeef ); - parent = CreateWindowEx(WS_EX_APPWINDOW | WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, + parent = CreateWindowExA(WS_EX_APPWINDOW | WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL); ok( parent != 0, "creation failed err %u\n", GetLastError()); expect_ex_style( parent, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); @@ -5423,12 +5464,12 @@ static void test_CreateWindow(void) res = pGetProcessDefaultLayout( &layout ); ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); ok( layout == LAYOUT_RTL, "GetProcessDefaultLayout wrong layout %x\n", layout ); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL); ok( hwnd != 0, "creation failed err %u\n", GetLastError()); expect_ex_style( hwnd, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); DestroyWindow( hwnd ); - hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, 0, 0, 100, 100, parent, 0, 0, NULL); ok( hwnd != 0, "creation failed err %u\n", GetLastError()); expect_ex_style( hwnd, WS_EX_APPWINDOW ); @@ -5443,8 +5484,8 @@ static void test_CreateWindow(void) DestroyWindow(parent); - UnregisterClass("MinMax_WndClass", GetModuleHandle(0)); - UnregisterClass("Sizes_WndClass", GetModuleHandle(0)); + UnregisterClassA("MinMax_WndClass", GetModuleHandleA(NULL)); + UnregisterClassA("Sizes_WndClass", GetModuleHandleA(NULL)); #undef expect_gle_broken_9x #undef expect_menu @@ -5468,23 +5509,23 @@ static void test_SetWindowLong(void) WNDPROC old_window_procW; SetLastError(0xdeadbeef); - retval = SetWindowLongPtr(NULL, GWLP_WNDPROC, 0); + retval = SetWindowLongPtrA(NULL, GWLP_WNDPROC, 0); ok(!retval, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval); ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE), "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %d\n", GetLastError()); SetLastError(0xdeadbeef); - retval = SetWindowLongPtr(hwndMain, 0xdeadbeef, 0); + retval = SetWindowLongPtrA(hwndMain, 0xdeadbeef, 0); ok(!retval, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval); ok(check_error(GetLastError(), ERROR_INVALID_INDEX), "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %d\n", GetLastError()); SetLastError(0xdeadbeef); - retval = SetWindowLongPtr(hwndMain, GWLP_WNDPROC, 0); + retval = SetWindowLongPtrA(hwndMain, GWLP_WNDPROC, 0); ok((WNDPROC)retval == main_window_procA || broken(!retval), /* win9x */ "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval); ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError()); - retval = GetWindowLongPtr(hwndMain, GWLP_WNDPROC); + retval = GetWindowLongPtrA(hwndMain, GWLP_WNDPROC); ok((WNDPROC)retval == main_window_procA, "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval); ok(!IsWindowUnicode(hwndMain), "hwndMain shouldn't be Unicode\n"); @@ -5501,7 +5542,7 @@ static void test_SetWindowLong(void) ok(IsWindowUnicode(hwndMain), "hwndMain should now be Unicode\n"); /* set it back to ANSI */ - SetWindowLongPtr(hwndMain, GWLP_WNDPROC, 0); + SetWindowLongPtrA(hwndMain, GWLP_WNDPROC, 0); } } @@ -5514,7 +5555,7 @@ static void test_ShowWindow(void) SetRect(&rcMain, 120, 120, 210, 210); - hwnd = CreateWindowEx(0, "MainWindowClass", NULL, + hwnd = CreateWindowExA(0, "MainWindowClass", NULL, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP, rcMain.left, rcMain.top, @@ -5522,7 +5563,7 @@ static void test_ShowWindow(void) 0, 0, 0, NULL); assert(hwnd); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(!(style & WS_DISABLED), "window should not be disabled\n"); ok(!(style & WS_VISIBLE), "window should not be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); @@ -5534,7 +5575,7 @@ static void test_ShowWindow(void) ret = ShowWindow(hwnd, SW_SHOW); ok(!ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(!(style & WS_DISABLED), "window should not be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); @@ -5546,7 +5587,7 @@ static void test_ShowWindow(void) ret = ShowWindow(hwnd, SW_MINIMIZE); ok(ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(!(style & WS_DISABLED), "window should not be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(style & WS_MINIMIZE, "window should be minimized\n"); @@ -5564,7 +5605,7 @@ static void test_ShowWindow(void) ShowWindow(hwnd, SW_RESTORE); ok(ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(!(style & WS_DISABLED), "window should not be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); @@ -5576,12 +5617,12 @@ static void test_ShowWindow(void) ret = EnableWindow(hwnd, FALSE); ok(!ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_DISABLED, "window should be disabled\n"); - ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); + ret = DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0); ok(!ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_DISABLED, "window should be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); @@ -5591,9 +5632,9 @@ static void test_ShowWindow(void) rcMain.left, rcMain.top, rcMain.right, rcMain.bottom, rc.left, rc.top, rc.right, rc.bottom); - ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0); + ret = DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0); ok(!ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_DISABLED, "window should be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); @@ -5605,7 +5646,7 @@ static void test_ShowWindow(void) ret = ShowWindow(hwnd, SW_MINIMIZE); ok(ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_DISABLED, "window should be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(style & WS_MINIMIZE, "window should be minimized\n"); @@ -5613,9 +5654,9 @@ static void test_ShowWindow(void) GetWindowRect(hwnd, &rc); ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n"); - ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); + ret = DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0); ok(!ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_DISABLED, "window should be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(style & WS_MINIMIZE, "window should be minimized\n"); @@ -5625,7 +5666,7 @@ static void test_ShowWindow(void) ret = ShowWindow(hwnd, SW_RESTORE); ok(ret, "not expected ret: %lu\n", ret); - style = GetWindowLong(hwnd, GWL_STYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); ok(style & WS_DISABLED, "window should be disabled\n"); ok(style & WS_VISIBLE, "window should be visible\n"); ok(!(style & WS_MINIMIZE), "window should not be minimized\n"); @@ -5635,49 +5676,49 @@ static void test_ShowWindow(void) rcMain.left, rcMain.top, rcMain.right, rcMain.bottom, rc.left, rc.top, rc.right, rc.bottom); - ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); + ret = DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); ok(!ret, "not expected ret: %lu\n", ret); ok(IsWindow(hwnd), "window should exist\n"); ret = EnableWindow(hwnd, TRUE); ok(ret, "not expected ret: %lu\n", ret); - ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); + ret = DefWindowProcA(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0); ok(!ret, "not expected ret: %lu\n", ret); ok(!IsWindow(hwnd), "window should not exist\n"); } static void test_gettext(void) { - WNDCLASS cls; + WNDCLASSA cls; LPCSTR clsname = "gettexttest"; HWND hwnd; LRESULT r; memset( &cls, 0, sizeof cls ); - cls.lpfnWndProc = DefWindowProc; + cls.lpfnWndProc = DefWindowProcA; cls.lpszClassName = clsname; - cls.hInstance = GetModuleHandle(NULL); + cls.hInstance = GetModuleHandleA(NULL); - if (!RegisterClass( &cls )) return; + if (!RegisterClassA( &cls )) return; - hwnd = CreateWindow( clsname, "test text", WS_OVERLAPPED, 0, 0, 10, 10, 0, NULL, NULL, NULL); + hwnd = CreateWindowA( clsname, "test text", WS_OVERLAPPED, 0, 0, 10, 10, 0, NULL, NULL, NULL); ok( hwnd != NULL, "window was null\n"); - r = SendMessage( hwnd, WM_GETTEXT, 0x10, 0x1000); + r = SendMessageA( hwnd, WM_GETTEXT, 0x10, 0x1000); ok( r == 0, "settext should return zero\n"); - r = SendMessage( hwnd, WM_GETTEXT, 0x10000, 0); + r = SendMessageA( hwnd, WM_GETTEXT, 0x10000, 0); ok( r == 0, "settext should return zero (%ld)\n", r); - r = SendMessage( hwnd, WM_GETTEXT, 0xff000000, 0x1000); + r = SendMessageA( hwnd, WM_GETTEXT, 0xff000000, 0x1000); ok( r == 0, "settext should return zero (%ld)\n", r); - r = SendMessage( hwnd, WM_GETTEXT, 0x1000, 0xff000000); + r = SendMessageA( hwnd, WM_GETTEXT, 0x1000, 0xff000000); ok( r == 0, "settext should return zero (%ld)\n", r); DestroyWindow(hwnd); - UnregisterClass( clsname, NULL ); + UnregisterClassA( clsname, NULL ); } @@ -5720,14 +5761,14 @@ static void test_GetUpdateRect(void) parent_wm_paint = FALSE; grandparent_wm_paint = FALSE; - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) { if (msg.message == WM_PAINT) { if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE; if (msg.hwnd == hparent) parent_wm_paint = TRUE; } - DispatchMessage(&msg); + DispatchMessageA(&msg); } ok(parent_wm_paint, "WM_PAINT should have been received in parent\n"); ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n"); @@ -5740,7 +5781,7 @@ static void test_GetUpdateRect(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = classNameA; @@ -5784,14 +5825,14 @@ static void test_GetUpdateRect(void) parent_wm_paint = FALSE; grandparent_wm_paint = FALSE; - while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) + while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) { if (msg.message == WM_PAINT) { if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE; if (msg.hwnd == hparent) parent_wm_paint = TRUE; } - DispatchMessage(&msg); + DispatchMessageA(&msg); } ok(parent_wm_paint, "WM_PAINT should have been received in parent\n"); ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n"); @@ -5830,7 +5871,7 @@ static LRESULT CALLBACK TestExposedRegion_WndProc(HWND hwnd, UINT msg, WPARAM wP return 1; } - return DefWindowProc(hwnd, msg, wParam, lParam); + return DefWindowProcA(hwnd, msg, wParam, lParam); } static void test_Expose(void) @@ -5859,7 +5900,7 @@ static LRESULT CALLBACK TestNCRedraw_WndProc(HWND hwnd, UINT msg, WPARAM wParam, switch(msg) { case WM_CREATE: - ncredrawflags = *(UINT *) (((CREATESTRUCT *)lParam)->lpCreateParams); + ncredrawflags = *(UINT *) (((CREATESTRUCTA *)lParam)->lpCreateParams); return 0; case WM_NCPAINT: RedrawWindow(hwnd, NULL, NULL, ncredrawflags); @@ -5869,7 +5910,7 @@ static LRESULT CALLBACK TestNCRedraw_WndProc(HWND hwnd, UINT msg, WPARAM wParam, EndPaint(hwnd, &ps); return 0; } - return DefWindowProc(hwnd, msg, wParam, lParam); + return DefWindowProcA(hwnd, msg, wParam, lParam); } static void run_NCRedrawLoop(UINT flags) @@ -5885,12 +5926,12 @@ static void run_NCRedrawLoop(UINT flags) ShowWindow(hwnd, SW_SHOW); UpdateWindow(hwnd); flush_events( FALSE ); - while(PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE) != 0) + while (PeekMessageA(&msg, hwnd, 0, 0, PM_REMOVE)) { if (msg.message == WM_PAINT) loopcount++; if (loopcount >= 100) break; TranslateMessage(&msg); - DispatchMessage(&msg); + DispatchMessageA(&msg); MsgWaitForMultipleObjects(0, NULL, FALSE, 100, QS_ALLINPUT); } if (flags == (RDW_INVALIDATE | RDW_FRAME)) @@ -5910,8 +5951,8 @@ static void test_NCRedraw(void) wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = 0; - wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); + wndclass.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION); + wndclass.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); wndclass.hbrBackground = GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName = NULL; @@ -5937,12 +5978,12 @@ static void test_GetWindowModuleFileName(void) hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL); assert(hwnd); - hinst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE); - ok(hinst == 0 || broken(hinst == GetModuleHandle(0)), /* win9x */ "expected 0, got %p\n", hinst); + hinst = (HINSTANCE)GetWindowLongPtrA(hwnd, GWLP_HINSTANCE); + ok(hinst == 0 || broken(hinst == GetModuleHandleA(NULL)), /* win9x */ "expected 0, got %p\n", hinst); buf1[0] = 0; SetLastError(0xdeadbeef); - ret1 = GetModuleFileName(hinst, buf1, sizeof(buf1)); + ret1 = GetModuleFileNameA(hinst, buf1, sizeof(buf1)); ok(ret1, "GetModuleFileName error %u\n", GetLastError()); buf2[0] = 0; @@ -5956,10 +5997,10 @@ static void test_GetWindowModuleFileName(void) ok(ret1 == ret2 || broken(ret2 == ret1 + 1), /* win98 */ "%u != %u\n", ret1, ret2); ok(!strcmp(buf1, buf2), "%s != %s\n", buf1, buf2); } - hinst = GetModuleHandle(0); + hinst = GetModuleHandleA(NULL); SetLastError(0xdeadbeef); - ret2 = GetModuleFileName(hinst, buf2, ret1 - 2); + ret2 = GetModuleFileNameA(hinst, buf2, ret1 - 2); ok(ret2 == ret1 - 2 || broken(ret2 == ret1 - 3), /* win98 */ "expected %u, got %u\n", ret1 - 2, ret2); ok(GetLastError() == 0xdeadbeef /* XP */ || @@ -5967,7 +6008,7 @@ static void test_GetWindowModuleFileName(void) "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError()); SetLastError(0xdeadbeef); - ret2 = GetModuleFileName(hinst, buf2, 0); + ret2 = GetModuleFileNameA(hinst, buf2, 0); ok(!ret2, "GetModuleFileName should return 0\n"); ok(GetLastError() == 0xdeadbeef /* XP */ || GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */ @@ -5998,7 +6039,7 @@ static void test_GetWindowModuleFileName(void) ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef), /* win9x */ "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError()); - hwnd = FindWindow("Shell_TrayWnd", NULL); + hwnd = FindWindowA("Shell_TrayWnd", NULL); ok(IsWindow(hwnd) || broken(!hwnd), "got invalid tray window %p\n", hwnd); SetLastError(0xdeadbeef); ret1 = pGetWindowModuleFileNameA(hwnd, buf1, sizeof(buf1)); @@ -6006,7 +6047,7 @@ static void test_GetWindowModuleFileName(void) if (!ret1) /* inter-process GetWindowModuleFileName works on win9x, so don't test the desktop there */ { - ret1 = GetModuleFileName(0, buf1, sizeof(buf1)); + ret1 = GetModuleFileNameA(0, buf1, sizeof(buf1)); hwnd = GetDesktopWindow(); ok(IsWindow(hwnd), "got invalid desktop window %p\n", hwnd); SetLastError(0xdeadbeef); @@ -6052,7 +6093,7 @@ static void test_hwnd_message(void) "parent shouldn't have parent %p\n", pGetAncestor(parent, GA_PARENT) ); trace("parent %p root %p desktop %p\n", parent, root, desktop); if (!GetClassNameA( parent, buffer, sizeof(buffer) )) buffer[0] = 0; - ok( !lstrcmpi( buffer, "Message" ), "wrong parent class '%s'\n", buffer ); + ok( !lstrcmpiA( buffer, "Message" ), "wrong parent class '%s'\n", buffer ); GetWindowRect( parent, &rect ); ok( rect.left == 0 && rect.right == 100 && rect.top == 0 && rect.bottom == 100, "wrong parent rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom ); @@ -6120,7 +6161,7 @@ static void test_layered_window(void) ok( !ret, "GetLayeredWindowAttributes should fail on non-layered window\n" ); ret = pSetLayeredWindowAttributes( hwnd, 0, 0, LWA_ALPHA ); ok( !ret, "SetLayeredWindowAttributes should fail on non-layered window\n" ); - SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); + SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags ); ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" ); ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE ); @@ -6140,13 +6181,13 @@ static void test_layered_window(void) ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() ); /* clearing WS_EX_LAYERED resets attributes */ - SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED ); + SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED ); SetLastError( 0xdeadbeef ); ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE ); ok( !ret, "UpdateLayeredWindow should fail on non-layered window\n" ); ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags ); ok( !ret, "GetLayeredWindowAttributes should fail on no longer layered window\n" ); - SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); + SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags ); ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" ); ret = pUpdateLayeredWindow( hwnd, 0, NULL, &sz, hdc, &pt, 0, NULL, ULW_OPAQUE ); @@ -6225,8 +6266,8 @@ static void test_layered_window(void) ok( flags == 0, "wrong flags %x\n", flags ); /* default alpha and color key is 0 */ - SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED ); - SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); + SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED ); + SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED ); ret = pSetLayeredWindowAttributes( hwnd, 0x222222, 55, 0 ); ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" ); ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags ); @@ -6268,7 +6309,7 @@ static LRESULT CALLBACK fullscreen_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPAR break; } } - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } static void test_fullscreen(void) @@ -6279,7 +6320,7 @@ static void test_fullscreen(void) static const DWORD t_ex_style[] = { 0, WS_EX_APPWINDOW, WS_EX_TOOLWINDOW }; - WNDCLASS cls; + WNDCLASSA cls; HWND hwnd; int i, j; POINT pt; @@ -6310,13 +6351,13 @@ static void test_fullscreen(void) cls.lpfnWndProc = fullscreen_wnd_proc; cls.cbClsExtra = 0; cls.cbWndExtra = 0; - cls.hInstance = GetModuleHandle(0); + cls.hInstance = GetModuleHandleA(NULL); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "fullscreen_class"; - RegisterClass(&cls); + RegisterClassA(&cls); for (i = 0; i < sizeof(t_style)/sizeof(t_style[0]); i++) { @@ -6334,7 +6375,7 @@ static void test_fullscreen(void) hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom, - GetDesktopWindow(), 0, GetModuleHandle(0), NULL); + GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style); GetWindowRect(hwnd, &rc); trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom); @@ -6346,7 +6387,7 @@ static void test_fullscreen(void) style = t_style[i] | WS_MAXIMIZE; hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom, - GetDesktopWindow(), 0, GetModuleHandle(0), NULL); + GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style); GetWindowRect(hwnd, &rc); trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom); @@ -6358,7 +6399,7 @@ static void test_fullscreen(void) style = t_style[i] | WS_MAXIMIZE | WS_CAPTION; hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom, - GetDesktopWindow(), 0, GetModuleHandle(0), NULL); + GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style); GetWindowRect(hwnd, &rc); trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom); @@ -6370,7 +6411,7 @@ static void test_fullscreen(void) style = t_style[i] | WS_CAPTION | WS_MAXIMIZEBOX; hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom, - GetDesktopWindow(), 0, GetModuleHandle(0), NULL); + GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style); GetWindowRect(hwnd, &rc); trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom); @@ -6382,7 +6423,7 @@ static void test_fullscreen(void) style = t_style[i] | WS_MAXIMIZE | WS_CAPTION | WS_MAXIMIZEBOX; hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom, - GetDesktopWindow(), 0, GetModuleHandle(0), NULL); + GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style); GetWindowRect(hwnd, &rc); trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom); @@ -6399,7 +6440,7 @@ static void test_fullscreen(void) style = t_style[i] | WS_MAXIMIZE | WS_MAXIMIZEBOX; hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style, mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom, - GetDesktopWindow(), 0, GetModuleHandle(0), NULL); + GetDesktopWindow(), 0, GetModuleHandleA(NULL), NULL); ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style); GetWindowRect(hwnd, &rc); trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom); @@ -6418,7 +6459,7 @@ static void test_fullscreen(void) } } - UnregisterClass("fullscreen_class", GetModuleHandle(0)); + UnregisterClassA("fullscreen_class", GetModuleHandleA(NULL)); } static BOOL test_thick_child_got_minmax; @@ -6529,7 +6570,7 @@ static void test_thick_child_size(HWND parentWindow) LONG expectedWidth; LONG expectedHeight; WNDCLASSA cls; - LPCTSTR className = "THICK_CHILD_CLASS"; + static const char className[] = "THICK_CHILD_CLASS"; int i; LONG adjustedStyle; static const LONG styles[NUMBER_OF_THICK_CHILD_TESTS] = { @@ -6594,7 +6635,7 @@ static void test_thick_child_size(HWND parentWindow) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = className; @@ -6610,7 +6651,7 @@ static void test_thick_child_size(HWND parentWindow) test_thick_child_got_minmax = FALSE; SetLastError(0xdeadbeef); - childWindow = CreateWindowEx( exStyles[i], className, "", styles[i], 0, 0, 0, 0, parentWindow, 0, GetModuleHandleA(0), NULL ); + childWindow = CreateWindowExA( exStyles[i], className, "", styles[i], 0, 0, 0, 0, parentWindow, 0, GetModuleHandleA(0), NULL ); ok(childWindow != NULL, "Failed to create child window, error: %u\n", GetLastError()); ok(test_thick_child_got_minmax, "Got no WM_GETMINMAXINFO\n"); @@ -6647,7 +6688,7 @@ static void test_thick_child_size(HWND parentWindow) success = DestroyWindow(childWindow); ok(success,"DestroyWindow call failed, error: %u\n", GetLastError()); } - ok(UnregisterClass(className, GetModuleHandleA(0)),"UnregisterClass call failed\n"); + ok(UnregisterClassA(className, GetModuleHandleA(NULL)),"UnregisterClass call failed\n"); } static void test_handles( HWND full_hwnd ) @@ -6933,15 +6974,15 @@ static void test_GetLastActivePopup(void) hwndOwner = CreateWindowExA(0, "MainWindowClass", NULL, WS_VISIBLE | WS_POPUPWINDOW, 100, 100, 200, 200, - NULL, 0, GetModuleHandle(0), NULL); + NULL, 0, GetModuleHandleA(NULL), NULL); hwndPopup1 = CreateWindowExA(0, "MainWindowClass", NULL, WS_VISIBLE | WS_POPUPWINDOW, 100, 100, 200, 200, - hwndOwner, 0, GetModuleHandle(0), NULL); + hwndOwner, 0, GetModuleHandleA(NULL), NULL); hwndPopup2 = CreateWindowExA(0, "MainWindowClass", NULL, WS_VISIBLE | WS_POPUPWINDOW, 100, 100, 200, 200, - hwndPopup1, 0, GetModuleHandle(0), NULL); + hwndPopup1, 0, GetModuleHandleA(NULL), NULL); ok( GetLastActivePopup(hwndOwner) == hwndPopup2, "wrong last active popup\n" ); DestroyWindow( hwndPopup2 ); DestroyWindow( hwndPopup1 ); @@ -6951,12 +6992,12 @@ static void test_GetLastActivePopup(void) static LRESULT WINAPI my_httrasparent_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { if (msg == WM_NCHITTEST) return HTTRANSPARENT; - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } static LRESULT WINAPI my_window_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { - return DefWindowProc(hwnd, msg, wp, lp); + return DefWindowProcA(hwnd, msg, wp, lp); } static void create_window_tree(HWND parent, HWND *window, int size) @@ -6970,76 +7011,76 @@ static void create_window_tree(HWND parent, HWND *window, int size) for (i = 0; i < sizeof(style)/sizeof(style[0]); i++) { assert(pos < size); - window[pos] = CreateWindowEx(0, "my_window", NULL, style[i] | WS_CHILD, + window[pos] = CreateWindowExA(0, "my_window", NULL, style[i] | WS_CHILD, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "my_window", NULL, style[i] | WS_CHILD, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "my_window", NULL, style[i] | WS_CHILD, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(0, "my_httrasparent", NULL, style[i] | WS_CHILD, + window[pos] = CreateWindowExA(0, "my_httrasparent", NULL, style[i] | WS_CHILD, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "my_httrasparent", NULL, style[i] | WS_CHILD, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "my_httrasparent", NULL, style[i] | WS_CHILD, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(0, "my_button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, + window[pos] = CreateWindowExA(0, "my_button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "my_button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "my_button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(0, "my_button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, + window[pos] = CreateWindowExA(0, "my_button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "my_button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "my_button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(0, "Button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, + window[pos] = CreateWindowExA(0, "Button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "Button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "Button", NULL, style[i] | WS_CHILD | BS_GROUPBOX, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(0, "Button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, + window[pos] = CreateWindowExA(0, "Button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "Button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "Button", NULL, style[i] | WS_CHILD | BS_PUSHBUTTON, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(0, "Static", NULL, style[i] | WS_CHILD, + window[pos] = CreateWindowExA(0, "Static", NULL, style[i] | WS_CHILD, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; assert(pos < size); - window[pos] = CreateWindowEx(WS_EX_TRANSPARENT, "Static", NULL, style[i] | WS_CHILD, + window[pos] = CreateWindowExA(WS_EX_TRANSPARENT, "Static", NULL, style[i] | WS_CHILD, 0, 0, 100, 100, parent, 0, 0, NULL); ok(window[pos] != 0, "CreateWindowEx failed\n"); pos++; @@ -7049,22 +7090,22 @@ static void create_window_tree(HWND parent, HWND *window, int size) struct window_attributes { char class_name[128]; - int is_visible, is_enabled, is_groupbox, is_httransparent, is_extransparent; + BOOL is_visible, is_enabled, is_groupbox, is_httransparent, is_extransparent; }; static void get_window_attributes(HWND hwnd, struct window_attributes *attrs) { DWORD style, ex_style, hittest; - style = GetWindowLong(hwnd, GWL_STYLE); - ex_style = GetWindowLong(hwnd, GWL_EXSTYLE); + style = GetWindowLongA(hwnd, GWL_STYLE); + ex_style = GetWindowLongA(hwnd, GWL_EXSTYLE); attrs->class_name[0] = 0; - GetClassName(hwnd, attrs->class_name, sizeof(attrs->class_name)); - hittest = SendMessage(hwnd, WM_NCHITTEST, 0, 0); + GetClassNameA(hwnd, attrs->class_name, sizeof(attrs->class_name)); + hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, 0); attrs->is_visible = (style & WS_VISIBLE) != 0; attrs->is_enabled = (style & WS_DISABLED) == 0; - attrs->is_groupbox = !lstrcmpi(attrs->class_name, "Button") && (style & BS_TYPEMASK) == BS_GROUPBOX; + attrs->is_groupbox = !lstrcmpiA(attrs->class_name, "Button") && (style & BS_TYPEMASK) == BS_GROUPBOX; attrs->is_httransparent = hittest == HTTRANSPARENT; attrs->is_extransparent = (ex_style & WS_EX_TRANSPARENT) != 0; } @@ -7093,26 +7134,26 @@ static void test_child_window_from_point(void) int found_invisible, found_disabled, found_groupbox, found_httransparent, found_extransparent; int ret, i; - ret = GetClassInfo(0, "Button", &cls); + ret = GetClassInfoA(0, "Button", &cls); ok(ret, "GetClassInfo(Button) failed\n"); cls.lpszClassName = "my_button"; - ret = RegisterClass(&cls); + ret = RegisterClassA(&cls); ok(ret, "RegisterClass(my_button) failed\n"); cls.lpszClassName = "my_httrasparent"; cls.lpfnWndProc = my_httrasparent_proc; - ret = RegisterClass(&cls); + ret = RegisterClassA(&cls); ok(ret, "RegisterClass(my_httrasparent) failed\n"); cls.lpszClassName = "my_window"; cls.lpfnWndProc = my_window_proc; - ret = RegisterClass(&cls); + ret = RegisterClassA(&cls); ok(ret, "RegisterClass(my_window) failed\n"); - parent = CreateWindowEx(0, "MainWindowClass", NULL, + parent = CreateWindowExA(0, "MainWindowClass", NULL, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE, 100, 100, 200, 200, - 0, 0, GetModuleHandle(0), NULL); + 0, 0, GetModuleHandleA(NULL), NULL); ok(parent != 0, "CreateWindowEx failed\n"); trace("parent %p\n", parent); @@ -7172,11 +7213,11 @@ todo_wine todo_wine ok(found_extransparent, "found %d extransparent windows\n", found_extransparent); - ret = UnregisterClass("my_button", cls.hInstance); + ret = UnregisterClassA("my_button", cls.hInstance); ok(ret, "UnregisterClass(my_button) failed\n"); - ret = UnregisterClass("my_httrasparent", cls.hInstance); + ret = UnregisterClassA("my_httrasparent", cls.hInstance); ok(ret, "UnregisterClass(my_httrasparent) failed\n"); - ret = UnregisterClass("my_window", cls.hInstance); + ret = UnregisterClassA("my_window", cls.hInstance); ok(ret, "UnregisterClass(my_window) failed\n"); } @@ -7194,11 +7235,11 @@ static void test_map_points(void) RECT client_rect; /* Create test windows */ - wnd = CreateWindow("static", "test1", WS_POPUP, pos.x, pos.y, width, height, NULL, NULL, NULL, NULL); + wnd = CreateWindowA("static", "test1", WS_POPUP, pos.x, pos.y, width, height, NULL, NULL, NULL, NULL); ok(wnd != NULL, "Failed %p\n", wnd); - wnd0 = CreateWindow("static", "test2", WS_POPUP, 0, 0, width, height, NULL, NULL, NULL, NULL); + wnd0 = CreateWindowA("static", "test2", WS_POPUP, 0, 0, width, height, NULL, NULL, NULL, NULL); ok(wnd0 != NULL, "Failed %p\n", wnd); - dwnd = CreateWindow("static", "test3", 0, 200, 300, 150, 150, NULL, NULL, NULL, NULL); + dwnd = CreateWindowA("static", "test3", 0, 200, 300, 150, 150, NULL, NULL, NULL, NULL); DestroyWindow(dwnd); ok(dwnd != NULL, "Failed %p\n", dwnd); @@ -7469,6 +7510,26 @@ todo_wine DestroyWindow(parent); } +static void test_window_without_child_style(void) +{ + HWND hwnd; + + hwnd = CreateWindowExA(0, "edit", NULL, WS_VISIBLE|WS_CHILD, + 0, 0, 50, 50, hwndMain, NULL, 0, NULL); + ok(hwnd != NULL, "CreateWindow failed\n"); + + ok(SetWindowLongA(hwnd, GWL_STYLE, GetWindowLongA(hwnd, GWL_STYLE) & (~WS_CHILD)), + "can't remove WS_CHILD style\n"); + + SetActiveWindow(hwndMain); + PostMessageW(hwnd, WM_LBUTTONUP, 0, 0); + SendMessageW(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0); + check_active_state(hwnd, hwnd, hwnd); + flush_events(TRUE); + + DestroyWindow(hwnd); +} + START_TEST(win) { HMODULE user32 = GetModuleHandleA( "user32.dll" ); @@ -7493,6 +7554,32 @@ START_TEST(win) if (!RegisterWindowClasses()) assert(0); + hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window", + WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | + WS_MAXIMIZEBOX | WS_POPUP | WS_VISIBLE, + 100, 100, 200, 200, + 0, 0, GetModuleHandleA(NULL), NULL); + assert( hwndMain ); + + if(!SetForegroundWindow(hwndMain)) { + /* workaround for foreground lock timeout */ + INPUT input[2]; + UINT events_no; + + memset(input, 0, sizeof(input)); + input[0].type = INPUT_MOUSE; + U(input[0]).mi.dx = 101; + U(input[0]).mi.dy = 101; + U(input[0]).mi.dwFlags = MOUSEEVENTF_LEFTDOWN; + input[0].type = INPUT_MOUSE; + U(input[0]).mi.dx = 101; + U(input[0]).mi.dy = 101; + U(input[0]).mi.dwFlags = MOUSEEVENTF_LEFTUP; + events_no = SendInput(2, input, sizeof(input[0])); + ok(events_no == 2, "SendInput returned %d\n", events_no); + ok(SetForegroundWindow(hwndMain), "SetForegroundWindow failed\n"); + } + SetLastError(0xdeafbeef); GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC); is_win9x = (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED); @@ -7504,17 +7591,11 @@ START_TEST(win) test_FindWindowEx(); test_SetParent(); - hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window", - WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | - WS_MAXIMIZEBOX | WS_POPUP, - 100, 100, 200, 200, - 0, 0, GetModuleHandle(0), NULL); hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2", WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP, 100, 100, 200, 200, - 0, 0, GetModuleHandle(0), NULL); - assert( hwndMain ); + 0, 0, GetModuleHandleA(NULL), NULL); assert( hwndMain2 ); our_pid = GetWindowThreadProcessId(hwndMain, NULL); @@ -7582,6 +7663,7 @@ START_TEST(win) test_winregion(); test_map_points(); test_update_region(); + test_window_without_child_style(); /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook); diff --git a/rostests/winetests/user32/winstation.c b/rostests/winetests/user32/winstation.c index 248b82e062b..7f91b8b2798 100755 --- a/rostests/winetests/user32/winstation.c +++ b/rostests/winetests/user32/winstation.c @@ -53,7 +53,7 @@ static void register_class(void) cls.cbWndExtra = 0; cls.hInstance = GetModuleHandleA(0); cls.hIcon = 0; - cls.hCursor = LoadCursorA(0, IDC_ARROW); + cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW); cls.hbrBackground = GetStockObject(WHITE_BRUSH); cls.lpszMenuName = NULL; cls.lpszClassName = "WinStationClass"; @@ -79,7 +79,7 @@ static DWORD CALLBACK thread( LPVOID arg ) ok( GetLastError() == ERROR_BUSY || broken(GetLastError() == 0xdeadbeef), /* wow64 */ "bad last error %d\n", GetLastError() ); print_object( d1 ); - d2 = CreateDesktop( "foobar2", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); + d2 = CreateDesktopA( "foobar2", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); trace( "created desktop %p\n", d2 ); ok( d2 != 0, "CreateDesktop failed\n" ); @@ -136,7 +136,7 @@ static void test_handles(void) TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" ); ok( CloseHandle(w2), "closing dup win station handle failed\n" ); - w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); + w2 = CreateWindowStationA("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); le = GetLastError(); ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "CreateWindowStation failed (%u)\n", le ); if (w2 != 0) @@ -148,39 +148,39 @@ static void test_handles(void) "bad last error %d\n", GetLastError() ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); - w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); + w2 = CreateWindowStationA("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); ok( CloseHandle( w2 ), "CloseHandle failed\n" ); } else if (le == ERROR_ACCESS_DENIED) win_skip( "Not enough privileges for CreateWindowStation\n" ); - w2 = OpenWindowStation("winsta0", TRUE, WINSTA_ALL_ACCESS ); + w2 = OpenWindowStationA("winsta0", TRUE, WINSTA_ALL_ACCESS ); ok( w2 != 0, "OpenWindowStation failed\n" ); ok( w2 != w1, "OpenWindowStation returned default handle\n" ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); - w2 = OpenWindowStation("dummy name", TRUE, WINSTA_ALL_ACCESS ); + w2 = OpenWindowStationA("dummy name", TRUE, WINSTA_ALL_ACCESS ); ok( !w2, "open dummy win station succeeded\n" ); CreateMutexA( NULL, 0, "foobar" ); - w2 = CreateWindowStation("foobar", 0, WINSTA_ALL_ACCESS, NULL ); + w2 = CreateWindowStationA("foobar", 0, WINSTA_ALL_ACCESS, NULL ); le = GetLastError(); ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "create foobar station failed (%u)\n", le ); if (w2 != 0) { - w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); + w3 = OpenWindowStationA("foobar", TRUE, WINSTA_ALL_ACCESS ); ok( w3 != 0, "open foobar station failed\n" ); ok( w3 != w2, "open foobar station returned same handle\n" ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); ok( CloseWindowStation( w3 ), "CloseWindowStation failed\n" ); - w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); + w3 = OpenWindowStationA("foobar", TRUE, WINSTA_ALL_ACCESS ); ok( !w3, "open foobar station succeeded\n" ); - w2 = CreateWindowStation("foobar1", 0, WINSTA_ALL_ACCESS, NULL ); + w2 = CreateWindowStationA("foobar1", 0, WINSTA_ALL_ACCESS, NULL ); ok( w2 != 0, "create foobar station failed\n" ); - w3 = CreateWindowStation("foobar2", 0, WINSTA_ALL_ACCESS, NULL ); + w3 = CreateWindowStationA("foobar2", 0, WINSTA_ALL_ACCESS, NULL ); ok( w3 != 0, "create foobar station failed\n" ); ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); ok( GetHandleInformation( w3, &flags ), "GetHandleInformation failed\n" ); @@ -233,10 +233,10 @@ static void test_handles(void) TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" ); ok( CloseHandle(d2), "closing dup desktop handle failed\n" ); - d2 = OpenDesktop( "dummy name", 0, TRUE, DESKTOP_ALL_ACCESS ); + d2 = OpenDesktopA( "dummy name", 0, TRUE, DESKTOP_ALL_ACCESS ); ok( !d2, "open dummy desktop succeeded\n" ); - d2 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); + d2 = CreateDesktopA( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); ok( d2 != 0, "create foobar desktop failed\n" ); SetLastError( 0xdeadbeef ); ok( !CloseWindowStation( (HWINSTA)d2 ), "CloseWindowStation succeeded on desktop\n" ); @@ -244,18 +244,18 @@ static void test_handles(void) "bad last error %d\n", GetLastError() ); SetLastError( 0xdeadbeef ); - d3 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); + d3 = CreateDesktopA( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); ok( d3 != 0, "create foobar desktop again failed\n" ); ok( GetLastError() == 0xdeadbeef, "bad last error %d\n", GetLastError() ); ok( CloseDesktop( d3 ), "CloseDesktop failed\n" ); - d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS ); + d3 = OpenDesktopA( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS ); ok( d3 != 0, "open foobar desktop failed\n" ); ok( d3 != d2, "open foobar desktop returned same handle\n" ); ok( CloseDesktop( d2 ), "CloseDesktop failed\n" ); ok( CloseDesktop( d3 ), "CloseDesktop failed\n" ); - d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS ); + d3 = OpenDesktopA( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS ); ok( !d3, "open foobar desktop succeeded\n" ); ok( !CloseHandle(d1), "closing thread desktop handle succeeded\n" ); @@ -270,6 +270,9 @@ static void test_handles(void) trace( "get other thread desktop: %p\n", GetThreadDesktop(id) ); WaitForSingleObject( hthread, INFINITE ); CloseHandle( hthread ); + + /* clean side effect */ + SetProcessWindowStation( w1 ); } /* Enumeration tests */ @@ -294,7 +297,8 @@ static BOOL CALLBACK open_window_station_callbackA(LPSTR winsta, LPARAM lp) static void test_enumstations(void) { - BOOL ret; + DWORD ret; + HWINSTA hwinsta; if (0) /* Crashes instead */ { @@ -304,6 +308,15 @@ static void test_enumstations(void) ok(GetLastError() == ERROR_INVALID_PARAMETER, "LastError is set to %08x\n", GetLastError()); } + hwinsta = CreateWindowStationA("winsta_test", 0, WINSTA_ALL_ACCESS, NULL); + ret = GetLastError(); + ok(hwinsta != NULL || ret == ERROR_ACCESS_DENIED, "CreateWindowStation failed (%u)\n", ret); + if (!hwinsta) + { + win_skip("Not enough privileges for CreateWindowStation\n"); + return; + } + SetLastError(0xdeadbeef); ret = EnumWindowStationsA(open_window_station_callbackA, 0x12345); ok(ret == 0x12345, "EnumWindowStationsA returned %x\n", ret); @@ -383,7 +396,7 @@ static void test_getuserobjectinformation(void) DWORD size; BOOL ret; - desk = CreateDesktop("foobarTest", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL); + desk = CreateDesktopA("foobarTest", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL); ok(desk != 0, "open foobarTest desktop failed\n"); strcpy(buffer, "blahblah"); @@ -475,6 +488,442 @@ static void test_getuserobjectinformation(void) ok(CloseDesktop(desk), "CloseDesktop failed\n"); } +static void test_inputdesktop(void) +{ + HDESK input_desk, old_input_desk, thread_desk, old_thread_desk, new_desk; + DWORD ret; + CHAR name[1024]; + INPUT inputs[1]; + + inputs[0].type = INPUT_KEYBOARD; + U(inputs[0]).ki.wVk = 0; + U(inputs[0]).ki.wScan = 0x3c0; + U(inputs[0]).ki.dwFlags = KEYEVENTF_UNICODE; + + /* OpenInputDesktop creates new handles for each calls */ + old_input_desk = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS); + ok(old_input_desk != NULL, "OpenInputDesktop failed!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(old_input_desk, UOI_NAME, name, 1024, NULL); + ok(ret, "GetUserObjectInformation failed!\n"); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + input_desk = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS); + ok(input_desk != NULL, "OpenInputDesktop failed!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(input_desk, UOI_NAME, name, 1024, NULL); + ok(ret, "GetUserObjectInformation failed!\n"); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + ok(old_input_desk != input_desk, "returned the same handle!\n"); + ret = CloseDesktop(input_desk); + ok(ret, "CloseDesktop failed!\n"); + + /* by default, GetThreadDesktop is the input desktop, SendInput should success. */ + old_thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(old_thread_desk != NULL, "GetThreadDesktop faile!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(old_thread_desk, UOI_NAME, name, 1024, NULL); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); + ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1, "unexpected return count %d\n", ret); + + /* Set thread desktop to the new desktop, SendInput should fail. */ + new_desk = CreateDesktopA("new_desk", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL); + ok(new_desk != NULL, "CreateDesktop failed!\n"); + ret = SetThreadDesktop(new_desk); + ok(ret, "SetThreadDesktop failed!\n"); + thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(thread_desk == new_desk, "thread desktop doesn't match!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(thread_desk, UOI_NAME, name, 1024, NULL); + ok(!strcmp(name, "new_desk"), "unexpected desktop %s\n", name); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); + if(broken(GetLastError() == 0xdeadbeef)) + { + SetThreadDesktop(old_thread_desk); + CloseDesktop(old_input_desk); + CloseDesktop(input_desk); + CloseDesktop(new_desk); + win_skip("Skip tests on NT4\n"); + return; + } +todo_wine + ok(GetLastError() == ERROR_ACCESS_DENIED, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1 || broken(ret == 0) /* Win64 */, "unexpected return count %d\n", ret); + + /* Set thread desktop back to the old thread desktop, SendInput should success. */ + ret = SetThreadDesktop(old_thread_desk); + ok(ret, "SetThreadDesktop failed!\n"); + thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(thread_desk == old_thread_desk, "thread desktop doesn't match!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(thread_desk, UOI_NAME, name, 1024, NULL); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); + ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1, "unexpected return count %d\n", ret); + + /* Set thread desktop to the input desktop, SendInput should success. */ + ret = SetThreadDesktop(old_input_desk); + ok(ret, "SetThreadDesktop failed!\n"); + thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(thread_desk == old_input_desk, "thread desktop doesn't match!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(thread_desk, UOI_NAME, name, 1024, NULL); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); + ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1, "unexpected return count %d\n", ret); + + /* Switch input desktop to the new desktop, SendInput should fail. */ + ret = SwitchDesktop(new_desk); + ok(ret, "SwitchDesktop failed!\n"); + input_desk = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS); + ok(input_desk != NULL, "OpenInputDesktop failed!\n"); + ok(input_desk != new_desk, "returned the same handle!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(input_desk, UOI_NAME, name, 1024, NULL); + ok(ret, "GetUserObjectInformation failed!\n"); +todo_wine + ok(!strcmp(name, "new_desk"), "unexpected desktop %s\n", name); + ret = CloseDesktop(input_desk); + ok(ret, "CloseDesktop failed!\n"); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); +todo_wine + ok(GetLastError() == ERROR_ACCESS_DENIED, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1 || broken(ret == 0) /* Win64 */, "unexpected return count %d\n", ret); + + /* Set thread desktop to the new desktop, SendInput should success. */ + ret = SetThreadDesktop(new_desk); + ok(ret, "SetThreadDesktop failed!\n"); + thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(thread_desk == new_desk, "thread desktop doesn't match!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(thread_desk, UOI_NAME, name, 1024, NULL); + ok(!strcmp(name, "new_desk"), "unexpected desktop %s\n", name); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); + ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1, "unexpected return count %d\n", ret); + + /* Switch input desktop to the old input desktop, set thread desktop to the old + * thread desktop, clean side effects. SendInput should success. */ + ret = SwitchDesktop(old_input_desk); + input_desk = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS); + ok(input_desk != NULL, "OpenInputDesktop failed!\n"); + ok(input_desk != old_input_desk, "returned the same handle!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(input_desk, UOI_NAME, name, 1024, NULL); + ok(ret, "GetUserObjectInformation failed!\n"); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + ret = SetThreadDesktop(old_thread_desk); + ok(ret, "SetThreadDesktop failed!\n"); + thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(thread_desk == old_thread_desk, "thread desktop doesn't match!\n"); + memset(name, 0, sizeof(name)); + ret = GetUserObjectInformationA(thread_desk, UOI_NAME, name, 1024, NULL); + ok(!strcmp(name, "Default"), "unexpected desktop %s\n", name); + + SetLastError(0xdeadbeef); + ret = SendInput(1, inputs, sizeof(INPUT)); + ok(GetLastError() == 0xdeadbeef, "unexpected last error %08x\n", GetLastError()); + ok(ret == 1, "unexpected return count %d\n", ret); + + /* free resources */ + ret = CloseDesktop(input_desk); + ok(ret, "CloseDesktop failed!\n"); + ret = CloseDesktop(old_input_desk); + ok(ret, "CloseDesktop failed!\n"); + ret = CloseDesktop(new_desk); + ok(ret, "CloseDesktop failed!\n"); +} + +static void test_inputdesktop2(void) +{ + HWINSTA w1, w2; + HDESK thread_desk, new_desk, input_desk, hdesk; + DWORD ret; + + thread_desk = GetThreadDesktop(GetCurrentThreadId()); + ok(thread_desk != NULL, "GetThreadDesktop failed!\n"); + w1 = GetProcessWindowStation(); + ok(w1 != NULL, "GetProcessWindowStation failed!\n"); + SetLastError(0xdeadbeef); + w2 = CreateWindowStationA("winsta_test", 0, WINSTA_ALL_ACCESS, NULL); + ret = GetLastError(); + ok(w2 != NULL || ret == ERROR_ACCESS_DENIED, "CreateWindowStation failed (%u)\n", ret); + if (!w2) + { + win_skip("Not enough privileges for CreateWindowStation\n"); + return; + } + + ret = EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA, 0); + ok(!ret, "EnumDesktopsA failed!\n"); + input_desk = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS); + ok(input_desk != NULL, "OpenInputDesktop failed!\n"); + ret = CloseDesktop(input_desk); + ok(ret, "CloseDesktop failed!\n"); + + ret = SetProcessWindowStation(w2); + ok(ret, "SetProcessWindowStation failed!\n"); + hdesk = GetThreadDesktop(GetCurrentThreadId()); + ok(hdesk != NULL, "GetThreadDesktop failed!\n"); + ok(hdesk == thread_desk, "thread desktop should not change after winstation changed!\n"); + ret = EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA, 0); + + new_desk = CreateDesktopA("desk_test", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL); + ok(new_desk != NULL, "CreateDesktop failed!\n"); + ret = EnumDesktopsA(GetProcessWindowStation(), desktop_callbackA, 0); + ok(!ret, "EnumDesktopsA failed!\n"); + SetLastError(0xdeadbeef); + input_desk = OpenInputDesktop(0, FALSE, DESKTOP_ALL_ACCESS); + ok(input_desk == NULL, "OpenInputDesktop should fail on non default winstation!\n"); + ok(GetLastError() == ERROR_INVALID_FUNCTION || broken(GetLastError() == 0xdeadbeef), "last error %08x\n", GetLastError()); + + hdesk = OpenDesktopA("desk_test", 0, TRUE, DESKTOP_ALL_ACCESS); + ok(hdesk != NULL, "OpenDesktop failed!\n"); + SetLastError(0xdeadbeef); + ret = SwitchDesktop(hdesk); +todo_wine + ok(!ret, "Switch to desktop belong to non default winstation should fail!\n"); +todo_wine + ok(GetLastError() == ERROR_ACCESS_DENIED || broken(GetLastError() == 0xdeadbeef), "last error %08x\n", GetLastError()); + ret = SetThreadDesktop(hdesk); + ok(ret, "SetThreadDesktop failed!\n"); + + /* clean side effect */ + ret = SetThreadDesktop(thread_desk); +todo_wine + ok(ret, "SetThreadDesktop should success even desktop is not belong to process winstation!\n"); + ret = SetProcessWindowStation(w1); + ok(ret, "SetProcessWindowStation failed!\n"); + ret = SetThreadDesktop(thread_desk); + ok(ret, "SetThreadDesktop failed!\n"); + ret = CloseWindowStation(w2); + ok(ret, "CloseWindowStation failed!\n"); + ret = CloseDesktop(new_desk); + ok(ret, "CloseDesktop failed!\n"); + ret = CloseDesktop(hdesk); + ok(ret, "CloseDesktop failed!\n"); +} + +static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (msg == WM_DESTROY) + { + trace("destroying hwnd %p\n", hWnd); + PostQuitMessage(0); + return 0; + } + return DefWindowProcA( hWnd, msg, wParam, lParam ); +} + +typedef struct tag_wnd_param +{ + const char *wnd_name; + HWND hwnd; + HDESK hdesk; + HANDLE hevent; +} wnd_param; + +static DWORD WINAPI create_window(LPVOID param) +{ + wnd_param *param1 = param; + DWORD ret; + MSG msg; + + ret = SetThreadDesktop(param1->hdesk); + ok(ret, "SetThreadDesktop failed!\n"); + param1->hwnd = CreateWindowA("test_class", param1->wnd_name, WS_POPUP, 0, 0, 100, 100, NULL, NULL, NULL, NULL); + ok(param1->hwnd != 0, "CreateWindowA failed!\n"); + ret = SetEvent(param1->hevent); + ok(ret, "SetEvent failed!\n"); + + while (GetMessageA(&msg, 0, 0, 0)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + return 0; +} + +static DWORD set_foreground(HWND hwnd) +{ + HWND hwnd_fore; + DWORD set_id, fore_id, ret; + char win_text[1024]; + + hwnd_fore = GetForegroundWindow(); + GetWindowTextA(hwnd_fore, win_text, 1024); + set_id = GetWindowThreadProcessId(hwnd, NULL); + fore_id = GetWindowThreadProcessId(hwnd_fore, NULL); + trace("\"%s\" %p %08x hwnd %p %08x\n", win_text, hwnd_fore, fore_id, hwnd, set_id); + ret = AttachThreadInput(set_id, fore_id, TRUE); + trace("AttachThreadInput returned %08x\n", ret); + ret = ShowWindow(hwnd, SW_SHOWNORMAL); + trace("ShowWindow returned %08x\n", ret); + ret = SetWindowPos(hwnd, HWND_TOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); + trace("set topmost returned %08x\n", ret); + ret = SetWindowPos(hwnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE); + trace("set notopmost returned %08x\n", ret); + ret = SetForegroundWindow(hwnd); + trace("SetForegroundWindow returned %08x\n", ret); + Sleep(250); + AttachThreadInput(set_id, fore_id, FALSE); + return ret; +} + +static void test_foregroundwindow(void) +{ + HWND hwnd, hwnd_test, partners[2], hwnds[2]; + HDESK hdesks[2]; + int thread_desk_id, input_desk_id, hwnd_id; + WNDCLASSA wclass; + wnd_param param; + DWORD ret, timeout, timeout_old; + char win_text[1024]; + +#define DESKTOPS 2 + + memset( &wclass, 0, sizeof(wclass) ); + wclass.lpszClassName = "test_class"; + wclass.lpfnWndProc = WndProc; + RegisterClassA(&wclass); + param.wnd_name = "win_name"; + + hdesks[0] = GetThreadDesktop(GetCurrentThreadId()); + ok(hdesks[0] != NULL, "OpenDesktop failed!\n"); + SetLastError(0xdeadbeef); + hdesks[1] = CreateDesktopA("desk2", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL); + ret = GetLastError(); + ok(hdesks[1] != NULL || ret == ERROR_ACCESS_DENIED, "CreateDesktop failed (%u)\n", ret); + if(!hdesks[1]) + { + win_skip("Not enough privileges for CreateDesktop\n"); + return; + } + + ret = SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout_old, 0); + if(!ret) + { + win_skip("Skip tests on NT4\n"); + CloseDesktop(hdesks[1]); + return; + } + trace("old timeout %d\n", timeout_old); + timeout = 0; + ret = SystemParametersInfoA(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, 0, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE); + ok(ret, "set foreground lock timeout failed!\n"); + ret = SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout, 0); + ok(ret, "get foreground lock timeout failed!\n"); + ok(timeout == 0, "unexpected timeout %d\n", timeout); + + for (thread_desk_id = 0; thread_desk_id < DESKTOPS; thread_desk_id++) + { + param.hdesk = hdesks[thread_desk_id]; + param.hevent = CreateEventA(NULL, TRUE, FALSE, NULL); + CreateThread(NULL, 0, create_window, ¶m, 0, NULL); + ret = WaitForSingleObject(param.hevent, INFINITE); + ok(ret == WAIT_OBJECT_0, "wait failed!\n"); + hwnds[thread_desk_id] = param.hwnd; + } + + for (thread_desk_id = 0; thread_desk_id < DESKTOPS; thread_desk_id++) + { + param.hdesk = hdesks[thread_desk_id]; + param.hevent = CreateEventA(NULL, TRUE, FALSE, NULL); + CreateThread(NULL, 0, create_window, ¶m, 0, NULL); + ret = WaitForSingleObject(param.hevent, INFINITE); + ok(ret == WAIT_OBJECT_0, "wait failed!\n"); + partners[thread_desk_id] = param.hwnd; + } + + trace("hwnd0 %p hwnd1 %p partner0 %p partner1 %p\n", hwnds[0], hwnds[1], partners[0], partners[1]); + + for (hwnd_id = 0; hwnd_id < DESKTOPS; hwnd_id++) + for (thread_desk_id = 0; thread_desk_id < DESKTOPS; thread_desk_id++) + for (input_desk_id = 0; input_desk_id < DESKTOPS; input_desk_id++) + { + trace("testing thread_desk %d input_desk %d hwnd %d\n", + thread_desk_id, input_desk_id, hwnd_id); + hwnd_test = hwnds[hwnd_id]; + ret = SetThreadDesktop(hdesks[thread_desk_id]); + ok(ret, "set thread desktop failed!\n"); + ret = SwitchDesktop(hdesks[input_desk_id]); + ok(ret, "switch desktop failed!\n"); + set_foreground(partners[0]); + set_foreground(partners[1]); + hwnd = GetForegroundWindow(); + ok(hwnd != hwnd_test, "unexpected foreground window %p\n", hwnd); + ret = set_foreground(hwnd_test); + hwnd = GetForegroundWindow(); + GetWindowTextA(hwnd, win_text, 1024); + trace("hwnd %p name %s\n", hwnd, win_text); + if (input_desk_id == hwnd_id) + { + if (input_desk_id == thread_desk_id) + { + ok(ret, "SetForegroundWindow failed!\n"); + ok(hwnd == hwnd_test , "unexpected foreground window %p\n", hwnd); + } + else + { + todo_wine ok(ret, "SetForegroundWindow failed!\n"); + todo_wine ok(hwnd == 0, "unexpected foreground window %p\n", hwnd); + } + } + else + { + if (input_desk_id == thread_desk_id) + { + ok(!ret, "SetForegroundWindow should fail!\n"); + ok(hwnd == partners[input_desk_id] , "unexpected foreground window %p\n", hwnd); + } + else + { + todo_wine ok(!ret, "SetForegroundWindow should fail!\n"); + todo_wine ok(hwnd == 0, "unexpected foreground window %p\n", hwnd); + } + } + } + + /* Clean up */ + + for (thread_desk_id = DESKTOPS - 1; thread_desk_id >= 0; thread_desk_id--) + { + ret = SetThreadDesktop(hdesks[thread_desk_id]); + ok(ret, "set thread desktop failed!\n"); + SendMessageA(hwnds[thread_desk_id], WM_DESTROY, 0, 0); + SendMessageA(partners[thread_desk_id], WM_DESTROY, 0, 0); + } + + ret = SwitchDesktop(hdesks[0]); + ok(ret, "switch desktop failed!\n"); + CloseDesktop(hdesks[1]); + + ret = SystemParametersInfoA(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UlongToPtr(timeout_old), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE); + ok(ret, "set foreground lock timeout failed!\n"); + ret = SystemParametersInfoA(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout, 0); + ok(ret, "get foreground lock timeout failed!\n"); + ok(timeout == timeout_old, "unexpected timeout %d\n", timeout); +} + START_TEST(winstation) { /* Check whether this platform supports WindowStation calls */ @@ -487,8 +936,11 @@ START_TEST(winstation) return; } + test_inputdesktop(); + test_inputdesktop2(); test_enumstations(); test_enumdesktops(); test_handles(); test_getuserobjectinformation(); + test_foregroundwindow(); } diff --git a/rostests/winetests/user32/wsprintf.c b/rostests/winetests/user32/wsprintf.c index 5370df4636a..15e4af0e692 100755 --- a/rostests/winetests/user32/wsprintf.c +++ b/rostests/winetests/user32/wsprintf.c @@ -113,16 +113,16 @@ static void wsprintfWTest(void) static void CharUpperTest(void) { - INT_PTR i,out,failed; + INT_PTR i, out; + BOOL failed = FALSE; - failed = 0; for (i=0;i<256;i++) { - out = (INT_PTR)CharUpper((LPTSTR)i); + out = (INT_PTR)CharUpperA((LPSTR)i); /* printf("%0x ",out); */ if ((out >> 16) != 0) { - failed = 1; + failed = TRUE; break; } } @@ -131,16 +131,16 @@ static void CharUpperTest(void) static void CharLowerTest(void) { - INT_PTR i,out,failed; + INT_PTR i, out; + BOOL failed = FALSE; - failed = 0; for (i=0;i<256;i++) { - out = (INT_PTR)CharLower((LPTSTR)i); + out = (INT_PTR)CharLowerA((LPSTR)i); /* printf("%0x ",out); */ if ((out >> 16) != 0) { - failed = 1; + failed = TRUE; break; } }