From 867e6faf468495b8536f52416fc17db8a5596824 Mon Sep 17 00:00:00 2001 From: AlexanderPro Date: Thu, 20 Jun 2019 12:07:26 +0300 Subject: [PATCH] Lister form has an owner. --- Wlx2Explorer/Forms/MainForm.cs | 3 ++- Wlx2Explorer/Win32WindowWrapper.cs | 18 ++++++++++++++++++ Wlx2Explorer/Wlx2Explorer.csproj | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Wlx2Explorer/Win32WindowWrapper.cs diff --git a/Wlx2Explorer/Forms/MainForm.cs b/Wlx2Explorer/Forms/MainForm.cs index 78b9401..668882c 100644 --- a/Wlx2Explorer/Forms/MainForm.cs +++ b/Wlx2Explorer/Forms/MainForm.cs @@ -214,7 +214,8 @@ private void ShowListerForm() } else { - _listerForm.Show(); + var foregroundWindowHandle = NativeMethods.GetForegroundWindow(); + _listerForm.Show(new Win32WindowWrapper(foregroundWindowHandle)); _listerForm.Activate(); } } diff --git a/Wlx2Explorer/Win32WindowWrapper.cs b/Wlx2Explorer/Win32WindowWrapper.cs new file mode 100644 index 0000000..38dcfde --- /dev/null +++ b/Wlx2Explorer/Win32WindowWrapper.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Wlx2Explorer +{ + class Win32WindowWrapper : IWin32Window + { + public IntPtr Handle { get; private set; } + + public Win32WindowWrapper(IntPtr handle) + { + Handle = handle; + } + } +} \ No newline at end of file diff --git a/Wlx2Explorer/Wlx2Explorer.csproj b/Wlx2Explorer/Wlx2Explorer.csproj index 21a0ba3..915facb 100644 --- a/Wlx2Explorer/Wlx2Explorer.csproj +++ b/Wlx2Explorer/Wlx2Explorer.csproj @@ -104,6 +104,7 @@ + AboutForm.cs