Solved

Retaining the application menu when closing the last child window

Posted on 1998-08-26
7
177 Views
Last Modified: 2013-11-19
I have an application whose data is in a file, which is represented in a explorer-like UI(a tree control on the left and a corresponding list control on the right, depending on the selected item in the tree control). I have the two standard menus, IDR_MAINFRAME and IDR_APPTYPE. Now, I want the IDR_APPTYPE menu to be displayed unless I choose File-Close. (but the window will still be open, I can open another file). But the problem is that when the last child window(last list view) is closed, the IDR_APPTYPE menu is gone, and replaced by IDR_MAINFRAME menu. How can I solve this problem?
Thanks.
0
Comment
Question by:pcasxd0
  • 4
  • 3
7 Comments
 

Author Comment

by:pcasxd0
ID: 1321314
Edited text of question
0
 
LVL 2

Expert Comment

by:milenvk
ID: 1321315
Why don't you put all the document specific commands in the IDR_APPTYPE menu and leave only the "File\Open" command and the like in the IDR_MAINFRAME menu? Alternatively you can specify in the document template only one menu to be active in both situations, i.e. put IDR_APPTYPE instead of IDR_MAINFRAME in the document template creation in your app's InitInstance function. In this way you will have IDR_APPTYPE displayed in all situations.
I know from experience that the menu switching in MFC lays deep down in the MFC code and is really hard to override.
0
 

Author Comment

by:pcasxd0
ID: 1321316
             I cannot make both menus same because I still need the IDR_MAINFRAME menu to be displayed (just with standard items like File, View, Help, etc..) when no file is open. All the document specific commands are in the IDR_APPTYPE menu, and I still need them even if the last list view (last child window) is closed. I want to establish the fact that closing the last view does not mean closing the entire document. Only 'File' - 'close' should ensure this.
              If I cannot override the menu switching process, I guess I will have to have the same menu at both places with all the doc-specific ones grayed when no file is open.(like Microsoft Word)
             Let me know if there is any other solution.
Thanks again.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:milenvk
ID: 1321317
Yes - the MS Word solution seems the best in your situation. Usually that's exactly what I do in my projects and that's what I proposed in my first answer. And as I said you will achieve that when you replace the IDR_MAINFRAME menu with the IDR_APPTYPE in the document template creation in your InitInstance() function. The menu items that you don't handle in your CWinApp derieved class or in CMainFrame will be automatically grayed in the menu when there are no open documents, i.e. put all the handlers of document specific functionality either in the view or in the document class, and all the main frame functionality either in your application or in your mainframe class.
0
 

Author Comment

by:pcasxd0
ID: 1321318
             I cannot make both menus same because I still need the IDR_MAINFRAME menu to be displayed (just with standard items like File, View, Help, etc..) when no file is open. All the document specific commands are in the IDR_APPTYPE menu, and I still need them even if the last list view (last child window) is closed. I want to establish the fact that closing the last view does not mean closing the entire document. Only 'File' - 'close' should ensure this.
              If I cannot override the menu switching process, I guess I will have to have the same menu at both places with all the doc-specific ones grayed when no file is open.(like Microsoft Word)
             Let me know if there is any other solution.
Thanks again.

0
 

Author Comment

by:pcasxd0
ID: 1321319
Milenvk, thanks for your help. I did not reject your second answer. Seems to me this system is screwed up. It rejected your answer and put my first comments again. So, if you just be kind enough to put another answer (just for the system), I can give you your points.
Thanks.
0
 
LVL 2

Accepted Solution

by:
milenvk earned 50 total points
ID: 1321320
Here I am :)))
Thanx pcasxd0 :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now