diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 89bad7dd4..7ea491628 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1243,15 +1243,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa ::GetCursorPos(&p); ContextMenu scintillaContextmenu; vector & tmp = pNppParam->getContextMenuItems(); - vector 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; } diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 5a147533c..afd20d6b4 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -128,7 +128,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) vector 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); diff --git a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp index 1d73b7131..4a6940f94 100644 --- a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp +++ b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp @@ -52,7 +52,7 @@ ContextMenu::~ContextMenu() } } -void ContextMenu::create(HWND hParent, const vector & menuItemArray) +void ContextMenu::create(HWND hParent, const vector & menuItemArray, const HMENU mainMenuHandle) { _hParent = hParent; _hMenu = ::CreatePopupMenu(); @@ -107,6 +107,18 @@ void ContextMenu::create(HWND hParent, const vector & 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); + } + } } \ No newline at end of file diff --git a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h index 010cd8125..6f7fb1132 100644 --- a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h +++ b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h @@ -46,7 +46,7 @@ public: ContextMenu() : _hParent(NULL), _hMenu(NULL) {}; ~ContextMenu(); - void create(HWND hParent, const vector & menuItemArray); + void create(HWND hParent, const vector & menuItemArray, const HMENU mainMenuHandle = NULL); bool isCreated() const {return _hMenu != NULL;}; void display(const POINT & p) const {