示例#1
0
        /// <summary>
        /// Get the main window location for the process.
        /// </summary>
        /// <param name="process"> The process that contains the window. </param>
        /// <returns> The location of the window. </returns>
        public static Point GetWindowLocation(this Process process)
        {
            var p = NativeMethods.GetWindowPlacement(process.MainWindowHandle);
            var location = p.rcNormalPosition.Location;

            if (p.ShowState == 2 || p.ShowState == 3)
            {
                var windowsRect = new NativeMethods.Rect();
                NativeMethods.GetWindowRect(process.MainWindowHandle, out windowsRect);
                location = new Point(windowsRect.Left + 8, windowsRect.Top + 8);
            }

            return location;
        }
示例#2
0
 /// <summary>
 /// Gets the size of the main window for the process.
 /// </summary>
 /// <param name="process"> The process to size. </param>
 /// <returns> The size of the main window. </returns>
 public static Size GetWindowSize(this Process process)
 {
     var data = new NativeMethods.Rect();
     NativeMethods.GetWindowRect(process.MainWindowHandle, out data);
     return new Size(data.Right - data.Left, data.Bottom - data.Top);
 }