CreateWindowExA function (winuser.h)

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:

  • WS_EX_ACCEPTFILES
  • WS_EX_APPWINDOW
  • WS_EX_CLIENTEDGE
  • WS_EX_COMPOSITED
  • WS_EX_CONTEXTHELP
  • WS_EX_CONTROLPARENT
  • WS_EX_DLGMODALFRAME
  • WS_EX_FORMSIZED
  • WS_EX_LAYOUTRTL
  • WS_EX_LEFT
  • WS_EX_LEFTSCROLLBAR
  • WS_EX_MDICHILD
  • WS_EX_NOACTIVATE
  • WS_EX_NOINHERITцах
  • WS_EX_NOPARENTNOTIFY
  • WS_EX_NOREDIRECTBINARY
  • WS_EX_OVERLAPPEDWINDOW
  • WS_EX_PALETTEWINDOW
  • WS_EX_RIGHT
  • WS_EX_RTLREADING
  • WS_EX_STATICEDGE
  • WS_EX_TOOLWINDOW
  • WS_EX_TOPMOST
  • WS_EX_TRANSPARENT
  • WS_EX_WINDOWEDGE
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:

  • WS_BORDER
  • WS_CAPTION
  • WS_CHILD
  • WS_CLIPCHILDREN
  • WS_CLIPSIBLINGS
  • WS_DISABLED
  • WS_DLGFRAME
  • WS_GROUP
  • WS_HSCROLL
  • WS_ICONIC
  • WS_MAXIMIZE
  • WS_MAXIMIZEBOX
  • WS_MINIMIZE
  • WS_MINIMIZEBOX
  • WS_OVERLAPPED
  • WS_POPUP
  • WS_SIZEBOX
  • WS_SYSMENU
  • WS_TABSTOP
  • WS_THICKFRAME
  • WS_TILED
  • WS_TILEDWINDOW
  • WS_VISIBLE
  • WS_VSCROLL
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.

  • For a child window, hMenu is the child-window identifier, an integer value greater than 1. The application uses this identifier to identify the child window when processing messages from the child window.
  • For a pop-up window, hMenu is a handle to the pop-up menu to be associated with the window.
  • For an overlapping window, hMenu is ignored.
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