Solved

Retaining the application menu when closing the last child window

Posted on 1998-08-26
7
181 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
[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
  • 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
Technology Partners: 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!

 
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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ffmpeg - "rtsp://...... Operation not permitted" 4 89
My project did see openJDK that I installed. What could be the problem 7 161
Fibonacci challenge 11 136
Problem to event 3 112
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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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