I have a CToolBar object in a CWnd derived class. During the CWnd derived class's OnCreate member, I call the CToolBar's Create member (I used code similar to that in the MAINFRM.CPP file of an AppWizard-generated application). It looks like this:
// create button bar
if (!m_buttonBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS)
||!m_buttonBar.LoadBitmap(IDB_BUTT_BAR)
||!m_buttonBar.SetButtons(bButtons, sizeof(bButtons) / sizeof(UINT)))
{
TRACE0("Failed to create Button Bar\n");
return -1; // fail to create
}
The m_buttonBar object is a CToolBar object declared in the CWnd class header. I do not want the toolbar to be "dockable" or "floatable," so I removed the CBRS_FLYBY flag and do not call EnableDocking. The code appears to execute OK (there are no assertions), but the toolbar never appears!
You should probably set the size of the toolbar. By default the width and height are (0, 0) since the CFrameWnd class controls its size (see CWnd::MoveWindow).