Solved

Retaining the application menu when closing the last child window

Posted on 1998-08-26
7
176 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
Comment Utility
Edited text of question
0
 
LVL 2

Expert Comment

by:milenvk
Comment Utility
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
Comment Utility
             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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 2

Expert Comment

by:milenvk
Comment Utility
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
Comment Utility
             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
Comment Utility
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
Comment Utility
Here I am :)))
Thanx pcasxd0 :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 87
Macro to save highlighted rows as a separate file 5 38
Detect CR LF to each line 12 137
no14 challenge 14 56
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

743 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

17 Experts available now in Live!

Get 1:1 Help Now