From 822a4eee02df84a7dfc662642087aa80a03966e5 Mon Sep 17 00:00:00 2001 From: Louis Lenders Date: Mon, 27 Sep 2010 22:13:19 +0200 Subject: user32: Unlike RedrawWindow, UpdateWindow doesn't accept a NULL hwnd --- dlls/user32/painting.c | 6 ++++++ dlls/user32/tests/win.c | 13 +++++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-) diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 9f02a03..d9a82ca 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 f34025f..4b8ff6b 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -6202,6 +6202,18 @@ 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(0xdadadada); + retval = UpdateWindow(NULL); + ok( !retval, "Expected 0, got %d\n", retval); + ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdadadada) /* win9x */, "Expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError()); +} + START_TEST(win) { HMODULE user32 = GetModuleHandleA( "user32.dll" ); @@ -6300,6 +6312,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