CToolBarCtrl::Create
BOOLCreate(DWORDdwStyle**,constRECT&rect,CWnd*pParentWnd,UINTnID);**
Return Value
Nonzero if successful; otherwise zero.
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 structure.
pParentWnd
Specifies the toolbar control’s parent window. It must not be NULL.
nID
Specifies the toolbar control’s ID.
Remarks
You construct a CToolBarCtrl in two steps. First call the constructor, then call Create, which creates the toolbar control and attaches it to the CToolBarCtrl object.
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.
Apply the following window styles to a toolbar control.
WS_CHILD Always
WS_VISIBLE Usually
WS_DISABLED Rarely
Next, you may want to apply one or more of the common control styles:
CCS_ADJUSTABLE Allows toolbars to be customized by the user. If this style is used, the toolbar’s owner window must handle the customization notification messages sent by the toolbar, as described in CToolBarCtrl: Handling Customization Notifications.
CCS_BOTTOM Causes the control to position itself at the bottom of the parent window’s client area and sets the width to be the same as the parent window’s width.
CCS_NODIVIDER Prevents a two-pixel highlight from being drawn at the top of the control.
CCS_NOHILITE Prevents a one-pixel highlight from being drawn at the top of the control.
CCS_NOMOVEY Causes the control to resize and move itself horizontally, but not vertically, in response to a WM_SIZE message. If the CCS_NORESIZE style is used, this style does not apply.
CCS_NOPARENTALIGN Prevents the control from automatically moving to the top or bottom of the parent window. Instead, the control keeps its position within the parent window despite changes to the size of the parent window. If the CCS_TOP or CCS_BOTTOM style is also used, the height is adjusted to the default, but the position and width remain unchanged.
CCS_NORESIZE Prevents the control from using the default width and height when setting its initial size or a new size. Instead, the control uses the width and height specified in the request for creation or sizing.
CCS_TOP Causes the control to position itself at the top of the parent window’s client area and sets the width to be the same as the parent window’s width. Toolbars have this style by default.
Finally, apply a combination of toolbar styles to either the control or the buttons themselves. The styles are described in the topic in the Platform SDK.
CToolBarCtrl Overview | Class Members | Hierarchy Chart
See Also CToolBarCtrl::CToolBarCtrl, CToolBarCtrl::SetButtonStructSize