diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 0bd6fbf069f..24e6ac28dbd 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2298,7 +2298,7 @@ static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, static void test_SetFocus(HWND hwnd) { - HWND child; + HWND child, child2; WNDPROC old_wnd_proc; /* check if we can set focus to non-visible windows */ @@ -2325,6 +2325,14 @@ static void test_SetFocus(HWND hwnd) ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() ); ShowWindow(child, SW_SHOW); + child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, 0, 0, NULL); + assert(child2); + ShowWindow(child2, SW_SHOW); + SetFocus(child2); + ShowWindow(child, SW_HIDE); + ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child ); + ok( GetFocus() == child2, "Focus should be on %p, not %p\n", child2, GetFocus() ); + ShowWindow(child, SW_SHOW); SetFocus(child); ok( GetFocus() == child, "Focus should be on child %p\n", child ); SetWindowPos(child,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW); @@ -2368,6 +2376,7 @@ todo_wine SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc); + DestroyWindow( child2 ); DestroyWindow( child ); } diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index c62fdaa7460..915cb5989a2 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -1056,7 +1056,7 @@ static BOOL show_window( HWND hwnd, INT cmd ) /* Revert focus to parent */ hFocus = GetFocus(); - if (hwnd == hFocus || IsChild(hwnd, hFocus)) + if (hwnd == hFocus) { HWND parent = GetAncestor(hwnd, GA_PARENT); if (parent == GetDesktopWindow()) parent = 0;