CWnd::CreateEx
BOOLCreateEx(DWORDdwExStyle**,LPCTSTRlpszClassName,LPCTSTRlpszWindowName,DWORDdwStyle,intx,inty,intnWidth,intnHeight,HWNDhwndParent,HMENUnIDorHMenu,LPVOID**lpParam = NULL);
BOOL CreateEx(DWORD dwExStyle**, LPCTSTR** lpszClassName**, LPCTSTR** lpszWindowName**, DWORD** dwStyle**, const RECT&** rect**, CWnd*** pParentWnd**, UINT** nID**, LPVOID** lpParam = NULL);
Return Value
Nonzero if successful; otherwise 0.
Parameters
dwExStyle
Specifies the extended style of the CWnd being created. Apply any of the extended window styles to the window.
lpszClassName
Points to a null-terminated character string that names the Windows class (a 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.
lpszWindowName
Points to a null-terminated character string that contains the window name.
dwStyle
Specifies the window style attributes. See Window Styles and CWnd::Create for a description of the possible values.
x
Specifies the initial x-position of the CWnd window.
y
Specifies the initial top position of the CWnd window.
nWidth
Specifies the width (in device units) of the CWnd window.
nHeight
Specifies the height (in device units) of the CWnd window.
hwndParent
Identifies the parent or owner window of the CWnd window being created. Use NULL for top-level windows.
nIDorHMenu
Identifies a menu or a child-window identifier. The meaning depends on the style of the window.
lpParam
Points to the data referenced by the lpCreateParams field of the CREATESTRUCT structure.
rect
The size and position of the window, in client coordinates of pParentWnd.
pParentWnd
The parent window.
nID
The ID of the child window.
Remarks
Creates an overlapped, pop-up, or child window with the extended style specified in dwExStyle.
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.
Example
void CMyDlg::OnCreateExtendedCtrl()
{
CWnd* pWnd = new CStatic;
pWnd->CreateEx(WS_EX_CLIENTEDGE, // Make a client edge label.
_T("STATIC"), "Hi",
WS_CHILD | WS_TABSTOP | WS_VISIBLE,
5, 5, 30, 30, m_hWnd, (HMENU)1234);
}
CWnd Overview | Class Members | Hierarchy Chart
See Also CWnd::Create,