Centerwindow () usage.

Source: Internet
Author: User
Centerwindow () is used as follows:
Void centerwindow (cwnd * palternateowner = NULL );
The palternateowner parameter points to the pointer of the window to be centered.
Then, use the getsystemmetrics (INT nindex) function to obtain the current system settings, such as screen resolution.
Nindexs = sm_cxscreen; Unit: pixel.
Nindexs = sm_cyscreen: the height of the screen returned by the function; Unit: pixel.
The function bool getwindowplacement (windowplacement * lpwndpl) is the most important. The parameter is a pointer to the Structure Variable windowplacement (lpwndpl). The data structure of the windowplacement structure variable is:
Typedef struct tagwindowplacement {/* wndpl */
Uint length;
Uint flags;
Uint showcmd;
Point ptminposition;
Point ptmaxposition;
Rect rcnormalposition;
} Windowplacement;
It contains the location information of the window on the screen. The member variables have the following meanings:
Length: the length of the structure variable, in bytes.
Flags: flag value. It is used to minimize the control window or restore the window. The following values can be taken:
Wpf_setminposition: Specifies the X position and Y position when the window is minimized.
Wpf_restoretomaximized: Specifies the window to be restored in the maximum mode, although the window may not be minimized in the maximum mode. The default Restore Mode of the window is not changed.
Showcmd: Specifies the current display status of the window. Optional values:
Sw_hide: Hide the window and activate another window.
Sw_minimize: minimizes the specified window and activates the top-level window in the system Window list.
Sw_restore: Activate and display the window. If the window is in the minimized or maximized state, the window is restored to the original size and position.
Sw_show: Activate and display the window with the current size and position of the window.
Sw_showmaximized: activates and displays a window in the maximum mode.
Sw_showminimized: activates and displays the window as an icon.
Sw_showminnoactive: the window is displayed as an icon. But does not change the window activity status.
Sw_showna: displays the window in the current status.
Sw_shownoactivate: displays the last window size and position. But does not change the active status of the window.
Sw_shownormal: activated and displayed in the window. If the window is maximized or minimized, the window is restored to the original size and position.
Ptminposition: Specify the coordinates of the left corner when the window is minimized.
Ptmaxposition: Specify the coordinates of the Left injury angle when the window is maximized.
Rcnormalposition: Specifies the coordinates of the window during restoration.
You can use the getwindowplacement () function to obtain window configuration information.
As you can see, some readers may have thought of the sister function setwindowplacement () of the getwindowplacement () function. Needless to say, its usage is as follows:
Bool setwindowplacement (windowplacement * lpwndpl );
Obviously, by using the setwindowplacement () function and simple calculation, we can set the position, size, and status of the window, this allows you to freely control whether the window is displayed or not, as well as the size and position of the window.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.