When using the ShowWindow method to set the state of the form, because you do not know the parameter value, it is very easy to use confusion, so the following parameters of the enumeration values, convenient for later use.
Public classUser32api {#regionShowWindow parameter enumeration for method form state/// <summary> ///hide windows and activate other Windows/// </summary> Public Const intSw_hide =0; /// <summary> ///activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and size. The application should specify this flag the first time the window is displayed/// </summary> Public Const intSw_shownormal =1; /// <summary> ///activates the window and minimizes it/// </summary> Public Const intsw_showminimized =2;
/// <summary> ///activates the window and maximizes it/// </summary> Public Const intsw_showmaximized =3; /// <summary> ///Displays the window with the last size and status of the window. This value is similar to Sw_shownormal, except that the window is not activated/// </summary> Public Const intSw_shownoactivate =4; /// <summary> ///activates and displays the window in its original position in its original size/// </summary> Public Const intSw_show =5; /// <summary> ///minimizes the specified window and activates the Next top-level window in the Z-order/// </summary> Public Const intSw_minimize =6; /// <summary> ///The minimized way to display the window, this value is similar to sw_showminimized, except that the window is not activated/// </summary> Public Const intSw_showminnoactive =7; /// <summary> ///Displays the window in its original state. This value is similar to Sw_show, except that the window is not activated/// </summary> Public Const intSw_showna =8; /// <summary> ///activates and displays the window. If the window is minimized or maximized, the system restores the window to its original size and position. The application should specify this flag when the minimized window is restored/// </summary> Public Const intSw_restore =9; /// <summary> ///The display state is set according to the SW_FLAG flag specified in the STARTUPINFO structure, which is passed to the CreateProcess function by the program that initiated the application ./// </summary> Public Const intSw_showdefault =Ten; /// <summary> ///minimizes the window, even if the thread that owns the window is suspended. Use this parameter when minimizing windows from other threads/// </summary> Public Const intSw_forceminimize = One; #endregion[DllImport ("user32.dll", EntryPoint ="ShowWindow")] Public Static extern BOOLShowWindow (inthwndintncmdshow); }
Call the ShowWindow method in WPF:
User32api.showwindow (new System.Windows.Interop.WindowInteropHelper (this). Handle.toint32 (), user32api.sw_hide)
The "This" here refers to the current window.
ShowWindow method parameter collation in the User32.dll in the Win32 API