CToolBar::CreateEx
BOOL CreateEx(CWnd* pParentWnd**, DWORD** dwCtrlStyle = TBSTYLE_FLAT, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect rcBorders = CRect(0, 0, 0, 0), UINT nID = AFX_IDW_TOOLBAR);
Return Value
Nonzero if successful; otherwise 0.
Parameters
pParentWnd
Pointer to the window that is the toolbar’s parent.
dwCtrlStyle
Additional styles for the creation of the embedded CToolBarCtrl object. By default, this value is set to TBSTYLE_FLAT. For a complete list of toolbar styles, see dwStyle.
dwStyle
The toolbar style. See Toolbar Control and Button Styles in the Platform SDK for a list of appropriate styles.
rcBorders
A CRect object that defines the widths of the toolbar window borders. These borders are set to 0,0,0,0 by default, thereby resulting in a toolbar window with no borders.
nID
The toolbar’s child-window ID.
Remarks
Call this function to create a Windows toolbar (a child window) and associate it with the CToolBar object. It also sets the toolbar height to a default value.
Use CreateEx, instead of Create, when certain styles need to be present during the creation of the embedded tool bar control. For example, set dwCtrlStyle to TBSTYLE_FLAT | TBSTYLE_TRANSPARENT to create a toolbar that resembles the Internet Explorer 4 toolbars.
Example
// This example demonstrates CToolBar::CreateEx by creating a
// toolbar as part of a child frame window. It also calls the
// LoadToolbar and EnableDocking functions
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndMyToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndMyToolBar.LoadToolBar(IDR_MYTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndMyToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMyToolBar);
return 0;
}