@@ -837,9 +837,9 @@ idx_t MenuManager::findPluginCommand(const TCHAR *pluginName, const TCHAR *menuO
837837 {
838838 HMENU hPluginMenu = (HMENU)::SendMessage (m_hNotepad, NPPM_GETMENUHANDLE, 0 , 0 );
839839
840- size_t iMenuItems = ( size_t ) GetMenuItemCount (hPluginMenu);
840+ int iMenuItems = GetMenuItemCount (hPluginMenu);
841841 TCHAR strBuffer[500 ]{};
842- for ( idx_t i = 0 ; i < iMenuItems; ++i )
842+ for ( int i = 0 ; i < iMenuItems; ++i )
843843 {
844844 MENUITEMINFO mii{};
845845 mii.cbSize = sizeof (MENUITEMINFO);
@@ -913,6 +913,9 @@ idx_t MenuManager::findMenuCommand(const TCHAR *menuName, const TCHAR *menuOptio
913913 }
914914
915915 HMENU hMenuBar = ::GetMenu (m_hNotepad);
916+ if (hMenuBar == NULL ) {
917+ return 0 ;
918+ }
916919 idx_t retVal = findMenuCommand (hMenuBar, _T (" " ), menuName, menuOption);
917920
918921 if (retVal != 0 )
@@ -936,12 +939,12 @@ tstring MenuManager::formatMenuName(const TCHAR *name)
936939
937940idx_t MenuManager::findMenuCommand (HMENU hParentMenu, const TCHAR *parentMenuName, const TCHAR *menuName, const TCHAR *menuOption)
938941{
939- size_t iMenuItems = ( size_t ) GetMenuItemCount (hParentMenu);
942+ int iMenuItems = GetMenuItemCount (hParentMenu);
940943 idx_t retVal = 0 ;
941944
942945 TCHAR strBuffer[500 ]{};
943946
944- for ( idx_t i = 0 ; i < iMenuItems; ++i )
947+ for ( int i = 0 ; i < iMenuItems; ++i )
945948 {
946949 MENUITEMINFO mii{};
947950 mii.cbSize = sizeof (MENUITEMINFO);
@@ -956,8 +959,8 @@ idx_t MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *parentMenuNam
956959 tstring thisMenuName = formatMenuName (strBuffer);
957960 if (NULL == menuName || 0 == _tcsicmp (menuName, thisMenuName.c_str ()))
958961 {
959- size_t subMenuItems = ( size_t ) GetMenuItemCount (mii.hSubMenu );
960- for (idx_t subMenuPos = 0 ; subMenuPos < subMenuItems; ++subMenuPos)
962+ int subMenuItems = GetMenuItemCount (mii.hSubMenu );
963+ for (int subMenuPos = 0 ; subMenuPos < subMenuItems; ++subMenuPos)
961964 {
962965 TCHAR *context = NULL ;
963966 ::GetMenuString (mii.hSubMenu, static_cast <UINT>(subMenuPos), strBuffer, 500, MF_BYPOSITION);
@@ -968,7 +971,7 @@ idx_t MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *parentMenuNam
968971
969972 if (0 == _tcsicmp (menuOption, nameStr.c_str ()))
970973 {
971- return ::GetMenuItemID (mii.hSubMenu , ( int ) subMenuPos);
974+ return ::GetMenuItemID (mii.hSubMenu , subMenuPos);
972975 }
973976 }
974977 }
@@ -1142,4 +1145,4 @@ void MenuManager::checkShowConsole(bool checked)
11421145{
11431146 ::SendMessage (m_hNotepad, NPPM_SETMENUITEMCHECK, (WPARAM)m_funcItems[1]._cmdID, (LPARAM)checked);
11441147 s_menuItemConsoleChecked = checked;
1145- }
1148+ }
0 commit comments