Retaining the application menu when closing the last child window

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.
pcasxd0Asked:
Who is Participating?
 
milenvkConnect With a Mentor Commented:
Here I am :)))
Thanx pcasxd0 :)
0
 
pcasxd0Author Commented:
Edited text of question
0
 
milenvkCommented:
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
pcasxd0Author Commented:
             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
 
milenvkCommented:
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
 
pcasxd0Author Commented:
             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
 
pcasxd0Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.