Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-25
6
Medium Priority
?
567 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 35

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 35

Accepted Solution

by:
sarabande earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

722 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