@@ -11096,6 +11096,17 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
1109611096
1109711097 m_bFullScreen = !m_bFullScreen;
1109811098
11099+ // Keep the main HWND logically visible so the normal MFC/child layout runs
11100+ // during the fullscreen resize, but temporarily remove it from DWM
11101+ // presentation while its frame and geometry are being rewritten. Cloaking
11102+ // is Windows 8+, so Windows 7 and earlier retain the original code path.
11103+ bool bCloakedForFullscreenTransition = false;
11104+ if (SysVersion::IsWin8orLater() && IsWindowVisible()) {
11105+ const BOOL bCloak = TRUE;
11106+ bCloakedForFullscreenTransition = SUCCEEDED(DwmSetWindowAttribute(
11107+ m_hWnd, DWMWA_CLOAK, &bCloak, sizeof(bCloak)));
11108+ }
11109+
1109911110 ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
1110011111
1110111112 static bool bChangeMonitor = false;
@@ -11209,6 +11220,17 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
1120911220 m_bFullScreenChangingMode = false;
1121011221 MoveVideoWindow();
1121111222
11223+ // Reveal only after the final top-level and video-child geometry has been
11224+ // processed. Wait for the compositor to reach the transition's final
11225+ // presentation point first; unlike a forced RedrawWindow this does not
11226+ // synchronously repaint a stale pre-WM_SIZE child surface.
11227+ if (bCloakedForFullscreenTransition) {
11228+ DwmFlush();
11229+
11230+ const BOOL bCloak = FALSE;
11231+ DwmSetWindowAttribute(m_hWnd, DWMWA_CLOAK, &bCloak, sizeof(bCloak));
11232+ }
11233+
1121211234 if (bChangeMonitor && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) { // Enabled shader ...
1121311235 SetShaders();
1121411236 }
0 commit comments