?
Solved

Retaining the application menu when closing the last child window

Posted on 1998-08-26
7
Medium Priority
?
184 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit 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 200 total points
ID: 1321320
Here I am :)))
Thanx pcasxd0 :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

800 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