dont bind to window if there is no active

This commit is contained in:
zznty
2022-10-29 02:01:08 +07:00
parent 66d3dc2ead
commit f440a57424

View File

@@ -53,7 +53,10 @@ public static class LoaderTools
throw new ArgumentOutOfRangeException(nameof(buttons), buttons, null);
}
WinRT.Interop.InitializeWithWindow.Initialize(dialog, Process.GetCurrentProcess().MainWindowHandle);
var hwnd = Process.GetCurrentProcess().MainWindowHandle;
if (hwnd != IntPtr.Zero)
WinRT.Interop.InitializeWithWindow.Initialize(dialog, hwnd);
var result = dialog.ShowAsync().AsTask().Result;