Revision: 8484 https://osdn.net/projects/ttssh2/scm/svn/commits/8484 Author: doda Date: 2020-01-18 03:15:18 +0900 (Sat, 18 Jan 2020) Log Message: ----------- メニュー項目名の他言語化対応 以下の TTX で、UI言語ファイルとシステムのロケールが異なる時でも 文字化けせずに表示出来るようにした。 ・TTXAlwaysOnTop ・TTXKanjiMenu Modified Paths: -------------- trunk/TTXKanjiMenu/ttxkanjimenu.c trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c -------------- next part -------------- Modified: trunk/TTXKanjiMenu/ttxkanjimenu.c =================================================================== --- trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:15:12 UTC (rev 8483) +++ trunk/TTXKanjiMenu/ttxkanjimenu.c 2020-01-17 18:15:18 UTC (rev 8484) @@ -27,6 +27,10 @@ #define IniSection "TTXKanjiMenu" #define ORDER 5000 +#define ID_MI_KANJIRECV 54009 +#define ID_MI_KANJISEND 54109 +#define ID_MI_USEONESETTING 54200 + #define UpdateRecvMenu(val) \ CheckMenuRadioItem(pvar->hmEncode, \ ID_MI_KANJIRECV + IdSJIS, \ @@ -40,6 +44,120 @@ ID_MI_KANJISEND + (val), \ MF_BYCOMMAND) +// \x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ږ\xBC\x82̏\xEE\x95\xF1 +typedef struct { + int menuID; + const char *menuStr; +} KmTextInfo; + +// \x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x93\xFA\x96{\x8C\xEA) +static const KmTextInfo MenuNameRecvJ[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv: &Shift_JIS" }, + { ID_MI_KANJIRECV + IdEUC, "Recv: &EUC-JP" }, + { ID_MI_KANJIRECV + IdJIS, "Recv: &JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m" } +}; + +// \x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x8A؍\x91\x8C\xEA) +static const KmTextInfo MenuNameRecvK[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv: &KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m" } +}; + +// \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x93\xFA\x96{\x8C\xEA) +static const KmTextInfo MenuNameSendJ[] = { + { ID_MI_KANJISEND + IdSJIS, "Send: S&hift_JIS" }, + { ID_MI_KANJISEND + IdEUC, "Send: EU&C-JP" }, + { ID_MI_KANJISEND + IdJIS, "Send: J&IS" }, + { ID_MI_KANJISEND + IdUTF8, "Send: U&TF-8" } +}; + +// \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x8A؍\x91\x8C\xEA) +static const KmTextInfo MenuNameSendK[] = { + { ID_MI_KANJISEND + IdSJIS, "Send: K&S5601" }, + { ID_MI_KANJISEND + IdUTF8, "Send: U&TF-8" } +}; + +// \x91\x97\x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x93\xFA\x96{\x8C\xEA) +static const KmTextInfo MenuNameOneJ[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv/Send: &Shift_JIS" }, + { ID_MI_KANJIRECV + IdEUC, "Recv/Send: &EUC-JP" }, + { ID_MI_KANJIRECV + IdJIS, "Recv/Send: &JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv/Send: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m/Send: UTF-8" } +}; + +// \x91\x97\x8E\xF3\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h (\x8A؍\x91\x8C\xEA) +static const KmTextInfo MenuNameOneK[] = { + { ID_MI_KANJIRECV + IdSJIS, "Recv/Send: &KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "Recv/Send: &UTF-8" }, + { ID_MI_KANJIRECV + IdUTF8m, "Recv: UTF-8&m/Send: UTF-8" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x8E\xA9\x91̂̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x93\xFA\x96{\x8C\xEA) +static DlgTextInfo MenuTitleInfoJ[] = { + { -1, "MENU_KANJI" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x8E\xA9\x91̂̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x8A؍\x91\x8C\xEA) +static DlgTextInfo MenuTitleInfoK[] = { + { -1, "MENU_KANJI_K" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x95\xAA\x97\xA3\x8E\x9E/\x93\xFA\x96{\x8C\xEA) +static const DlgTextInfo MenuInfoSeparateJ[] = { + // \x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_RECV_SJIS" }, + { ID_MI_KANJIRECV + IdEUC, "MENU_RECV_EUCJP" }, + { ID_MI_KANJIRECV + IdJIS, "MENU_RECV_JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_RECV_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_RECV_UTF8m" }, + // \x91\x97\x90M + { ID_MI_KANJISEND + IdSJIS, "MENU_SEND_SJIS" }, + { ID_MI_KANJISEND + IdEUC, "MENU_SEND_EUCJP" }, + { ID_MI_KANJISEND + IdJIS, "MENU_SEND_JIS" }, + { ID_MI_KANJISEND + IdUTF8, "MENU_SEND_UTF8" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x95\xAA\x97\xA3\x8E\x9E/\x8A؍\x91\x8C\xEA) +static const DlgTextInfo MenuInfoSeparateK[] = { + // \x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_RECV_KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_RECV_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_RECV_UTF8m" }, + // \x91\x97\x90M + { ID_MI_KANJISEND + IdSJIS, "MENU_SEND_KS5601" }, + { ID_MI_KANJISEND + IdUTF8, "MENU_SEND_UTF8" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x8B\xA4\x92ʎ\x9E/\x93\xFA\x96{\x8C\xEA) +static const DlgTextInfo MenuInfoOneJ[] = { + // \x91\x97\x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_SJIS" }, + { ID_MI_KANJIRECV + IdEUC, "MENU_EUCJP" }, + { ID_MI_KANJIRECV + IdJIS, "MENU_JIS" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_UTF8m" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + +// \x83\x81\x83j\x83\x85\x81[\x93\xE0\x82̊e\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x97p\x8F\xEE\x95\xF1 (\x91\x97\x8E\xF3\x90M\x8B\xA4\x92ʎ\x9E/\x8A؍\x91\x8C\xEA) +static const DlgTextInfo MenuInfoOneK[] = { + // \x91\x97\x8E\xF3\x90M + { ID_MI_KANJIRECV + IdSJIS, "MENU_KS5601" }, + { ID_MI_KANJIRECV + IdUTF8, "MENU_UTF8" }, + { ID_MI_KANJIRECV + IdUTF8m, "MENU_UTF8m" }, + // UseOneSetting + { ID_MI_USEONESETTING, "MENU_USE_ONE_SETTING" } +}; + static HANDLE hInst; /* Instance handle of TTX*.DLL */ typedef struct { @@ -59,7 +177,7 @@ static TInstVar InstVar; /* - * This function is called when Tera Term starts up. + * \x8F\x89\x8A\xFA\x89\xBB */ static void PASCAL TTXInit(PTTSet ts, PComVar cv) { pvar->ts = ts; @@ -138,6 +256,9 @@ SendMessage(hWin, WM_COMMAND, MAKELONG(ID_SETUP_TERMINAL, 0), 0); } +/* + * \x90ݒ\xE8\x82̓ǂݍ\x9E\x82\xDD + */ static void PASCAL TTXKanjiMenuReadIniFile(PCHAR fn, PTTSet ts) { char buff[20]; @@ -150,6 +271,7 @@ } else { pvar->UseOneSetting = TRUE; + // UseOneSetting \x82\xAA on \x82̏ꍇ\x82́A\x91\x97\x8E\xF3\x90M\x90ݒ肪\x93\xAF\x82\xB6\x82ɂȂ\xE9\x82悤\x82ɒ\xB2\x90\xAE\x82\xB7\x82\xE9 if (pvar->ts->Language == IdJapanese) { if (pvar->ts->KanjiCode == IdUTF8m) { pvar->ts->KanjiCodeSend = IdUTF8; @@ -165,6 +287,9 @@ return; } +/* + * \x90ݒ\xE8\x82̕ۑ\xB6 + */ static void PASCAL TTXKanjiMenuWriteIniFile(PCHAR fn, PTTSet ts) { /* Call original WriteIniFile */ pvar->origWriteIniFile(fn, ts); @@ -174,6 +299,9 @@ return; } +/* + * \x90ݒ\xE8\x82̓ǂݏ\x91\x82\xAB\x82\xF0\x83t\x83b\x83N\x82\xB7\x82\xE9 + */ static void PASCAL TTXGetSetupHooks(TTXSetupHooks *hooks) { pvar->origReadIniFile = *hooks->ReadIniFile; *hooks->ReadIniFile = TTXKanjiMenuReadIniFile; @@ -181,124 +309,112 @@ *hooks->WriteIniFile = TTXKanjiMenuWriteIniFile; } -#define ID_MI_KANJIRECV 54009 -#define ID_MI_KANJISEND 54109 -#define ID_MI_USEONESETTING 54200 +/* + * \x93\xC1\x92\xE8\x82\xCCID\x82̎q\x82\xF0\x8E\x9D\x82\x81\x83j\x83\x85\x81[\x82̈ʒu\x82\xF0\x95Ԃ\xB7 + */ +static int GetMenuPosByChildId(HMENU menu, UINT id) { + UINT i, j, items, subitems, cur_id; + HMENU m; + items = GetMenuItemCount(menu); + + for (i=0; i<items; i++) { + if (m = GetSubMenu(menu, i)) { + subitems = GetMenuItemCount(m); + for (j=0; j<subitems; j++) { + cur_id = GetMenuItemID(m, j); + if (cur_id == id) { + return i; + } + } + } + } + return -1; +} + +/* + * \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h\x90ݒ\xE8\x97p\x82̃\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x92lj\xC1\x82\xB7\x82\xE9 + * + * UseOneSetting \x82\xAA off \x82̎\x9E\x82Ɏg\x82\xA4 + */ static void InsertSendKcodeMenu(HMENU menu) { UINT flag = MF_BYPOSITION | MF_STRING | MF_CHECKED; + int i; if (pvar->ts->Language == IdJapanese) { - InsertMenu(menu, 5, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); - - GetI18nStr(IniSection, "MENU_SEND_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: S&hift_JIS", pvar->ts->UILanguageFile); - InsertMenu(menu, 6, flag, ID_MI_KANJISEND+IdSJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_SEND_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: EU&C-JP", pvar->ts->UILanguageFile); - InsertMenu(menu, 7, flag, ID_MI_KANJISEND+IdEUC, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_SEND_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: J&IS", pvar->ts->UILanguageFile); - InsertMenu(menu, 8, flag, ID_MI_KANJISEND+IdJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_SEND_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: U&TF-8", pvar->ts->UILanguageFile); - InsertMenu(menu, 9, flag, ID_MI_KANJISEND+IdUTF8, pvar->ts->UIMsg); + for (i = 0; i < _countof(MenuNameSendJ); i++) { + InsertMenu(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_STRING, + MenuNameSendJ[i].menuID, MenuNameSendJ[i].menuStr); + } } else { // IdKorean - InsertMenu(menu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); + for (i = 0; i < _countof(MenuNameSendK); i++) { + InsertMenu(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_STRING, + MenuNameSendK[i].menuID, MenuNameSendK[i].menuStr); + } + } - GetI18nStr(IniSection, "MENU_SEND_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: K&S5601", pvar->ts->UILanguageFile); - InsertMenu(menu, 3, flag, ID_MI_KANJISEND+IdSJIS, pvar->ts->UIMsg); - - GetI18nStr(IniSection, "MENU_SEND_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Send: U&TF-8", pvar->ts->UILanguageFile); - InsertMenu(menu, 4, flag, ID_MI_KANJISEND+IdUTF8, pvar->ts->UIMsg); - } + InsertMenu(menu, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); } +/* + * \x91\x97\x90M\x8A\xBF\x8E\x9A\x83R\x81[\x83h\x90ݒ\xE8\x97p\x82̃\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x8D폜\x82\xB7\x82\xE9 + * + * UseOneSetting \x82\xAA on \x82ɂ\xB3\x82ꂽ\x8E\x9E\x82ɌĂ\xEA\x82\xE9 + */ static void DeleteSendKcodeMenu(HMENU menu) { + int i; + if (pvar->ts->Language == IdJapanese) { - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); - DeleteMenu(menu, 5, MF_BYPOSITION); + for (i=0; i < _countof(MenuNameSendJ); i++) { + DeleteMenu(menu, MenuNameSendJ[i].menuID, MF_BYCOMMAND); + } + // \x8E\xF3\x90M\x83\x81\x83j\x83\x85\x81[\x82̒\xBC\x8C\xE3\x82ɗL\x82\xE9\x83Z\x83p\x83\x8C\x81[\x83^\x82\xF0\x8D폜\x82\xB7\x82\xE9 + DeleteMenu(menu, _countof(MenuNameRecvJ), MF_BYPOSITION); } else { // IdKorean - DeleteMenu(menu, 3, MF_BYPOSITION); - DeleteMenu(menu, 3, MF_BYPOSITION); - DeleteMenu(menu, 3, MF_BYPOSITION); + for (i=0; i < _countof(MenuNameSendK); i++) { + DeleteMenu(menu, MenuNameSendK[i].menuID, MF_BYCOMMAND); + } + // \x8E\xF3\x90M\x83\x81\x83j\x83\x85\x81[\x82̒\xBC\x8C\xE3\x82ɗL\x82\xE9\x83Z\x83p\x83\x8C\x81[\x83^\x82\xF0\x8D폜\x82\xB7\x82\xE9 + DeleteMenu(menu, _countof(MenuNameRecvK), MF_BYPOSITION); } } -static void UpdateRecvMenuCaption(HMENU menu, BOOL UseOneSetting) { - if (UseOneSetting) { - if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &Shift_JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &EUC-JP", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdEUC, MF_BYCOMMAND, ID_MI_KANJIRECV+IdEUC, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m/Send: UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8m, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8m, - pvar->ts->UIMsg); +/* + * \x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ̍X\x90V + * + * \x88ȉ\xBA\x82̓\xF1\x82ɂ\xA2\x82ă\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x8DX\x90V\x82\xB7\x82\xE9\x81B + * 1. UseOneSetting \x82̐ݒ\xE8\x82Ɋ\xEE\x82Â\xA2\x82āA\x8E\xF3\x90M\x97p\x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ\xF0\x8E\xF3\x90M\x90\xEA\x97p/\x91\x97\x8E\xF3\x90M\x8C\x93\x97p\x82̐\xE8\x91ւ\xA6\x82\xF0\x8Ds\x82\xA4 + * 2. \x83\x81\x83j\x83\x85\x81[\x8D\x80\x96ڂ̍\x91\x8Dۉ\xBB\x82\xF0\x8Ds\x82\xA4 + * + * \x92ʏ\xED\x82\xCD 1 \x82Őݒ肵\x82\xBD\x8D\x80\x96ږ\xBC\x82\xCD 2 \x82ŏ㏑\x82\xAB\x8DX\x90V\x82\xB3\x82\xEA\x82邪\x81Alng \x83t\x83@\x83C\x83\x8B\x82\xAA\x90ݒ肳\x82\xEA\x82Ă\xA2\x82Ȃ\xA2\x81A + * \x82܂\xBD\x82\xCD lng \x83t\x83@\x83C\x83\x8B\x82Ƀ\x81\x83j\x83\x85\x81[\x8D\x80\x96ږ\xBC\x82\xAA\x8A܂܂\xEA\x82Ă\xA2\x82Ȃ\xA2\x8Fꍇ\x82ւ̑Ή\x9E\x82Ƃ\xB5\x82\xC4 1 \x82\xF0\x8Ds\x82\xC1\x82Ă\xA2\x82\xE9\x81B + */ +static void UpdateMenuCaption(HMENU menu, BOOL UseOneSetting) { +#define doUpdateMenu(nameInfo, i18nInfo) { \ + UINT i, id; \ + for (i=0; i < _countof(nameInfo); i++) { \ + id = (nameInfo)[i].menuID; \ + ModifyMenu(menu, id, MF_BYCOMMAND, id, (nameInfo)[i].menuStr); \ + } \ + SetI18MenuStrs(IniSection, menu, (i18nInfo), _countof(i18nInfo), pvar->ts->UILanguageFile); \ +} + + if (pvar->ts->Language == IdJapanese) { + if (UseOneSetting) { + doUpdateMenu(MenuNameOneJ, MenuInfoOneJ); } - else { // IdKorean - GetI18nStr(IniSection, "MENU_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &KS5601", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv/Send: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); + else { + doUpdateMenu(MenuNameRecvJ, MenuInfoSeparateJ); } } - else { - if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_RECV_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &Shift_JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &EUC-JP", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdEUC, MF_BYCOMMAND, ID_MI_KANJIRECV+IdEUC, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &JIS", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8m, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8m, - pvar->ts->UIMsg); + else { // IdKorean + if (UseOneSetting) { + doUpdateMenu(MenuNameOneK, MenuInfoOneK); } - else { // IdKorean - GetI18nStr(IniSection, "MENU_RECV_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &KS5601", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdSJIS, MF_BYCOMMAND, ID_MI_KANJIRECV+IdSJIS, - pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - ModifyMenu(menu, ID_MI_KANJIRECV+IdUTF8, MF_BYCOMMAND, ID_MI_KANJIRECV+IdUTF8, - pvar->ts->UIMsg); + else { + doUpdateMenu(MenuNameRecvK, MenuInfoSeparateK); } } } @@ -307,8 +423,6 @@ * This function is called when Tera Term creates a new menu. */ static void PASCAL TTXModifyMenu(HMENU menu) { - UINT flag = MF_ENABLED; - // \x8C\xBE\x8Cꂪ\x93\xFA\x96{\x8C\xEA\x82܂\xBD\x82͊؍\x91\x8C\xEA\x82̎\x9E\x82̂݃\x81\x83j\x83\x85\x81[\x82ɒlj\xC1\x82\xB7\x82\xE9 if (pvar->ts->Language != IdJapanese && pvar->ts->Language != IdKorean) { return; @@ -316,6 +430,7 @@ { MENUITEMINFO mi; + int pos, i; pvar->hmEncode = CreateMenu(); @@ -331,68 +446,53 @@ mi.fMask = MIIM_TYPE | MIIM_SUBMENU; mi.fType = MFT_STRING; mi.hSubMenu = pvar->hmEncode; + if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_KANJI", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "&KanjiCode", pvar->ts->UILanguageFile); + mi.dwTypeData = "&KanjiCode"; } else { // IdKorean - GetI18nStr(IniSection, "MENU_KANJI_K", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Coding(&K)", pvar->ts->UILanguageFile); + mi.dwTypeData = "Coding(&K)"; } - mi.dwTypeData = pvar->ts->UIMsg; InsertMenuItem(menu, ID_HELPMENU, FALSE, &mi); - flag = MF_STRING|MF_CHECKED; if (pvar->ts->Language == IdJapanese) { - GetI18nStr(IniSection, "MENU_RECV_SJIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &Shift_JIS", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdSJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_EUCJP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &EUC-JP", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdEUC, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_JIS", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &JIS", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8m", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: UTF-8&m", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8m, pvar->ts->UIMsg); + for (i = 0; i < _countof(MenuNameRecvJ); i++) { + AppendMenu(pvar->hmEncode, MF_STRING, MenuNameRecvJ[i].menuID, MenuNameRecvJ[i].menuStr); + } } else { // IdKorean - GetI18nStr(IniSection, "MENU_RECV_KS5601", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &KS5601", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdSJIS, pvar->ts->UIMsg); - GetI18nStr(IniSection, "MENU_RECV_UTF8", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Recv: &UTF-8", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_KANJIRECV+IdUTF8, pvar->ts->UIMsg); + for (i = 0; i < _countof(MenuNameRecvK); i++) { + AppendMenu(pvar->hmEncode, MF_STRING, MenuNameRecvK[i].menuID, MenuNameRecvK[i].menuStr); + } } + AppendMenu(pvar->hmEncode, MF_SEPARATOR, 0, NULL); + AppendMenu(pvar->hmEncode, MF_STRING, ID_MI_USEONESETTING , "Use &one setting"); + if (!pvar->UseOneSetting) { InsertSendKcodeMenu(pvar->hmEncode); } - else { - UpdateRecvMenuCaption(pvar->hmEncode, pvar->UseOneSetting); - } - AppendMenu(pvar->hmEncode, MF_SEPARATOR, 0, NULL); - GetI18nStr(IniSection, "MENU_USE_ONE_SETTING", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "Use &one setting", pvar->ts->UILanguageFile); - AppendMenu(pvar->hmEncode, flag, ID_MI_USEONESETTING , pvar->ts->UIMsg); + pos = GetMenuPosByChildId(menu, ID_MI_KANJIRECV + IdSJIS); - UpdateRecvMenu(pvar->ts->KanjiCode); - if (!pvar->UseOneSetting) { - UpdateSendMenu(pvar->ts->KanjiCodeSend); + if (pos > 0) { + if (pvar->ts->Language == IdJapanese) { + MenuTitleInfoJ->nIDDlgItem = pos; + SetI18MenuStrs(IniSection, menu, MenuTitleInfoJ, _countof(MenuTitleInfoJ), pvar->ts->UILanguageFile); + } + else { + MenuTitleInfoK->nIDDlgItem = pos; + SetI18MenuStrs(IniSection, menu, MenuTitleInfoK, _countof(MenuTitleInfoK), pvar->ts->UILanguageFile); + } } - CheckMenuItem(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | (pvar->UseOneSetting)?MF_CHECKED:0); + UpdateMenuCaption(pvar->hmEncode, pvar->UseOneSetting); } } /* - * This function is called when Tera Term pops up a submenu menu. + * \x83\x89\x83W\x83I\x83\x81\x83j\x83\x85\x81[/\x83`\x83F\x83b\x83N\x83\x81\x83j\x83\x85\x81[\x82̏\xF3\x91Ԃ\xF0\x90ݒ\xE8\x82ɍ\x87\x82킹\x82čX\x90V\x82\xB7\x82\xE9\x81B */ static void PASCAL TTXModifyPopupMenu(HMENU menu) { // \x83\x81\x83j\x83\x85\x81[\x82\xAA\x8CĂяo\x82\xB3\x82ꂽ\x82\xE7\x81A\x8DŐV\x82̐ݒ\xE8\x82ɍX\x90V\x82\xB7\x82\xE9\x81B(2007.5.25 yutaka) @@ -439,7 +539,6 @@ if (pvar->UseOneSetting) { pvar->UseOneSetting = FALSE; InsertSendKcodeMenu(pvar->hmEncode); - CheckMenuItem(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND); } else { pvar->UseOneSetting = TRUE; @@ -453,9 +552,8 @@ pvar->cv->KanjiCodeSend = pvar->ts->KanjiCodeSend = val; DeleteSendKcodeMenu(pvar->hmEncode); - CheckMenuItem(pvar->hmEncode, ID_MI_USEONESETTING, MF_BYCOMMAND | MF_CHECKED); } - UpdateRecvMenuCaption(pvar->hmEncode, pvar->UseOneSetting); + UpdateMenuCaption(pvar->hmEncode, pvar->UseOneSetting); return 1; } Modified: trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c =================================================================== --- trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:12 UTC (rev 8483) +++ trunk/TTXSamples/TTXAlwaysOnTop/TTXAlwaysOnTop.c 2020-01-17 18:15:18 UTC (rev 8484) @@ -63,6 +63,10 @@ } static void PASCAL TTXModifyMenu(HMENU menu) { + static const DlgTextInfo MenuTextInfo[] = { + { ID_MENU_BASE, "MENU_ALWAYSONTOP" } + }; + UINT flag = MF_BYCOMMAND | MF_STRING | MF_ENABLED; pvar->ControlMenu = GetControlMenu(menu); @@ -70,10 +74,10 @@ flag |= MF_CHECKED; } - GetI18nStr(IniSection, "MENU_ALWAYSONTOP", pvar->ts->UIMsg, sizeof(pvar->ts->UIMsg), - "&Always on top", pvar->ts->UILanguageFile); - InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, pvar->ts->UIMsg); + InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, flag, ID_MENU_BASE, "&Alwais on top"); InsertMenu(pvar->ControlMenu, ID_CONTROL_MACRO, MF_BYCOMMAND | MF_SEPARATOR, 0, NULL); + + SetI18MenuStrs(IniSection, menu, MenuTextInfo, _countof(MenuTextInfo), pvar->ts->UILanguageFile); } static int PASCAL TTXProcessCommand(HWND hWin, WORD cmd) {