This commit is contained in:
stax76
2023-12-15 01:24:43 +01:00
parent cd54e67b87
commit e0616dee76
8 changed files with 125 additions and 63 deletions

View File

@@ -96,13 +96,13 @@ public partial class MessageBoxEx : Window, INotifyPropertyChanged
public static void SetOwner(Window window)
{
IntPtr ownerHandle = GetOwnerHandle();
IntPtr parentHandle = GetParentHandle();
if (ownerHandle != IntPtr.Zero)
new WindowInteropHelper(window).Owner = ownerHandle;
if (parentHandle != IntPtr.Zero)
new WindowInteropHelper(window).Owner = parentHandle;
}
public static IntPtr GetOwnerHandle()
public static IntPtr GetParentHandle()
{
IntPtr foregroundWindow = GetForegroundWindow();
GetWindowThreadProcessId(foregroundWindow, out var procID);