In my MDI project I have multiple Documents and Views. Based on the Document selected I want to change the Menu Bar. Is it possible to do this in the :
Code:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::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_MAINFRAME)) // Would like to change this to a
different ToolBar????
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
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: Delete these three lines if you don't want the toolbar to
// be dockable
//m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
//EnableDocking(CBRS_ALIGN_ANY);
//DockControlBar(&m_wndToolBar);
return 0;
}
or do I need to do it elsewhere? Any help would be greatly appreciated.
Thanks!
Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
OnCreate is the right place. BTW, did you say toolbar or menubar. Your code seems to be indicating a toolbar, while your question seems to be about menubar
Again my apologies, but I am hoping you might be able to shed a little more light on this subject. I have created the ToolBars in the OnCreateClient in CMainFrame. You said I could show/hide them based on a particular CChildFrame being activated is this correct? My question is do I access the tool bar created in CMainFrame or do I need to create a new one in the CChildFrame? If you could provide a sample it would be Greatly appreciate?
Thanks,
Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
See attached. It contains a sample MDI app with 2 document templates. The 2 templates differ in the framewindow class. ChildFrm and ChildFrm2.
1. ChildFrm when activated shall show toolbar1 and when deactivated shall hide toolbar1
2. ChildFrm2 when activated shall show toolbar2 and when deactivated shall hide toolbar2
Check out how WS_VISIBLE style is removed from the toolbar creation in mainfrm.cpp, and how ShowControlBar is used to show/hide individual toolbars in the same file
Thank You! That is exactly what I was looking for. This will allow me to finally finish this project with all of the functionality I wanted! Thanks for taking the time and effort to provide a small project that will save me hours of frustration! Have a Great Day!
Thanks,
Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.