+ upd: fix for grepWin language switching (github.com/stefankueng/grepWin/issues/199)

This commit is contained in:
Rainer Kottenhoff 2020-09-27 08:24:04 +02:00
parent 98aa14ee79
commit 580ffa53ee
2 changed files with 52 additions and 3 deletions

View File

@ -215,8 +215,22 @@
</nant>
<property name="verstring" value="${environment::get-variable('MajorVersion')}.${environment::get-variable('MinorVersion')}.${environment::get-variable('MicroVersion')}" />
<property name="verstringfull" value="${verstring}.${environment::get-variable('WCREV')}" />
<copy file="bin\Release\grepWin.exe" tofile="bin\grepWin-${verstring}_portable.exe" />
<copy file="bin\Release64\grepWin.exe" tofile="bin\grepWin-x64-${verstring}_portable.exe" />
<zip zipfile="bin\grepWin-${verstring}_portable.zip" ziplevel="9">
<fileset basedir="bin\release">
<include name="grepWin.exe" />
</fileset>
<fileset basedir="src\Setup">
<include name="website.url" />
</fileset>
</zip>
<zip zipfile="bin\grepWin-x64-${verstring}_portable.zip" ziplevel="9">
<fileset basedir="bin\release64">
<include name="grepWin.exe" />
</fileset>
<fileset basedir="src\Setup">
<include name="website.url" />
</fileset>
</zip>
<exec program="checksum" output="bin\checksum.txt">
<arg value="-t" />

View File

@ -181,6 +181,12 @@ void CLanguage::TranslateWindow(HWND hWnd)
// texts with the translation
TranslateWindowProc(hWnd, (LPARAM)&langmap);
EnumChildWindows(hWnd, TranslateWindowProc, (LPARAM)&langmap);
EnumThreadWindows(GetCurrentThreadId(), TranslateWindowProc, (LPARAM)&langmap);
HMENU hSysMenu = GetSystemMenu(hWnd, FALSE);
if (hSysMenu)
{
TranslateMenu(hSysMenu);
}
}
void CLanguage::TranslateMenu(HMENU hMenu)
@ -228,7 +234,8 @@ BOOL CALLBACK CLanguage::TranslateWindowProc(HWND hwnd, LPARAM lParam)
wchar_t classname[1024] = {0};
if (GetClassName(hwnd, classname, _countof(classname)))
{
if (wcscmp(classname, WC_COMBOBOX) == 0)
if ((wcscmp(classname, WC_COMBOBOX) == 0) ||
(wcscmp(classname, WC_COMBOBOXEX) == 0))
{
// translate the items in the combobox
int nSel = (int)SendMessage(hwnd, CB_GETCURSEL, 0, 0);
@ -297,6 +304,34 @@ BOOL CALLBACK CLanguage::TranslateWindowProc(HWND hwnd, LPARAM lParam)
Header_SetItem(hwnd, i, &hdi);
}
}
else if (wcscmp(classname, WC_EDIT) == 0)
{
// translate hint texts in edit controls
const int bufCount = 4096;
auto buf = std::make_unique<wchar_t[]>(bufCount);
SecureZeroMemory(buf.get(), bufCount * sizeof(wchar_t));
Edit_GetCueBannerText(hwnd, buf.get(), bufCount);
auto sTranslated = GetTranslatedString(buf.get(), pLangMap);
Edit_SetCueBannerText(hwnd, buf.get());
}
else if (wcscmp(classname, TOOLTIPS_CLASS) == 0)
{
const int bufCount = 4096;
auto buf = std::make_unique<wchar_t[]>(bufCount);
auto toolCount = (int)SendMessage(hwnd, TTM_GETTOOLCOUNT, 0, 0);
for (int i = 0; i < toolCount; ++i)
{
SecureZeroMemory(buf.get(), bufCount * sizeof(wchar_t));
TOOLINFO tt = {0};
tt.cbSize = sizeof(TOOLINFO);
tt.lpszText = buf.get();
SendMessage(hwnd, TTM_ENUMTOOLS, i, (LPARAM)&tt);
auto sTranslated = GetTranslatedString(buf.get(), pLangMap);
tt.lpszText = sTranslated.data();
SendMessage(hwnd, TTM_SETTOOLINFO, 0, (LPARAM)&tt);
}
}
}
return TRUE;