Creates an overlapping, top-level window or a child window. Overlapping windows have a title bar and a border.
HWND CreateWindowExA(
DWORD dwExStyle,
LPCSTR lpClassName,
LPCSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
Syntax
#ifdef UNICODE
#define CreateWindowEx CreateWindowExW
#else
#define CreateWindowEx CreateWindowExA
#endif
HWND CreateWindowEx(
DWORD dwExStyle,
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);
Parameters
Parameter | Description |
---|---|
dwExStyle |
The extended window style. This parameter can be a combination of the following values:
|
lpClassName |
A pointer to a null-terminated string that specifies the window class. The class name must be the same as any class previously registered by calling the RegisterClass or RegisterClassEx function. |
lpWindowName |
A pointer to a null-terminated string that specifies the window text. |
dwStyle |
The window style. For a list of window styles, see Window Styles. This parameter can be a combination of the following values:
|
x |
The position of the window's left side, in screen coordinates. |
y |
The position of the window's top, in screen coordinates. |
nWidth |
The width, in screen coordinates, of the window. |
nHeight |
The height, in screen coordinates, of the window. |
hWndParent |
A handle to the parent window or owner window of the window being created. This parameter is required for child windows. For pop-up, overlapping, and top-level windows, this parameter can be NULL . |
hMenu |
A handle to a menu, or specifies a child-window identifier. The meaning depends on the type of window being created.
|
hInstance |
A handle to the instance of the module that creates the window. |
lpParam |
A pointer to a value of type WPARAM . This parameter is used to pass data to the newly created window. |
Return value
If the function fails, the return value is NULL .To get extended error information, call GetLastError. |
If the function succeeds, the return value is a handle to the new window. |
Remarks
If you are creating a child window, the dwExStyle
parameter can include WS_EX_NOPARENTNOTIFY
. If you do not include this flag, the parent window receives a WM_PARENTNOTIFY
message when the child window is created and destroyed.
The system automatically cleans up resources associated with a window when the window is destroyed. For example, the system automatically destroys the window's menu and menu items.
Note
The system forwards the WM_CREATE
message to the window procedure of the newly created window. The lpParam
parameter of WM_CREATE
is a pointer to a CREATESTRUCT
structure, which contains the parameters specified in the CreateWindowEx
function call. If the application creates a child window, it can use the lpParam
member of the CREATESTRUCT
structure to pass a pointer to a structure containing initialization data.
Tip
For overlapping windows, the system determines the window's default position and size if you specify CW_USEDEFAULT
for the x
, y
, nWidth
, and/or nHeight
parameters.
Requirements
Minimum supported client | Windows 2000 Professional |
Minimum supported server | Windows 2000 Server |
Header | winuser.h (include windows.h ) |
Library | User32.lib |
DLL | User32.dll |