다음을 통해 공유


CToolBarCtrl::Create

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

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

Parameters

  • dwStyle
    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.

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

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

  • nID
    Specifies the toolbar control's ID.

Return Value

Nonzero if successful; otherwise zero.

Remarks

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 Windows SDK for a description of window styles.

Optionally, apply a combination of common control styles, as described in the Windows 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 Windows 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.

Requirements

Header: afxcmn.h

See Also

Reference

CToolBarCtrl Class

Hierarchy Chart

CToolBarCtrl::CToolBarCtrl

CToolBarCtrl::SetButtonStructSize

Other Resources

CToolBarCtrl Members