From 8f38e518f221be749fb90ce1a1b86ab8285d1877 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 23 Feb 2015 22:39:05 +0100 Subject: [PATCH] use GetWindowRect to save possible snapped window --- MahApps.Metro/Controls/WindowSettings.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/MahApps.Metro/Controls/WindowSettings.cs b/MahApps.Metro/Controls/WindowSettings.cs index f831b5743d..6b93e919e8 100644 --- a/MahApps.Metro/Controls/WindowSettings.cs +++ b/MahApps.Metro/Controls/WindowSettings.cs @@ -123,9 +123,20 @@ protected virtual void SaveWindowState() wp.length = Marshal.SizeOf(wp); UnsafeNativeMethods.GetWindowPlacement(hwnd, ref wp); // check for saveable values - if (wp.showCmd != (int)Constants.ShowWindowCommands.SW_HIDE && wp.length > 0 && !wp.normalPosition.IsEmpty) + if (wp.showCmd != (int)Constants.ShowWindowCommands.SW_HIDE && wp.length > 0) { - _settings.Placement = wp; + if (wp.showCmd == (int)Constants.ShowWindowCommands.SW_NORMAL) + { + RECT rect; + if (UnsafeNativeMethods.GetWindowRect(hwnd, out rect)) + { + wp.normalPosition = rect; + } + } + if (!wp.normalPosition.IsEmpty) + { + _settings.Placement = wp; + } } _settings.Save(); }