From 689356585fdc4851bd988d9ca775363560e98098 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Wed, 5 Dec 2018 12:44:13 +0100 Subject: [PATCH] (GH-2820) fix for: MahApps.Metro's borderlesswindowbehavior does not work with stickywindows. Closes #2820 Closes #2822 --- src/MahApps.Metro/Controls/MetroWindow.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/MahApps.Metro/Controls/MetroWindow.cs b/src/MahApps.Metro/Controls/MetroWindow.cs index 905d159a99..ba895d71f4 100644 --- a/src/MahApps.Metro/Controls/MetroWindow.cs +++ b/src/MahApps.Metro/Controls/MetroWindow.cs @@ -1353,16 +1353,20 @@ internal static void DoWindowTitleThumbMoveOnDragDelta(IMetroThumb thumb, [NotNu Mouse.Capture(thumb, CaptureMode.Element); } }; + window.StateChanged -= windowOnStateChanged; window.StateChanged += windowOnStateChanged; } var criticalHandle = window.CriticalHandle; - // DragMove works too - // window.DragMove(); - // instead this 2 lines #pragma warning disable 618 - NativeMethods.SendMessage(criticalHandle, WM.SYSCOMMAND, (IntPtr)SC.MOUSEMOVE, IntPtr.Zero); - NativeMethods.SendMessage(criticalHandle, WM.LBUTTONUP, IntPtr.Zero, IntPtr.Zero); + // these lines are from DragMove + // NativeMethods.SendMessage(criticalHandle, WM.SYSCOMMAND, (IntPtr)SC.MOUSEMOVE, IntPtr.Zero); + // NativeMethods.SendMessage(criticalHandle, WM.LBUTTONUP, IntPtr.Zero, IntPtr.Zero); + + var wpfPoint = window.PointToScreen(Mouse.GetPosition(window)); + var x = (int)wpfPoint.X; + var y = (int)wpfPoint.Y; + NativeMethods.SendMessage(criticalHandle, WM.NCLBUTTONDOWN, (IntPtr)HT.CAPTION, new IntPtr(x | (y << 16))); #pragma warning restore 618 }