Tool bar alignment
Posted on 2001-08-09
In an Doc/View MFC application i have five toolbars .I want to align it one after another in an linear fashion below the Menu.I have created these toolbar as CBRS_ALIGN_ANY.I use the following logic
I have now five toolbar objects;
Now i call CMainFrame::PlaceControlBar() in the following order.
PlaceControlBar( NULL, &m_wndToolBar );
PlaceControlBar( &m_wndToolBar, &m_wndToolBar2 );
PlaceControlBar( &m_wndMapTool, &m_wndDateBar );
PlaceControlBar( &m_wndDateBar, &m_wndViewScale);
void CMainFrame::PlaceControlBar( CControlBar* pLast, CControlBar* pCurrent )
if( pLast == NULL )
DockControlBar(pCurrent, AFX_IDW_DOCKBAR_TOP, NULL );
ASSERT( pLast != NULL );
ASSERT( pCurrent != NULL );
// Toolbar placement forces non-client areas to overlap.
// Hence we use the client rectangle and not the window rectangle.
pLast->GetClientRect( &rcLast );
pLast->ClientToScreen( &rcLast );
CRect rcDock(rcLast.right, rcLast.top, rcLast.right+1, rcLast.top+1 );
DockControlBar(pCurrent, AFX_IDW_DOCKBAR_TOP, &rcDock );
now comming to the problem.Only the first three toolbars are aligned one after another in one line,but the next two toolbar is taking the place of next row even though there is enough space in first row.How to solve this problem?