fix broken "keep in front"

This commit is contained in:
Paddy Xu
2018-06-23 17:41:21 +03:00
parent a47b9854f3
commit 3d11c9b1f7
2 changed files with 6 additions and 4 deletions

View File

@@ -42,13 +42,15 @@ namespace QuickLook.Common.Helpers
new Size(screen.Width / scale.Horizontal, screen.Height / scale.Vertical)); new Size(screen.Width / scale.Horizontal, screen.Height / scale.Vertical));
} }
public static void BringToFront(this Window window) public static void BringToFront(this Window window, bool keep)
{ {
var handle = new WindowInteropHelper(window).Handle; var handle = new WindowInteropHelper(window).Handle;
User32.SetWindowPos(handle, User32.HWND_TOPMOST, 0, 0, 0, 0, User32.SetWindowPos(handle, User32.HWND_TOPMOST, 0, 0, 0, 0,
User32.SWP_NOMOVE | User32.SWP_NOSIZE | User32.SWP_NOACTIVATE); User32.SWP_NOMOVE | User32.SWP_NOSIZE | User32.SWP_NOACTIVATE);
User32.SetWindowPos(handle, User32.HWND_NOTOPMOST, 0, 0, 0, 0,
User32.SWP_NOMOVE | User32.SWP_NOSIZE | User32.SWP_NOACTIVATE); if (!keep)
User32.SetWindowPos(handle, User32.HWND_NOTOPMOST, 0, 0, 0, 0,
User32.SWP_NOMOVE | User32.SWP_NOSIZE | User32.SWP_NOACTIVATE);
} }
public static void MoveWindow(this Window window, public static void MoveWindow(this Window window,

View File

@@ -101,7 +101,7 @@ namespace QuickLook
if (double.IsNaN(Left) || double.IsNaN(Top)) // first time showing if (double.IsNaN(Left) || double.IsNaN(Top)) // first time showing
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
Dispatcher.BeginInvoke(new Action(this.BringToFront), DispatcherPriority.Render); Dispatcher.BeginInvoke(new Action(() => this.BringToFront(Topmost)), DispatcherPriority.Render);
} }
} }