Every time i wanna float my newly added toolbar, i just can't because i've got
a CRASH message Debug assertion fail. My member var for the toolbar is m_wndControlBar of type CToolBar linked to the resource toolbar IDR_CONTROLTOOLBAR. The codes from mainfrm.cpp and mainfrm.h are below. Please can you tell me what's wrong
---->MainFrm.cpp<----
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndDlgBar.Create(this, IDR_MAINFRAME,
CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
{
TRACE0("Failed to create dialogbar\n");
return -1; // fail to create
}
if (!m_wndReBar.Create(this) ||
!m_wndReBar.AddBar(&m_wndToolBar) ||
!m_wndReBar.AddBar(&m_wndDlgBar))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
//New toolbar (controls) is added here
if(!m_wndControlBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD |
WS_VISIBLE | CBRS_GRIPPER |CBRS_TOP | CBRS_TOOLTIPS |
CBRS_FLYBY | CBRS_SIZE_DYNAMIC | CBRS_FLOAT_MULTI) ||
!m_wndControlBar.LoadToolBar(IDR_CONTROLTOOLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
//end adding toolbar
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// TODO: Remove this if you don't want tool tips
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY);
//Float the toolbar
FloatControlBar(m_wndControlBar, CPoint(4, 4), CBRS_ALIGN_TOP);
return 0;
}
and the declaration for the m_wndControlBar
----->MainFrm.h<-----
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CReBar m_wndReBar;
CDialogBar m_wndDlgBar;
CToolBar m_wndControlBar;