This documentation is archived and is not being maintained.


Creates a toolbar control and attaches it to a CToolBarCtrl object.

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



Specifies the toolbar control's style. Toolbars must always have the WS_CHILD style. In addition, you can specify any combination of toolbar styles and window styles as described under Remarks.


Optionally specifies the toolbar control's size and position. It can be either a CRect object or a RECT structure.


Specifies the toolbar control's parent window. It must not be NULL.


Specifies the toolbar control's ID.

Nonzero if successful; otherwise zero.

You construct a CToolBarCtrl in two steps. First, call the constructor, and then call Create, which creates the toolbar control and attaches it to the CToolBarCtrl object. Apply the following window styles to a toolbar control.

  • WS_CHILD   Always

  • WS_VISIBLE   Usually

  • WS_DISABLED   Rarely

See CreateWindow in the Platform SDK for a description of window styles.

Optionally, apply a combination of common control styles, as described in the Platform SDK.

Apply a combination of toolbar styles to either the control or the buttons themselves. The styles are described in the topic Toolbar Control and Button Styles in the Platform SDK.

To use extended toolbar styles, call SetExtendedStyle after you call Create. To create a toolbar with extended window styles, call CToolBarCtrl::CreateEx instead of Create.

The toolbar control automatically sets the size and position of the toolbar window. The height is based on the height of the buttons in the toolbar. The width is the same as the width of the parent window's client area. The CCS_TOP and CCS_BOTTOM styles determine whether the toolbar is positioned along the top or bottom of the client area. By default, a toolbar has the CCS_TOP style.