[BUG_FIXED] Fixed context menu population to check sub menus of main menu entries.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@472 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Thell Fowler 2009-04-29 17:30:32 +00:00
parent fd94587a2e
commit 10aa27cfe5
2 changed files with 43 additions and 12 deletions

View File

@ -207,6 +207,7 @@ BEGIN
MENUITEM "Cu&t", IDM_EDIT_CUT
MENUITEM "&Copy", IDM_EDIT_COPY
MENUITEM "&Paste", IDM_EDIT_PASTE
MENUITEM "&Delete", IDM_EDIT_DELETE
MENUITEM "Select A&ll", IDM_EDIT_SELECTALL
MENUITEM SEPARATOR
POPUP "Copy to clipboard"

View File

@ -1191,19 +1191,49 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle)
::GetMenuString(mainMenuHadle, i, menuEntryString, 64, MF_BYPOSITION);
if (generic_stricmp(menuEntryName, purgeMenuItemString(menuEntryString).c_str()) == 0)
{
HMENU subMenu = ::GetSubMenu(mainMenuHadle, i);
int nbSubMenuCmd = ::GetMenuItemCount(subMenu);
for (int j = 0 ; j < nbSubMenuCmd ; j++)
{
TCHAR cmdStr[256];
::GetMenuString(subMenu, j, cmdStr, 256, MF_BYPOSITION);
if (generic_stricmp(menuItemName, purgeMenuItemString(cmdStr).c_str()) == 0)
{
int cmdId = ::GetMenuItemID(subMenu, j);
_contextMenuItems.push_back(MenuItemUnit(cmdId, TEXT("")));
break;
vector< pair<HMENU, int> > parentMenuPos;
HMENU topMenu = ::GetSubMenu(mainMenuHadle, i);
int maxTopMenuPos = ::GetMenuItemCount(topMenu);
HMENU currMenu = topMenu;
int currMaxMenuPos = maxTopMenuPos;
int currMenuPos = 0;
bool notFound = false;
do {
if ( ::GetSubMenu( currMenu, currMenuPos ) ) {
// Go into sub menu
parentMenuPos.push_back( ::make_pair( currMenu, currMenuPos ) );
currMenu = ::GetSubMenu( currMenu, currMenuPos );
currMenuPos = 0;
currMaxMenuPos = ::GetMenuItemCount(currMenu);
}
}
else {
// Check current menu position.
TCHAR cmdStr[256];
::GetMenuString(currMenu, currMenuPos, cmdStr, 256, MF_BYPOSITION);
if (generic_stricmp(menuItemName, purgeMenuItemString(cmdStr).c_str()) == 0)
{
int cmdId = ::GetMenuItemID(currMenu, currMenuPos);
_contextMenuItems.push_back(MenuItemUnit(cmdId, TEXT("")));
break;
}
if ( ( currMenuPos >= currMaxMenuPos ) && ( parentMenuPos.size() > 0 ) ) {
currMenu = parentMenuPos.back().first;
currMenuPos = parentMenuPos.back().second;
parentMenuPos.pop_back();
currMaxMenuPos = ::GetMenuItemCount( currMenu );
}
if ( ( currMenu == topMenu ) && ( currMenuPos >= maxTopMenuPos ) ) {
notFound = true;
}
else {
currMenuPos++;
}
}
} while (! notFound );
break;
}
}