44 lines
1.1 KiB
C#
44 lines
1.1 KiB
C#
using Microsoft.UI.Xaml;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace VDownload
|
|
{
|
|
public static partial class WindowHelper
|
|
{
|
|
#region PUBLIC METHODS
|
|
|
|
public static void ShowWindow(Window window)
|
|
{
|
|
// Bring the window to the foreground... first get the window handle...
|
|
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
|
|
|
|
// Restore window if minimized... requires DLL import above
|
|
ShowWindow(hwnd, 0x00000009);
|
|
|
|
// And call SetForegroundWindow... requires DLL import above
|
|
SetForegroundWindow(hwnd);
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region PRIVATE METHODS
|
|
|
|
[LibraryImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
private static partial bool ShowWindow(IntPtr hWnd, int nCmdShow);
|
|
|
|
[LibraryImport("user32.dll")]
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
private static partial bool SetForegroundWindow(IntPtr hWnd);
|
|
|
|
#endregion
|
|
}
|
|
}
|