[Ttssh2-commit] [8310] メニュー順序がずれないよう修正

scmno****@osdn***** scmno****@osdn*****
2019年 10月 16日 (水) 00:01:16 JST


Revision: 8310
          https://osdn.net/projects/ttssh2/scm/svn/commits/8310
Author:   zmatsuo
Date:     2019-10-16 00:01:16 +0900 (Wed, 16 Oct 2019)
Log Message:
-----------
メニュー順序がずれないよう修正

- 特に内容を変更しない場合でも、一度ModifyMenu()を呼ばないと順序がおかしくなる
- Ttssh2-devel 4285
- r8246

Revision Links:
--------------
    https://osdn.net/projects/ttssh2/scm/svn/commits/8246

Modified Paths:
--------------
    branches/unicode_buf/teraterm/common/compat_win.cpp
    branches/unicode_buf/teraterm/common/compat_win.h
    branches/unicode_buf/teraterm/common/i18n.c
    branches/unicode_buf/teraterm/teraterm/vtwin.cpp

-------------- next part --------------
Modified: branches/unicode_buf/teraterm/common/compat_win.cpp
===================================================================
--- branches/unicode_buf/teraterm/common/compat_win.cpp	2019-10-14 16:29:52 UTC (rev 8309)
+++ branches/unicode_buf/teraterm/common/compat_win.cpp	2019-10-15 15:01:16 UTC (rev 8310)
@@ -43,7 +43,8 @@
 INT_PTR (WINAPI *pPropertySheetW)(LPCPROPSHEETHEADERW constPropSheetHeaderPointer);
 LRESULT (WINAPI *pSendDlgItemMessageW)(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
 BOOL (WINAPI *pModifyMenuW)(HMENU hMnu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
-BOOL (WINAPI *pSetWindowTextW)(HWND hWnd, LPCWSTR lpString);
+int(WINAPI *pGetMenuStringW)(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int cchMax, UINT flags);
+BOOL(WINAPI *pSetWindowTextW)(HWND hWnd, LPCWSTR lpString);
 DWORD (WINAPI *pGetPrivateProfileStringW)(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName);
 UINT (WINAPI *pDragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch);
 DWORD (WINAPI *pGetFileAttributesW)(LPCWSTR lpFileName);
@@ -72,6 +73,7 @@
 	{ "SetDlgItemTextW", (void **)&pSetDlgItemTextW },
 	{ "SetWindowTextW", (void **)&pSetWindowTextW },
 	{ "ModifyMenuW", (void **)&pModifyMenuW },
+	{ "GetMenuStringW", (void **)&pGetMenuStringW },
 	{ "SendDlgItemMessageW", (void **)&pSendDlgItemMessageW },
 	{},
 };

Modified: branches/unicode_buf/teraterm/common/compat_win.h
===================================================================
--- branches/unicode_buf/teraterm/common/compat_win.h	2019-10-14 16:29:52 UTC (rev 8309)
+++ branches/unicode_buf/teraterm/common/compat_win.h	2019-10-15 15:01:16 UTC (rev 8310)
@@ -75,6 +75,7 @@
 extern INT_PTR (WINAPI *pPropertySheetW)(LPCPROPSHEETHEADERW constPropSheetHeaderPointer);
 extern LRESULT (WINAPI *pSendDlgItemMessageW)(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
 extern BOOL(WINAPI *pModifyMenuW)(HMENU hMnu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem);
+extern int(WINAPI *pGetMenuStringW)(HMENU hMenu, UINT uIDItem, LPWSTR lpString, int cchMax, UINT flags);
 extern BOOL(WINAPI *pSetWindowTextW)(HWND hWnd, LPCWSTR lpString);
 extern DWORD(WINAPI *pGetPrivateProfileStringW)(LPCWSTR lpAppName, LPCWSTR lpKeyName, LPCWSTR lpDefault,
 												LPWSTR lpReturnedString, DWORD nSize, LPCWSTR lpFileName);

Modified: branches/unicode_buf/teraterm/common/i18n.c
===================================================================
--- branches/unicode_buf/teraterm/common/i18n.c	2019-10-14 16:29:52 UTC (rev 8309)
+++ branches/unicode_buf/teraterm/common/i18n.c	2019-10-15 15:01:16 UTC (rev 8310)
@@ -35,6 +35,7 @@
 
 /**
  *	GetI18nStr() \x82\xCC unicode\x94\xC5
+ *	@param	buf_len		\x95\xB6\x8E\x9A\x90\x94(\0\x8A܂\xDE)
  */
 DllExport void WINAPI GetI18nStrW(const char *section, const char *key, wchar_t *buf, int buf_len, const wchar_t *def,
 								  const char *iniFile)
@@ -70,6 +71,7 @@
  *	section/key\x82\xAA\x8C\xA9\x82‚\xA9\x82\xE7\x82Ȃ\xA9\x82\xC1\x82\xBD\x8Fꍇ\x81A
  *		def\x82̕\xB6\x8E\x9A\x97\xF1\x82\xF0buf\x82ɃZ\x83b\x83g\x82\xB7\x82\xE9
  *		def\x82\xAANULL\x82̏ꍇbuf[0] = 0\x82ƂȂ\xE9
+ *	@param	buf_len		\x95\xB6\x8E\x9A\x90\x94(\0\x8A܂\xDE)
  */
 DllExport void WINAPI GetI18nStr(const char *section, const char *key, PCHAR buf, int buf_len, const char *def, const char *iniFile)
 {
@@ -177,7 +179,7 @@
 		else {
 			// UNICODE
 			wchar_t uimsg[MAX_UIMSG];
-			GetI18nStrW(section, key, uimsg, sizeof(uimsg), NULL, UILanguageFile);
+			GetI18nStrW(section, key, uimsg, _countof(uimsg), NULL, UILanguageFile);
 			if (uimsg[0] != L'\0') {
 				const int nIDDlgItem = infos[i].nIDDlgItem;
 				if (nIDDlgItem == 0) {
@@ -199,6 +201,7 @@
 void WINAPI SetI18MenuStrs(const char *section, HMENU hMenu, const DlgTextInfo *infos, size_t infoCount,
 						   const char *UILanguageFile)
 {
+	const int id_position_threshold = 1000;
 	size_t i;
 	for (i = 0; i < infoCount; i++) {
 		const int nIDDlgItem = infos[i].nIDDlgItem;
@@ -206,9 +209,9 @@
 		if (pGetPrivateProfileStringW == NULL) {
 			// ANSI
 			char uimsg[MAX_UIMSG];
-			GetI18nStr(section, key, uimsg, sizeof(uimsg), "", UILanguageFile);
+			GetI18nStr(section, key, uimsg, sizeof(uimsg), NULL, UILanguageFile);
 			if (uimsg[0] != '\0') {
-				if (nIDDlgItem < 1000) {
+				if (nIDDlgItem < id_position_threshold) {
 					ModifyMenuA(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg);
 				}
 				else {
@@ -215,13 +218,20 @@
 					ModifyMenuA(hMenu, nIDDlgItem, MF_BYCOMMAND, nIDDlgItem, uimsg);
 				}
 			}
+			else {
+				if (nIDDlgItem < id_position_threshold) {
+					// \x88\xEA\x93xModifyMenu()\x82\xB5\x82Ă\xA8\x82\xA9\x82Ȃ\xA2\x82ƃ\x81\x83j\x83\x85\x81[\x82̈ʒu\x82\xAA\x82\xB8\x82\xEA\x82\xE9
+					GetMenuStringA(hMenu, nIDDlgItem, uimsg, _countof(uimsg), MF_BYPOSITION);
+					ModifyMenuA(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg);
+				}
+			}
 		}
 		else {
 			// UNICODE
 			wchar_t uimsg[MAX_UIMSG];
-			GetI18nStrW(section, key, uimsg, sizeof(uimsg), L"", UILanguageFile);
+			GetI18nStrW(section, key, uimsg, _countof(uimsg), NULL, UILanguageFile);
 			if (uimsg[0] != '\0') {
-				if (nIDDlgItem < 1000) {
+				if (nIDDlgItem < id_position_threshold) {
 					pModifyMenuW(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg);
 				}
 				else {
@@ -228,6 +238,13 @@
 					pModifyMenuW(hMenu, nIDDlgItem, MF_BYCOMMAND, nIDDlgItem, uimsg);
 				}
 			}
+			else {
+				if (nIDDlgItem < id_position_threshold) {
+					// \x88\xEA\x93xModifyMenu()\x82\xB5\x82Ă\xA8\x82\xA9\x82Ȃ\xA2\x82ƃ\x81\x83j\x83\x85\x81[\x82̈ʒu\x82\xAA\x82\xB8\x82\xEA\x82\xE9
+					pGetMenuStringW(hMenu, nIDDlgItem, uimsg, _countof(uimsg), MF_BYPOSITION);
+					pModifyMenuW(hMenu, nIDDlgItem, MF_BYPOSITION, nIDDlgItem, uimsg);
+				}
+			}
 		}
 	}
 }

Modified: branches/unicode_buf/teraterm/teraterm/vtwin.cpp
===================================================================
--- branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-10-14 16:29:52 UTC (rev 8309)
+++ branches/unicode_buf/teraterm/teraterm/vtwin.cpp	2019-10-15 15:01:16 UTC (rev 8310)
@@ -1181,10 +1181,10 @@
 	}
 
 	SetDlgMenuTexts(FileMenu, FileMenuTextInfo, _countof(FileMenuTextInfo), ts.UILanguageFile);
-	SetDlgMenuTexts(hMenu, EditMenuTextInfo, _countof(EditMenuTextInfo), ts.UILanguageFile);
+	SetDlgMenuTexts(EditMenu, EditMenuTextInfo, _countof(EditMenuTextInfo), ts.UILanguageFile);
 	SetDlgMenuTexts(SetupMenu, SetupMenuTextInfo, _countof(SetupMenuTextInfo), ts.UILanguageFile);
-	SetDlgMenuTexts(hMenu, ControlMenuTextInfo, _countof(ControlMenuTextInfo), ts.UILanguageFile);
-	SetDlgMenuTexts(hMenu, HelpMenuTextInfo, _countof(HelpMenuTextInfo), ts.UILanguageFile);
+	SetDlgMenuTexts(ControlMenu, ControlMenuTextInfo, _countof(ControlMenuTextInfo), ts.UILanguageFile);
+	SetDlgMenuTexts(HelpMenu, HelpMenuTextInfo, _countof(HelpMenuTextInfo), ts.UILanguageFile);
 
 	if ((ts.MenuFlag & MF_SHOWWINMENU) !=0) {
 		TCHAR uimsg[MAX_UIMSG];


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