[BUG_FIXED] Fix context menu does not "check" items that should be "checked".

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1178 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2014-02-16 20:55:42 +00:00
parent 63626f65c1
commit 53b81b3186
4 changed files with 16 additions and 12 deletions

View File

@ -1243,15 +1243,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
::GetCursorPos(&p);
ContextMenu scintillaContextmenu;
vector<MenuItemUnit> & tmp = pNppParam->getContextMenuItems();
vector<bool> isEnable;
for (size_t i = 0, len = tmp.size(); i < len ; ++i)
{
isEnable.push_back((::GetMenuState(_mainMenuHandle, tmp[i]._cmdID, MF_BYCOMMAND)&MF_DISABLED) == 0);
}
scintillaContextmenu.create(_pPublicInterface->getHSelf(), tmp);
for (size_t i = 0, len = isEnable.size(); i < len ; ++i)
scintillaContextmenu.enableItem(tmp[i]._cmdID, isEnable[i]);
scintillaContextmenu.create(_pPublicInterface->getHSelf(), tmp, _mainMenuHandle);
scintillaContextmenu.display(p);
return TRUE;
}

View File

@ -128,7 +128,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
vector<MenuItemUnit> itemUnitArray;
itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_GOTO_ANOTHER_VIEW, goToView));
itemUnitArray.push_back(MenuItemUnit(IDM_VIEW_CLONE_TO_ANOTHER_VIEW, cloneToView));
_tabPopupDropMenu.create(_pPublicInterface->getHSelf(), itemUnitArray);
_tabPopupDropMenu.create(_pPublicInterface->getHSelf(), itemUnitArray, _mainMenuHandle);
_nativeLangSpeaker.changeLangTabDrapContextMenu(_tabPopupDropMenu.getMenuHandle());
}
_tabPopupDropMenu.display(p);

View File

@ -52,7 +52,7 @@ ContextMenu::~ContextMenu()
}
}
void ContextMenu::create(HWND hParent, const vector<MenuItemUnit> & menuItemArray)
void ContextMenu::create(HWND hParent, const vector<MenuItemUnit> & menuItemArray, const HMENU mainMenuHandle)
{
_hParent = hParent;
_hMenu = ::CreatePopupMenu();
@ -107,6 +107,18 @@ void ContextMenu::create(HWND hParent, const vector<MenuItemUnit> & menuItemArra
{
lastIsSep = true;
}
if (mainMenuHandle)
{
bool isEnabled = (::GetMenuState(mainMenuHandle, item._cmdID, MF_BYCOMMAND)&(MF_DISABLED|MF_GRAYED)) == 0;
bool isChecked = (::GetMenuState(mainMenuHandle, item._cmdID, MF_BYCOMMAND)&(MF_CHECKED)) != 0;
if (!isEnabled)
enableItem(item._cmdID, isEnabled);
if (isChecked)
checkItem(item._cmdID, isChecked);
}
}
}

View File

@ -46,7 +46,7 @@ public:
ContextMenu() : _hParent(NULL), _hMenu(NULL) {};
~ContextMenu();
void create(HWND hParent, const vector<MenuItemUnit> & menuItemArray);
void create(HWND hParent, const vector<MenuItemUnit> & menuItemArray, const HMENU mainMenuHandle = NULL);
bool isCreated() const {return _hMenu != NULL;};
void display(const POINT & p) const {