[Ttssh2-commit] [8487] MessageBox()を_MessageBoxW()にリプレース

scmno****@osdn***** scmno****@osdn*****
2020年 1月 19日 (日) 00:16:20 JST


Revision: 8487
          https://osdn.net/projects/ttssh2/scm/svn/commits/8487
Author:   zmatsuo
Date:     2020-01-19 00:16:20 +0900 (Sun, 19 Jan 2020)
Log Message:
-----------
MessageBox()を_MessageBoxW()にリプレース

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2020-01-18 08:11:11 UTC (rev 8486)
+++ trunk/teraterm/teraterm/vtwin.cpp	2020-01-18 15:16:20 UTC (rev 8487)
@@ -417,7 +417,8 @@
 	GlobalUnlock(pSym);
 	GlobalFree(pSym);
 
-	MessageBox(NULL, msg, "Tera Term: Application fault", MB_OK | MB_ICONEXCLAMATION);
+	// \x97\xE1\x8AO\x8F\x88\x97\x9D\x92\x86\x82Ȃ̂ŁAAPI\x82𒼐ڌĂяo\x82\xB7
+	::MessageBoxA(NULL, msg, "Tera Term: Application fault", MB_OK | MB_ICONEXCLAMATION);
 
 error:
 //	return (EXCEPTION_EXECUTE_HANDLER);  /* \x82\xBB\x82̂܂܃v\x83\x8D\x83Z\x83X\x82\xF0\x8FI\x97\xB9\x82\xB3\x82\xB9\x82\xE9 */
