Commit 5e65b652 authored by Rodrigo Rivas Costa's avatar Rodrigo Rivas Costa Committed by Alexandre Julliard

user32: Make DeferWindowPos() fail on invalid window handles.

parent 137030bf
......@@ -8821,6 +8821,40 @@ static void test_winproc_limit(void)
ok(i == 1, "winproc should be called once (%d)\n", i);
}
static void test_deferwindowpos(void)
{
HDWP hdwp, hdwp2;
BOOL ret;
hdwp = BeginDeferWindowPos(0);
ok(hdwp != NULL, "got %p\n", hdwp);
ret = EndDeferWindowPos(NULL);
ok(!ret, "got %d\n", ret);
hdwp2 = DeferWindowPos(NULL, NULL, NULL, 0, 0, 10, 10, 0);
todo_wine
ok(hdwp2 == NULL && ((GetLastError() == ERROR_INVALID_DWP_HANDLE) ||
broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE) /* before win8 */), "got %p, error %d\n", hdwp2, GetLastError());
hdwp2 = DeferWindowPos((HDWP)0xdead, GetDesktopWindow(), NULL, 0, 0, 10, 10, 0);
todo_wine
ok(hdwp2 == NULL && ((GetLastError() == ERROR_INVALID_DWP_HANDLE) ||
broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE) /* before win8 */), "got %p, error %d\n", hdwp2, GetLastError());
hdwp2 = DeferWindowPos(hdwp, NULL, NULL, 0, 0, 10, 10, 0);
ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %d\n", hdwp2, GetLastError());
hdwp2 = DeferWindowPos(hdwp, GetDesktopWindow(), NULL, 0, 0, 10, 10, 0);
ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %d\n", hdwp2, GetLastError());
hdwp2 = DeferWindowPos(hdwp, (HWND)0xdead, NULL, 0, 0, 10, 10, 0);
ok(hdwp2 == NULL && GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "got %p, error %d\n", hdwp2, GetLastError());
ret = EndDeferWindowPos(hdwp);
ok(ret, "got %d\n", ret);
}
START_TEST(win)
{
char **argv;
......@@ -8963,6 +8997,7 @@ START_TEST(win)
test_GetMessagePos();
test_activateapp(hwndMain);
test_winproc_handles(argv[0]);
test_deferwindowpos();
/* add the tests above this line */
if (hhook) UnhookWindowsHookEx(hhook);
......
......@@ -2348,7 +2348,11 @@ HDWP WINAPI DeferWindowPos( HDWP hdwp, HWND hwnd, HWND hwndAfter,
hdwp, hwnd, hwndAfter, x, y, cx, cy, flags);
hwnd = WIN_GetFullHandle( hwnd );
if (is_desktop_window( hwnd )) return 0;
if (is_desktop_window( hwnd ) || !IsWindow( hwnd ))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (!(pDWP = get_user_handle_ptr( hdwp, USER_DWP ))) return 0;
if (pDWP == OBJ_OTHER_PROCESS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment