From 6d9d4a7112e3db72258989139907619b6bb65729 Mon Sep 17 00:00:00 2001 From: Laszlo Nemeth <57342539+donlaci@users.noreply.github.com> Date: Wed, 16 Nov 2022 10:20:02 +0100 Subject: [PATCH] [FancyZones] Resizing non visible windows with hide attribute (#21565) * Fix for issue microsoft#19440 Resizing non visible windows with attribute hide to avoid re-appearing * Simplifying code --- .../fancyzones/FancyZonesLib/WindowUtils.cpp | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp b/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp index 14036a7816..ee37b65866 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WindowUtils.cpp @@ -318,18 +318,25 @@ void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept ::GetWindowPlacement(window, &placement); } - // Do not restore minimized windows. We change their placement though so they restore to the correct zone. - if ((placement.showCmd != SW_SHOWMINIMIZED) && - (placement.showCmd != SW_MINIMIZE)) + if (!IsWindowVisible(window)) { - placement.showCmd = SW_RESTORE; + placement.showCmd = SW_HIDE; } - - // Remove maximized show command to make sure window is moved to the correct zone. - if (placement.showCmd == SW_SHOWMAXIMIZED) + else { - placement.showCmd = SW_RESTORE; - placement.flags &= ~WPF_RESTORETOMAXIMIZED; + // Do not restore minimized windows. We change their placement though so they restore to the correct zone. + if ((placement.showCmd != SW_SHOWMINIMIZED) && + (placement.showCmd != SW_MINIMIZE)) + { + placement.showCmd = SW_RESTORE; + } + + // Remove maximized show command to make sure window is moved to the correct zone. + if (placement.showCmd == SW_SHOWMAXIMIZED) + { + placement.showCmd = SW_RESTORE; + placement.flags &= ~WPF_RESTORETOMAXIMIZED; + } } ScreenToWorkAreaCoords(window, rect);