Example #1
0
        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;
            }
        }
Example #2
0
        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);
        }
Example #3
0
 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 GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
Example #5
0
 public static extern bool SetWindowPlacement(IntPtr hWnd, [In] ref WINDOWPLACEMENT lpwndpl);
        public static void RestoreWindow(IntPtr handle)
        {
            WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
            GetWindowPlacement(handle, ref wp);

            if (wp.flags == (int)WindowPlacementFlags.WPF_RESTORETOMAXIMIZED)
            {
                wp.showCmd = (int)SHOWWINDOW.SW_SHOWMAXIMIZED;
            }
            else
            {
                wp.showCmd = (int)SHOWWINDOW.SW_RESTORE;
            }

            SetWindowPlacement(handle, ref wp);
        }
 public static bool IsWindowMaximized(IntPtr handle)
 {
     WINDOWPLACEMENT wp = new WINDOWPLACEMENT();
     GetWindowPlacement(handle, ref wp);
     return wp.showCmd == (int)SHOWWINDOW.SW_MAXIMIZE;
 }