Revision: 8490 https://osdn.net/projects/ttssh2/scm/svn/commits/8490 Author: zmatsuo Date: 2020-01-19 01:12:09 +0900 (Sun, 19 Jan 2020) Log Message: ----------- Windowメニューを多言語化 - pInsertMenuW() を追加 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/compat_win.cpp 2020-01-18 16:12:09 UTC (rev 8490) @@ -71,6 +71,9 @@ HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); +BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); + /** * GetConsoleWindow() \x82Ɠ\xAF\x82\xB6\x93\xAE\x8D\xEC\x82\xF0\x82\xB7\x82\xE9 * https://support.microsoft.com/ja-jp/help/124103/how-to-obtain-a-console-window-handle-hwnd @@ -126,6 +129,8 @@ { "SendDlgItemMessageW", (void **)&pSendDlgItemMessageW }, { "MessageBoxW", (void **)&pMessageBoxW }, { "DialogBoxIndirectParamW", (void **)&pDialogBoxIndirectParamW }, + { "InsertMenuW", (void **)&pInsertMenuW }, + { "AppendMenuW", (void **)&pAppendMenuW }, {}, }; @@ -199,6 +204,7 @@ pSetWindowTextW = NULL; pSetDlgItemTextW = NULL; pGetDlgItemTextW = NULL; + pDialogBoxIndirectParamW = NULL; } // GetConsoleWindow\x93\xC1\x95ʏ\x88\x97\x9D Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/compat_win.h 2020-01-18 16:12:09 UTC (rev 8490) @@ -102,6 +102,8 @@ extern INT_PTR (WINAPI *pDialogBoxIndirectParamW)(HINSTANCE hInstance, LPCDLGTEMPLATEW hDialogTemplate, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam); extern HWND (WINAPI *pHtmlHelpW)(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData); extern HWND (WINAPI *pHtmlHelpA)(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData); +extern BOOL (WINAPI *pInsertMenuW)(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); +extern BOOL (WINAPI *pAppendMenuW)(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); #ifdef UNICODE #define pAddFontResourceEx pAddFontResourceExW Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-01-18 16:12:09 UTC (rev 8490) @@ -316,3 +316,16 @@ free(captionA); return result; } + +BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem) +{ + if (pInsertMenuW != NULL) { + return pInsertMenuW(hMenu, uPosition, uFlags, uIDNewItem, lpNewItem); + } + + char *itemA = ToCharW(lpNewItem); + int result = InsertMenuA(hMenu, uPosition, uFlags, uIDNewItem, itemA); + free(itemA); + return result; +} + Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/common/layer_for_unicode.h 2020-01-18 16:12:09 UTC (rev 8490) @@ -55,6 +55,7 @@ ATOM _RegisterClassW(const WNDCLASSW *lpWndClass); int _DrawTextW(HDC hdc, LPCWSTR lpchText, int cchText, LPRECT lprc, UINT format); int _MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); +BOOL _InsertMenuW(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCWSTR lpNewItem); #ifdef __cplusplus } Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 15:16:37 UTC (rev 8489) +++ trunk/teraterm/teraterm/vtwin.cpp 2020-01-18 16:12:09 UTC (rev 8490) @@ -1173,13 +1173,13 @@ SetDlgMenuTexts(HelpMenu, HelpMenuTextInfo, _countof(HelpMenuTextInfo), ts.UILanguageFile); if ((ts.MenuFlag & MF_SHOWWINMENU) !=0) { - char uimsg[MAX_UIMSG]; + wchar_t uimsg[MAX_UIMSG]; WinMenu = CreatePopupMenu(); - get_lang_msgT("MENU_WINDOW", uimsg, _countof(uimsg), - "&Window", ts.UILanguageFile); - ::InsertMenuA(hMenu, ID_HELPMENU, - MF_STRING | MF_ENABLED | MF_POPUP | MF_BYPOSITION, - (UINT_PTR)WinMenu, uimsg); + get_lang_msgW("MENU_WINDOW", uimsg, _countof(uimsg), + L"&Window", ts.UILanguageFile); + _InsertMenuW(hMenu, ID_HELPMENU, + MF_STRING | MF_ENABLED | MF_POPUP | MF_BYPOSITION, + (UINT_PTR)WinMenu, uimsg); } TTXModifyMenu(hMenu); /* TTPLUG */