From f05d569387b0366b8e3a8649a8c4c099e54cfa32 Mon Sep 17 00:00:00 2001 From: Kang Yu Date: Thu, 1 May 2025 09:57:36 -0700 Subject: [PATCH] #400, fix wrong mismatch of dialog of different style --- .../Common/Models/ApplicationDisplayMetrics.cs | 2 ++ .../Common/PersistentWindowProcessor.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Ninjacrab.PersistentWindows.Solution/Common/Models/ApplicationDisplayMetrics.cs b/Ninjacrab.PersistentWindows.Solution/Common/Models/ApplicationDisplayMetrics.cs index a18acd2..1c4acc4 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/Models/ApplicationDisplayMetrics.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/Models/ApplicationDisplayMetrics.cs @@ -26,6 +26,8 @@ namespace PersistentWindows.Common.Models public bool IsFullScreen { get; set; } public bool IsMinimized { get; set; } public bool IsInvisible { get; set; } + public long Style { get; set; } + public long ExtStyle { get; set; } // for restore window position to display session end time public DateTime CaptureTime { get; set; } diff --git a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs index 1eb5531..afaa950 100644 --- a/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs +++ b/Ninjacrab.PersistentWindows.Solution/Common/PersistentWindowProcessor.cs @@ -1496,6 +1496,9 @@ namespace PersistentWindows.Common DateTime last_killed_time = new DateTime(0); IntPtr last_killed_hid = IntPtr.Zero; + long style = User32.GetWindowLong(hwnd, User32.GWL_STYLE); + long ext_style = User32.GetWindowLong(hwnd, User32.GWL_EXSTYLE); + var deadAppPos = deadApps[curDisplayKey]; lock(captureLock) foreach (var kid in deadAppPos.Keys) @@ -1505,6 +1508,11 @@ namespace PersistentWindows.Common if (!procName.Equals(appPos.ProcessName)) continue; + if (appPos.Style != 0 && style != appPos.Style) + continue; + if (appPos.ExtStyle != 0 && ext_style != appPos.ExtStyle) + continue; + if (!className.Equals(appPos.ClassName)) { if (className.Length != appPos.ClassName.Length) @@ -1513,6 +1521,7 @@ namespace PersistentWindows.Common continue; } + if (IsMinimized(hwnd) != appPos.IsMinimized) continue; if (User32.IsWindowVisible(hwnd) == appPos.IsInvisible) @@ -3319,6 +3328,9 @@ namespace PersistentWindows.Common NeedUpdateWindowPlacement = false, ScreenPosition = screenPosition, + Style = User32.GetWindowLong(hwnd, User32.GWL_STYLE), + ExtStyle = User32.GetWindowLong(hwnd, User32.GWL_EXSTYLE), + IsTopMost = IsWindowTopMost(hwnd), NeedClearTopMost = false,