Add sub-menu bullets for cascaded Encoding and Language menus

Fix #8327, close #8328
This commit is contained in:
Udo Hoffmann 2020-05-27 20:30:12 +02:00 committed by Don HO
parent 9b36ba102a
commit b73721f0b4
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -2091,23 +2091,24 @@ void Notepad_plus::checkSyncState()
enableCommand(IDM_VIEW_SYNSCROLLH, canDoSync, MENU | TOOLBAR); enableCommand(IDM_VIEW_SYNSCROLLH, canDoSync, MENU | TOOLBAR);
} }
void doCheck(HMENU mainHandle, int id) bool doCheck(HMENU mainHandle, int id)
{ {
MENUITEMINFO mii; MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO); mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_SUBMENU | MIIM_FTYPE | MIIM_ID | MIIM_STATE; mii.fMask = MIIM_SUBMENU | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
bool found = false;
int count = ::GetMenuItemCount(mainHandle); int count = ::GetMenuItemCount(mainHandle);
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
::GetMenuItemInfo(mainHandle, i, MF_BYPOSITION, &mii); ::GetMenuItemInfo(mainHandle, i, MF_BYPOSITION, &mii);
if (mii.fType == MFT_RADIOCHECK || mii.fType == MFT_STRING) if (mii.fType == MFT_RADIOCHECK || mii.fType == MFT_STRING)
{ {
if (mii.hSubMenu == 0) bool checked = mii.hSubMenu ? doCheck(mii.hSubMenu, id) : (mii.wID == (unsigned int)id);
{ if (checked)
if (mii.wID == (unsigned int)id)
{ {
::CheckMenuRadioItem(mainHandle, 0, count, i, MF_BYPOSITION); ::CheckMenuRadioItem(mainHandle, 0, count, i, MF_BYPOSITION);
found = true;
} }
else else
{ {
@ -2115,12 +2116,8 @@ void doCheck(HMENU mainHandle, int id)
::SetMenuItemInfo(mainHandle, i, MF_BYPOSITION, &mii); ::SetMenuItemInfo(mainHandle, i, MF_BYPOSITION, &mii);
} }
} }
else
{
doCheck(mii.hSubMenu, id);
}
}
} }
return found;
} }
void Notepad_plus::checkLangsMenu(int id) const void Notepad_plus::checkLangsMenu(int id) const
@ -3914,8 +3911,7 @@ void Notepad_plus::checkUnicodeMenuItems() const
{ {
// Uncheck all in the sub encoding menu // Uncheck all in the sub encoding menu
HMENU _formatMenuHandle = ::GetSubMenu(_mainMenuHandle, MENUINDEX_FORMAT); HMENU _formatMenuHandle = ::GetSubMenu(_mainMenuHandle, MENUINDEX_FORMAT);
doCheck(_formatMenuHandle, IDM_FORMAT_ENCODE); doCheck(_formatMenuHandle, -1);
::CheckMenuItem(_mainMenuHandle, IDM_FORMAT_ENCODE, MF_UNCHECKED | MF_BYCOMMAND);
if (id == -1) //um == uni16BE_NoBOM || um == uni16LE_NoBOM if (id == -1) //um == uni16BE_NoBOM || um == uni16LE_NoBOM
{ {