diff --git a/src/WpfScreenHelper/Enum/WindowPositions.cs b/src/WpfScreenHelper/Enum/WindowPositions.cs index 3067662..c329657 100644 --- a/src/WpfScreenHelper/Enum/WindowPositions.cs +++ b/src/WpfScreenHelper/Enum/WindowPositions.cs @@ -11,6 +11,6 @@ public enum WindowPositions TopRight, BottomRight, BottomLeft, - Maximize + Fill } } diff --git a/src/WpfScreenHelper/WindowHelper.cs b/src/WpfScreenHelper/WindowHelper.cs index 9511173..5b0babb 100644 --- a/src/WpfScreenHelper/WindowHelper.cs +++ b/src/WpfScreenHelper/WindowHelper.cs @@ -20,6 +20,8 @@ public static class WindowHelper /// New height of the window. public static void SetWindowPosition(this Window window, int x, int y, int width, int height) { + //Force to normal to allow setting the window position + window.WindowState = WindowState.Normal; // The first move puts it on the correct monitor, which triggers WM_DPICHANGED // The +1/-1 coerces WPF to update Window.Top/Left/Width/Height in the second move NativeMethods.MoveWindow(new WindowInteropHelper(window).Handle, x - 1, y, width + 1, height, false); @@ -135,7 +137,7 @@ private static Rect CalculateWindowCoordinates(FrameworkElement window, WindowPo return new Rect(screen.WpfBounds.X * screen.ScaleFactor, y * screen.ScaleFactor, window.Width * screen.ScaleFactor, window.Height * screen.ScaleFactor); } - case WindowPositions.Maximize: + case WindowPositions.Fill: return new Rect(screen.WpfBounds.X * screen.ScaleFactor, screen.WpfBounds.Y * screen.ScaleFactor, screen.WpfBounds.Width * screen.ScaleFactor, screen.WpfBounds.Height * screen.ScaleFactor); default: diff --git a/src/WpfScreenHelper/WpfScreenHelper.csproj b/src/WpfScreenHelper/WpfScreenHelper.csproj index 77d41b8..c796181 100644 --- a/src/WpfScreenHelper/WpfScreenHelper.csproj +++ b/src/WpfScreenHelper/WpfScreenHelper.csproj @@ -1,4 +1,4 @@ - + net40;net6.0-windows;net8.0-windows @@ -14,7 +14,8 @@ WPF Screen Monitor Display Helper https://github.com/micdenny/WpfScreenHelper MIT - 2.1.1 + 2.2.1 + 2025.2.18.3 diff --git a/test/WpfScreenHelper.DpiTestWpfApp/MainWindow.xaml b/test/WpfScreenHelper.DpiTestWpfApp/MainWindow.xaml index 2d1835b..4254c5e 100644 --- a/test/WpfScreenHelper.DpiTestWpfApp/MainWindow.xaml +++ b/test/WpfScreenHelper.DpiTestWpfApp/MainWindow.xaml @@ -4,31 +4,111 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" - Title="MainWindow" Name="Wnd" - Height="400" Width="700" SnapsToDevicePixels="True" WindowStyle="None" ResizeMode="NoResize" - Loaded="MainWindow_OnLoaded" MouseLeftButtonDown="MainWindow_OnMouseLeftButtonDown"> + Title="MainWindow" + Name="Wnd" + Height="400" + Width="700" + SnapsToDevicePixels="True" + WindowStyle="None" + ResizeMode="NoResize" + Loaded="MainWindow_OnLoaded" + MouseLeftButtonDown="MainWindow_OnMouseLeftButtonDown"> - -