public static Rect GetWindowPlacement(this Window window)
 {
     var helper = new WindowInteropHelper(window);
     var wpl = new WINDOWPLACEMENT();
     wpl.length = Marshal.SizeOf(wpl);
     GetWindowPlacement((int)helper.Handle, ref wpl);
     return new Rect(wpl.rcNormalPosition.left, wpl.rcNormalPosition.top,
         wpl.rcNormalPosition.right - wpl.rcNormalPosition.left,
         wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top);
 }
 public static void SetWindowPlacement(this Window window, Rect placement)
 {
     var helper = new WindowInteropHelper(window);
     var wpl = new WINDOWPLACEMENT();
     wpl.length = Marshal.SizeOf(wpl);
     wpl.rcNormalPosition.left = (int)placement.Left;
     wpl.rcNormalPosition.right = (int)placement.Right;
     wpl.rcNormalPosition.top = (int)placement.Top;
     wpl.rcNormalPosition.bottom = (int)placement.Bottom;
     NativeMethods.SetWindowPlacement(helper.Handle, ref wpl);
 }
 public static Rect GetWindowPlacement(this Window window)
 {
     var helper = new WindowInteropHelper(window);
     var wpl = new WINDOWPLACEMENT();
     wpl.length = Marshal.SizeOf(wpl);
     NativeMethods.GetWindowPlacement(helper.Handle, ref wpl);
     var width = wpl.rcNormalPosition.right - wpl.rcNormalPosition.left;
     var height = wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top;
     return new Rect(wpl.rcNormalPosition.left, wpl.rcNormalPosition.top,
         width >= 0 ? width : 0,
         height >= 0 ? height : 0);
 }
Exemplo n.º 4
0
 internal extern static bool SetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpWndPl);
 extern static bool SetWindowPlacement(int hWnd, ref WINDOWPLACEMENT lpwndpl);