mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-10-21 05:42:35 +00:00
Windows: localize main menu commands by traversal
Traverse menu items and submenus instead of scanning consecutive IDs, so missing translations cannot block later commands. Preserve item state and custom labels, and retain popup localization and Homepage alignment.
This commit is contained in:
+48
-17
@@ -967,11 +967,46 @@ void EndMainDlg (HWND hwndDlg)
|
||||
the parking dimensions, so neither IsIconic nor the current size can be trusted. */
|
||||
static SIZE MainDlgNormalSize = {0};
|
||||
|
||||
static void LocalizeMainMenu (HMENU menu)
|
||||
{
|
||||
int count = GetMenuItemCount (menu);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
MENUITEMINFOW info = {0};
|
||||
wchar_t *str;
|
||||
|
||||
info.cbSize = sizeof (info);
|
||||
info.fMask = MIIM_ID | MIIM_SUBMENU | MIIM_FTYPE | MIIM_BITMAP | MIIM_STRING;
|
||||
if (!GetMenuItemInfoW (menu, i, TRUE, &info))
|
||||
continue;
|
||||
|
||||
if (info.hSubMenu != NULL)
|
||||
{
|
||||
LocalizeMainMenu (info.hSubMenu);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((info.fType & (MFT_SEPARATOR | MFT_OWNERDRAW | MFT_BITMAP))
|
||||
|| (info.hbmpItem != NULL && info.cch == 0))
|
||||
continue;
|
||||
|
||||
// Missing mappings (including user-defined favorites) must not stop localization.
|
||||
str = (wchar_t *) GetDictionaryValueByInt (info.wID);
|
||||
if (str == NULL)
|
||||
continue;
|
||||
|
||||
info.fMask = MIIM_STRING;
|
||||
info.dwTypeData = str;
|
||||
info.cch = (UINT) wcslen (str);
|
||||
SetMenuItemInfoW (menu, i, TRUE, &info);
|
||||
}
|
||||
}
|
||||
|
||||
static void InitMainDialog (HWND hwndDlg)
|
||||
{
|
||||
MENUITEMINFOW info;
|
||||
char *popupTexts[] = {"MENU_VOLUMES", "MENU_SYSTEM_ENCRYPTION", "MENU_FAVORITES", "MENU_TOOLS", "MENU_SETTINGS", "MENU_HELP", "MENU_WEBSITE", 0};
|
||||
wchar_t *str;
|
||||
int i;
|
||||
|
||||
if (MainDlgNormalSize.cx == 0)
|
||||
@@ -1003,28 +1038,24 @@ static void InitMainDialog (HWND hwndDlg)
|
||||
InitHelpFileName();
|
||||
|
||||
// Localize menu strings
|
||||
for (i = 40001; str = (wchar_t *)GetDictionaryValueByInt (i); i++)
|
||||
{
|
||||
info.cbSize = sizeof (info);
|
||||
info.fMask = MIIM_TYPE;
|
||||
info.fType = MFT_STRING;
|
||||
info.dwTypeData = str;
|
||||
info.cch = (UINT) wcslen (str);
|
||||
|
||||
SetMenuItemInfoW (GetMenu (hwndDlg), i, FALSE, &info);
|
||||
}
|
||||
LocalizeMainMenu (GetMenu (hwndDlg));
|
||||
|
||||
for (i = 0; popupTexts[i] != 0; i++)
|
||||
{
|
||||
str = GetString (popupTexts[i]);
|
||||
MENUITEMINFOW info = {0};
|
||||
wchar_t *str = GetString (popupTexts[i]);
|
||||
|
||||
info.cbSize = sizeof (info);
|
||||
info.fMask = MIIM_TYPE;
|
||||
info.fMask = MIIM_STRING;
|
||||
|
||||
if (strcmp (popupTexts[i], "MENU_WEBSITE") == 0)
|
||||
info.fType = MFT_STRING | MFT_RIGHTJUSTIFY;
|
||||
else
|
||||
info.fType = MFT_STRING;
|
||||
{
|
||||
info.fMask = MIIM_FTYPE;
|
||||
if (!GetMenuItemInfoW (GetMenu (hwndDlg), i, TRUE, &info))
|
||||
continue;
|
||||
info.fMask = MIIM_STRING | MIIM_FTYPE;
|
||||
info.fType |= MFT_RIGHTJUSTIFY;
|
||||
}
|
||||
|
||||
if (strcmp (popupTexts[i], "MENU_FAVORITES") == 0)
|
||||
FavoriteVolumesMenu = GetSubMenu (GetMenu (hwndDlg), i);
|
||||
|
||||
Reference in New Issue
Block a user