From fed1803c788589be7f5655c9342684fe7bbf0d30 Mon Sep 17 00:00:00 2001 From: Udo Hoffmann Date: Thu, 21 Jan 2021 22:56:39 +0100 Subject: [PATCH] Fix Switch-To keyboard shortcuts cannot be used in context menu Fix #943, close #9436 --- .../src/WinControls/ContextMenu/ContextMenu.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp index 22e5de2c7..49aa5e6d9 100644 --- a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp +++ b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.cpp @@ -112,15 +112,18 @@ void ContextMenu::create(HWND hParent, const std::vector & menuIte { 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); + UINT s = ::GetMenuState(mainMenuHandle, item._cmdID, MF_BYCOMMAND); + if (s != -1) + { + bool isEnabled = (s & (MF_DISABLED | MF_GRAYED)) == 0; + bool isChecked = (s & (MF_CHECKED)) != 0; + if (!isEnabled) + enableItem(item._cmdID, isEnabled); + if (isChecked) + checkItem(item._cmdID, isChecked); + } // set up any menu item bitmaps in the context menu, using main menu bitmaps memset(&mii, 0, sizeof(mii));