Browse Source

Fixed that you cant move maximized window when the mouse's Y position is between 1 and 5

CPKreuz 4 years ago
parent
commit
1d4e0fc44c

+ 2 - 0
PixiEditor/Helpers/WindowSizeHelper.cs

@@ -7,6 +7,8 @@ namespace PixiEditor.Helpers
     {
         public static IntPtr SetMaxSizeHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
         {
+            // All windows messages (msg) can be found here
+            // https://docs.microsoft.com/de-de/windows/win32/winmsg/window-notifications
             if (msg == WM_GETMINMAXINFO)
             {
                 // We need to tell the system what our size should be when maximized. Otherwise it will

+ 1 - 2
PixiEditor/Views/MainWindow.xaml

@@ -18,8 +18,7 @@
         WindowStartupLocation="CenterScreen" WindowState="Maximized"
         AllowDrop="True" Drop="MainWindow_Drop">
     <WindowChrome.WindowChrome>
-        <WindowChrome CaptionHeight="35"
-                      ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
+        <WindowChrome CaptionHeight="35" x:Name="windowsChrome"/>
     </WindowChrome.WindowChrome>
 
     <Window.Resources>

+ 17 - 2
PixiEditor/Views/MainWindow.xaml.cs

@@ -41,7 +41,8 @@ namespace PixiEditor
 
             pixiEditorLogo = BitmapFactory.FromResource(@"/Images/PixiEditorLogo.png");
 
-            StateChanged += MainWindowStateChangeRaised;
+            UpdateWindowChromeBorderThickness();
+            StateChanged += MainWindow_StateChanged;
             Activated += MainWindow_Activated;
 
             DataContext.CloseAction = Close;
@@ -133,8 +134,22 @@ namespace PixiEditor
             CloseHelloThereIfRelease();
         }
 
-        private void MainWindowStateChangeRaised(object sender, EventArgs e)
+        private void UpdateWindowChromeBorderThickness()
         {
+            if (WindowState == WindowState.Maximized)
+            {
+                windowsChrome.ResizeBorderThickness = new Thickness(0, 0, 0, 0);
+            }
+            else
+            {
+                windowsChrome.ResizeBorderThickness = new Thickness(5, 5, 5, 5);
+            }
+        }
+
+        private void MainWindow_StateChanged(object sender, EventArgs e)
+        {
+            UpdateWindowChromeBorderThickness();
+
             if (WindowState == WindowState.Maximized)
             {
                 RestoreButton.Visibility = Visibility.Visible;