diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 1964e88..246347f 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -4789,14 +4789,20 @@ static void test_hwnd_message(void) SetLastError(0xdeadbeef); found = FindWindowExA( GetDesktopWindow(), 0, 0, "message window" ); ok( found == 0, "found message window %p/%p\n", found, hwnd ); - todo_wine - ok(GetLastError() == ERROR_FILE_NOT_FOUND, "ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); if (parent) { found = FindWindowExA( parent, 0, 0, "message window" ); ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd ); } + /* test SetLastError Setting in FindWindow too*/ + + SetLastError(0xdeadbeef); + found = FindWindowA( "thiswindow@#%%doesnotexist...",0 ); + ok( found == 0, "found message window %p\n", found); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); + /* test IsChild behavior */ if (parent) ok( !IsChild( parent, hwnd ), "HWND_MESSAGE is child of top window\n" ); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 7756ab0..a2ebf0e 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -1613,6 +1613,7 @@ HWND WINAPI FindWindowExW( HWND parent, HWND child, LPCWSTR className, LPCWSTR t done: HeapFree( GetProcessHeap(), 0, list ); HeapFree( GetProcessHeap(), 0, buffer ); + if (!retvalue) SetLastError(ERROR_FILE_NOT_FOUND); return retvalue; } @@ -1623,9 +1624,7 @@ HWND WINAPI FindWindowExW( HWND parent, HWND child, LPCWSTR className, LPCWSTR t */ HWND WINAPI FindWindowA( LPCSTR className, LPCSTR title ) { - HWND ret = FindWindowExA( 0, 0, className, title ); - if (!ret) SetLastError (ERROR_CANNOT_FIND_WND_CLASS); - return ret; + return FindWindowExA( 0, 0, className, title ); }