HWND CreateWindowEx(dwExStyle, lpszClassName, lpszWindowName, dwStyle, x, y, nWidth, nHeight, hwndParent, hmenu, hinst, lpvCreateParams) | |||||
DWORD dwExStyle; | /* extended window style | */ | |||
LPCSTR lpszClassName; | /* address of registered class name | */ | |||
LPCSTR lpszWindowName; | /* address of window text | */ | |||
DWORD dwStyle; | /* window style, */ | ||||
int x; | /* horizontal position of the window | */ | |||
int y; | /* vertical position of the window | */ | |||
int nWidth; | /* window width, */ | ||||
int nHeight; | /* window height, */ | ||||
HWND hwndParent; | /* handle of parent window | */ | |||
HMENU hmenu; | /* handle of menu or child-window identifier | */ | |||
HINSTANCE hinst; | /* handle of application instance | */ | |||
void FAR* lpvCreateParams; | /* address of window-creation data | */ |
The CreateWindowEx function creates an overlapped, pop-up, or child window with an extended style; otherwise, this function is identical to the CreateWindow function. For more information about creating a window and for full descriptions of the other parameters of CreateWindowEx, see the preceding description of the CreateWindow function.
dwExStyle
Specifies the extended style of the window. This parameter can be one of the following values:
Style | Meaning |
WS_EX_ACCEPTFILES | Specifies that a window created with this style accepts drag-drop files. |
WS_EX_DLGMODALFRAME | Designates a window with a double border that may (optionally) be created with a title bar by specifying the WS_CAPTION style flag in the dwStyle parameter. |
WS_EX_NOPARENTNOTIFY | Specifies that a child window created by using this style will not send the WM_PARENTNOTIFY message to its parent window when the child window is created or destroyed. |
WS_EX_TOPMOST | Specifies that a window created with this style should be placed above all non-topmost windows and stay above them even when the window is deactivated. An application can use the SetWindowPos function to add or remove this attribute. |
WS_EX_TRANSPARENT | Specifies that a window created with this style is to be transparent. That is, any windows that are beneath the window are not obscured by the window. A window created with this style receives WM_PAINT messages only after all sibling windows beneath it have been updated. |
lpszClassName
Points to a null-terminated string containing the name of the window class.
lpszWindowName
Points to a null-terminated string containing the name of the window.
dwStyle
Specifies the style of the window. For a list of the window styles that can be specified in this parameter, see the preceding description of the CreateWindow function.
x
Specifies the initial left-side position of the window.
y
Specifies the initial top position of the window.
nWidth
Specifies the width, in device units, of the window.
nHeight
Specifies the height, in device units, of the window.
hwndParent
Identifies the parent or owner window of the window to be created.
hmenu
Identifies a menu or a child window. The meaning depends on the window style.
hinst
Identifies the instance of the module to be associated with the window.
lpvCreateParams
Contains any application-specific creation parameters. The window being created may access this data when the CREATESTRUCT structure is passed to the window by the WM_NCCREATE and WM_CREATE messages.
The CREATESTRUCT structure has the following form:
typedef struct tagCREATESTRUCT { /* cs */
void FAR* lpCreateParams;
HINSTANCE hInstance;
HMENU hMenu;
HWND hwndParent;
int cy;
int cx;
int y;
int x;
LONG style;
LPCSTR lpszName;
LPCSTR lpszClass;
DWORD dwExStyle;
} CREATESTRUCT;
For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.
The return value identifies the new window if the function is successful. Otherwise, it is NULL.
The CreateWindowEx function sends the following messages to the window being created:
WM_NCCREATE
WM_NCCALCSIZE
WM_CREATE
The following example creates a main window that has the WS_EX_TOPMOST extended style, makes the window visible, and updates the window's client area:
char szClassName[] = "MyClass";
/* Create the main window. */
hwnd = CreateWindowEx(WS_EX_TOPMOST, szClassName, "Grouper",
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
hinst, NULL);
/* Make the window visible and update its client area. */
ShowWindow(hwnd, SW_SHOW); /* always show the window */
UpdateWindow(hwnd);