@@ -837,9 +837,9 @@ idx_t MenuManager::findPluginCommand(const TCHAR *pluginName, const TCHAR *menuO
837
837
{
838
838
HMENU hPluginMenu = (HMENU)::SendMessage (m_hNotepad, NPPM_GETMENUHANDLE, 0 , 0 );
839
839
840
- size_t iMenuItems = ( size_t ) GetMenuItemCount (hPluginMenu);
840
+ int iMenuItems = GetMenuItemCount (hPluginMenu);
841
841
TCHAR strBuffer[500 ]{};
842
- for ( idx_t i = 0 ; i < iMenuItems; ++i )
842
+ for ( int i = 0 ; i < iMenuItems; ++i )
843
843
{
844
844
MENUITEMINFO mii{};
845
845
mii.cbSize = sizeof (MENUITEMINFO);
@@ -913,6 +913,9 @@ idx_t MenuManager::findMenuCommand(const TCHAR *menuName, const TCHAR *menuOptio
913
913
}
914
914
915
915
HMENU hMenuBar = ::GetMenu (m_hNotepad);
916
+ if (hMenuBar == NULL ) {
917
+ return 0 ;
918
+ }
916
919
idx_t retVal = findMenuCommand (hMenuBar, _T (" " ), menuName, menuOption);
917
920
918
921
if (retVal != 0 )
@@ -936,12 +939,12 @@ tstring MenuManager::formatMenuName(const TCHAR *name)
936
939
937
940
idx_t MenuManager::findMenuCommand (HMENU hParentMenu, const TCHAR *parentMenuName, const TCHAR *menuName, const TCHAR *menuOption)
938
941
{
939
- size_t iMenuItems = ( size_t ) GetMenuItemCount (hParentMenu);
942
+ int iMenuItems = GetMenuItemCount (hParentMenu);
940
943
idx_t retVal = 0 ;
941
944
942
945
TCHAR strBuffer[500 ]{};
943
946
944
- for ( idx_t i = 0 ; i < iMenuItems; ++i )
947
+ for ( int i = 0 ; i < iMenuItems; ++i )
945
948
{
946
949
MENUITEMINFO mii{};
947
950
mii.cbSize = sizeof (MENUITEMINFO);
@@ -956,8 +959,8 @@ idx_t MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *parentMenuNam
956
959
tstring thisMenuName = formatMenuName (strBuffer);
957
960
if (NULL == menuName || 0 == _tcsicmp (menuName, thisMenuName.c_str ()))
958
961
{
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)
961
964
{
962
965
TCHAR *context = NULL ;
963
966
::GetMenuString (mii.hSubMenu, static_cast <UINT>(subMenuPos), strBuffer, 500, MF_BYPOSITION);
@@ -968,7 +971,7 @@ idx_t MenuManager::findMenuCommand(HMENU hParentMenu, const TCHAR *parentMenuNam
968
971
969
972
if (0 == _tcsicmp (menuOption, nameStr.c_str ()))
970
973
{
971
- return ::GetMenuItemID (mii.hSubMenu , ( int ) subMenuPos);
974
+ return ::GetMenuItemID (mii.hSubMenu , subMenuPos);
972
975
}
973
976
}
974
977
}
@@ -1142,4 +1145,4 @@ void MenuManager::checkShowConsole(bool checked)
1142
1145
{
1143
1146
::SendMessage (m_hNotepad, NPPM_SETMENUITEMCHECK, (WPARAM)m_funcItems[1]._cmdID, (LPARAM)checked);
1144
1147
s_menuItemConsoleChecked = checked;
1145
- }
1148
+ }
0 commit comments