[Ttssh2-commit] [8496] common_static を ttpcmn からリンク, windowメニューを多言語化

scmno****@osdn***** scmno****@osdn*****
2020年 1月 22日 (水) 22:53:43 JST


Revision: 8496
          https://osdn.net/projects/ttssh2/scm/svn/commits/8496
Author:   zmatsuo
Date:     2020-01-22 22:53:43 +0900 (Wed, 22 Jan 2020)
Log Message:
-----------
common_static を ttpcmn からリンク, windowメニューを多言語化

Modified Paths:
--------------
    trunk/teraterm/ttermpro.sln
    trunk/teraterm/ttpcmn/CMakeLists.txt
    trunk/teraterm/ttpcmn/ttcmn.c
    trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj
    trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters
    trunk/teraterm/ttpcmn/ttpcmn.vcproj

-------------- next part --------------
Modified: trunk/teraterm/ttermpro.sln
===================================================================
--- trunk/teraterm/ttermpro.sln	2020-01-22 13:53:33 UTC (rev 8495)
+++ trunk/teraterm/ttermpro.sln	2020-01-22 13:53:43 UTC (rev 8496)
@@ -14,6 +14,9 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "keycode", "keycode\keycode.vcproj", "{B31BF2E8-79E6-4735-BEA2-C1B4041C2D2E}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpcmn", "ttpcmn\ttpcmn.vcproj", "{118E0D32-5553-4F73-9927-E873C1C500E4}"
+	ProjectSection(ProjectDependencies) = postProject
+		{DF4E3C36-A743-4FB4-8EE9-49899E69ED32} = {DF4E3C36-A743-4FB4-8EE9-49899E69ED32}
+	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ttpfile", "ttpfile\ttpfile.vcproj", "{311F2B21-AEC4-4384-8209-BB83B54749B4}"
 	ProjectSection(ProjectDependencies) = postProject

Modified: trunk/teraterm/ttpcmn/CMakeLists.txt
===================================================================
--- trunk/teraterm/ttpcmn/CMakeLists.txt	2020-01-22 13:53:33 UTC (rev 8495)
+++ trunk/teraterm/ttpcmn/CMakeLists.txt	2020-01-22 13:53:43 UTC (rev 8496)
@@ -5,7 +5,6 @@
 set(COMMON_SRC
   ../common/teraterm.h
   ../common/tttypes.h
-  ../common/i18n.c
   ../common/i18n.h
   ../common/ttlib.c
   ../common/ttlib.h
@@ -16,11 +15,8 @@
   ../common/ttcommon.h
   ../common/tt_res.h
   ../common/codeconv.h
-  ../common/codeconv.cpp
   ../common/compat_win.h
-  ../common/compat_win.cpp
   ../common/dllutil.h
-  ../common/dllutil.cpp
   )
 
 source_group(
@@ -73,6 +69,7 @@
 
 target_link_libraries(
   ttpcmn
+  common_static
   ole32
   setupapi
   delayimp

Modified: trunk/teraterm/ttpcmn/ttcmn.c
===================================================================
--- trunk/teraterm/ttpcmn/ttcmn.c	2020-01-22 13:53:33 UTC (rev 8495)
+++ trunk/teraterm/ttpcmn/ttcmn.c	2020-01-22 13:53:43 UTC (rev 8496)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 1994-1998 T. Teranishi
- * (C) 2004-2019 TeraTerm Project
+ * (C) 2004-2020 TeraTerm Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -58,6 +58,7 @@
 
 #define DllExport __declspec(dllexport)
 #include "ttcommon.h"
+#include "layer_for_unicode.h"
 
 
 // TMap \x82\xF0\x8Ai\x94[\x82\xB7\x82\xE9\x83t\x83@\x83C\x83\x8B\x83}\x83b\x83s\x83\x93\x83O\x83I\x83u\x83W\x83F\x83N\x83g(\x8B\xA4\x97L\x83\x81\x83\x82\x83\x8A)\x82̖\xBC\x91O
@@ -76,14 +77,6 @@
 #define VTCLASSNAME _T("VTWin32")
 #define TEKCLASSNAME _T("TEKWin32")
 
-#ifdef UNICODE
-static HWND(WINAPI *pHtmlHelp)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData);
-#define HTMLHELP_API_NAME	"HtmlHelpW"
-#else
-static HWND(WINAPI *pHtmlHelp)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
-#define HTMLHELP_API_NAME	"HtmlHelpA"
-#endif
-
 enum window_style {
 	WIN_CASCADE,
 	WIN_STACKED,
@@ -950,6 +943,7 @@
 	int i;
 	char Temp[MAXPATHLEN];
 	HWND Hw;
+	wchar_t uimsg[MAX_UIMSG];
 
 	// delete all items in Window menu
 	i = GetMenuItemCount(menu);
@@ -981,39 +975,40 @@
 			UnregWin(Hw);
 		}
 	}
