user32: Add an invalid window check to SetActiveWindow.
This commit is contained in:
parent
d09e973f7d
commit
98e2bf4e1c
|
@ -232,12 +232,18 @@ HWND WINAPI SetActiveWindow( HWND hwnd )
|
||||||
|
|
||||||
if (hwnd)
|
if (hwnd)
|
||||||
{
|
{
|
||||||
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
LONG style;
|
||||||
|
|
||||||
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD)
|
|
||||||
return GetActiveWindow(); /* Windows doesn't seem to return an error here */
|
|
||||||
|
|
||||||
hwnd = WIN_GetFullHandle( hwnd );
|
hwnd = WIN_GetFullHandle( hwnd );
|
||||||
|
if (!IsWindow( hwnd ))
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
style = GetWindowLongW( hwnd, GWL_STYLE );
|
||||||
|
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD)
|
||||||
|
return GetActiveWindow(); /* Windows doesn't seem to return an error here */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!set_active_window( hwnd, &prev, FALSE, TRUE )) return 0;
|
if (!set_active_window( hwnd, &prev, FALSE, TRUE )) return 0;
|
||||||
|
|
|
@ -13602,10 +13602,9 @@ static void test_SetFocus(void)
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
old_active = SetActiveWindow((HWND)0xdeadbeef);
|
old_active = SetActiveWindow((HWND)0xdeadbeef);
|
||||||
todo_wine
|
|
||||||
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
|
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "expected ERROR_INVALID_WINDOW_HANDLE, got %d\n", GetLastError());
|
||||||
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
|
||||||
ok_sequence(WmEmptySeq, "SetActiveWindow on an invalid window", TRUE);
|
ok_sequence(WmEmptySeq, "SetActiveWindow on an invalid window", FALSE);
|
||||||
ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
|
ok(old_active == 0, "expected old focus 0, got %p\n", old_active);
|
||||||
ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
|
ok(GetActiveWindow() == parent, "expected active %p, got %p\n", parent, GetActiveWindow());
|
||||||
ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
|
ok(GetFocus() == parent, "expected focus %p, got %p\n", parent, GetFocus());
|
||||||
|
|
Loading…
Reference in New Issue