diff --git a/win32ss/user/ntuser/defwnd.c b/win32ss/user/ntuser/defwnd.c index 81ece247b78..a5c230df5b0 100644 --- a/win32ss/user/ntuser/defwnd.c +++ b/win32ss/user/ntuser/defwnd.c @@ -797,6 +797,11 @@ IntDefWindowProc( HWND hwndTop = UserGetForegroundWindow(); PWND topWnd = UserGetWindowObject(hwndTop); + /* MS Doc: The foreground window can be NULL in certain circumstances, + such as when a window is losing activation */ + if (!topWnd) + return 0; + // We want to forbid snapping operations on the TaskBar // We use a heuristic for detecting the TaskBar Wnd by its typical Style & ExStyle Values ExStyleTB = (topWnd->ExStyle & WS_EX_TOOLWINDOW); @@ -805,7 +810,7 @@ IntDefWindowProc( && (ExStyleTB == WS_EX_TOOLWINDOW); TRACE("ExStyle=%x Style=%x IsTaskBar=%d\n", ExStyleTB, StyleTB, IsTaskBar); - if (topWnd && !IsTaskBar) + if (!IsTaskBar) { if ((topWnd->style & WS_THICKFRAME) == 0) return 0;