示例#1
0
 public static void PutWindowOnTop(IntPtr window)
 {
     // Set window as topmost
     ExternDLLUtilities.SetWindowPos(window, new IntPtr(-1), 0, 0, 0, 0, (uint)(PositioningFlags.SWP_NOSIZE | PositioningFlags.SWP_DRAWFRAME | PositioningFlags.SWP_SHOWWINDOW));
     // Reset window as non-topmost so it stays on top but does not stay on top when non activate
     ExternDLLUtilities.SetWindowPos(window, new IntPtr(-2), 0, 0, 0, 0, (uint)(PositioningFlags.SWP_NOSIZE | PositioningFlags.SWP_DRAWFRAME | PositioningFlags.SWP_SHOWWINDOW));
 }
示例#2
0
        public static WindowPosition GetWindowPosition(IntPtr window)
        {
            var rect = new Rect();

            ExternDLLUtilities.GetWindowRect(window, ref rect);
            return(new WindowPosition(rect, GetScalingFactor()));
        }
示例#3
0
        private static float GetScalingFactor()
        {
            Graphics g                    = Graphics.FromHwnd(IntPtr.Zero);
            IntPtr   desktop              = g.GetHdc();
            var      logicalScreenHeight  = ExternDLLUtilities.GetDeviceCaps(desktop, (int)DeviceCap.VERTRES);
            var      physicalScreenHeight = ExternDLLUtilities.GetDeviceCaps(desktop, (int)DeviceCap.DESKTOPVERTRES);

            return(physicalScreenHeight / (float)logicalScreenHeight);
        }
示例#4
0
        public static string GetClassName(IntPtr window)
        {
            // Pre-allocate 256 characters, since this is the maximum class name length.
            var className = new StringBuilder(256);
            //Get the window class name
            var nRet = ExternDLLUtilities.GetClassName(window, className, className.Capacity);

            return(nRet != 0 ? className.ToString() : "No Class Name");
        }
示例#5
0
        /// <summary>
        /// returns width as item 1 and height as item 2
        /// </summary>
        /// <returns></returns>
        public static Tuple <int, int> GetApplicationSize(IntPtr window)
        {
            var rect = new Rect();

            ExternDLLUtilities.GetWindowRect(window, ref rect);
            var windowPosition = new WindowPosition(rect, GetScalingFactor());

            Logger.Info(windowPosition);
            return(new Tuple <int, int>(windowPosition.Width, windowPosition.Height));
        }