title | author | date | CreateTime | categories |
---|---|---|---|---|
win10 uwp 获取窗口的坐标和宽度高度 |
lindexi |
2018-11-26 15:4:0 +0800 |
2018-11-26 09:49:58 +0800 |
Win10 UWP |
本文告诉大家几个方法在 UWP 获取窗口的坐标和宽度高度
获取可视范围
获取窗口的可视大小
Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().VisibleBounds
获取当前窗口的坐标和宽度高度
Window.Current.Bounds
获取最前窗口的范围
通过 Win32 的 Api 获取最前的窗口的范围
IntPtr hWID = GetForegroundWindow();
Rect rect;
Rect* ptr = ▭
GetWindowRect(GetForegroundWindow(), pAngle);
return rect;
[DllImport("user32.dll", CharSet = CharSet.Ansi)]
private static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Ansi)]
private unsafe static extern Boolean GetWindowRect(IntPtr intPtr, Rect* lpRect);
private struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
}