Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize


Creates an overlapped, pop-up, or child window with the extended style specified in dwExStyle.

virtual BOOL CreateEx(
   DWORD dwExStyle,
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName,
   DWORD dwStyle,
   int x,
   int y,
   int nWidth,
   int nHeight,
   HWND hWndParent,
   HMENU nIDorHMenu,
   LPVOID lpParam = NULL 
virtual BOOL CreateEx(
   DWORD dwExStyle,
   LPCTSTR lpszClassName,
   LPCTSTR lpszWindowName,
   DWORD dwStyle,
   const RECT& rect,
   CWnd* pParentWnd,
   UINT nID,
   LPVOID lpParam = NULL


Specifies the extended style of the CWnd being created. Apply any of the extended window styles to the window.
Points to a null-terminated character string that names the Windows class (a WNDCLASS structure). The class name can be any name registered with the global AfxRegisterWndClass function or any of the predefined control-class names. It must not be NULL.
Points to a null-terminated character string that contains the window name.
Specifies the window style attributes. See Window Styles and CWnd::Create for a description of the possible values.
Specifies the initial x-position of the CWnd window.
Specifies the initial top position of the CWnd window.
Specifies the width (in device units) of the CWnd window.
Specifies the height (in device units) of the CWnd window.
Identifies the parent or owner window of the CWnd window being created. Use NULL for top-level windows.
Identifies a menu or a child-window identifier. The meaning depends on the style of the window.
Points to the data referenced by the lpCreateParams field of the CREATESTRUCT structure.
The size and position of the window, in client coordinates of pParentWnd.
The parent window.
The ID of the child window.

Return Value

Nonzero if successful; otherwise 0.


The CreateEx parameters specify the WNDCLASS, window title, window style, and (optionally) initial position and size of the window. CreateEx also specifies the window's parent (if any) and ID.

When CreateEx executes, Windows sends the WM_GETMINMAXINFO, WM_NCCREATE, WM_NCCALCSIZE, and WM_CREATE messages to the window.

To extend the default message handling, derive a class from CWnd, add a message map to the new class, and provide member functions for the above messages. Override OnCreate, for example, to perform needed initialization for a new class.

Override further OnMessage message handlers to add further functionality to your derived class.

If the WS_VISIBLE style is given, Windows sends the window all the messages required to activate and show the window. If the window style specifies a title bar, the window title pointed to by the lpszWindowName parameter is displayed in the title bar.

The dwStyle parameter can be any combination of window styles.


void CMyDlg::OnCreateExtendedCtrl() 
   CWnd* pWnd = new CStatic;
   pWnd->CreateEx(WS_EX_CLIENTEDGE, // Make a client edge label.
      _T("STATIC"), "Hi",
      5, 5, 30, 30, m_hWnd, (HMENU)1234);

See Also

CWnd Overview | Class Members | Hierarchy Chart | CWnd::Create | CreateWindowEx

© 2015 Microsoft