[Peek]Center Peek window on File Explorer activated monitor (#26349)

This commit is contained in:
Samuel Chapleau
2023-05-26 08:50:15 -07:00
committed by GitHub
parent d3b1c0a067
commit 6d676329ce
4 changed files with 50 additions and 17 deletions

View File

@@ -4,8 +4,10 @@
using System.Text;
using Peek.UI.Native;
using Windows.Foundation;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Gdi;
namespace Peek.UI.Extensions
{
@@ -47,5 +49,14 @@ namespace Peek.UI.Extensions
{
return PInvoke.FindWindowEx(windowHandle, HWND.Null, className, null);
}
internal static Size GetMonitorSize(this HWND hwnd)
{
var monitor = PInvoke.MonitorFromWindow(hwnd, MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
MONITORINFO info = default(MONITORINFO);
info.cbSize = 40;
PInvoke.GetMonitorInfo(monitor, ref info);
return new Size(info.rcMonitor.Size.Width, info.rcMonitor.Size.Height);
}
}
}