One-day training of Windows APIs (6) createwindow Function
Source: Internet
Author: User
To display a window, you must first create it. You need to call the API function createwindow. Therefore, you need to call the create Window Function in the second step after the window is registered.
The function declaration is as follows:
Winuserapi
Hwnd
Winapi
Createmediawexa (
_ In DWORD dwexstyle,
_ In_opt maid,
_ In_opt lpcstr lpwindowname,
_ In DWORD dwstyle,
_ In int X,
_ In int y,
_ In int nwidth,
_ In int nheight,
_ In_opt hwnd hwndparent,
_ In_opt hmenu,
_ In_opt hinstance,
_ In_opt lpvoid lpparam );
Winuserapi
Hwnd
Winapi
Createmediawexw (
_ In DWORD dwexstyle,
_ In_opt maid,
_ In_opt lpcwstr lpwindowname,
_ In DWORD dwstyle,
_ In int X,
_ In int y,
_ In int nwidth,
_ In int nheight,
_ In_opt hwnd hwndparent,
_ In_opt hmenu,
_ In_opt hinstance,
_ In_opt lpvoid lpparam );
# Ifdef Unicode
# Define createmediawex createmediawexw
# Else
# Define createmediawex createmediawexa
# Endif //! Unicode
DwexstyleIs an extended window type.
LpclassnameIs the registered window type name.
LpwindownameIs the window name.
DwstyleIs the window type.
XIs the position in the upper left corner of the window.
YIs the position in the upper left corner of the window.
NwidthIs the window width.
NheightIs the height of the window.
HwndparentIs the parent window.
HmenuIs the main menu.
HinstanceIs the application instance handle.
LpparamIs the custom parameter sent to the window.
An example of calling this function is as follows:
#001 //
#002 // function: initinstance (hinstance, INT)
#003 //
#004 // purpose: Save the program instance handle and display it in the create window.
#005 //
#006 // Cai junsheng 2007/07/12
#007 //
#008 bool initinstance (hinstance, int ncmdshow)
#009 {
#010 hwnd;
#011
#012 hinst = hinstance; // Save the instance handle to the global variable.
#013
#014 hwnd = createwindow (szwindowclass,
#015 sztitle,
#016 ws_overlappedwindow,
#017 cw_usedefault,
#018 0,
#019 cw_usedefault,
#020 0,
#021 null,
#022 null,
#023 hinstance,
#024 null );
#025
#026 if (! Hwnd)
#027 {
#028 return false;
#029}
#030
#031 showwindow (hwnd, ncmdshow );
#032 updatewindow (hwnd );
#033
#034 return true;
#035}
In row 14th, you can call the create window function. Szwindowclass is the name of the window registration, which has been described earlier.
The sztitle of Row 3 is the title displayed in the window.
Row 16th is the window display type.
Row 17th is the default coordinate in the upper left corner.
Rows 18th are the coordinates in the upper left corner of the window. Because the X coordinates are set to the default coordinates, all the values are ignored.
Row 19th sets the window width. Use the default value.
Row 3 ignores the window height.
Row 21st does not have a parent window.
There is no main menu in row 22nd.
Row 23rd is the handle of the current window instance.
Row 24th is the custom parameter passed to the window.
If the window is created successfully, the handle of the window is returned. Otherwise, a null value is returned.
With this setting, you can create various windows and change them as long as you like them.
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