Partilhar via


CComboBox::Create

Creates the combo box and attaches it to the CComboBox object.

virtual BOOL Create(
   DWORD dwStyle,
   const RECT& rect,
   CWnd* pParentWnd,
   UINT nID 
);

Parameters

  • dwStyle
    Specifies the style of the combo box. Apply any combination of combo-box styles to the box.

  • rect
    Points to the position and size of the combo box. Can be a RECT structure or a CRect object.

  • pParentWnd
    Specifies the combo box's parent window (usually a CDialog). It must not be NULL.

  • nID
    Specifies the combo box's control ID.

Return Value

Nonzero if successful; otherwise 0.

Remarks

You construct a CComboBox object in two steps. First, call the constructor and then call Create, which creates the Windows combo box and attaches it to the CComboBox object.

When Create executes, Windows sends the WM_NCCREATE, WM_CREATE, WM_NCCALCSIZE, and WM_GETMINMAXINFO messages to the combo box.

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

Apply the following window styles to a combo-box control. :

  • WS_CHILD   Always

  • WS_VISIBLE   Usually

  • WS_DISABLED   Rarely

  • WS_VSCROLL   To add vertical scrolling for the list box in the combo box

  • WS_HSCROLL   To add horizontal scrolling for the list box in the combo box

  • WS_GROUP   To group controls

  • WS_TABSTOP   To include the combo box in the tabbing order

Example

m_pComboBox->Create(
   WS_CHILD|WS_VISIBLE|WS_VSCROLL|CBS_DROPDOWNLIST,
   CRect(10,10,200,100), pParentWnd, 1);

Requirements

Header: afxwin.h

See Also

Reference

CComboBox Class

Hierarchy Chart

CComboBox::CComboBox

Combo-Box Styles

Other Resources

CComboBox Members