Solved

VS2010 C++ MDI with two sets of toolbar and menus

Posted on 2011-02-25
6
562 Views
Last Modified: 2012-05-11
I am looking for an example program that has the following:

VS2010 C++ MDI program with two different kind of child windows: Child1 and Child2
Each child window has its own toolbar and  menu set
File/NEW1 will create the Child1 with toolbar1 with menu1
File/NEW2 will create the Child2 with toolbar2 with menu2

Because VS2010 MDI project always creates one set of window with toolbar. I have a hard time figuring out how to add an additional different child window with different toolbar.  

Thanks.
0
Comment
Question by:BaritoneH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 11

Expert Comment

by:cup
ID: 34985938
What type of project is it?  VS can generate forms for different project types.  The ones I know of are

unmanaged SDK
MFC
WTL
managed Winforms stuff
0
 

Author Comment

by:BaritoneH
ID: 34986392
The project is C++ with MFC. Just the basic MFC, nothing extra.
0
 
LVL 34

Expert Comment

by:sarabande
ID: 34998160
an MDI app is a multi-document application what means that you would need to add a second doument class to the project.

in InitInstance of your application class you would create an additional triple of document, frame and view:

    m_pTemplate1 = new CMultiDocTemplate(
        IDR_FIRST,
        RUNTIME_CLASS(CMyDoc1),
        RUNTIME_CLASS(CMyChildFrame),        // standard MDI child frame
        RUNTIME_CLASS(CMyView1));
    AddDocTemplate(m_pTemplate1);
                                                                                               
    m_pTemplate2 = new CMultiDocTemplate(
        IDR_SECOND,
        RUNTIME_CLASS(CMyDoc2),
        RUNTIME_CLASS(CMyChildFrame),        // standard MDI child frame
        RUNTIME_CLASS(CView2));
    AddDocTemplate(m_pTemplate2);

The IDR_FIRST and IDR_SECOND are resource ids where you bind the menu and toolbar.

Sara
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

Author Comment

by:BaritoneH
ID: 34999319
Thanks for the note.

I created an example MFC MDI project in VS2010 and then I add two classes CDoc2 and CView2. Duplicated the menu1 and toolbar1 to menu2 and toolbar2. Initialized the m_pTemplate2.  I can switch the menu, but I am still having trouble switching the toolbar in CView2.  Do I need to do anything about the m_wndTooBar?

The m_wndToolBar was created in the MainFrm::OnCreate.  Does it need to be assigned to different toolbar in ChildFrame?  It would be great if I can get a working examples. Thanks.
0
 
LVL 34

Accepted Solution

by:
sarabande earned 500 total points
ID: 34999457
yes, the toolbar 'normally' isn't supposed to change but only the menus.

but you could make two 'mdichildwnd' frame classes where each of them installs an own toolbar (exactly removes or minimizes current toolbar and restores or creates new toolbar).

you also could use mainframe to take the switch. add a second member m_wndToolBar2 and create it using the second resource but not show it.  then when the menu was switched call a new member function of CMainFrame which would exchange the toolbars. you can access CMainFrame object from everywhere for example by

  ((CMainFrame*)AfxGetMainWnd())->switchToolbar(2);

if you would use two frame classes you would install the proper toolbar when the frame was activated and the OnInitialUpdate override was called.

Sara
0
 

Author Closing Comment

by:BaritoneH
ID: 35001304
Thanks for the help!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question