mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-10 05:06:36 +02:00
[KBM] move interop methods to dedicated class (#10958)
This commit is contained in:
@@ -13,5 +13,16 @@ namespace Microsoft.PowerToys.Settings.UI.Library.Utilities
|
|||||||
{
|
{
|
||||||
[DllImport("user32.dll")]
|
[DllImport("user32.dll")]
|
||||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||||
|
|
||||||
|
public const int SWRESTORE = 9;
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
||||||
|
public static extern bool SetForegroundWindow(IntPtr handle);
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
||||||
|
public static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
||||||
|
|
||||||
|
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
||||||
|
public static extern bool IsIconic(IntPtr handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,27 +192,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
IntPtr handle = process.MainWindowHandle;
|
IntPtr handle = process.MainWindowHandle;
|
||||||
if (IsIconic(handle))
|
if (NativeMethods.IsIconic(handle))
|
||||||
{
|
{
|
||||||
ShowWindow(handle, SWRESTORE);
|
NativeMethods.ShowWindow(handle, NativeMethods.SWRESTORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetForegroundWindow(handle);
|
NativeMethods.SetForegroundWindow(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int SWRESTORE = 9;
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
|
||||||
private static extern bool SetForegroundWindow(IntPtr handle);
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
|
||||||
|
|
||||||
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
|
||||||
|
|
||||||
[System.Runtime.InteropServices.DllImport("User32.dll")]
|
|
||||||
|
|
||||||
private static extern bool IsIconic(IntPtr handle);
|
|
||||||
|
|
||||||
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions here (especially mutex errors) should not halt app execution, but they will be logged.")]
|
[SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Exceptions here (especially mutex errors) should not halt app execution, but they will be logged.")]
|
||||||
private void OpenEditor(int type)
|
private void OpenEditor(int type)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user