Showing the list of open documents in the Windows Menu

Posted on 1999-01-07
Medium Priority
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.
Question by:traott
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
  • 3
  • 2

Expert Comment

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.

Author Comment

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?

Expert Comment

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.
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.


Author Comment

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?
LVL 15

Accepted Solution

Tommy Hui earned 400 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.

Expert Comment

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.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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 …
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…
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…
Suggested Courses
Course of the Month8 days, 22 hours left to enroll

765 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