diff --git a/AssetRipper.NativeDialogs/OpenFileDialog.cs b/AssetRipper.NativeDialogs/OpenFileDialog.cs index aa2c9e1..1d4be15 100644 --- a/AssetRipper.NativeDialogs/OpenFileDialog.cs +++ b/AssetRipper.NativeDialogs/OpenFileDialog.cs @@ -40,7 +40,7 @@ public static class OpenFileDialog { OPENFILENAMEW ofn = default; ofn.lStructSize = (uint)Unsafe.SizeOf(); - ofn.hwndOwner = default; // No owner window. + ofn.hwndOwner = Windows.GetConsoleWindow(); // Use console window as owner to ensure dialog comes to foreground ofn.lpstrFile = bufferPtr; ofn.nMaxFile = (uint)buffer.Length; ofn.lpstrFilter = filterPtr; @@ -119,7 +119,7 @@ public static class OpenFileDialog { OPENFILENAMEW ofn = default; ofn.lStructSize = (uint)Unsafe.SizeOf(); - ofn.hwndOwner = default; // No owner window. + ofn.hwndOwner = Windows.GetConsoleWindow(); // Use console window as owner to ensure dialog comes to foreground ofn.lpstrFile = bufferPtr; ofn.nMaxFile = (uint)buffer.Length; ofn.lpstrFilter = filterPtr; diff --git a/AssetRipper.NativeDialogs/OpenFolderDialog.cs b/AssetRipper.NativeDialogs/OpenFolderDialog.cs index e9c18e2..0531107 100644 --- a/AssetRipper.NativeDialogs/OpenFolderDialog.cs +++ b/AssetRipper.NativeDialogs/OpenFolderDialog.cs @@ -90,8 +90,9 @@ public static class OpenFolderDialog pFileDialog->GetOptions(&dwOptions); pFileDialog->SetOptions(dwOptions | (uint)FILEOPENDIALOGOPTIONS.FOS_PICKFOLDERS | (uint)FILEOPENDIALOGOPTIONS.FOS_FORCEFILESYSTEM); - // Show the dialog - hr = pFileDialog->Show(default); + // Show the dialog with console window as owner to ensure it comes to foreground + HWND hwndOwner = Windows.GetConsoleWindow(); + hr = pFileDialog->Show(hwndOwner); if (Windows.SUCCEEDED(hr)) { IShellItem* pItem; @@ -221,8 +222,9 @@ public static class OpenFolderDialog string[]? result = null; - // Show the dialog - hr = pFileDialog->Show(default); + // Show the dialog with console window as owner to ensure it comes to foreground + HWND hwndOwner = Windows.GetConsoleWindow(); + hr = pFileDialog->Show(hwndOwner); if (Windows.SUCCEEDED(hr)) { IShellItemArray* pItemArray; diff --git a/AssetRipper.NativeDialogs/SaveFileDialog.cs b/AssetRipper.NativeDialogs/SaveFileDialog.cs index aebb119..a09a8fb 100644 --- a/AssetRipper.NativeDialogs/SaveFileDialog.cs +++ b/AssetRipper.NativeDialogs/SaveFileDialog.cs @@ -42,7 +42,7 @@ public static class SaveFileDialog { OPENFILENAMEW ofn = default; ofn.lStructSize = (uint)Unsafe.SizeOf(); - ofn.hwndOwner = default; // No owner window. + ofn.hwndOwner = Windows.GetConsoleWindow(); // Use console window as owner to ensure dialog comes to foreground ofn.lpstrFile = bufferPtr; ofn.nMaxFile = (uint)buffer.Length; ofn.lpstrFilter = filterPtr;