diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 6e11ff21d94..915012c2243 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -3091,7 +3091,9 @@ static void test_SetFocus(HWND hwnd) ShowWindow(child, SW_SHOW); SetFocus(child); ok( GetFocus() == child, "Focus should be on child %p\n", child ); + SetLastError(0xdeadbeef); EnableWindow(hwnd, FALSE); + ok(GetLastError() == 0xdeadbeef, "got error %u in EnableWindow call\n", GetLastError()); ok( GetFocus() == child, "Focus should still be on child %p\n", child ); EnableWindow(hwnd, TRUE); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 440657719e7..f3b4ef547c6 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2171,7 +2171,7 @@ BOOL WINAPI EnableWindow( HWND hwnd, BOOL enable ) SetFocus( 0 ); /* A disabled window can't have the focus */ capture_wnd = GetCapture(); - if (hwnd == capture_wnd || IsChild(hwnd, capture_wnd)) + if (capture_wnd && (hwnd == capture_wnd || IsChild(hwnd, capture_wnd))) ReleaseCapture(); /* A disabled window can't capture the mouse */ SendMessageW( hwnd, WM_ENABLE, FALSE, 0 );