This documentation is archived and is not being maintained.


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

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



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


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


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


Specifies the combo box's control ID.

Nonzero if successful; otherwise 0.

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

// pParentWnd is an external pointer to the parent window.
extern CWnd* pParentWnd;
// The pointer to my combo box.
extern CComboBox* pmyComboBox;

      CRect(10,10,200,100), pParentWnd, 1);