-	get_lang_msg("MENU_WINDOW_WINDOW", buf, buflen, "&Window", langFile);
 	if (VTFlag == 1) {
+		static const DlgTextInfo MenuTextInfo[] = {
+			{ ID_WINDOW_WINDOW, "MENU_WINDOW_WINDOW" },
+			{ ID_WINDOW_MINIMIZEALL, "MENU_WINDOW_MINIMIZEALL" },
+			{ ID_WINDOW_RESTOREALL, "MENU_WINDOW_RESTOREALL" },
+			{ ID_WINDOW_CASCADEALL, "MENU_WINDOW_CASCADE" },
+			{ ID_WINDOW_STACKED, "MENU_WINDOW_STACKED" },
+			{ ID_WINDOW_SIDEBYSIDE, "MENU_WINDOW_SIDEBYSIDE" },
+		};
+
 		AppendMenu(menu, MF_SEPARATOR, 0, NULL);
-		AppendMenu(menu,MF_ENABLED | MF_STRING,ID_WINDOW_WINDOW, buf);
+		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_WINDOW, "&Window");
+		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_MINIMIZEALL, "&Minimize All");
+		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_RESTOREALL, "&Restore All");
+		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_CASCADEALL, "&Cascade");
+		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_STACKED, "&Stacked");
+		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_SIDEBYSIDE, "Side &by Side");
 
-		get_lang_msg("MENU_WINDOW_MINIMIZEALL", buf, buflen, "&Minimize All", langFile);
-		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_MINIMIZEALL, buf);
+		SetI18nMenuStrs("Tera Term", menu, MenuTextInfo, _countof(MenuTextInfo), langFile);
 
-		get_lang_msg("MENU_WINDOW_RESTOREALL", buf, buflen, "&Restore All", langFile);
-		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_RESTOREALL, buf);
-
-		get_lang_msg("MENU_WINDOW_CASCADE", buf, buflen, "&Cascade", langFile);
-		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_CASCADEALL, buf);
-
-		get_lang_msg("MENU_WINDOW_STACKED", buf, buflen, "&Stacked", langFile);
-		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_STACKED, buf);
-
-		get_lang_msg("MENU_WINDOW_SIDEBYSIDE", buf, buflen, "Side &by Side", langFile);
-		AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_SIDEBYSIDE, buf);
-
 		if (pm->WinUndoFlag) {
 			if (pm->WinUndoStyle == WIN_CASCADE)
-				get_lang_msg("MENU_WINDOW_CASCADE_UNDO", buf, buflen, "&Undo - Cascade", langFile);
+				get_lang_msgW("MENU_WINDOW_CASCADE_UNDO", uimsg, _countof(uimsg), L"&Undo - Cascade", langFile);
 			else if (pm->WinUndoStyle == WIN_STACKED)
-				get_lang_msg("MENU_WINDOW_STACKED_UNDO", buf, buflen, "&Undo - Stacked", langFile);
+				get_lang_msgW("MENU_WINDOW_STACKED_UNDO", uimsg, _countof(uimsg), L"&Undo - Stacked", langFile);
 			else
-				get_lang_msg("MENU_WINDOW_SIDEBYSIDE_UNDO", buf, buflen, "&Undo - Side by Side", langFile);
-			AppendMenu(menu, MF_ENABLED | MF_STRING, ID_WINDOW_UNDO, buf);
+				get_lang_msgW("MENU_WINDOW_SIDEBYSIDE_UNDO", uimsg, _countof(uimsg), L"&Undo - Side by Side", langFile);
+			_AppendMenuW(menu, MF_ENABLED | MF_STRING, ID_WINDOW_UNDO, uimsg);		// TODO UNICODE
 		}
 
 	}
 	else {
-		AppendMenu(menu,MF_ENABLED | MF_STRING,ID_TEKWINDOW_WINDOW, buf);
+		get_lang_msgW("MENU_WINDOW_WINDOW", uimsg, _countof(uimsg), L"&Window", langFile);
+		_AppendMenuW(menu,MF_ENABLED | MF_STRING,ID_TEKWINDOW_WINDOW, uimsg);
 	}
 }
 
