mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
[RegistryPreview]Fix duplicate file pickers, open modal (#32025)
This commit is contained in:
@@ -155,7 +155,9 @@ namespace RegistryPreview
|
|||||||
|
|
||||||
// Pull in a new REG file - we have to use the direct Win32 method because FileOpenPicker crashes when it's
|
// Pull in a new REG file - we have to use the direct Win32 method because FileOpenPicker crashes when it's
|
||||||
// called while running as admin
|
// called while running as admin
|
||||||
|
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(this);
|
||||||
string filename = OpenFilePicker.ShowDialog(
|
string filename = OpenFilePicker.ShowDialog(
|
||||||
|
windowHandle,
|
||||||
resourceLoader.GetString("FilterRegistryName") + '\0' + "*.reg" + '\0' + resourceLoader.GetString("FilterAllFiles") + '\0' + "*.*" + '\0' + '\0',
|
resourceLoader.GetString("FilterRegistryName") + '\0' + "*.reg" + '\0' + resourceLoader.GetString("FilterAllFiles") + '\0' + "*.*" + '\0' + '\0',
|
||||||
resourceLoader.GetString("OpenDialogTitle"));
|
resourceLoader.GetString("OpenDialogTitle"));
|
||||||
|
|
||||||
@@ -197,7 +199,9 @@ namespace RegistryPreview
|
|||||||
{
|
{
|
||||||
// Save out a new REG file and then open it - we have to use the direct Win32 method because FileOpenPicker crashes when it's
|
// Save out a new REG file and then open it - we have to use the direct Win32 method because FileOpenPicker crashes when it's
|
||||||
// called while running as admin
|
// called while running as admin
|
||||||
|
IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(this);
|
||||||
string filename = SaveFilePicker.ShowDialog(
|
string filename = SaveFilePicker.ShowDialog(
|
||||||
|
windowHandle,
|
||||||
resourceLoader.GetString("SuggestFileName"),
|
resourceLoader.GetString("SuggestFileName"),
|
||||||
resourceLoader.GetString("FilterRegistryName") + '\0' + "*.reg" + '\0' + resourceLoader.GetString("FilterAllFiles") + '\0' + "*.*" + '\0' + '\0',
|
resourceLoader.GetString("FilterRegistryName") + '\0' + "*.reg" + '\0' + resourceLoader.GetString("FilterAllFiles") + '\0' + "*.*" + '\0' + '\0',
|
||||||
resourceLoader.GetString("SaveDialogTitle"));
|
resourceLoader.GetString("SaveDialogTitle"));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace RegistryPreview
|
namespace RegistryPreview
|
||||||
@@ -13,11 +14,12 @@ namespace RegistryPreview
|
|||||||
[DllImport("comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
[DllImport("comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
private static extern bool GetOpenFileName(ref FileName openFileName);
|
private static extern bool GetOpenFileName(ref FileName openFileName);
|
||||||
|
|
||||||
public static string ShowDialog(string filter, string dialogTitle)
|
public static string ShowDialog(IntPtr windowHandle, string filter, string dialogTitle)
|
||||||
{
|
{
|
||||||
FileName openFileName = default(FileName);
|
FileName openFileName = default(FileName);
|
||||||
openFileName.StructSize = Marshal.SizeOf(openFileName);
|
openFileName.StructSize = Marshal.SizeOf(openFileName);
|
||||||
|
|
||||||
|
openFileName.HwndOwner = windowHandle;
|
||||||
openFileName.Filter = filter;
|
openFileName.Filter = filter;
|
||||||
openFileName.File = new string(new char[256]);
|
openFileName.File = new string(new char[256]);
|
||||||
openFileName.MaxFile = openFileName.File.Length;
|
openFileName.MaxFile = openFileName.File.Length;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace RegistryPreview
|
namespace RegistryPreview
|
||||||
@@ -13,11 +14,12 @@ namespace RegistryPreview
|
|||||||
[DllImport("comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
[DllImport("comdlg32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
private static extern bool GetSaveFileName(ref FileName saveFileName);
|
private static extern bool GetSaveFileName(ref FileName saveFileName);
|
||||||
|
|
||||||
public static string ShowDialog(string suggestedFilename, string filter, string dialogTitle)
|
public static string ShowDialog(IntPtr windowHandle, string suggestedFilename, string filter, string dialogTitle)
|
||||||
{
|
{
|
||||||
FileName saveFileName = default(FileName);
|
FileName saveFileName = default(FileName);
|
||||||
saveFileName.StructSize = Marshal.SizeOf(saveFileName);
|
saveFileName.StructSize = Marshal.SizeOf(saveFileName);
|
||||||
|
|
||||||
|
saveFileName.HwndOwner = windowHandle;
|
||||||
saveFileName.Filter = filter;
|
saveFileName.Filter = filter;
|
||||||
saveFileName.File = new string(new char[256]);
|
saveFileName.File = new string(new char[256]);
|
||||||
saveFileName.MaxFile = saveFileName.File.Length;
|
saveFileName.MaxFile = saveFileName.File.Length;
|
||||||
|
|||||||
Reference in New Issue
Block a user