okg
asked on
How to dock mutiple toolbars in a row ?
Dear experts
I'm using VC++5.0 in WindowsNT4.0.
I'd like to dock mutiple toolbars in a row, i.e. top row.
I tried as following codes.
Where I created 4 toolbars.
As you see, my app has three mode(user interface is changed in each mode), and each mode has its toolbar. So the other toolbars are hided.
But one of four toolbars, m_wndCommonToolbar, is displayed in every mode.
Anyway, problem is they (i.e. anyone of mode toolbar and m_wndCommonToolbar) aren't docked in a row.
At start up, they(e.g. DesignToolbar and Common toolbar) has its own row. i.e. So, totally two rows.
Even I dragged they into a row, if I changed mode and come back, they (including status bar) are scattered again.
Any comments will be appreciated.
---- source code ------
int CMainFrame::OnCreate(LPCRE ATESTRUCT lpCreateStruct)
{
CWnd wnd;
WINDOWPLACEMENT windowInfo;
windowInfo.length = sizeof( WINDOWPLACEMENT );
windowInfo.showCmd = SW_HIDE;
if (CFrameWnd::OnCreate(lpCre ateStruct) == -1)
return -1;
SetWindowPos( &wnd, 0, 0, 1024, 768, 0 );
m_wndDesignToolBar.CreateT oolBar(thi s, IDR_MAINFRAME ); // CBRS_SIZE_DYNAMIC flag is set.
m_wndDesignToolBar.SetBarS tyle(m_wnd DesignTool Bar.GetBar Style() |
CBRS_TOOLTIPS | CBRS_FLYBY );
if (!m_wndPlayToolBar.Create( this) ||
!m_wndPlayToolBar.LoadTool Bar(IDR_TR ANSMITMENU ))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPlayToolBar.SetBarSty le(m_wndPl ayToolBar. GetBarStyl e() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
if (!m_wndMotionToolBar.Creat e(this) ||
!m_wndMotionToolBar.LoadTo olBar(IDR_ MOTION_MEN U))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndMotionToolBar.SetBarS tyle(m_wnd MotionTool Bar.GetBar Style() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
if(!m_wndCommonToolBar.Cre ate(this) ||
!m_wndCommonToolBar.LoadTo olBar(IDR_ COMMON_TOO LBAR))
{
TRACE0("Failed to create Common toolbar\n");
return -1; // fail to create
}
m_wndCommonToolBar.SetBarS tyle(m_wnd CommonTool Bar.GetBar Style() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
m_wndDesignToolBar.EnableD ocking(CBR S_ALIGN_TO P);
m_wndPlayToolBar.EnableDoc king(CBRS_ ALIGN_TOP) ;
m_wndMotionToolBar.EnableD ocking(CBR S_ALIGN_TO P);
m_wndCommonToolBar.EnableD ocking(CBR S_ALIGN_TO P);
EnableDocking(CBRS_ALIGN_T OP);
RecalcLayout();
CRect rtWnd;
m_wndDesignToolBar.GetWind owRect(rtW nd);
rtWnd.OffsetRect(0, -72);
DockControlBar(&m_wndDesig nToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
RecalcLayout();
m_wndCommonToolBar.GetWind owRect(rtW nd); // having 3 buttons
rtWnd.OffsetRect(950, 0);
DockControlBar(&m_wndCommo nToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
RecalcLayout();
m_wndPlayToolBar.GetWindow Rect(rtWnd );
// rtWnd.OffsetRect(0, 0);
DockControlBar(&m_wndPlayT oolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
RecalcLayout();
m_wndMotionToolBar.GetWind owRect(rtW nd);
// rtWnd.OffsetRect(0, 0);
DockControlBar(&m_wndMotio nToolBar, AFX_IDW_DOCKBAR_TOP, rtWnd);
RecalcLayout();
ShowControlBar(&m_wndCommo nToolBar, TRUE, FALSE);
ShowControlBar(&m_wndDesig nToolBar, TRUE, FALSE);
ShowControlBar(&m_wndMotio nToolBar, FALSE, FALSE);
ShowControlBar(&m_wndPlayT oolBar, FALSE, FALSE);
//
if (!m_wndStatusBar.Create(th is, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, ID_CG_STATUS_BAR ) ||
!m_wndStatusBar.SetIndicat ors(indica tors,
sizeof(indicators) / sizeof(UINT)) )
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
//
SetCursor( LoadCursor( NULL, IDC_ARROW ) );
return 0;
}
I'm using VC++5.0 in WindowsNT4.0.
I'd like to dock mutiple toolbars in a row, i.e. top row.
I tried as following codes.
Where I created 4 toolbars.
As you see, my app has three mode(user interface is changed in each mode), and each mode has its toolbar. So the other toolbars are hided.
But one of four toolbars, m_wndCommonToolbar, is displayed in every mode.
Anyway, problem is they (i.e. anyone of mode toolbar and m_wndCommonToolbar) aren't docked in a row.
At start up, they(e.g. DesignToolbar and Common toolbar) has its own row. i.e. So, totally two rows.
Even I dragged they into a row, if I changed mode and come back, they (including status bar) are scattered again.
Any comments will be appreciated.
---- source code ------
int CMainFrame::OnCreate(LPCRE
{
CWnd wnd;
WINDOWPLACEMENT windowInfo;
windowInfo.length = sizeof( WINDOWPLACEMENT );
windowInfo.showCmd = SW_HIDE;
if (CFrameWnd::OnCreate(lpCre
return -1;
SetWindowPos( &wnd, 0, 0, 1024, 768, 0 );
m_wndDesignToolBar.CreateT
m_wndDesignToolBar.SetBarS
CBRS_TOOLTIPS | CBRS_FLYBY );
if (!m_wndPlayToolBar.Create(
!m_wndPlayToolBar.LoadTool
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndPlayToolBar.SetBarSty
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
if (!m_wndMotionToolBar.Creat
!m_wndMotionToolBar.LoadTo
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndMotionToolBar.SetBarS
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
if(!m_wndCommonToolBar.Cre
!m_wndCommonToolBar.LoadTo
{
TRACE0("Failed to create Common toolbar\n");
return -1; // fail to create
}
m_wndCommonToolBar.SetBarS
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
m_wndDesignToolBar.EnableD
m_wndPlayToolBar.EnableDoc
m_wndMotionToolBar.EnableD
m_wndCommonToolBar.EnableD
EnableDocking(CBRS_ALIGN_T
RecalcLayout();
CRect rtWnd;
m_wndDesignToolBar.GetWind
rtWnd.OffsetRect(0, -72);
DockControlBar(&m_wndDesig
RecalcLayout();
m_wndCommonToolBar.GetWind
rtWnd.OffsetRect(950, 0);
DockControlBar(&m_wndCommo
RecalcLayout();
m_wndPlayToolBar.GetWindow
// rtWnd.OffsetRect(0, 0);
DockControlBar(&m_wndPlayT
RecalcLayout();
m_wndMotionToolBar.GetWind
// rtWnd.OffsetRect(0, 0);
DockControlBar(&m_wndMotio
RecalcLayout();
ShowControlBar(&m_wndCommo
ShowControlBar(&m_wndDesig
ShowControlBar(&m_wndMotio
ShowControlBar(&m_wndPlayT
//
if (!m_wndStatusBar.Create(th
!m_wndStatusBar.SetIndicat
sizeof(indicators) / sizeof(UINT)) )
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
//
SetCursor( LoadCursor( NULL, IDC_ARROW ) );
return 0;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.