Solved

Showing the list of open documents in the Windows Menu

Posted on 1999-01-07
6
743 Views
Last Modified: 2013-11-20
How dow you get the List of Open Documents in an MDI application to show on the Window Sub Menu?  If I create a new MDI application from the Wizard I get it for free, but the application I am currently working on I cannot get the list.
0
Comment
Question by:traott
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:plaroche
ID: 1327356
The Window menu is automatically updated by MFC. There is a kludge in the code which makes some applications not to behave properly.

MFC assumes the Window menu is the second from the right, assuming the last one is the help menu. This "assuming" is considered ok because it is a standard thorugh all Windows applications.

I'm  willing to bet that you have removed the help menu or added a new menu and that your WINDOW menu isn't second from the right.
0
 

Author Comment

by:traott
ID: 1327357
I checked my menu setup and I do have the Window menu in the correct position (second from the right) and I am still not getting a window list. Is there something else I need to do?
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1327358
Are you handling WM_MDIREFRESHMENU in any way? This message tells the MDI client window to refresh the window menu.  Maybe one of your overrides bypasses that message.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:traott
ID: 1327359
I am not handling WM_MDIREFRESHMENU anywhere. When I create a new document the menu is getting updated, so if I close all documents then the simplistic menu for no documents are there, and if I open a document then the menu get replace by the correct menu.  I had to subclass the CMDIDocTemplate class to handle a specific case of opening my file type, but everything I have read says that this should not affect the updating of the menu.  Am I mistaken and have to handle the refresh of the menu because of this?
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1327360
If you look in GetWindowMenuPopup() in winmdi.cpp, you will see that MFC searches through your entire menu looking for menu items in the range of AFX_IDM_WINDOW_FIRST to AFX_IDM_WINDOW_LAST. It returns the HMENU of the first submenu that contains those items. Typically, if you have a submenu with either ID_WINDOW_NEW, ID_WINDOW_ARRANGE, _CASCADE, _TILE_HORZ, _TILE_VERT or _SPLIT, then MFC will find the menu.

To fix this problem, make sure you have a submenu with those items in it. Or since the GetWindowMenuPopup() is virtual, in your derived class of CMDIFrame, you can override it to return the proper HMENU.
0
 
LVL 3

Expert Comment

by:plaroche
ID: 1327361
If you're not bypassing standard behavior it shouldn't be a problem.

One thing you might want to try, look at the MFC source code in WINMDI.CPP, there are several occurances of WM_MDIREFRESHMENU.  place a breakpoint on each of them and try to manipulate your app so that each breakpoint gets executed.

If some of them aren't reached, place a breakpoint at the beginning of the function, try to see why the message isn't sent.

It's something that won't take too long to try I think.

Also, if your project isn't too big or too far into I could try to check it out.  EMail at: plaroche@cybectec.com.  I've done it a couple times for other questions ans was able to find the problem.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
ODBC Connection Logging, ADO.NET 6 50
Separate into files by filename 12 67
java ^ examples 8 58
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

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

11 Experts available now in Live!

Get 1:1 Help Now