Revision: 8552 https://osdn.net/projects/ttssh2/scm/svn/commits/8552 Author: zmatsuo Date: 2020-02-20 00:38:18 +0900 (Thu, 20 Feb 2020) Log Message: ----------- About TTProxy ダイアログの文字化けを修正 Modified Paths: -------------- trunk/TTProxy/ProxyWSockHook.h -------------- next part -------------- Modified: trunk/TTProxy/ProxyWSockHook.h =================================================================== --- trunk/TTProxy/ProxyWSockHook.h 2020-02-19 15:38:09 UTC (rev 8551) +++ trunk/TTProxy/ProxyWSockHook.h 2020-02-19 15:38:18 UTC (rev 8552) @@ -17,6 +17,7 @@ #include "ttlib.h" #include "i18n.h" +#include "layer_for_unicode.h" extern char UILanguageFile[MAX_PATH]; @@ -25,6 +26,11 @@ GetI18nStr("TTProxy", key, buf, buf_len, def, UILanguageFile); } +void UTIL_get_lang_msgW(const char *key, wchar_t *buf, int buf_len, const wchar_t *def) +{ + GetI18nStrW("TTProxy", key, buf, buf_len, def, UILanguageFile); +} + class ProxyWSockHook { public: class MessageShower { @@ -1069,25 +1075,29 @@ class AboutDialog : public Dialog { private: virtual bool onInitDialog() { - String buf; - char *buf2; + wchar_t buf[MAX_UIMSG]; + wchar_t *buf2; const char *ver; - int n, a, b, c, d, len; - char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], uimsg3[MAX_UIMSG]; + int n, a, b, c, d; + size_t len; + wchar_t uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], uimsg3[MAX_UIMSG]; + HWND hWnd = (HWND)*this; - GetWindowText(uimsg2, sizeof(uimsg2)); - UTIL_get_lang_msg("DLG_ABOUT_TITLE", uimsg, sizeof(uimsg), uimsg2); - SetWindowText(uimsg); + const static DlgTextInfo text_info[] = { + { 0, "DLG_ABOUT_TITLE" }, + { IDOK, "BTN_OK" }, + }; + SetI18nDlgStrs("TTProxy", hWnd, text_info, _countof(text_info), UILanguageFile); - UTIL_get_lang_msg("DLG_ABOUT_EXTENSION", uimsg, sizeof(uimsg), - "Tera Term proxy extension"); - UTIL_get_lang_msg("DLG_ABOUT_YEBISUYA", uimsg2, sizeof(uimsg2), - "YebisuyaHompo"); - UTIL_get_lang_msg("DLG_ABOUT_HOMEPAGE", uimsg3, sizeof(uimsg3), - "TTProxy home page"); - buf = GetDlgItemText(IDC_VERSION); - len = buf.length() + 50; - buf2 = (char *)_alloca(len); + UTIL_get_lang_msgW("DLG_ABOUT_EXTENSION", uimsg, sizeof(uimsg), + L"Tera Term proxy extension"); + UTIL_get_lang_msgW("DLG_ABOUT_YEBISUYA", uimsg2, sizeof(uimsg2), + L"YebisuyaHompo"); + UTIL_get_lang_msgW("DLG_ABOUT_HOMEPAGE", uimsg3, sizeof(uimsg3), + L"TTProxy home page"); + _GetDlgItemTextW(hWnd, IDC_VERSION, buf, _countof(buf)); + len = wcslen(buf) + 50; + buf2 = (wchar_t *)_alloca(sizeof(wchar_t) * len); if (buf2 == NULL) { return true; } @@ -1094,16 +1104,12 @@ ver = FileVersion::getOwnVersion().getFileVersion(); n = sscanf_s(ver, "%d, %d, %d, %d", &a, &b, &c, &d); if (n == 4) { - sprintf_s(buf2, len, buf, uimsg, a, b, c, d, uimsg2, uimsg3); + swprintf_s(buf2, len, buf, uimsg, a, b, c, d, uimsg2, uimsg3); } - SetDlgItemText(IDC_VERSION, (n == 4) ? buf2 : buf); + _SetDlgItemTextW(hWnd, IDC_VERSION, (n == 4) ? buf2 : buf); - GetDlgItemText(IDOK, uimsg, sizeof(uimsg)); - UTIL_get_lang_msg("BTN_OK", uimsg, sizeof(uimsg),"OK"); - SetDlgItemText(IDOK, uimsg); + CenterWindow(hWnd, GetParent()); - CenterWindow((HWND)*this, GetParent()); - return true; } virtual void onOK() {