Esempio n. 1
0
 public static WindowPlacement SaveWindowPlacement(Window window)
 {
     WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
     IntPtr hwnd = new WindowInteropHelper(window).Handle;
     GetWindowPlacement(hwnd, out wp);
     var p = new WindowPlacement();
     p.MinX = wp.minPosition.X;
     p.MinY = wp.minPosition.Y;
     p.MaxX = wp.maxPosition.X;
     p.MaxY = wp.maxPosition.Y;
     p.Left = wp.normalPosition.Left;
     p.Top = wp.normalPosition.Top;
     p.Right = wp.normalPosition.Right;
     p.Bottom = wp.normalPosition.Bottom;
     p.ShowMaximized = wp.showCmd == SW_SHOWMAXIMIZED;
     return p;
 }
Esempio n. 2
0
 public static void LoadWindowPlacement(Window window, WindowPlacement placement)
 {
     try
     {
         // Load window placement details for previous application session from application settings
         // Note - if window was closed on a monitor that is now disconnected from the computer,
         //        SetWindowPlacement will place the window onto a visible monitor.
         WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
         wp.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT));
         wp.flags = 0;
         var p = placement;
         wp.showCmd = p.ShowMaximized ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
         wp.minPosition = new POINT(p.MinX, p.MinY);
         wp.maxPosition = new POINT(p.MaxX, p.MaxY);
         wp.normalPosition = new RECT(p.Left, p.Top,
             p.Right, p.Bottom);
         IntPtr hwnd = new WindowInteropHelper(window).Handle;
         SetWindowPlacement(hwnd, ref wp);
     }
     catch { }
 }
Esempio n. 3
0
 static public void LoadWindowPlacement(Window window, WindowPlacement placement)
 {
     NativeMethods.LoadWindowPlacement(window, placement);
 }
Esempio n. 4
0
 public static extern bool GetWindowPlacement(IntPtr window, ref WindowPlacement position);
Esempio n. 5
0
 public static void LoadWindowPlacement(Window window, WindowPlacement placement)
 {
     NativeMethods.LoadWindowPlacement(window, placement);
 }