Release v0.6.33: warn about unsaved settings and expose menu access keys
This commit is contained in:
@@ -159,6 +159,31 @@ void showRequestedWindow(HWND window)
|
||||
if (!IsWindowVisible(window))
|
||||
ShowWindow(window, SW_SHOW);
|
||||
}
|
||||
void showMenuAccessKeys(HMENU menu)
|
||||
{
|
||||
// Mouse-opened popups ignore the owner's keyboard-cue state.
|
||||
// Preserve the mnemonic and expose it in the right-hand hint column.
|
||||
for (int i = 0; i < GetMenuItemCount(menu); ++i)
|
||||
{
|
||||
if (auto child = GetSubMenu(menu, i)) showMenuAccessKeys(child);
|
||||
int length = GetMenuStringW(menu, i, nullptr, 0, MF_BYPOSITION);
|
||||
std::wstring text(length + 1, L'\0');
|
||||
GetMenuStringW(menu, i, text.data(), (int)text.size(), MF_BYPOSITION);
|
||||
text.resize(length);
|
||||
if (text.find(L'\t') != text.npos) continue;
|
||||
for (size_t p = 0; p + 1 < text.size(); ++p)
|
||||
{
|
||||
if (text[p] != L'&') continue;
|
||||
if (text[p + 1] == L'&') { ++p; continue; }
|
||||
text += L"\t" + upper(text.substr(p + 1, 1));
|
||||
MENUITEMINFOW item{sizeof(item)};
|
||||
item.fMask = MIIM_STRING;
|
||||
item.dwTypeData = text.data();
|
||||
SetMenuItemInfoW(menu, i, TRUE, &item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool activateWindow(HWND window)
|
||||
{
|
||||
if (!IsWindow(window))
|
||||
|
||||
Reference in New Issue
Block a user