Share via


CWnd::Create

virtualBOOLCreate(LPCTSTRlpszClassName**,LPCTSTRlpszWindowName,DWORDdwStyle,constRECT&rect,CWnd*pParentWnd,UINTnID,CCreateContext*** pContext = NULL);

Return Value

Nonzero if successful; otherwise 0.

Parameters

lpszClassName

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. If NULL, uses the default CWnd attributes.

lpszWindowName

Points to a null-terminated character string that contains the window name.

dwStyle

Specifies the window style attributes.  WS_POPUP cannot be used. If you wish to create a pop-up window, use CWnd::CreateEx instead.

rect

The size and position of the window, in client coordinates of pParentWnd.

pParentWnd

The parent window.

nID

The ID of the child window.

pContext

The create context of the window.

Remarks

Creates a Windows child window and attaches it to the CWnd object.

You construct a child window in two steps. First, call the constructor, which constructs the CWnd object. Then call Create, which creates the Windows child window and attaches it to CWnd. Create initializes the window’s class name and window name and registers values for its style, parent, and ID.

Example

// Dynamically create static control using CWnd::Create,
// instead of with CStatic::Create, which doesn't
// need the "STATIC" class name.

void CMyDlg::OnCreateStatic()
{
   CWnd* pWnd = new CWnd;
   pWnd->Create(_T("STATIC"), "Hi", WS_CHILD | WS_VISIBLE,
       CRect(0, 0, 20, 20), this, 1234);
}

CWnd OverviewClass MembersHierarchy Chart

See Also   CWnd::CWnd, CWnd::CreateEx