public void GetFormState(Form form) { WINDOWPLACEMENT wp = new WINDOWPLACEMENT(); wp.length = Marshal.SizeOf(wp); if (NativeMethods.GetWindowPlacement(form.Handle, ref wp)) { Location = wp.rcNormalPosition.Location; Size = wp.rcNormalPosition.Size; IsMaximized = wp.showCmd == WindowShowStyle.Maximize; } }
public static void RestoreWindow(IntPtr handle) { WINDOWPLACEMENT wp = new WINDOWPLACEMENT(); wp.length = Marshal.SizeOf(wp); GetWindowPlacement(handle, ref wp); if (wp.flags == (int)WindowPlacementFlags.WPF_RESTORETOMAXIMIZED) { wp.showCmd = WindowShowStyle.ShowMaximized; } else { wp.showCmd = WindowShowStyle.Restore; } SetWindowPlacement(handle, ref wp); }
public static bool IsWindowMaximized(IntPtr handle) { WINDOWPLACEMENT wp = new WINDOWPLACEMENT(); wp.length = Marshal.SizeOf(wp); GetWindowPlacement(handle, ref wp); return wp.showCmd == WindowShowStyle.Maximize; }
public static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);