Windows API one-day training (7) showwindow Function

Source: Internet
Author: User
The showwindow API function is a display window, but it is different in the first call and later call. During the first call, its input parameter ncmdshow is the ncmdshow parameter that needs to be input in the winmain function, rather than other parameters.
 
The function declaration is as follows:
Winuserapi
Bool
Winapi
Showwindow (
_ In hwnd,
_ In int ncmdshow );
HwndIs the handle of the window.
NcmdshowIs the status displayed in the window. The possible values are as follows:
Sw_forceminimize is used to minimize the number of forced windows. It is mainly used by other threads that are not the main thread of the window.
Sw_hide shows that the window is hidden.
Sw_maximize indicates that the display window is maximized.
Sw_minimize indicates that the display window is minimized.
Sw_restore is displayed in the recovery window from the task.
Sw_show indicates that the activation window is the current window and displayed as the current size and position.
Sw_showdefault is the window value displayed when the process is created.
Sw_showmaximized indicates that the activation window is the current window and the display is maximized.
Sw_showminimized indicates that the activation window is the current window and the display is minimized.
Sw_showminnoactive indicates that the display window is minimized, but is not activated as the current window.
Sw_showna is displayed as the current size and position, but is not activated as the current window.
Sw_shownoactivate displays the current window but does not activate it as the current window.
Sw_shownormal indicates that the current window is displayed, but the size and position of the window are restored when the window is minimized or maximized.
 
An example of calling this function is as follows:
#001 bool initinstance (hinstance, int ncmdshow)
#002 {
#003 hwnd;
#004
#005 hinst = hinstance; // Save the instance handle to the global variable.
#006
#007 hwnd = createwindow (szwindowclass,
#008 sztitle,
#009 ws_overlappedwindow,
#010 cw_usedefault,
#011 0,
#012 cw_usedefault,
#013 0,
#014 null,
#015 null,
#016 hinstance,
#017 null );
#018
#019 if (! Hwnd)
#020 {
#021 return false;
#022}
#023
#024 showwindow (hwnd, ncmdshow );
#025 updatewindow (hwnd );
#026
#027 //
#028 // Cai junsheng 2007/07/14
#029 // display window test.
#030 MessageBox (null, _ T ("maximize"), _ T ("test"), mb_ OK );
#031
#032 // the display window is maximized.
#033 showwindow (hwnd, sw_showmaximized );
#034
#035
#036 MessageBox (null, _ T ("original location"), _ T ("test"), mb_ OK );
#037
#038 // the original position of the display window is displayed.
#039 showwindow (hwnd, sw_shownormal );
#040
#041
#042 return true;
#043}
 
Call this function in row 24th to display the window status of the created process.
33rd the window displayed in the row is maximized.
The window is displayed as the original status in row 39th.
 
In this way, you can master the use of the showwindow function.
Related Article

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.