Maximizing the minimum allowed function is the ShowWindow function
ShowWindow (sw_showminimized); // minimization of ShowWindow (sw_showmaximized); // maximized ShowWindow (Sw_restore); // restore ------- PostMessage (hwnd,wm_syscommand,sc_minimize,0); Sc_maximize to maximize.
How to use:
BOOL ShowWindow ( int ncmdshow ); The parameter nCmdShow specifies how CWnd will be displayed. it must be one of the following values: sw_hide hides the window and launches to another window. sw_minimize minimizes the window and activates the list of top-level windows in the system. Sw_restore activates and displays the window. If the window is minimized or maximized, Windows reverts to its original size and location. Sw_show Activates the window and displays its current size and position. sw_showmaximized Activates the window and displays it as a maximized window size. sw_showminimized Activates the window and displays it as an icon. sw_showminnoactive The display window as an icon. the currently active window remains in effect. Sw_showna Displays the window in its current state. the currently active window remains in effect. sw_shownoactivate Displays the window at its nearest size and location. the currently active window remains in effect. Sw_shownormal activates and displays the window.
The return value is nonzero, the window was previously visible,0
You can also use the message method to resolve:
PostMessage (hwnd,wm_syscommand,sc_maximize,0);
System message Command sc_maximize Minimize command
The HWND is the object to be manipulated!
The first method: using the SetWindowPos function
Cwnd::setwindowpos
BOOL SetWindowPos (const cwnd* pwndinsertafter, int x, int y, int cx, int cy,uint nflags);
return value if the function succeeds, it returns a value other than 0, otherwise 0 is returned.
Description
Call this member function to change the size, position, and Z-Order of the child window, pop-up window, and top-level window. The windows are sorted on the screen in their z-axis order. The window at the top of the z-axis order is the program at the top of all other windows. All coordinates of the child window are customer coordinates (relative to the upper-left corner of the client area of the parent window). The window can be moved to the top of the z-axis order, either by setting the pWndInsertAfter parameter to &wndtopmost and by making sure that the Swp_nozorder flag is not set, or by set the window's z-order so that it is above all existing top-level windows. When a non-top-level window is set to the top-level window, the window it owns is also set to the top level. Its owner does not change. If the top-level window is relocated to the bottom of the Z-order (&wndbottom) or any non-top-level window, it will no longer be the top-level window. When the When top layer window is turned into a non-top-level window, all its owners and all the windows it owns are turned into non-top-level windows. If neither the swp_noactive flag is specified nor the SWP_NOZORDER flag is specified (this means that the application requires that the window be activated simultaneously and placed in the specified z-order), the value specified in the pWndInsertAfter parameter will apply only in the following environments: l Neither &wndtopmost nor &wndnotopmost is specified in the pWndInsertAfter parameter.
This window is not an active window. The application cannot activate an inactive window but does not take it to the top of the z-axis order at the same time. The application can change the z-axis order of the active window without any restrictions. A non-top-level window may have a top-level window, but the reverse is not true. Any window owned by a top-level window, such as a dialog box, changes itself to a top-level window to ensure that all owned windows are located above their owners. In Windows 3.1 or later versions, you can move windows to the top of the z-axis order and lock them up by setting their ws_ex_topmost style. This top-level window maintains the top-level position even after it loses its active state. For example, selecting the Always on top command for WinHelp makes the Help window the top layer and remains visible after you return to the application. To create a top-level window, you should set the pWndInsertAfter parameter to &wndtopmost when calling SetWindowPos, or the ws_ex_topmost style when creating the window. If any of the Ws_ex_topmost-style windows are included in the z-order, the window that is moved with &wndtopmost will be placed at the top of all non-top-level windows, but below any top-level window. When an application activates an inactive window that does not have a ws_ex_topmost style, the window is moved above all non-top-level windows, but below all the top-level windows. If the pWndInsertAfter parameter is set to &wndbottom when calling SetWindowPos, and CWnd is a top-level window, the window loses its top state (Ws_ex_bottom style is cleared), And the System places the window at the bottom of the z-axis order.
Parameter pWndInsertAfter
The CWnd object that precedes the CWnd object in the Z-order is identified. This parameter can be a pointer to a CWnd object, or a pointer to the following values:
Wndbottom the window at the bottom of the z-axis order. If this CWnd is a top-level window, the window loses its top-level state; the System places the window at the bottom of all other windows.
Wndtop the window to the top of the z-axis order.
wndTopMost the window on top of all non-top-level windows. This window will hold its top-level position even if it loses its active state.
Wndnotopmost the window to the top of all non-top-level windows (which means under all top-level windows). This flag does not work for windows that are already non-top-level windows. See the Description section for the usage rules for this function and these parameters.
x Specifies the new position to the left of the window.
y Specifies the new position at the top of the window.
CX Specifies the new width of the window.
CY Specifies the new height of the window.
NFLAGS Specifies the size and location options. This parameter can be a combination of the following values:
Swp_drawframe draws a border around the window (defined when creating the window).
Swp_framechanged sends a WM_NCCALCSIZE message to the window, even if the size of the window does not change. If this flag is not specified, the Wm_nccalcsize message is sent only when the size of the window changes.
Swp_hidewindow hidden window.
Swp_noactivate does not activate the window. If this flag is not set, the window is activated and moved to the top or non-top-level window group (dependent on the setting of the pWndInsertAfter parameter).
Swp_nocopybits discards the content of this client area. If this parameter is not specified, the valid contents of the client area are saved and copied back to the customer area after the window's size or position is changed.
Swp_nomove maintains the current position (ignoring the x and Y parameters).
Swp_noownerzorder does not change the position of the owner window in the z-axis order.
Swp_noredraw does not redraw the change. If this flag is set, no change of any kind occurs. This applies to the customer area, the non-client area (including the title and scroll bar), and any part of the parent window that is covered by the moved window. When this flag is set, the application must explicitly invalidate or redraw any part of the window and the parent window to repaint.
Swp_noreposition is the same as Swp_noownerzorder.
Swp_nosendchanging prevents the window from receiving wm_windowposchanging messages.
Swp_nosize maintains the current size (ignoring the CX and CY parameters).
Swp_nozorder Keep the current order (ignore pWndInsertAfter).
Swp_showwindow display window.
========================================================================
Second approach: using the MoveWindow function
void Cwnd::movewindow (int x, int y, int nwidth, int nheight, BOOL brepaint = TRUE);
void Cwnd::movewindow (Lpcrect lpRect, BOOL brepaint = TRUE);
Parameters
x Specifies the new position to the left of CWnd.
y Specifies the new position at the top of the CWnd.
NWIDTH Specifies the new width of CWnd.
nheight specifies a new height for CWnd.
BREPAINT Specifies whether to repaint CWnd. If true, CWnd receives a WM_PAINT message in the OnPaint message handler function as usual. If this parameter is False, no redraw action of any kind will occur. This applies to the customer area, the non-client area (including the title bar and scroll bar), and any portion of the parent window that is exposed as a result of CWnd movement. When this parameter is false, the application must explicitly invalidate or redraw the parts of CWnd and the parent window that must be redrawn.
A Lprectcrect object or RECT structure that specifies the new size and position. Indicates that the function changes the position and size of the window. For the top-level CWnd object, the x and Y parameters are relative to the upper-left corner of the screen. For child objects, they are relative to the upper-left corner of the client area of the parent window.
The MoveWindow function sends a WM_GETMINMAXINFO message. When handling this message, CWnd gets an opportunity to change the maximum and minimum window default values. If the arguments passed to the MoveWindow member function exceed these values, the values can be substituted with the minimum or maximum values in the Wm_getminmaxinfo handler.
VC + + How to maximize or minimize the form