Windows API Reference

CreateWindowEx

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

  • dwExStyle
    [in] The extended window style. For a list of extended window styles, see Extended Window Styles.
  • lpClassName
    [in, optional] A pointer to a null-terminated string that specifies the window class name. For more information, see RegisterClassEx.
  • lpWindowName
    [in, optional] A pointer to a null-terminated string that specifies the text of the window.
  • dwStyle
    [in] The window style. For a list of values, see Window Styles.
  • x
    [in] The position of the window's left side, in screen coordinates.
  • y
    [in] The position of the window's top side, in screen coordinates.
  • nWidth
    [in] The width, in device units, of the window.
  • nHeight
    [in] The height, in device units, of the window.
  • hWndParent
    [in, optional] A handle to the parent window or owner window of the class being created. This parameter is required for child windows and owner-drawn buttons. If this parameter is NULL, the window will be a top-level window.
  • hMenu
    [in, optional] A handle to a menu, or a child-window identifier, depending on the window style. For a top-level window, the menu is specified by the hMenu parameter. For a child window, this parameter is the child-window identifier, an integer value greater than or equal to 0 when the child window will be used by the parent to identify the control. If this parameter is NULL, the window has no menu.
  • hInstance
    [in] A handle to the instance of the module that creates the window.
  • lpParam
    [in, optional] Pointer to a value to be passed to the window through WM_CREATE.

Return Value

If the function succeeds, the return value is a handle to the new window. If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The CreateWindowEx function creates an overlapping, pop-up, or child window. It determines its message table by registering a window class using the RegisterClassEx function.

CreateWindowEx also specifies the window that owns the current thread.

If the lpClassName parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function; the atom must be a local atom created by a previous call to the LocalAddAtom function.

If the lpClassName parameter is a string, it must be a pointer to a null-terminated string. It can be any registered class name or any of the system-defined component class names.