@@ -1171,12 +1166,9 @@
 	char HomeDir[MAX_PATH];
 	char Temp[MAX_PATH];
 	HWND HWin;
-	TCHAR HelpFN[MAX_PATH];
-	TCHAR uimsg[MAX_UIMSG];
-	TCHAR dllName[MAX_PATH];
-	const TCHAR *HomeDirT;
-	const TCHAR *errorFile;
-	TCHAR buf[MAX_PATH];
+	wchar_t HelpFN[MAX_PATH];
+	wchar_t uimsg[MAX_UIMSG];
+	wchar_t *HomeDirT;
 
 	/* Get home directory */
 	if (GetModuleFileNameA(NULL,Temp,_countof(Temp)) == 0) {
@@ -1183,43 +1175,29 @@
 		return;
 	}
 	ExtractDirName(Temp, HomeDir);
-	HomeDirT = ToTcharA(HomeDir);
+	HomeDirT = ToWcharA(HomeDir);
 
-	get_lang_msgT("HELPFILE", uimsg, _countof(uimsg),
-				  _T("teraterm.chm"), UILanguageFile);
+	get_lang_msgW("HELPFILE", uimsg, _countof(uimsg), L"teraterm.chm", UILanguageFile);
 
-	if (pHtmlHelp == NULL) {
-		HINSTANCE hDll;
-		GetSystemDirectory(dllName, _countof(dllName));
-		_tcscat_s(dllName, _countof(dllName), _T("\\hhctrl.ocx"));
-		hDll = LoadLibrary(dllName);
-		if (hDll == NULL) {
-			errorFile = dllName;
-			goto error;
-		}
-		pHtmlHelp = (void *)GetProcAddress(hDll, HTMLHELP_API_NAME);
-		if (pHtmlHelp == NULL) {
-			errorFile = dllName;
-			goto error;
-		}
-	}
 	// \x83w\x83\x8B\x83v\x82̃I\x81[\x83i\x81[\x82͏\xED\x82Ƀf\x83X\x83N\x83g\x83b\x83v\x82ɂȂ\xE9 (2007.5.12 maya)
 	HWin = GetDesktopWindow();
-	_sntprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, _T("%s\\%s"), (TCHAR *)HomeDirT, uimsg);
-	if (pHtmlHelp != NULL && pHtmlHelp(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) {
-		errorFile = HelpFN;
+	_snwprintf_s(HelpFN, _countof(HelpFN), _TRUNCATE, L"%s\\%s", HomeDirT, uimsg);
+	if (_HtmlHelpW(HWin, HelpFN, Command, Data) == NULL && Command != HH_CLOSE_ALL) {
 		goto error;
 	}
 	goto finish;
 
 error:
-	get_lang_msgT("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg),
-				  _T("Can't open HTML help file(%s)."), UILanguageFile);
-	_sntprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN);
-	MessageBox(HWin, buf, _T("Tera Term: HTML help"), MB_OK | MB_ICONERROR);
+	{
+		wchar_t buf[MAX_PATH];
+		get_lang_msgW("MSG_OPENHELP_ERROR", uimsg, _countof(uimsg),
+					  L"Can't open HTML help file(%s).", UILanguageFile);
+		_snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg, HelpFN);
+		_MessageBoxW(HWin, buf, L"Tera Term: HTML help", MB_OK | MB_ICONERROR);
+	}
 
 finish:
