Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Progress
Screencast - Getting to Know the Pipeline

971 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