Getting rid of Window List from MDI applications | CodeGuru

Getting rid of Window List from MDI applications

. The MDI apps typically have a list of open windows. The list is appended to a menu item which is 1 position to the left of the right most menu item. This is just ONE (simpler?) way of getting rid of it. There are other methods which duplicate some MFC code in application and […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 6, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

.

The MDI apps typically have a list of open windows. The list is
appended to a menu item which is 1 position to the left of the right
most menu item.

This is just ONE (simpler?) way of getting rid of it. There are other
methods which duplicate some MFC code in application and then suppress
WM_MDIREFRESHMENU message send.

I have not noticed any side effects of this. But use it at your own
risk.

1. Define a popup menu item under the menu item which is one position
left to the rightmost menu item. For example, given the following
layout, add an item under “Windows”.

File    Edit    View    Windows  Help

Dummy

2. Add a Menu Update Handler:

void MyApp::OnUpdateDummy(CCmdUI* pCmdUI)
{
	// TODO: Add your command update UI handler code here

	if (!m_pMainWnd)
	{
		return;
	}

	CMenu* pMenu = m_pMainWnd->GetMenu();

	ASSERT(pMenu);

//	CMenu* pWindowList = pMenu->GetSubMenu(4); //or 3? or 5?
	CMenu* pWindowList =
		((CMDIFrameWnd*)AfxGetMainWnd())->GetWindowMenuPopup(pMenu->m_hMenu);


	ASSERT (pWindowList);

	CCmdUI item;
	item.m_pMenu = pWindowList;

	item.m_nIndexMax = pWindowList->GetMenuItemCount();
	item.m_nIndex = 0;

	//loop thru all menu items
	for (;item.m_nIndex < item.m_nIndexMax; item.m_nIndex++)
	{
		item.m_nID = pWindowList->GetMenuItemID(item.m_nIndex);
		switch(item.m_nID)
		{
        case ID_DUMMY:
			//do whatever
			item.Enable(TRUE);
			break;
        default:
			pWindowList->DeleteMenu(item.m_nID, MF_BYCOMMAND);
			break;
		}
	}
}
CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.