Skip to content

Commit

Permalink
use GetWindowRect to save possible snapped window
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Feb 23, 2015
1 parent 3b9a91a commit 8f38e51
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions MahApps.Metro/Controls/WindowSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 8f38e51

Please # to comment.