public static Rectangle GetWindowRectangle(IntPtr handle, bool maximizeFix = true) { Rectangle rect = Rectangle.Empty; if (NativeMethods.IsDWMEnabled()) { Rectangle tempRect; if (NativeMethods.GetExtendedFrameBounds(handle, out tempRect)) { rect = tempRect; } } if (rect.IsEmpty) { rect = NativeMethods.GetWindowRect(handle); } if (maximizeFix && NativeMethods.IsZoomed(handle)) { rect = NativeMethods.MaximizedWindowFix(handle, rect); } return(rect); }
public static Rect GetWindowRectangle(IntPtr handle) { Rect rect = Rect.Empty; if (NativeMethods.IsDWMEnabled()) { Rect tempRect; if (NativeMethods.GetExtendedFrameBounds(handle, out tempRect)) { rect = tempRect; } } if (rect.IsEmpty) { rect = NativeMethods.GetWindowRect(handle); } if (!Helper.IsWindows10OrGreater() && NativeMethods.IsZoomed(handle)) { rect = NativeMethods.MaximizedWindowFix(handle, rect); } return(rect); }