Share via


CEdit::Create

BOOLCreate(DWORDdwStyle**,constRECT&rect,CWnd*pParentWnd,UINTnID);**

Return Value

Nonzero if initialization is successful; otherwise 0.

Parameters

dwStyle

Specifies the edit control’s style. Apply any combination of edit styles to the control. 

rect

Specifies the edit control’s size and position. Can be a CRect object or RECT structure.

pParentWnd

Specifies the edit control’s parent window (usually a CDialog). It must not be NULL.

nID

Specifies the edit control’s ID.

Remarks

You construct a CEdit object in two steps. First, call the CEdit constructor, then call Create, which creates the Windows edit control and attaches it to the CEdit object.

When Create executes, Windows sends the , , , and messages to the edit control.

These messages are handled by default by the OnNcCreate, OnNcCalcSize, OnCreate, and OnGetMinMaxInfo member functions in the CWnd base class. To extend the default message handling, derive a class from CEdit, add a message map to the new class, and override the above message-handler member functions. Override OnCreate, for example, to perform needed initialization for the new class.

Apply the following window styles to an edit control. 

  • WS_CHILD   Always

  • WS_VISIBLE   Usually

  • WS_DISABLED   Rarely

  • WS_GROUP   To group controls

  • WS_TABSTOP   To include edit control in the tabbing order

Example

void CMyView::OnInitialUpdate()
{
   CView::OnInitialUpdate();

   // dynamically create an edit control on the view
   CEdit* pEdit = new CEdit;
   pEdit->Create(ES_MULTILINE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
      CRect(10, 10, 100, 100), this, 1);
}

CEdit OverviewClass MembersHierarchy Chart

See Also   CEdit::CEdit