zoukankan      html  css  js  c++  java
  • 2018-11-26-win10-uwp-获取窗口的坐标和宽度高度

    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;
    }
  • 相关阅读:
    Redis事务和锁
    11/6笔记 补充(Redis持久化,RDB&&AOF)
    11/6随笔
    Redis 安装教程
    Redis通用指令和第一个Jedis程序的实现
    Redis学习第二天
    SpringBoot学习笔记
    1000行代码手写服务器
    log4j创建实例异常
    寒假阅读人月神话3
  • 原文地址:https://www.cnblogs.com/lindexi/p/12085788.html
Copyright © 2011-2022 走看看