• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

Tera Termの個人的な作業用リポジトリ


Commit MetaInfo

修订版6f1e3cb13796f3562a7cf959fb911965cd8c021d (tree)
时间2020-03-24 00:54:26
作者zmatsuo <zmatsuo@user...>
Commiterzmatsuo

Log Message

TTMessageBoxW() を追加、一部利用するよう修正

- MessageBox()の i18n 対応版
- TTMessageBoxW() を使用

- ttssh/ttxssh.c
- teraterm/teraterm/commlib.c
- teraterm/ttpcmn/ttcmn.c

- GetI18nStrW() に戻り値を追加、文字数を返す
- TTGetLangStrW() 追加

- GetI18nStrW() の動的バッファ版

git-svn-id: svn+ssh://svn.osdn.net/svnroot/ttssh2/trunk@8616 f5f01b69-1e22-0410-acbf-894ab4bd6246

更改概述

差异

--- a/teraterm/common/CMakeLists.txt
+++ b/teraterm/common/CMakeLists.txt
@@ -10,12 +10,8 @@ add_library(
1010 compat_win.cpp
1111 compat_win.h
1212 dlglib.c
13- dlglib.c
14- dlglib.h
1513 dlglib.h
1614 dlglib_cpp.cpp
17- dlglib_cpp.cpp
18- dlglib_tmpl.cpp
1915 dlglib_tmpl.cpp
2016 dllutil.cpp
2117 dllutil.h
@@ -25,7 +21,6 @@ add_library(
2521 getcontent.h
2622 i18n.h
2723 i18n_static.c
28- i18n_static.c
2924 layer_for_unicode.cpp
3025 layer_for_unicode.h
3126 layer_for_unicode_comctl32.cpp
@@ -37,6 +32,7 @@ add_library(
3732 tmfc_property.cpp
3833 ttlib.h
3934 ttlib_static.c
35+ ttlib_static_cpp.cpp
4036 win16api.c
4137 win16api.h
4238 )
--- a/teraterm/common/common_static.v16.vcxproj
+++ b/teraterm/common/common_static.v16.vcxproj
@@ -148,6 +148,7 @@
148148 <ClCompile Include="layer_for_unicode.cpp" />
149149 <ClCompile Include="layer_for_unicode_comctl32.cpp" />
150150 <ClCompile Include="ttlib_static.c" />
151+ <ClCompile Include="ttlib_static_cpp.cpp" />
151152 <ClCompile Include="win16api.c" />
152153 </ItemGroup>
153154 <ItemGroup>
--- a/teraterm/common/common_static.v8.vcproj
+++ b/teraterm/common/common_static.v8.vcproj
@@ -289,6 +289,10 @@
289289 >
290290 </File>
291291 <File
292+ RelativePath=".\ttlib_static_cpp.cpp"
293+ >
294+ </File>
295+ <File
292296 RelativePath=".\win16api.c"
293297 >
294298 </File>
--- a/teraterm/common/i18n.c
+++ b/teraterm/common/i18n.c
@@ -35,12 +35,13 @@
3535
3636 /**
3737 * GetI18nStr() の unicode版
38- * @param buf_len 文字数(\0含む)
38+ * @param[in] buf_len 文字数(\0含む)
39+ * @reterm バッファの文字数(L'\0'を含む)
3940 */
40-DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def,
41- const char *iniFile)
41+DllExport size_t WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def,
42+ const char *iniFile)
4243 {
43- DWORD size;
44+ size_t size;
4445 if (pGetPrivateProfileStringW != NULL) {
4546 wchar_t sectionW[64];
4647 wchar_t keyW[128];
@@ -48,6 +49,8 @@ DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t
4849 MultiByteToWideChar(CP_ACP, 0, section, -1, sectionW, _countof(sectionW));
4950 MultiByteToWideChar(CP_ACP, 0, key, -1, keyW, _countof(keyW));
5051 MultiByteToWideChar(CP_ACP, 0, iniFile, -1, iniFileW, _countof(iniFileW));
52+ // The return value is the number of characters copied to the buffer,
53+ // not including the terminating null character.
5154 size = pGetPrivateProfileStringW(sectionW, keyW, def, buf, buf_len, iniFileW);
5255 if (size == 0 && def == NULL) {
5356 buf[0] = 0;
@@ -63,7 +66,8 @@ DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t
6366 }
6467 MultiByteToWideChar(CP_ACP, 0, tmp, -1, buf, buf_len);
6568 }
66- RestoreNewLineW(buf);
69+ size = RestoreNewLineW(buf);
70+ return size;
6771 }
6872
6973 /**
--- a/teraterm/common/i18n.h
+++ b/teraterm/common/i18n.h
@@ -51,7 +51,7 @@ typedef struct {
5151 const wchar_t *default_text; // key == NULL && default_text == NULLの場合終端
5252 } I18nTextInfo;
5353
54-DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def, const char *iniFile);
54+DllExport size_t WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def, const char *iniFile);
5555 DllExport void WINAPI GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile);
5656 DllExport int WINAPI GetI18nLogfont(const char *section, const char *key, PLOGFONTA logfont, int ppi, const char *iniFile);
5757 DllExport int WINAPI SetI18nDlgStrs(const char *section, HWND hDlgWnd,
--- a/teraterm/common/i18n_static.c
+++ b/teraterm/common/i18n_static.c
@@ -80,7 +80,7 @@ void SetI18nList(const char *section, HWND hDlg, int nIDDlgItem, const I18nTextI
8080 {
8181 UINT ADDSTRING;
8282 UINT SETCURSEL;
83- int i;
83+ size_t i;
8484 char ClassName[32];
8585 int r = GetClassNameA(GetDlgItem(hDlg, nIDDlgItem), ClassName, _countof(ClassName));
8686 assert(r != 0);
--- a/teraterm/common/ttlib.c
+++ b/teraterm/common/ttlib.c
@@ -807,10 +807,16 @@ void RestoreNewLine(PCHAR Text)
807807 memcpy(Text, buf, size);
808808 }
809809
810-void RestoreNewLineW(wchar_t *Text)
810+/**
811+ * エスケープ文字を処理する
812+ * \\,\n,\t,\0 を置き換える
813+ * @return 文字数(L'\0'を含む)
814+ */
815+size_t RestoreNewLineW(wchar_t *Text)
811816 {
812- int i, j=0;
813- int size= wcslen(Text);
817+ size_t i;
818+ int j=0;
819+ size_t size= wcslen(Text);
814820 wchar_t *buf = (wchar_t *)_alloca((size+1) * sizeof(wchar_t));
815821
816822 memset(buf, 0, (size+1) * sizeof(wchar_t));
@@ -844,7 +850,9 @@ void RestoreNewLineW(wchar_t *Text)
844850 }
845851 }
846852 /* use memcpy to copy with '\0' */
847- memcpy(Text, buf, size * sizeof(wchar_t));
853+ j++; // 文字列長
854+ memcpy(Text, buf, j * sizeof(wchar_t));
855+ return j;
848856 }
849857
850858 BOOL GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest)
--- a/teraterm/common/ttlib.h
+++ b/teraterm/common/ttlib.h
@@ -67,7 +67,7 @@ void deleteInvalidStrftimeChar(PCHAR FName);
6767 void ParseStrftimeFileName(PCHAR FName, int destlen);
6868 void ConvFName(PCHAR HomeDir, PCHAR Temp, int templen, PCHAR DefExt, PCHAR FName, int destlen);
6969 void RestoreNewLine(PCHAR Text);
70-void RestoreNewLineW(wchar_t *Text);
70+size_t RestoreNewLineW(wchar_t *Text);
7171 BOOL GetNthString(PCHAR Source, int Nth, int Size, PCHAR Dest);
7272 void GetNthNum(PCHAR Source, int Nth, int far *Num);
7373 int GetNthNum2(PCHAR Source, int Nth, int defval);
@@ -147,6 +147,17 @@ enum serial_port_conf {
147147 COM_FLOWCTRL,
148148 };
149149
150+typedef struct {
151+ const char *section; // セクション名
152+ const char *title_key; // タイトル(NULLのとき、title_default を常に使用)
153+ const wchar_t *title_default; // lng ファイルに見つからなかったとき使用
154+ const char *message_key; // メッセージ
155+ const wchar_t *message_default; // lng ファイルに見つからなかったとき使用
156+} TTMessageBoxInfoW;
157+
158+int TTMessageBoxW(HWND hWnd, const TTMessageBoxInfoW *info, UINT uType, const char *UILanguageFile, ...);
159+wchar_t *TTGetLangStrW(const char *section, const char *key, const wchar_t *def, const char *UILanguageFile);
160+
150161 #ifdef __cplusplus
151162 }
152163 #endif
--- /dev/null
+++ b/teraterm/common/ttlib_static_cpp.cpp
@@ -0,0 +1,76 @@
1+
2+#include <windows.h>
3+#include <string.h>
4+#if !defined(_CRTDBG_MAP_ALLOC)
5+#define _CRTDBG_MAP_ALLOC
6+#endif
7+#include <stdlib.h>
8+#include <crtdbg.h>
9+
10+
11+#include "i18n.h"
12+#include "layer_for_unicode.h"
13+#include "asprintf.h"
14+
15+#include "ttlib.h"
16+
17+/**
18+ * GetI18nStrW() の動的バッファ版
19+ */
20+wchar_t *TTGetLangStrW(const char *section, const char *key, const wchar_t *def, const char *UILanguageFile)
21+{
22+ wchar_t *buf = (wchar_t *)malloc(MAX_UIMSG * sizeof(wchar_t));
23+ size_t size = GetI18nStrW(section, key, buf, MAX_UIMSG, def, UILanguageFile);
24+ buf = (wchar_t *)realloc(buf, size * sizeof(wchar_t));
25+ return buf;
26+}
27+
28+/**
29+ * MessageBoxを表示する
30+ *
31+ * @param[in] hWnd 親 window
32+ * @param[in] info タイトル、メッセージ
33+ * @param[in] uType MessageBoxの uType
34+ * @param[in] UILanguageFile lngファイル
35+ * @param[in] ... フォーマット引数
36+ *
37+ * info.message を書式化文字列として、
38+ * UILanguageFileより後ろの引数を出力する
39+ *
40+ * info.message_key, info.message_default 両方ともNULLの場合
41+ * 可変引数の1つ目を書式化文字列として使用する
42+ */
43+int TTMessageBoxW(HWND hWnd, const TTMessageBoxInfoW *info, UINT uType, const char *UILanguageFile, ...)
44+{
45+ const char *section = info->section;
46+ wchar_t *title;
47+ if (info->title_key == NULL) {
48+ title = _wcsdup(info->title_default);
49+ }
50+ else {
51+ title = TTGetLangStrW(section, info->title_key, info->title_default, UILanguageFile);
52+ }
53+
54+ wchar_t *message = NULL;
55+ if (info->message_key == NULL && info->message_default == NULL) {
56+ wchar_t *format;
57+ va_list ap;
58+ va_start(ap, UILanguageFile);
59+ format = va_arg(ap, wchar_t *);
60+ vaswprintf(&message, format, ap);
61+ }
62+ else {
63+ wchar_t *format = TTGetLangStrW(section, info->message_key, info->message_default, UILanguageFile);
64+ va_list ap;
65+ va_start(ap, UILanguageFile);
66+ vaswprintf(&message, format, ap);
67+ free(format);
68+ }
69+
70+ int r = _MessageBoxW(hWnd, message, title, uType);
71+
72+ free(title);
73+ free(message);
74+
75+ return r;
76+}
--- a/teraterm/teraterm/commlib.c
+++ b/teraterm/teraterm/commlib.c
@@ -1,6 +1,6 @@
11 /*
22 * Copyright (C) 1994-1998 T. Teranishi
3- * (C) 2005-2017 TeraTerm Project
3+ * (C) 2005-2020 TeraTerm Project
44 * All rights reserved.
55 *
66 * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,9 @@
4747 #include <time.h>
4848 #include <locale.h>
4949
50+#include "ttlib.h"
51+#include "codeconv.h"
52+
5053 static SOCKET OpenSocket(PComVar);
5154 static void AsyncConnect(PComVar);
5255 static int CloseSocket(SOCKET);
@@ -288,7 +291,8 @@ error:
288291
289292 void CommOpen(HWND HW, PTTSet ts, PComVar cv)
290293 {
291- char ErrMsg[21+256];
294+ char ErrMsg[21 + 256];
295+ wchar_t ErrMsgW[21 + 256];
292296 char P[50+256];
293297
294298 MSG Msg;
@@ -297,8 +301,6 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
297301
298302 BOOL InvalidHost;
299303
300- char uimsg[MAX_UIMSG];
301-
302304 // ホスト名が名前付きパイプかどうかを調べる。
303305 if (ts->PortType == IdTCPIP) {
304306 if (CheckNamedPipeFormat(ts->HostName, strlen(ts->HostName)) == 0) {
@@ -373,9 +375,15 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
373375 }
374376 if (! LoadWinsock()) {
375377 if (cv->NoMsg==0) {
376- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
377- get_lang_msg("MSG_WINSOCK_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot use winsock", ts->UILanguageFile);
378- MessageBox(cv->HWin,ts->UIMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
378+ static const TTMessageBoxInfoW info = {
379+ "Tera Term",
380+ "MSG_TT_ERROR", L"Tera Term: Error",
381+ "MSG_WINSOCK_ERROR", L"Cannot use winsock",
382+ };
383+ TTMessageBoxW(
384+ cv->HWin,
385+ &info, (MB_TASKMODAL | MB_ICONEXCLAMATION),
386+ ts->UILanguageFile);
379387 }
380388 InvalidHost = TRUE;
381389 }
@@ -429,9 +437,13 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
429437
430438 if (InvalidHost) {
431439 if (cv->NoMsg==0) {
432- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
433- get_lang_msg("MSG_INVALID_HOST_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Invalid host", ts->UILanguageFile);
434- MessageBox(cv->HWin,ts->UIMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
440+ static const TTMessageBoxInfoW info = {
441+ "Tera Term",
442+ "MSG_TT_ERROR", L"Tera Term: Error",
443+ "MSG_INVALID_HOST_ERROR", L"Invalid host"
444+ };
445+ TTMessageBoxW(
446+ cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile);
435447 }
436448 goto BreakSC;
437449 }
@@ -457,26 +469,34 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
457469 cv->ComID = PCreateFile(P, GENERIC_READ | GENERIC_WRITE, 0, NULL,
458470 OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
459471 if (cv->ComID == INVALID_HANDLE_VALUE ) {
460- DWORD err = GetLastError();
461-
462- switch (err) {
463- case ERROR_FILE_NOT_FOUND:
464- get_lang_msg("MSG_CANTOPEN_ERROR_NOTFOUND", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. Not found.", ts->UILanguageFile);
465- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, &P[4]);
466- break;
467- case ERROR_ACCESS_DENIED:
468- get_lang_msg("MSG_CANTOPEN_ERROR_DENIED", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. Access denied.", ts->UILanguageFile);
469- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, &P[4]);
470- break;
471- default:
472- get_lang_msg("MSG_CANTOPEN_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. (0x%08x)", ts->UILanguageFile);
473- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, &P[4], err);
474- break;
475- }
476-
477472 if (cv->NoMsg==0) {
478- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
479- MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
473+ DWORD err = GetLastError();
474+ wchar_t *format;
475+ wchar_t *PW = ToWcharA(&P[4]);
476+ static const TTMessageBoxInfoW info = {
477+ "Tera Term",
478+ "MSG_TT_ERROR", L"Tera Term: Error",
479+ };
480+
481+ switch (err) {
482+ case ERROR_FILE_NOT_FOUND:
483+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR_NOTFOUND", L"Cannot open %s. Not found.", ts->UILanguageFile);
484+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW);
485+ break;
486+ case ERROR_ACCESS_DENIED:
487+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR_DENIED", L"Cannot open %s. Access denied.", ts->UILanguageFile);
488+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW);
489+ break;
490+ default:
491+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR", L"Cannot open %s. (0x%08x)", ts->UILanguageFile);
492+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW, err);
493+ break;
494+ }
495+ free(format);
496+ free(PW);
497+
498+ TTMessageBoxW(
499+ cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile, ErrMsgW);
480500 }
481501 InvalidHost = TRUE;
482502 }
@@ -503,9 +523,13 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
503523 InvalidHost = (cv->ComID == INVALID_HANDLE_VALUE);
504524 if (InvalidHost) {
505525 if (cv->NoMsg==0) {
506- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
507- get_lang_msg("MSG_CANTOPEN_FILE_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open file", ts->UILanguageFile);
508- MessageBox(cv->HWin,ts->UIMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
526+ static const TTMessageBoxInfoW info = {
527+ "Tera Term",
528+ "MSG_TT_ERROR", L"Tera Term: Error",
529+ "MSG_CANTOPEN_FILE_ERROR", L"Cannot open file"
530+ };
531+ TTMessageBoxW(
532+ cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile);
509533 }
510534 }
511535 else {
@@ -523,15 +547,18 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
523547
524548 // 名前付きパイプが正しい書式かをチェックする。
525549 if (CheckNamedPipeFormat(P, strlen(P)) < 0) {
550+ static const TTMessageBoxInfoW info = {
551+ "Tera Term",
552+ "MSG_TT_ERROR", L"Tera Term: Error",
553+ };
526554 InvalidHost = TRUE;
527555
528- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE,
529- "Invalid pipe name (%d)\n\n"
530- "A valid pipe name has the form\n"
531- "\"\\\\<ServerName>\\pipe\\<PipeName>\"",
556+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE,
557+ L"Invalid pipe name (%d)\n\n"
558+ L"A valid pipe name has the form\n"
559+ L"\"\\\\<ServerName>\\pipe\\<PipeName>\"",
532560 GetLastError());
533- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
534- MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
561+ TTMessageBoxW(cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile, ErrMsgW);
535562 break;
536563 }
537564
@@ -539,30 +566,38 @@ void CommOpen(HWND HW, PTTSet ts, PComVar cv)
539566 0, // ブロッキングモードにする(FILE_FLAG_OVERLAPPED は指定しない)
540567 NULL);
541568 if (cv->ComID == INVALID_HANDLE_VALUE ) {
542- DWORD err = GetLastError();
543-
544- switch (err) {
545- case ERROR_FILE_NOT_FOUND:
546- get_lang_msg("MSG_CANTOPEN_ERROR_NOTFOUND", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. Not found.", ts->UILanguageFile);
547- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, P);
548- break;
549- case ERROR_ACCESS_DENIED:
550- get_lang_msg("MSG_CANTOPEN_ERROR_DENIED", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. Access denied.", ts->UILanguageFile);
551- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, P);
552- break;
553- case ERROR_PIPE_BUSY:
554- get_lang_msg("MSG_CANTOPEN_ERROR_PIPEBUSY", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. Pipe is busy.", ts->UILanguageFile);
555- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, P);
556- break;
557- default:
558- get_lang_msg("MSG_CANTOPEN_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot open %s. (0x%08x)", ts->UILanguageFile);
559- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, ts->UIMsg, P, err);
560- break;
561- }
562-
563569 if (cv->NoMsg==0) {
564- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
565- MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
570+ DWORD err = GetLastError();
571+ wchar_t *format;
572+ wchar_t* PW = ToWcharA(&P[4]);
573+ static const TTMessageBoxInfoW info = {
574+ "Tera Term",
575+ "MSG_TT_ERROR", L"Tera Term: Error",
576+ };
577+
578+ switch (err) {
579+ case ERROR_FILE_NOT_FOUND:
580+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR_NOTFOUND", L"Cannot open %s. Not found.", ts->UILanguageFile);
581+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW);
582+ break;
583+ case ERROR_ACCESS_DENIED:
584+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR_DENIED", L"Cannot open %s. Access denied.", ts->UILanguageFile);
585+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW);
586+ break;
587+ case ERROR_PIPE_BUSY:
588+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR_PIPEBUSY", L"Cannot open %s. Pipe is busy.", ts->UILanguageFile);
589+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW);
590+ break;
591+ default:
592+ format = TTGetLangStrW("Tera Term", "MSG_CANTOPEN_ERROR", L"Cannot open %s. (0x%08x)", ts->UILanguageFile);
593+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, format, PW, err);
594+ break;
595+ }
596+ free(format);
597+ free(PW);
598+
599+ TTMessageBoxW(
600+ cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile, ErrMsgW);
566601 }
567602 InvalidHost = TRUE;
568603 }
@@ -664,8 +699,9 @@ void CommThread(void *arg)
664699 void CommStart(PComVar cv, LONG lParam, PTTSet ts)
665700 {
666701 char ErrMsg[31];
702+ wchar_t ErrMsgW[31];
667703 char Temp[20];
668- char uimsg[MAX_UIMSG];
704+ wchar_t UIMsgW[MAX_UIMSG];
669705
670706 if (! cv->Open ) {
671707 return;
@@ -684,20 +720,20 @@ void CommStart(PComVar cv, LONG lParam, PTTSet ts)
684720 ErrMsg[0] = 0;
685721 switch (HIWORD(lParam)) {
686722 case WSAECONNREFUSED:
687- get_lang_msg("MSG_COMM_REFUSE_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Connection refused", ts->UILanguageFile);
688- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, "%s", ts->UIMsg);
723+ get_lang_msgW("MSG_COMM_REFUSE_ERROR", UIMsgW, _countof(UIMsgW), L"Connection refused", ts->UILanguageFile);
724+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, L"%s", UIMsgW);
689725 break;
690726 case WSAENETUNREACH:
691- get_lang_msg("MSG_COMM_REACH_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Network cannot be reached", ts->UILanguageFile);
692- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, "%s", ts->UIMsg);
727+ get_lang_msgW("MSG_COMM_REACH_ERROR", UIMsgW, _countof(UIMsgW), L"Network cannot be reached", ts->UILanguageFile);
728+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, L"%s", UIMsgW);
693729 break;
694730 case WSAETIMEDOUT:
695- get_lang_msg("MSG_COMM_CONNECT_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Connection timed out", ts->UILanguageFile);
696- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, "%s", ts->UIMsg);
731+ get_lang_msgW("MSG_COMM_CONNECT_ERROR", UIMsgW, _countof(UIMsgW), L"Connection timed out", ts->UILanguageFile);
732+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, L"%s", UIMsgW);
697733 break;
698734 default:
699- get_lang_msg("MSG_COMM_TIMEOUT_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Cannot connect the host", ts->UILanguageFile);
700- _snprintf_s(ErrMsg, sizeof(ErrMsg), _TRUNCATE, "%s", ts->UIMsg);
735+ get_lang_msgW("MSG_COMM_TIMEOUT_ERROR", UIMsgW, _countof(UIMsgW), L"Cannot connect the host", ts->UILanguageFile);
736+ _snwprintf_s(ErrMsgW, _countof(ErrMsgW), _TRUNCATE, L"%s", UIMsgW);
701737 }
702738 if (HIWORD(lParam)>0) {
703739 /* connect() failed */
@@ -719,8 +755,15 @@ void CommStart(PComVar cv, LONG lParam, PTTSet ts)
719755 /* trying with all protocol family are failed */
720756 if (cv->NoMsg==0)
721757 {
722- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
723- MessageBox(cv->HWin,ErrMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
758+ static const TTMessageBoxInfoW info = {
759+ "Tera Term",
760+ "MSG_TT_ERROR", L"Tera Term: Error",
761+ NULL, NULL
762+ };
763+ TTMessageBoxW(
764+ cv->HWin,
765+ &info, (MB_TASKMODAL | MB_ICONEXCLAMATION),
766+ ts->UILanguageFile, ErrMsgW);
724767 }
725768 PostMessage(cv->HWin, WM_USER_COMMNOTIFY, 0, FD_CLOSE);
726769 cv->RetryWithOtherProtocol = FALSE;
@@ -746,9 +789,12 @@ void CommStart(PComVar cv, LONG lParam, PTTSet ts)
746789
747790 /* create the receiver thread */
748791 if (_beginthread(CommThread,0,cv) == -1) {
749- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
750- get_lang_msg("MSG_TT_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Can't create thread", ts->UILanguageFile);
751- MessageBox(cv->HWin,ts->UIMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
792+ static const TTMessageBoxInfoW info = {
793+ "Tera Term",
794+ "MSG_TT_ERROR", L"Tera Term: Error",
795+ "MSG_TT_ERROR", L"Can't create thread"
796+ };
797+ TTMessageBoxW(cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile);
752798 }
753799 break;
754800
@@ -769,9 +815,12 @@ void CommStart(PComVar cv, LONG lParam, PTTSet ts)
769815
770816 /* create the receiver thread */
771817 if (_beginthread(NamedPipeThread,0,cv) == -1) {
772- get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: Error", ts->UILanguageFile);
773- get_lang_msg("MSG_TT_ERROR", ts->UIMsg, sizeof(ts->UIMsg), "Can't create thread", ts->UILanguageFile);
774- MessageBox(cv->HWin,ts->UIMsg,uimsg,MB_TASKMODAL | MB_ICONEXCLAMATION);
818+ static const TTMessageBoxInfoW info = {
819+ "Tera Term",
820+ "MSG_TT_ERROR", L"Tera Term: Error",
821+ "MSG_TT_ERROR", L"Can't create thread"
822+ };
823+ TTMessageBoxW(cv->HWin, &info, MB_TASKMODAL | MB_ICONEXCLAMATION, ts->UILanguageFile);
775824 }
776825 break;
777826 }
--- a/teraterm/ttpcmn/ttcmn.c
+++ b/teraterm/ttpcmn/ttcmn.c
@@ -140,14 +140,16 @@ void WINAPI RestartTeraTerm(HWND hwnd, PTTSet ts)
140140 char path[1024];
141141 STARTUPINFO si;
142142 PROCESS_INFORMATION pi;
143- char uimsg[MAX_UIMSG];
144143 int ret;
145144
146- get_lang_msg("MSG_TT_TAKE_EFFECT", uimsg, sizeof(uimsg),
147- "This option takes effect the next time a session is started.\n"
148- "Are you sure that you want to relaunch Tera Term?"
149- , ts->UILanguageFile);
150- ret = MessageBox(hwnd, uimsg, "Tera Term: Configuration Warning", MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2);
145+ static const TTMessageBoxInfoW info = {
146+ "Tera Term",
147+ NULL, L"Tera Term: Configuration Warning",
148+ "MSG_TT_TAKE_EFFECT",
149+ L"This option takes effect the next time a session is started.\n"
150+ L"Are you sure that you want to relaunch Tera Term?"
151+ };
152+ ret = TTMessageBoxW(hwnd, &info, MB_YESNO | MB_ICONEXCLAMATION | MB_DEFBUTTON2, ts->UILanguageFile);
151153 if (ret != IDYES)
152154 return;
153155
@@ -1184,11 +1186,11 @@ void WINAPI OpenHelp(UINT Command, DWORD Data, char *UILanguageFile)
11841186 HWin = GetDesktopWindow();
11851187 if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL) {
11861188 // ヘルプが開けなかった
1187- wchar_t buf[MAX_PATH];
1188- get_lang_msgW("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg),
1189- L"Can't open HTML help file(%s).", UILanguageFile);
1190- _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN);
1191- _MessageBoxW(HWin, buf, L"Tera Term: HTML help", MB_OK | MB_ICONERROR);
1189+ static const TTMessageBoxInfoW info = {
1190+ "Tera Term",
1191+ NULL, L"Tera Term: HTML help",
1192+ "MSG_OPENHELP_ERROR", L"Can't open HTML help file(%s)." };
1193+ TTMessageBoxW(HWin, &info, MB_OK | MB_ICONERROR, UILanguageFile, HelpFN);
11921194 return;
11931195 }
11941196 }
--- a/ttssh2/ttxssh/ttxssh.c
+++ b/ttssh2/ttxssh/ttxssh.c
@@ -1317,7 +1317,6 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
13171317 WORD ComPortTable[MAXCOMPORT];
13181318 static char *ComPortDesc[MAXCOMPORT];
13191319 int comports;
1320- BOOL Ok;
13211320 static HWND hwndHostname = NULL; // HOSTNAME dropdown
13221321 static HWND hwndHostnameEdit = NULL; // Edit control on HOSTNAME dropdown
13231322
@@ -1497,17 +1496,20 @@ static INT_PTR CALLBACK TTXHostDlg(HWND dlg, UINT msg, WPARAM wParam,
14971496 GetHNRec = (PGetHNRec) GetWindowLongPtr(dlg, DWLP_USER);
14981497 if (GetHNRec != NULL) {
14991498 if (IsDlgButtonChecked(dlg, IDC_HOSTTCPIP)) {
1499+ BOOL Ok;
15001500 char afstr[BUFSIZ];
15011501 i = GetDlgItemInt(dlg, IDC_HOSTTCPPORT, &Ok, FALSE);
1502- if (Ok) {
1503- GetHNRec->TCPPort = i;
1504- } else {
1505- UTIL_get_lang_msg("MSG_TCPPORT_NAN_ERROR", pvar,
1506- "The TCP port must be a number.");
1507- MessageBox(dlg, pvar->ts->UIMsg,
1508- "Tera Term", MB_OK | MB_ICONEXCLAMATION);
1502+ if (!Ok) {
1503+ // TODO IDC_HOSTTCPPORTは数値しか入力できない、不要?
1504+ static const TTMessageBoxInfoW info = {
1505+ "TTSSH",
1506+ NULL, L"Tera Term",
1507+ "MSG_TCPPORT_NAN_ERROR", L"The TCP port must be a number."
1508+ };
1509+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
15091510 return TRUE;
15101511 }
1512+ GetHNRec->TCPPort = i;
15111513 #define getaf(str) \
15121514 ((strcmp((str), "IPv6") == 0) ? AF_INET6 : \
15131515 ((strcmp((str), "IPv4") == 0) ? AF_INET : AF_UNSPEC))
@@ -1897,13 +1899,12 @@ static void PASCAL TTXParseParam(PCHAR param, PTTSet ts, PCHAR DDETopic) {
18971899 pvar->settings.ssh_protocol_version = 2;
18981900
18991901 } else {
1900- char buf[1024];
1901-
1902- UTIL_get_lang_msg("MSG_UNKNOWN_OPTION_ERROR", pvar,
1903- "Unrecognized command-line option: %s");
1904- _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg, option);
1905-
1906- MessageBox(NULL, buf, "TTSSH", MB_OK | MB_ICONEXCLAMATION);
1902+ static const TTMessageBoxInfoW info = {
1903+ "TTSSH",
1904+ NULL, L"TTSSH",
1905+ "MSG_UNKNOWN_OPTION_ERROR", L"Unrecognized command-line option: %s"
1906+ };
1907+ TTMessageBoxW(NULL, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile, option);
19071908 }
19081909
19091910 // ttermpro.exe の /T= 指定の流用なので、大文字も許す (2006.10.19 maya)
@@ -3155,12 +3156,12 @@ static int get_keys_file_name(HWND parent, char *buf, int bufsize,
31553156 int err = CommDlgExtendedError();
31563157
31573158 if (err != 0) {
3158- char buf[1024];
3159- UTIL_get_lang_msg("MSG_OPEN_FILEDLG_KNOWNHOSTS_ERROR", pvar,
3160- "Unable to display file dialog box: error %d");
3161- _snprintf_s(buf, sizeof(buf), _TRUNCATE, pvar->ts->UIMsg, err);
3162- MessageBox(parent, buf, "TTSSH Error",
3163- MB_OK | MB_ICONEXCLAMATION);
3159+ static const TTMessageBoxInfoW info = {
3160+ "TTSSH",
3161+ NULL, L"TTSSH Error",
3162+ "MSG_OPEN_FILEDLG_KNOWNHOSTS_ERROR", L"Unable to display file dialog box: error %d"
3163+ };
3164+ TTMessageBoxW(parent, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile, err);
31643165 }
31653166
31663167 return 0;
@@ -4021,7 +4022,6 @@ static void save_bcrypt_private_key(char *passphrase, char *filename, char *comm
40214022 unsigned char *cp = NULL;
40224023 unsigned int len, check;
40234024 FILE *fp;
4024- char uimsg[MAX_UIMSG];
40254025
40264026 b = buffer_init();
40274027 kdf = buffer_init();
@@ -4131,20 +4131,22 @@ static void save_bcrypt_private_key(char *passphrase, char *filename, char *comm
41314131 // 秘密鍵をファイルに保存する。
41324132 fp = fopen(filename, "wb");
41334133 if (fp == NULL) {
4134- UTIL_get_lang_msg("MSG_SAVE_KEY_OPENFILE_ERROR", pvar,
4135- "Can't open key file");
4136- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4137- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4138- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4134+ static const TTMessageBoxInfoW info = {
4135+ "TTSSH",
4136+ "MSG_ERROR", L"ERROR",
4137+ "MSG_SAVE_KEY_OPENFILE_ERROR", L"Can't open key file"
4138+ };
4139+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
41394140 goto ed25519_error;
41404141 }
41414142 n = fwrite(buffer_ptr(blob), buffer_len(blob), 1, fp);
41424143 if (n != 1) {
4143- UTIL_get_lang_msg("MSG_SAVE_KEY_WRITEFILE_ERROR", pvar,
4144- "Can't open key file");
4145- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4146- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4147- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4144+ static const TTMessageBoxInfoW info = {
4145+ "TTSSH",
4146+ "MSG_ERROR", L"ERROR",
4147+ "MSG_SAVE_KEY_WRITEFILE_ERROR", L"Can't open key file"
4148+ };
4149+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
41484150 }
41494151 fclose(fp);
41504152
@@ -4242,10 +4244,12 @@ static INT_PTR CALLBACK TTXKeyGenerator(HWND dlg, UINT msg, WPARAM wParam,
42424244 case KEY_RSA:
42434245 case KEY_DSA:
42444246 if (bits < ((key_type==KEY_DSA)?SSH_DSA_MINIMUM_KEY_SIZE:SSH_RSA_MINIMUM_KEY_SIZE)) {
4245- UTIL_get_lang_msg("MSG_KEYBITS_MIN_ERROR", pvar,
4246- "The key bits is too small.");
4247- MessageBox(dlg, pvar->ts->UIMsg,
4248- "Tera Term", MB_OK | MB_ICONEXCLAMATION);
4247+ static const TTMessageBoxInfoW info = {
4248+ "TTSSH",
4249+ NULL, L"Tera Term",
4250+ "MSG_KEYBITS_MIN_ERROR", L"The key bits is too small."
4251+ };
4252+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
42494253 return TRUE;
42504254 }
42514255 break;
@@ -4541,11 +4545,12 @@ static INT_PTR CALLBACK TTXKeyGenerator(HWND dlg, UINT msg, WPARAM wParam,
45414545 // saving public key file
45424546 fp = fopen(filename, "wb");
45434547 if (fp == NULL) {
4544- UTIL_get_lang_msg("MSG_SAVE_KEY_OPENFILE_ERROR", pvar,
4545- "Can't open key file");
4546- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4547- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4548- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4548+ static const TTMessageBoxInfoW info = {
4549+ "TTSSH",
4550+ "MSG_ERROR", L"ERROR",
4551+ "MSG_SAVE_KEY_OPENFILE_ERROR", L"Can't open key file"
4552+ };
4553+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
45494554 break;
45504555 }
45514556
@@ -4666,21 +4671,23 @@ public_error:
46664671
46674672 // check matching
46684673 if (strcmp(buf, buf_conf) != 0) {
4669- UTIL_get_lang_msg("MSG_SAVE_PRIVATE_KEY_MISMATCH_ERROR", pvar,
4670- "Two passphrases don't match.");
4671- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4672- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4673- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4674+ static const TTMessageBoxInfoW info = {
4675+ "TTSSH",
4676+ "MSG_ERROR", L"ERROR",
4677+ "MSG_SAVE_PRIVATE_KEY_MISMATCH_ERROR", L"Two passphrases don't match."
4678+ };
4679+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
46744680 break;
46754681 }
46764682
46774683 // check empty-passphrase (this is warning level)
46784684 if (buf[0] == '\0') {
4679- UTIL_get_lang_msg("MSG_SAVE_PRIVATEKEY_EMPTY_WARN", pvar,
4680- "Are you sure that you want to use a empty passphrase?");
4681- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4682- UTIL_get_lang_msg("MSG_WARNING", pvar, "WARNING");
4683- ret = MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_YESNO | MB_ICONWARNING);
4685+ static const TTMessageBoxInfoW info = {
4686+ "TTSSH",
4687+ "MSG_WARNING", L"WARNING",
4688+ "MSG_SAVE_PRIVATEKEY_EMPTY_WARN", L"Are you sure that you want to use a empty passphrase?",
4689+ };
4690+ ret = TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
46844691 if (ret == IDNO)
46854692 break;
46864693 }
@@ -4689,17 +4696,21 @@ public_error:
46894696 if (SendMessage(GetDlgItem(dlg, IDC_BCRYPT_KDF_CHECK), BM_GETCHECK, 0, 0) == BST_CHECKED) {
46904697 rounds = GetDlgItemInt(dlg, IDC_BCRYPT_KDF_ROUNDS, NULL, FALSE);
46914698 if (rounds < SSH_KEYGEN_MINIMUM_ROUNDS) {
4692- UTIL_get_lang_msg("MSG_BCRYPT_ROUNDS_MIN_ERROR", pvar,
4693- "The number of rounds is too small.");
4694- MessageBox(dlg, pvar->ts->UIMsg,
4695- "Tera Term", MB_OK | MB_ICONEXCLAMATION);
4699+ static const TTMessageBoxInfoW info = {
4700+ "TTSSH",
4701+ NULL, L"Tera Term",
4702+ "MSG_BCRYPT_ROUNDS_MIN_ERROR", L"The number of rounds is too small."
4703+ };
4704+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
46964705 break;
46974706 }
46984707 if (rounds > SSH_KEYGEN_MAXIMUM_ROUNDS) {
4699- UTIL_get_lang_msg("MSG_BCRYPT_ROUNDS_MAX_ERROR", pvar,
4700- "The number of rounds is too large.");
4701- MessageBox(dlg, pvar->ts->UIMsg,
4702- "Tera Term", MB_OK | MB_ICONEXCLAMATION);
4708+ static const TTMessageBoxInfoW info = {
4709+ "TTSSH",
4710+ NULL, L"Tera Term",
4711+ "MSG_BCRYPT_ROUNDS_MAX_ERROR", L"The number of rounds is too large."
4712+ };
4713+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
47034714 break;
47044715 }
47054716 }
@@ -4872,11 +4883,12 @@ public_error:
48724883 // saving private key file (binary mode)
48734884 fp = fopen(filename, "wb");
48744885 if (fp == NULL) {
4875- UTIL_get_lang_msg("MSG_SAVE_KEY_OPENFILE_ERROR", pvar,
4876- "Can't open key file");
4877- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4878- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4879- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4886+ static const TTMessageBoxInfoW info = {
4887+ "TTSSH",
4888+ "MSG_ERROR", L"ERROR",
4889+ "MSG_SAVE_KEY_OPENFILE_ERROR", L"Can't open key file"
4890+ };
4891+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
48804892 break;
48814893 }
48824894 fwrite(buffer_ptr(enc), buffer_len(enc), 1, fp);
@@ -4913,11 +4925,12 @@ error:;
49134925
49144926 fp = fopen(filename, "w");
49154927 if (fp == NULL) {
4916- UTIL_get_lang_msg("MSG_SAVE_KEY_OPENFILE_ERROR", pvar,
4917- "Can't open key file");
4918- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4919- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4920- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4928+ static const TTMessageBoxInfoW info = {
4929+ "TTSSH",
4930+ "MSG_ERROR", L"ERROR",
4931+ "MSG_SAVE_KEY_OPENFILE_ERROR", L"Can't open key file"
4932+ };
4933+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
49214934 break;
49224935 }
49234936
@@ -4935,11 +4948,12 @@ error:;
49354948 break;
49364949 }
49374950 if (ret == 0) {
4938- UTIL_get_lang_msg("MSG_SAVE_KEY_WRITEFILE_ERROR", pvar,
4939- "Can't open key file");
4940- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4941- UTIL_get_lang_msg("MSG_ERROR", pvar, "ERROR");
4942- MessageBox(dlg, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4951+ static const TTMessageBoxInfoW info = {
4952+ "TTSSH",
4953+ "MSG_ERROR", L"ERROR",
4954+ "MSG_SAVE_KEY_WRITEFILE_ERROR", L"Can't open key file"
4955+ };
4956+ TTMessageBoxW(dlg, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
49434957 }
49444958 fclose(fp);
49454959 }
@@ -4958,8 +4972,6 @@ error:;
49584972
49594973 static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
49604974 {
4961- char uimsg[MAX_UIMSG];
4962-
49634975 if (pvar->fatal_error) {
49644976 return 0;
49654977 }
@@ -4975,11 +4987,12 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
49754987 UTIL_SetDialogFont();
49764988 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHSCP), hWin, TTXScpDialog,
49774989 (LPARAM) pvar) == -1) {
4978- UTIL_get_lang_msg("MSG_CREATEWINDOW_SCP_ERROR", pvar,
4979- "Unable to display SCP dialog box.");
4980- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4981- UTIL_get_lang_msg("MSG_TTSSH_ERROR", pvar, "TTSSH Error");
4982- MessageBox(hWin, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
4990+ static const TTMessageBoxInfoW info = {
4991+ "TTSSH",
4992+ "MSG_TTSSH_ERROR", L"TTSSH Error",
4993+ "MSG_CREATEWINDOW_SCP_ERROR", L"Unable to display SCP dialog box."
4994+ };
4995+ TTMessageBoxW(hWin, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
49834996 }
49844997 return 1;
49854998
@@ -4987,11 +5000,12 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
49875000 UTIL_SetDialogFont();
49885001 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHKEYGEN), hWin, TTXKeyGenerator,
49895002 (LPARAM) pvar) == -1) {
4990- UTIL_get_lang_msg("MSG_CREATEWINDOW_KEYGEN_ERROR", pvar,
4991- "Unable to display Key Generator dialog box.");
4992- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
4993- UTIL_get_lang_msg("MSG_TTSSH_ERROR", pvar, "TTSSH Error");
4994- MessageBox(hWin, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
5003+ static const TTMessageBoxInfoW info = {
5004+ "TTSSH",
5005+ "MSG_TTSSH_ERROR", L"TTSSH Error",
5006+ "MSG_CREATEWINDOW_KEYGEN_ERROR", L"Unable to display Key Generator dialog box."
5007+ };
5008+ TTMessageBoxW(hWin, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
49955009 }
49965010 return 1;
49975011
@@ -4999,11 +5013,12 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
49995013 UTIL_SetDialogFont();
50005014 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ABOUTDIALOG),
50015015 hWin, TTXAboutDlg, (LPARAM) pvar) == -1) {
5002- UTIL_get_lang_msg("MSG_CREATEWINDOW_ABOUT_ERROR", pvar,
5003- "Unable to display About dialog box.");
5004- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
5005- UTIL_get_lang_msg("MSG_TTSSH_ERROR", pvar, "TTSSH Error");
5006- MessageBox(hWin, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
5016+ static const TTMessageBoxInfoW info = {
5017+ "TTSSH",
5018+ "MSG_TTSSH_ERROR", L"TTSSH Error",
5019+ "MSG_CREATEWINDOW_ABOUT_ERROR", L"Unable to display About dialog box."
5020+ };
5021+ TTMessageBoxW(hWin, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
50075022 }
50085023 return 1;
50095024 case ID_SSHAUTH:
@@ -5014,11 +5029,12 @@ static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd)
50145029 UTIL_SetDialogFont();
50155030 if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHSETUP),
50165031 hWin, TTXSetupDlg, (LPARAM) pvar) == -1) {
5017- UTIL_get_lang_msg("MSG_CREATEWINDOW_SETUP_ERROR", pvar,
5018- "Unable to display TTSSH Setup dialog box.");
5019- strncpy_s(uimsg, sizeof(uimsg), pvar->ts->UIMsg, _TRUNCATE);
5020- UTIL_get_lang_msg("MSG_TTSSH_ERROR", pvar, "TTSSH Error");
5021- MessageBox(hWin, uimsg, pvar->ts->UIMsg, MB_OK | MB_ICONEXCLAMATION);
5032+ static const TTMessageBoxInfoW info = {
5033+ "TTSSH",
5034+ "MSG_TTSSH_ERROR", L"TTSSH Error",
5035+ "MSG_CREATEWINDOW_SETUP_ERROR", L"Unable to display TTSSH Setup dialog box."
5036+ };
5037+ TTMessageBoxW(hWin, &info, MB_OK | MB_ICONEXCLAMATION, pvar->ts->UILanguageFile);
50225038 }
50235039 return 1;
50245040 case ID_SSHAUTHSETUPMENU: