From 63c15a70eeb95ce57fa49893eb5cab401d984bd5 Mon Sep 17 00:00:00 2001 From: Louis Lenders Date: Tue, 28 Sep 2010 18:56:40 +0200 Subject: user32: Unlike RedrawWindow, UpdateWindow doesn't accept a NULL hwnd --- dlls/user32/painting.c | 6 ++++++ dlls/user32/tests/win.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-) diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 9f02a03..e7ce2ec 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -1202,6 +1202,12 @@ BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags ) */ BOOL WINAPI UpdateWindow( HWND hwnd ) { + if (!hwnd) + { + SetLastError( ERROR_INVALID_WINDOW_HANDLE ); + return FALSE; + } + return RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN ); } diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index f1f590c..fa36885 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6217,6 +6217,20 @@ static void test_rtl_layout(void) DestroyWindow( parent ); } +void test_UpdateWindow_nullhwnd(void) +{ + /*test to show a difference between UpdateWindow and RedrawWindow with NULL hwnd */ + BOOL retval; + retval = RedrawWindow(NULL, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN ); + ok( retval, "Expected 1, got %d\n", retval); + SetLastError(0xdeadbeef); + retval = UpdateWindow(NULL); + ok( !retval, "Expected 0, got %d\n", retval); + ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE || + broken(GetLastError() == 0xdeadbeef) /* win9x */, + "Expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError()); +} + START_TEST(win) { HMODULE user32 = GetModuleHandleA( "user32.dll" ); @@ -6316,6 +6330,7 @@ START_TEST(win) test_shell_window(); test_handles( hwndMain ); test_winregion(); + test_UpdateWindow_nullhwnd(); /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook); -- 1.7.0.4