Skip to content

Commit

Permalink
Merge pull request #4407 from ykarpeev/develop
Browse files Browse the repository at this point in the history
when restoring window size use the DPI scale factor
  • Loading branch information
punker76 authored Dec 9, 2023
2 parents 924425f + 9669216 commit 183f421
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/MahApps.Metro/Controls/WinApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@ public static unsafe void SetWindowPlacement(Window? window, WINDOWPLACEMENT? wp
return;
}

// Get the current DPI scale factor
var dpiScale = VisualTreeHelper.GetDpi(window);

var x = CalcIntValue(wp?.rcNormalPosition.left, window.Left);
var y = CalcIntValue(wp?.rcNormalPosition.top, window.Top);
var width = CalcIntValue(wp?.rcNormalPosition.GetWidth(), window.ActualWidth);
var height = CalcIntValue(wp?.rcNormalPosition.GetHeight(), window.ActualHeight);
var width = CalcIntValue(wp?.rcNormalPosition.GetWidth() * dpiScale.DpiScaleX, window.ActualWidth);
var height = CalcIntValue(wp?.rcNormalPosition.GetHeight() * dpiScale.DpiScaleY, window.ActualHeight);

var placement = new WINDOWPLACEMENT
{
Expand Down

0 comments on commit 183f421

Please sign in to comment.