public static System.Drawing.Size GetWindowSize(IntPtr hWnd) { NativeMethods.WindowRect rect = new NativeMethods.WindowRect(); if (!NativeMethods.GetWindowRect(hWnd, ref rect)) { throw new InvalidOperationException("Unable to get the size of the Window."); } return(new Size(rect.Right - rect.Left, rect.Bottom - rect.Top)); }
public static System.Drawing.Point GetWindowPosition(IntPtr hWnd) { NativeMethods.WindowRect rect = new NativeMethods.WindowRect(); if (!NativeMethods.GetWindowRect(hWnd, ref rect)) { throw new InvalidOperationException("Unable to get the position of the Window."); } return(new Point(rect.Top, rect.Left)); }