-	free((void *)HomeDirT);
+	free(HomeDirT);
 }
 
 HWND WINAPI GetNthWin(int n)

Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj
===================================================================
--- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj	2020-01-22 13:53:33 UTC (rev 8495)
+++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj	2020-01-22 13:53:43 UTC (rev 8496)
@@ -131,10 +131,6 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="..\common\codeconv.cpp" />
-    <ClCompile Include="..\common\compat_win.cpp" />
-    <ClCompile Include="..\common\dllutil.cpp" />
-    <ClCompile Include="..\common\i18n.c" />
     <ClCompile Include="..\common\servicenames.c" />
     <ClCompile Include="..\common\ttlib.c" />
     <ClCompile Include="comportinfo.cpp" />
@@ -157,6 +153,11 @@
   <ItemGroup>
     <ResourceCompile Include="ttpcmn-version.rc" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\common\common_static.v16.vcxproj">
+      <Project>{ac42387d-23ec-45db-81f9-8933c7efa52a}</Project>
+    </ProjectReference>
+  </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>

Modified: trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters
===================================================================
--- trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters	2020-01-22 13:53:33 UTC (rev 8495)
+++ trunk/teraterm/ttpcmn/ttpcmn.v16.vcxproj.filters	2020-01-22 13:53:43 UTC (rev 8496)
@@ -19,9 +19,6 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\common\i18n.c">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="language.c">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -34,9 +31,6 @@
     <ClCompile Include="..\common\ttlib.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\common\codeconv.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="comportinfo.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -60,6 +54,12 @@
     <ClInclude Include="comportinfo.h">
       <Filter>Source Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\common\compat_win.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\common\dllutil.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="ttpcmn.def">

Modified: trunk/teraterm/ttpcmn/ttpcmn.vcproj
===================================================================
--- trunk/teraterm/ttpcmn/ttpcmn.vcproj	2020-01-22 13:53:33 UTC (rev 8495)
+++ trunk/teraterm/ttpcmn/ttpcmn.vcproj	2020-01-22 13:53:43 UTC (rev 8496)
@@ -207,18 +207,10 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
 			>
 			<File
-				RelativePath="..\common\codeconv.cpp"
-				>
-			</File>
-			<File
 				RelativePath=".\comportinfo.cpp"
 				>
 			</File>
 			<File
-				RelativePath="..\common\i18n.c"
-				>
-			</File>
-			<File
 				RelativePath="language.c"
 				>
 			</File>
@@ -234,14 +226,6 @@
 				RelativePath="..\common\ttlib.c"
 				>
 			</File>
-			<File
-				RelativePath="..\common\compat_win.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\common\dllutil.cpp"
-				>
-			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
@@ -248,6 +232,10 @@
 			Filter="h;hpp;hxx;hm;inl;fi;fd"
 			>
 			<File
+				RelativePath="..\common\compat_win.h"
+				>
+			</File>
+			<File
 				RelativePath=".\comportinfo.h"
 				>
 			</File>
@@ -256,6 +244,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\common\dllutil.h"
+				>
+			</File>
+			<File
 				RelativePath="..\common\i18n.h"
 				>
 			</File>
@@ -271,14 +263,6 @@
 				RelativePath="..\common\ttlib.h"
 				>
 			</File>
-			<File
-				RelativePath="..\common\compat_win.h"
-				>
-			</File>
-			<File
-				RelativePath="..\common\dllutil.h"
-				>
-			</File>
 		</Filter>
 		<Filter
 			Name="Def File"


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