@@ -1719,10 +1720,10 @@
 {
 	// \x93ˑR\x8FI\x97\xB9\x82\xB3\x82\xB9\x82\xE9\x82Ɗ댯\x82Ȃ̂ŁA\x82\xA9\x82Ȃ炸\x83\x86\x81[\x83U\x82ɖ₢\x8D\x87\x82킹\x82\xF0\x8Fo\x82\xB7\x82悤\x82ɂ\xB7\x82\xE9\x81B
 	// (2013.8.17 yutaka)
-	get_lang_msg("MSG_ALL_TERMINATE_CONF", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Terminate ALL Tera Term(s)?", ts.UILanguageFile);
-	if (::MessageBox(HVTWin, ts.UIMsg, "Tera Term",
-	     MB_OKCANCEL | MB_ICONERROR | MB_DEFBUTTON2)==IDCANCEL)
+	wchar_t uimsg[MAX_UIMSG];
+
+	get_lang_msgW("MSG_ALL_TERMINATE_CONF", uimsg, _countof(uimsg), L"Terminate ALL Tera Term(s)?", ts.UILanguageFile);
+	if (_MessageBoxW(HVTWin, uimsg, L"Tera Term", MB_OKCANCEL | MB_ICONERROR | MB_DEFBUTTON2) == IDCANCEL)
 		return;
 
 	BroadcastClosingMessage(HVTWin);
@@ -3820,7 +3821,7 @@
 	strncpy_s(cygterm_cfg, sizeof(cygterm_cfg), ts.HomeDir, _TRUNCATE);
 	AppendSlash(cygterm_cfg, sizeof(cygterm_cfg));
 	strncat_s(cygterm_cfg, sizeof(cygterm_cfg), "cygterm.cfg", _TRUNCATE);
-	fp = fopen(cygterm_cfg, "r");
+	fopen_s(&fp, cygterm_cfg, "r");
 	if (fp != NULL) {
 		while (fgets(buf, sizeof(buf), fp) != NULL) {
 			int len = strlen(buf);
@@ -3884,13 +3885,14 @@
 
 	if (CreateProcess(NULL, Command, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
-		char buf[80];
-		char uimsg[MAX_UIMSG];
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_EXEC_TT_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Can't execute Tera Term. (%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		wchar_t buf[80];
+		wchar_t uimsg[MAX_UIMSG];
+		wchar_t uimsg2[MAX_UIMSG];
+		get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("MSG_EXEC_TT_ERROR", uimsg2, _countof(uimsg2),
+					  L"Can't execute Tera Term. (%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, GetLastError());
+		_MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
 	} else {
 		CloseHandle(pi.hThread);
 		CloseHandle(pi.hProcess);
@@ -3910,7 +3912,8 @@
 	char cygterm[MAX_PATH];
 	STARTUPINFO si;
 	PROCESS_INFORMATION pi;
-	char uimsg[MAX_UIMSG];
+	wchar_t uimsg[MAX_UIMSG];
+	wchar_t uimsg2[MAX_UIMSG];
 
 	if (strlen(ts.CygwinDirectory) > 0) {
 		if (SearchPath(ts.CygwinDirectory, "bin\\cygwin1", ".dll", sizeof(file), file, &filename) > 0) {
@@ -3930,10 +3933,10 @@
 		}
 	}
 
-	get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-	get_lang_msg("MSG_FIND_CYGTERM_DIR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-	             "Can't find Cygwin directory.", ts.UILanguageFile);
-	::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING);
+	get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+	get_lang_msgW("MSG_FIND_CYGTERM_DIR_ERROR", uimsg2, sizeof(uimsg2),
+				  L"Can't find Cygwin directory.", ts.UILanguageFile);
+	_MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING);
 	return;
 
 found_dll:;
@@ -3942,10 +3945,10 @@
 	if (envptr != NULL) {
 		envbufflen = strlen(file) + strlen(envptr) + 7; // "PATH="(5) + ";"(1) + NUL(1)
 		if ((envbuff = (char *)malloc(envbufflen)) == NULL) {
-			get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-			get_lang_msg("MSG_CYGTERM_ENV_ALLOC_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-			             "Can't allocate memory for environment variable.", ts.UILanguageFile);
-			::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING);
+			get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+			get_lang_msgW("MSG_CYGTERM_ENV_ALLOC_ERROR", uimsg2, _countof(uimsg2),
+						  L"Can't allocate memory for environment variable.", ts.UILanguageFile);
+			_MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING);
 			return;
 		}
 		_snprintf_s(envbuff, envbufflen, _TRUNCATE, "PATH=%s;%s", file, envptr);
@@ -3952,10 +3955,10 @@
 	} else {
 		envbufflen = strlen(file) + 6; // "PATH="(5) + NUL(1)
 		if ((envbuff = (char *)malloc(envbufflen)) == NULL) {
-			get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-			get_lang_msg("MSG_CYGTERM_ENV_ALLOC_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-			             "Can't allocate memory for environment variable.", ts.UILanguageFile);
-			::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING);
+			get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+			get_lang_msgW("MSG_CYGTERM_ENV_ALLOC_ERROR", uimsg2, _countof(uimsg2),
+						  L"Can't allocate memory for environment variable.", ts.UILanguageFile);
+			_MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING);
 			return;
 		}
 		_snprintf_s(envbuff, envbufflen, _TRUNCATE, "PATH=%s", file);
@@ -3977,10 +3980,10 @@
 
 	if (CreateProcess(NULL, cygterm, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_EXEC_CYGTERM_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Can't execute Cygterm.", ts.UILanguageFile);
-		::MessageBox(NULL, ts.UIMsg, uimsg, MB_OK | MB_ICONWARNING);
+		get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("MSG_EXEC_CYGTERM_ERROR", uimsg2, _countof(uimsg2),
+		              L"Can't execute Cygterm.", ts.UILanguageFile);
+		_MessageBoxW(NULL, uimsg2, uimsg, MB_OK | MB_ICONWARNING);
 	} else {
 		CloseHandle(pi.hThread);
 		CloseHandle(pi.hProcess);
@@ -4003,13 +4006,14 @@
 
 	if (CreateProcess(exename, NULL, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
-		char buf[80];
-		char uimsg[MAX_UIMSG];
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_EXEC_TTMENU_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Can't execute TeraTerm Menu. (%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		wchar_t buf[80];
+		wchar_t uimsg[MAX_UIMSG];
+		wchar_t uimsg2[MAX_UIMSG];
+		get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("MSG_EXEC_TTMENU_ERROR", uimsg2, _countof(uimsg2),
+					  L"Can't execute TeraTerm Menu. (%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, GetLastError());
+		_MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
 	} else {
 		CloseHandle(pi.hThread);
 		CloseHandle(pi.hProcess);
@@ -4035,13 +4039,14 @@
 
 	if (CreateProcess(NULL, LogMeTT, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
-		char buf[80];
-		char uimsg[MAX_UIMSG];
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_EXEC_LOGMETT_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Can't execute LogMeTT. (%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		wchar_t buf[80];
+		wchar_t uimsg[MAX_UIMSG];
+		wchar_t uimsg2[MAX_UIMSG];
+		get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("MSG_EXEC_LOGMETT_ERROR", uimsg2, _countof(uimsg2),
+					  L"Can't execute LogMeTT. (%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, GetLastError());
+		_MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
 	} else {
 		CloseHandle(pi.hThread);
 		CloseHandle(pi.hProcess);
@@ -4127,13 +4132,14 @@
 
 	if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
-		char buf[80];
-		char uimsg[MAX_UIMSG];
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_VIEW_LOGFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Can't view logging file. (%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		wchar_t buf[80];
+		wchar_t uimsgW[MAX_UIMSG];
+		wchar_t uimsgW2[MAX_UIMSG];
+		get_lang_msgW("MSG_ERROR", uimsgW, _countof(uimsgW), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("MSG_VIEW_LOGFILE_ERROR", uimsgW2, _countof(uimsgW2),
+					  L"Can't view logging file. (%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsgW2, GetLastError());
+		_MessageBoxW(NULL, buf, uimsgW, MB_OK | MB_ICONWARNING);
 	} else {
 		CloseHandle(pi.hThread);
 		CloseHandle(pi.hProcess);
@@ -4199,12 +4205,14 @@
 
 	if (CreateProcess(NULL, Command, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
-		char buf[80];
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("MSG_EXEC_TT_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Can't execute Tera Term. (%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		wchar_t buf[80];
+		wchar_t uimsgW[MAX_UIMSG];
+		wchar_t uimsgW2[MAX_UIMSG];
+		get_lang_msgW("MSG_ERROR", uimsgW, _countof(uimsgW), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("MSG_EXEC_TT_ERROR", uimsgW2, _countof(uimsgW2),
+		              L"Can't execute Tera Term. (%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsgW2, GetLastError());
+		_MessageBoxW(NULL, buf, uimsgW, MB_OK | MB_ICONWARNING);
 	} else {
 		CloseHandle(pi.hThread);
 		CloseHandle(pi.hProcess);
@@ -4357,7 +4365,7 @@
 									  data->UILanguageFile);
 						get_lang_msgW("MSG_CANTOPEN_FILE_ERROR", message, _countof(message), L"Cannot open file",
 									  data->UILanguageFile);
-						MessageBoxW(hDlgWnd, message, caption, MB_TASKMODAL | MB_ICONEXCLAMATION);
+						_MessageBoxW(hDlgWnd, message, caption, MB_TASKMODAL | MB_ICONEXCLAMATION);
 
 						free(strW);
 
@@ -4591,9 +4599,10 @@
 	if ((cv.PortType==IdTCPIP) &&
 	    ((ts.PortFlag & PF_CONFIRMDISCONN) != 0) &&
 	    (confirm)) {
-		get_lang_msg("MSG_DISCONNECT_CONF", ts.UIMsg, sizeof(ts.UIMsg),
-		             "Disconnect?", ts.UILanguageFile);
-		if (::MessageBox(HVTWin, ts.UIMsg, "Tera Term",
+		wchar_t uimsg[MAX_UIMSG];
+		get_lang_msgW("MSG_DISCONNECT_CONF", uimsg, _countof(uimsg),
+					  L"Disconnect?", ts.UILanguageFile);
+		if (_MessageBoxW(HVTWin, uimsg, L"Tera Term",
 		                 MB_OKCANCEL | MB_ICONEXCLAMATION | MB_DEFBUTTON2)==IDCANCEL) {
 			return;
 		}
@@ -5014,11 +5023,12 @@
 	// \x8F\x91\x82\xAB\x8D\x9E\x82݂ł\xAB\x82邩\x82̔\xBB\x95ʂ\xF0\x92lj\xC1 (2005.11.3 yutaka)
 	if ((ret = _access(ts.SetupFName, 0x02)) != 0) {
 		if (errno != ENOENT) {  // \x83t\x83@\x83C\x83\x8B\x82\xAA\x82\xB7\x82łɑ\xB6\x8D݂\xB7\x82\xE9\x8Fꍇ\x82̂݃G\x83\x89\x81[\x82Ƃ\xB7\x82\xE9 (2005.12.13 yutaka)
-			char uimsg[MAX_UIMSG];
-			get_lang_msg("MSG_TT_ERROR", uimsg, sizeof(uimsg), "Tera Term: ERROR", ts.UILanguageFile);
-			get_lang_msg("MSG_SAVESETUP_PERMISSION_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-			             "TERATERM.INI file doesn't have the writable permission.", ts.UILanguageFile);
-			MessageBox(ts.UIMsg, uimsg, MB_OK|MB_ICONEXCLAMATION);
+			wchar_t uimsg[MAX_UIMSG];
+			wchar_t uimsg2[MAX_UIMSG];
+			get_lang_msgW("MSG_TT_ERROR", uimsg, _countof(uimsg), L"Tera Term: ERROR", ts.UILanguageFile);
+			get_lang_msgW("MSG_SAVESETUP_PERMISSION_ERROR", uimsg2, _countof(uimsg2),
+						  L"TERATERM.INI file doesn't have the writable permission.", ts.UILanguageFile);
+			_MessageBoxW(HVTWin, uimsg2, uimsg, MB_OK|MB_ICONEXCLAMATION);
 			return;
 		}
 	}
@@ -5085,8 +5095,9 @@
 	STARTUPINFO si;
 	PROCESS_INFORMATION pi;
 	BOOL ret = FALSE;
-	char buf[80];
-	char uimsg[MAX_UIMSG];
+	wchar_t buf[80];
+	wchar_t uimsg[MAX_UIMSG];
+	wchar_t uimsg2[MAX_UIMSG];
 
 	SetLastError(NO_ERROR);
 
@@ -5093,11 +5104,11 @@
 	_snprintf_s(fullpath, sizeof(fullpath), "%s\\%s", pathname, filename);
 	if (_access(fullpath, 0) != 0) { // \x83t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB5\x82Ȃ\xA2
 		DWORD no = GetLastError();
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("DLG_SETUPDIR_NOFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-			"File does not exist.(%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, no);
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("DLG_SETUPDIR_NOFILE_ERROR", uimsg2, _countof(uimsg2),
+					  L"File does not exist.(%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no);
+		_MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
 		goto error;
 	}
 
@@ -5110,11 +5121,11 @@
 	if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0,
 		NULL, NULL, &si, &pi) == 0) { // \x8BN\x93\xAE\x8E\xB8\x94s
 		DWORD no = GetLastError();
-		get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
-		get_lang_msg("DLG_SETUPDIR_OPENFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
-			"Cannot open file.(%d)", ts.UILanguageFile);
-		_snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, no);
-		::MessageBox(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
+		get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile);
+		get_lang_msgW("DLG_SETUPDIR_OPENFILE_ERROR", uimsg2, _countof(uimsg2),
+					  L"Cannot open file.(%d)", ts.UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no);
+		_MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING);
 		goto error;
 	} else {
 		CloseHandle(pi.hThread);


Ttssh2-commit メーリングリストの案内