From 05ce44a61fcc3dad6e23977539ae06c678f46896 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 15 Mar 2005 19:06:04 +0000 Subject: Correctly remove menu items. git-svn-id: http://svn.leocad.org/trunk@390 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- win/Bmpmenu.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'win/Bmpmenu.cpp') diff --git a/win/Bmpmenu.cpp b/win/Bmpmenu.cpp index 67bfb0a..98fb39f 100644 --- a/win/Bmpmenu.cpp +++ b/win/Bmpmenu.cpp @@ -1,5 +1,8 @@ // BMPMenu.cpp : implementation file -// Version : 2.3 +// +// Based on Brent Corkum's BCMenu 2.3 class from +// http://www.rocscience.com/~corkum/BCMenu.html +// #include "stdafx.h" #include "BMPMenu.h" @@ -1414,14 +1417,29 @@ BOOL CBMPMenu::ChangeMenuItemShortcut(const char *Shortcut, UINT nID) BOOL CBMPMenu::DeleteMenu(UINT nPosition, UINT nFlags) { if (nFlags == MF_BYPOSITION) - m_MenuList.RemoveAt(nPosition); + { + CBMPMenu* pSubMenu = (CBMPMenu*)GetSubMenu(nPosition); + if (pSubMenu == NULL) + { + UINT ID = GetMenuItemID(nPosition); + for (int i = 0; i < m_MenuList.GetSize(); i++) + { + if (m_MenuList[i]->nID == ID) + { + delete m_MenuList.GetAt(i); + m_MenuList.RemoveAt(i); + break; + } + } + } + } else { int nLoc; CBMPMenu *psubmenu = FindMenuOption(nPosition, nLoc); if (psubmenu && nLoc >= 0) - psubmenu->m_MenuList.RemoveAt(nLoc); + psubmenu->DeleteMenu(nLoc, MF_BYPOSITION); } return (CMenu::DeleteMenu(nPosition, nFlags)); -- cgit v1.2.3