private void RestoreWindowPlacement(NativeMethods.WINDOWPLACEMENT?nwp) { if (nwp.HasValue) { // restore the placement of this window NativeMethods.WINDOWPLACEMENT wp = nwp.Value; wp.Length = Marshal.SizeOf(typeof(NativeMethods.WINDOWPLACEMENT)); wp.Flags = 0; wp.ShowCmd = (wp.ShowCmd == NativeMethods.SW_SHOWMINIMIZED ? NativeMethods.SW_SHOWNORMAL : wp.ShowCmd); IntPtr hwnd = new WindowInteropHelper(this).Handle; NativeMethods.SetWindowPlacement(hwnd, ref wp); } return; }
private NativeMethods.WINDOWPLACEMENT?GetWindowPlacement() { // get placement information of this window from Win32. NativeMethods.WINDOWPLACEMENT wp = new NativeMethods.WINDOWPLACEMENT(); wp.Length = Marshal.SizeOf(typeof(NativeMethods.WINDOWPLACEMENT)); IntPtr hwnd = new WindowInteropHelper(this).Handle; if (NativeMethods.GetWindowPlacement(hwnd, out wp)) { return(wp); } else { return(null); } }