EDN Admin
Well-known member
I want creating a MDI project,which has"Tabbed documents", "a toobar in mainframe EnableDocking CBRS_ALIGN_ANY ",and"a toolbar in each childframe Docking CBRS_ALIGN_LEFT ".
When creating a MDI project, I choose"Tabbed documents" ,"use a menu bar and toolbar","user-defined toolbars and images","Personalized menu behavior".In MainFrame ,there is a toolbar, it is EnableDocking CBRS_ALIGN_ANY default.I want to creat a toolbar for each childframe.
So in ChildFrm.h,
I add code:
"
protected:
CMFCToolBar m_wndToolBar;
"
In ChindFrm.cpp
"
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_CHILDFRAME_256))
{
TRACE0("Failed to create toolbarn");
return -1; // fail to create
}
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY );
EnableDocking(CBRS_ALIGN_ANY );
DockPane(&m_wndToolBar);
// TODO: Add your specialized creation code here
return 0;
}
"
After debuging,the toolbar in mainframe can dock CBRS_ALIGN_ANY ,while the toolbar in childframe can not dock CBRS_ALIGN_ANY ,it isalways docking CBRS_ALIGN_TOP even I used
CBRS_ALIGN_LEFT in CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct).
However,when creating my project, I choose"using a classic menu" "use a classic docking menu",and the "Tabbed documents" is not supported in this way .
In MainFrm.h, CToolbar is used instead of CMFCToolbar.
In ChildFrm.h, I changed"CMFCToolBar m_wndToolBar;" with "CToolBar m_wndToolBar;"
In ChildFrm.cpp, I changed"DockPane(&m_wndToolBar)"with"DockControlBar(&m_wndToolBar);"
After debuging, the toolbar in chindframe can dock CBRS_ALIGN_ANY.
I also find when I use CMFCToolbar,the toolbar in mainframe and the toolbar in chindframe must have thesame colors ,Height,and width.
When the toolbar in mainframe with 256 colors, the childframe toolbar with 16 colors, the icons in childframe toolbar areinvisible.
When the toolbar in mainframe with height 15 and width 16,the childframe toolbar with height 24 and width 24, onlypart of icons(height 15,width 16) in childframe are visible.
How to make the Toolbar in chindframe docking CBRS_ALIGN_ANY when using CMFCToolBar?
Any suggestion will be appreciated!
View the full article
When creating a MDI project, I choose"Tabbed documents" ,"use a menu bar and toolbar","user-defined toolbars and images","Personalized menu behavior".In MainFrame ,there is a toolbar, it is EnableDocking CBRS_ALIGN_ANY default.I want to creat a toolbar for each childframe.
So in ChildFrm.h,
I add code:
"
protected:
CMFCToolBar m_wndToolBar;
"
In ChindFrm.cpp
"
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_CHILDFRAME_256))
{
TRACE0("Failed to create toolbarn");
return -1; // fail to create
}
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY );
EnableDocking(CBRS_ALIGN_ANY );
DockPane(&m_wndToolBar);
// TODO: Add your specialized creation code here
return 0;
}
"
After debuging,the toolbar in mainframe can dock CBRS_ALIGN_ANY ,while the toolbar in childframe can not dock CBRS_ALIGN_ANY ,it isalways docking CBRS_ALIGN_TOP even I used
CBRS_ALIGN_LEFT in CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct).
However,when creating my project, I choose"using a classic menu" "use a classic docking menu",and the "Tabbed documents" is not supported in this way .
In MainFrm.h, CToolbar is used instead of CMFCToolbar.
In ChildFrm.h, I changed"CMFCToolBar m_wndToolBar;" with "CToolBar m_wndToolBar;"
In ChildFrm.cpp, I changed"DockPane(&m_wndToolBar)"with"DockControlBar(&m_wndToolBar);"
After debuging, the toolbar in chindframe can dock CBRS_ALIGN_ANY.
I also find when I use CMFCToolbar,the toolbar in mainframe and the toolbar in chindframe must have thesame colors ,Height,and width.
When the toolbar in mainframe with 256 colors, the childframe toolbar with 16 colors, the icons in childframe toolbar areinvisible.
When the toolbar in mainframe with height 15 and width 16,the childframe toolbar with height 24 and width 24, onlypart of icons(height 15,width 16) in childframe are visible.
How to make the Toolbar in chindframe docking CBRS_ALIGN_ANY when using CMFCToolBar?
Any suggestion will be appreciated!
View the full article