Revision: 8826 https://osdn.net/projects/ttssh2/scm/svn/commits/8826 Author: zmatsuo Date: 2020-07-03 23:43:28 +0900 (Fri, 03 Jul 2020) Log Message: ----------- ブロードキャストコマンドのリアルタイム=OFF、マクロコマンドをUnicode化 - リアルタイム=OFF時の送信時、エディットボックスをUnicode化 - マクロコマンドのブロードキャスト,マルチキャストをUnicode化 - sendbroadcast - sendmulticast - setmulticastname Modified Paths: -------------- trunk/teraterm/teraterm/broadcast.cpp trunk/teraterm/teraterm/broadcast.h trunk/teraterm/teraterm/ttdde.c -------------- next part -------------- Modified: trunk/teraterm/teraterm/broadcast.cpp =================================================================== --- trunk/teraterm/teraterm/broadcast.cpp 2020-07-03 14:43:19 UTC (rev 8825) +++ trunk/teraterm/teraterm/broadcast.cpp 2020-07-03 14:43:28 UTC (rev 8826) @@ -41,6 +41,7 @@ #include <string.h> #include <windowsx.h> #include <commctrl.h> +#include <wchar.h> // for wmemcpy_s() #include "ttsetup.h" #include "keyboard.h" // for ShiftKey() ControlKey() @@ -47,18 +48,48 @@ #include "ttlib.h" #include "dlglib.h" #include "tt_res.h" -#include "clipboar.h" +#include "layer_for_unicode.h" +#include "codeconv.h" +#include "sendmem.h" +//#include "clipboar.h" #include "broadcast.h" // WM_COPYDATA\x82ɂ\xE6\x82\xE9\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82̎\xED\x95\xCA (2005.1.22 yutaka) -#define IPC_BROADCAST_COMMAND 1 // \x91S\x92[\x96\x96\x82֑\x97\x90M -#define IPC_MULTICAST_COMMAND 2 // \x94C\x88ӂ̒[\x96\x96\x8CQ\x82֑\x97\x90M +#define IPC_BROADCAST_COMMAND 1 // \x91S\x92[\x96\x96\x82֑\x97\x90M +#define IPC_MULTICAST_COMMAND 2 // \x94C\x88ӂ̒[\x96\x96\x8CQ\x82֑\x97\x90M +/* + * COPYDATASTRUCT + * + * dwData + * IPC_BROADCAST_COMMAND + * lpData + * +--------------+--+ + * |string |\0| + * +--------------+--+ + * <--------------> + * cbData + * strlen(string) + 1 + * (wcslen(string) + 1) * sizeof(wchar_t) + * buf\x82̒\xBC\x8C\xE3\x82ɂ\xCD \0 \x82͕t\x82\xA9\x82Ȃ\xA2 + * + * dwData + * IPC_MULTICAST_COMMAND + * lpData + * +------+--------------+--+ + * |name\0|string |\0| + * +------+--------------+--+ + * <---------------------> + * cbData + * strlen(string) + 1 + strlen(string) + * (wcslen(name) + 1 + wcslen(string)) * sizeof(wchar_t) + * buf\x82̒\xBC\x8C\xE3\x82ɂ\xCD \0 \x82͕t\x82\xA9\x82Ȃ\xA2 + */ + #define BROADCAST_LOGFILE "broadcast.log" - static void ApplyBroadCastCommandHisotry(HWND Dialog, char *historyfile) { char EntName[13]; @@ -127,7 +158,7 @@ SendMessage(dlg, EM_SETSEL, 0, 0); } - count = SendMessage(BroadcastWindowList, LB_GETCOUNT, 0, 0); + count = (int)SendMessage(BroadcastWindowList, LB_GETCOUNT, 0, 0); for (i = 0 ; i < count ; i++) { if (SendMessage(BroadcastWindowList, LB_GETSEL, i, 0)) { hd = GetNthWin(i); @@ -144,7 +175,7 @@ return FALSE; default: - return CallWindowProc(OrigBroadcastEditProc, dlg, msg, wParam, lParam); + return _CallWindowProcW(OrigBroadcastEditProc, dlg, msg, wParam, lParam); } return FALSE; @@ -170,135 +201,160 @@ } } +static COPYDATASTRUCT *BuildBroadcastCDSW(const wchar_t *buf) +{ + COPYDATASTRUCT *cds = (COPYDATASTRUCT *)malloc(sizeof(COPYDATASTRUCT)); + size_t buflen = wcslen(buf); + + cds->dwData = IPC_BROADCAST_COMMAND; + cds->cbData = (DWORD)(buflen * sizeof(wchar_t)); // '\0' \x82͊܂܂Ȃ\xA2 + cds->lpData = (void *)buf; + + return cds; +} + +static COPYDATASTRUCT *BuildMulticastCDSW(const wchar_t *name, const wchar_t *buf) +{ + size_t buflen = wcslen(buf); + size_t nlen = wcslen(name) + 1; + size_t msglen = nlen + buflen; + wchar_t *msg = (wchar_t *)malloc(msglen * sizeof(wchar_t)); + if (msg == NULL) { + return NULL; + } + wcscpy_s(msg, msglen, name); + wmemcpy_s(msg + nlen, msglen - nlen, buf, buflen); + + COPYDATASTRUCT *cds = (COPYDATASTRUCT *)malloc(sizeof(COPYDATASTRUCT)); + if (cds == NULL) { + free(msg); + return NULL; + } + cds->dwData = IPC_MULTICAST_COMMAND; + cds->cbData = (DWORD)(msglen * sizeof(wchar_t)); + cds->lpData = msg; + + return cds; +} + /* * \x83_\x83C\x83A\x83\x8D\x83O\x82őI\x91\xF0\x82\xB3\x82ꂽ\x83E\x83B\x83\x93\x83h\x83E\x82̂݁A\x82\xE0\x82\xB5\x82\xAD\x82͐e\x83E\x83B\x83\x93\x83h\x83E\x82݂̂ɑ\x97\x82\xE9\x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B * \x83\x8A\x83A\x83\x8B\x83^\x83C\x83\x80\x83\x82\x81[\x83h\x82\xAA off \x82̎\x9E\x82ɗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B */ -static void SendBroadcastMessageToSelected(HWND HVTWin, HWND hWnd, int parent_only, char *buf, int buflen) +static void SendBroadcastMessageToSelected(HWND HVTWin, HWND hWnd, int parent_only, const wchar_t *buf) { - int i; - int count; - HWND hd; - COPYDATASTRUCT cds; + COPYDATASTRUCT *cds = BuildBroadcastCDSW(buf); - ZeroMemory(&cds, sizeof(cds)); - cds.dwData = IPC_BROADCAST_COMMAND; - cds.cbData = buflen; - cds.lpData = buf; - if (parent_only) { // \x90e\x83E\x83B\x83\x93\x83h\x83E\x82݂̂\xC9 WM_COPYDATA \x83\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9 - SendMessage(GetParent(hWnd), WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds); + SendMessage(GetParent(hWnd), WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)cds); } else { // \x83_\x83C\x83A\x83\x8D\x83O\x82őI\x91\xF0\x82\xB3\x82ꂽ\x83E\x83B\x83\x93\x83h\x83E\x82Ƀ\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9 - count = SendMessage(BroadcastWindowList, LB_GETCOUNT, 0, 0); - for (i = 0 ; i < count ; i++) { + int count = (int)SendMessage(BroadcastWindowList, LB_GETCOUNT, 0, 0); + for (int i = 0 ; i < count ; i++) { // \x83\x8A\x83X\x83g\x83{\x83b\x83N\x83X\x82őI\x91\xF0\x82\xB3\x82\xEA\x82Ă\xA2\x82邩 if (SendMessage(BroadcastWindowList, LB_GETSEL, i, 0)) { - if ((hd = GetNthWin(i)) != NULL) { + HWND hd = GetNthWin(i); + if (hd != NULL) { // WM_COPYDATA\x82\xF0\x8Eg\x82\xC1\x82āA\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82\xF0\x8Ds\x82\xA4\x81B - SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds); + SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)cds); } } } } + + free(cds); } -/* - * \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B - * "sendbroadcast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82̂ݗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B +/** + * \x91S Tera Term \x82\xD6COPYDATASTRUCT\x82𑗐M\x82\xB7\x82\xE9 + * @param[in] hWnd \x91\x97\x90M\x8C\xB3 + * @param[in] cds COPYDATASTRUCT */ -void SendBroadcastMessage(HWND HVTWin, HWND hWnd, char *buf, int buflen) +static void SendCDS(HWND hWnd, const COPYDATASTRUCT *cds) { - int i, count; - HWND hd; - COPYDATASTRUCT cds; - - ZeroMemory(&cds, sizeof(cds)); - cds.dwData = IPC_BROADCAST_COMMAND; - cds.cbData = buflen; - cds.lpData = buf; - - count = GetRegisteredWindowCount(); - - // \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗂\xE9\x81B - for (i = 0 ; i < count ; i++) { - if ((hd = GetNthWin(i)) == NULL) { + int count = GetRegisteredWindowCount(); + for (int i = 0 ; i < count ; i++) { + HWND hd = GetNthWin(i); + if (hd == NULL) { break; } // WM_COPYDATA\x82\xF0\x8Eg\x82\xC1\x82āA\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82\xF0\x8Ds\x82\xA4\x81B - SendMessage(hd, WM_COPYDATA, (WPARAM)HVTWin, (LPARAM)&cds); + SendMessage(hd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)cds); } } - /* - * \x94C\x88ӂ\xCC Tera Term \x8CQ\x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83}\x83\x8B\x83`\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B\x8C\xB5\x96\xA7\x82ɂ́A - * \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x91\x97\x90M\x82\xF0\x8Ds\x82\xA2\x81A\x8E\xF3\x90M\x91\xA4\x82Ń\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8E\xE6\x8ȆI\x91\xF0\x82\xB7\x82\xE9\x81B - * "sendmulticast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82̂ݗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B + * \x91S Tera Term \x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B + * "sendbroadcast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82̂ݗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B */ -void SendMulticastMessage(HWND hVTWin_, HWND hWnd, char *name, char *buf, int buflen) +void SendBroadcastMessage(HWND HVTWin, HWND hWnd, const wchar_t *buf) { - int i, count; - HWND hd; - COPYDATASTRUCT cds; - char *msg = NULL; - int msglen, nlen; + COPYDATASTRUCT *cds = BuildBroadcastCDSW(buf); + SendCDS(HVTWin, cds); + free(cds); +} - /* \x91\x97\x90M\x83\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8D\\x92z\x82\xB7\x82\xE9\x81B - * - * msg - * +------+--------------+--+ - * |name\0|buf |\0| - * +------+--------------+--+ - * <---------------------> - * msglen = strlen(name) + 1 + buflen - * buf\x82̒\xBC\x8C\xE3\x82ɂ\xCD \0 \x82͕t\x82\xA9\x82Ȃ\xA2\x81B - */ - nlen = strlen(name) + 1; - msglen = nlen + buflen; - if ((msg = (char *)malloc(msglen)) == NULL) { - return; +static COPYDATASTRUCT *BuildMulticastCopyData(const char *name, const char *buf) +{ + size_t buflen = strlen(buf); + size_t nlen = strlen(name) + 1; + size_t msglen = nlen + buflen; + char *msg = (char *)malloc(msglen); + if (msg == NULL) { + return NULL; } strcpy_s(msg, msglen, name); memcpy_s(msg + nlen, msglen - nlen, buf, buflen); - ZeroMemory(&cds, sizeof(cds)); - cds.dwData = IPC_MULTICAST_COMMAND; - cds.cbData = msglen; - cds.lpData = msg; - - count = GetRegisteredWindowCount(); - - // \x82\xB7\x82ׂĂ\xCCTera Term\x82Ƀ\x81\x83b\x83Z\x81[\x83W\x82ƃf\x81[\x83^\x82𑗂\xE9 - for (i = 0 ; i < count ; i++) { - if ((hd = GetNthWin(i)) == NULL) { - break; - } - - // WM_COPYDATA\x82\xF0\x8Eg\x82\xC1\x82āA\x83v\x83\x8D\x83Z\x83X\x8AԒʐM\x82\xF0\x8Ds\x82\xA4\x81B - SendMessage(hd, WM_COPYDATA, (WPARAM)hVTWin_, (LPARAM)&cds); + COPYDATASTRUCT *cds = (COPYDATASTRUCT *)malloc(sizeof(COPYDATASTRUCT)); + if (cds == NULL) { + free(msg); + return NULL; } + cds->dwData = IPC_MULTICAST_COMMAND; + cds->cbData = (DWORD)msglen; + cds->lpData = msg; - free(msg); + return cds; } -void SetMulticastName(char *name) +/* + * \x94C\x88ӂ\xCC Tera Term \x8CQ\x82փ\x81\x83b\x83Z\x81[\x83W\x82𑗐M\x82\xB7\x82\xE9\x83}\x83\x8B\x83`\x83L\x83\x83\x83X\x83g\x83\x82\x81[\x83h\x81B\x8C\xB5\x96\xA7\x82ɂ́A + * \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x91\x97\x90M\x82\xF0\x8Ds\x82\xA2\x81A\x8E\xF3\x90M\x91\xA4\x82Ń\x81\x83b\x83Z\x81[\x83W\x82\xF0\x8E\xE6\x8ȆI\x91\xF0\x82\xB7\x82\xE9\x81B + * "sendmulticast"\x83}\x83N\x83\x8D\x83R\x83}\x83\x93\x83h\x82\xA9\x82\xE7\x82̂ݗ\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B + */ +void SendMulticastMessage(HWND HVTWin_, HWND hWnd, const wchar_t *name, const wchar_t *buf) { - strncpy_s(ts.MulticastName, sizeof(ts.MulticastName), name, _TRUNCATE); + COPYDATASTRUCT *cdsW = BuildMulticastCDSW(name, buf); + SendCDS(HVTWin_, cdsW); + free(cdsW->lpData); + free(cdsW); } -static int CompareMulticastName(char *name) +void SetMulticastName(const wchar_t *name) { - return strcmp(ts.MulticastName, name); + // TODO MulticastName \x82\xF0 wchar_t \x89\xBB + char *nameA = ToCharW(name); + strncpy_s(ts.MulticastName, sizeof(ts.MulticastName), nameA, _TRUNCATE); + free(nameA); } +static int CompareMulticastName(const wchar_t *name) +{ + // TODO MulticastName \x82\xF0 wchar_t \x89\xBB + wchar_t *MulticastNameW = ToWcharA(ts.MulticastName); + int result = wcscmp(MulticastNameW, name); + free(MulticastNameW); + return result; +} + // // \x82\xB7\x82ׂẴ^\x81[\x83~\x83i\x83\x8B\x82֓\xAF\x88\xEA\x83R\x83}\x83\x93\x83h\x82𑗐M\x82\xB7\x82郂\x81[\x83h\x83\x8C\x83X\x83_\x83C\x83A\x83\x8D\x83O\x82̕\\x8E\xA6 // (2005.1.22 yutaka) // -static LRESULT CALLBACK BroadcastCommandDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) +static INT_PTR CALLBACK BroadcastCommandDlgProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { static const DlgTextInfo TextInfos[] = { { 0, "DLG_BROADCAST_TITLE" }, @@ -309,8 +365,6 @@ { IDOK, "DLG_BROADCAST_SUBMIT" }, { IDCANCEL, "BTN_CLOSE" }, }; - char buf[256 + 3]; - UINT ret; LRESULT checked; LRESULT history; char historyfile[MAX_PATH]; @@ -355,8 +409,7 @@ // \x83T\x83u\x83N\x83\x89\x83X\x89\xBB\x82\xB3\x82\xB9\x82ă\x8A\x83A\x83\x8B\x83^\x83C\x83\x80\x83\x82\x81[\x83h\x82ɂ\xB7\x82\xE9 (2008.1.21 yutaka) hwndBroadcast = GetDlgItem(hWnd, IDC_COMMAND_EDIT); hwndBroadcastEdit = GetWindow(hwndBroadcast, GW_CHILD); - OrigBroadcastEditProc = (WNDPROC)GetWindowLongPtr(hwndBroadcastEdit, GWLP_WNDPROC); - SetWindowLongPtr(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)BroadcastEditProc); + OrigBroadcastEditProc = (WNDPROC)_SetWindowLongPtrW(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)BroadcastEditProc); // \x83f\x83t\x83H\x83\x8B\x83g\x82\xCDon\x81B\x8Ec\x82\xE8\x82\xCDdisable\x81B SendMessage(GetDlgItem(hWnd, IDC_REALTIME_CHECK), BM_SETCHECK, BST_CHECKED, 0); // default on EnableWindow(GetDlgItem(hWnd, IDC_HISTORY_CHECK), FALSE); @@ -431,8 +484,7 @@ // new handler hwndBroadcast = GetDlgItem(hWnd, IDC_COMMAND_EDIT); hwndBroadcastEdit = GetWindow(hwndBroadcast, GW_CHILD); - OrigBroadcastEditProc = (WNDPROC)GetWindowLongPtr(hwndBroadcastEdit, GWLP_WNDPROC); - SetWindowLongPtr(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)BroadcastEditProc); + OrigBroadcastEditProc = (WNDPROC)_SetWindowLongPtrW(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)BroadcastEditProc); EnableWindow(GetDlgItem(hWnd, IDC_HISTORY_CHECK), FALSE); EnableWindow(GetDlgItem(hWnd, IDC_RADIO_CRLF), FALSE); @@ -443,7 +495,7 @@ EnableWindow(GetDlgItem(hWnd, IDC_LIST), TRUE); // true } else { // restore old handler - SetWindowLongPtr(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)OrigBroadcastEditProc); + _SetWindowLongPtrW(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)OrigBroadcastEditProc); EnableWindow(GetDlgItem(hWnd, IDC_HISTORY_CHECK), TRUE); EnableWindow(GetDlgItem(hWnd, IDC_RADIO_CRLF), TRUE); @@ -459,7 +511,8 @@ switch (LOWORD(wp)) { case IDOK: { - memset(buf, 0, sizeof(buf)); + wchar_t buf[256 + 3]; + //memset(buf, 0, sizeof(buf)); // realtime mode\x82̏ꍇ\x81AEnter key\x82̂ݑ\x97\x82\xE9\x81B // cf. http://logmett.com/forum/viewtopic.php?f=8&t=1601 @@ -466,59 +519,60 @@ // (2011.3.14 hirata) checked = SendMessage(GetDlgItem(hWnd, IDC_REALTIME_CHECK), BM_GETCHECK, 0, 0); if (checked & BST_CHECKED) { // check\x82\xA0\x82\xE8 - strncpy_s(buf, sizeof(buf), "\n", _TRUNCATE); - SetDlgItemText(hWnd, IDC_COMMAND_EDIT, ""); - goto skip; + wcsncpy_s(buf, _countof(buf), L"\n", _TRUNCATE); + SetDlgItemTextA(hWnd, IDC_COMMAND_EDIT, ""); } + else { + UINT ret = _GetDlgItemTextW(hWnd, IDC_COMMAND_EDIT, buf, 256 - 1); + if (ret == 0) { // error + memset(buf, 0, sizeof(buf)); + } - ret = GetDlgItemText(hWnd, IDC_COMMAND_EDIT, buf, 256 - 1); - if (ret == 0) { // error - memset(buf, 0, sizeof(buf)); - } - - // \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83R\x83}\x83\x93\x83h\x82̗\x9A\x97\xF0\x82\xF0\x95ۑ\xB6 (2007.3.3 maya) - history = SendMessage(GetDlgItem(hWnd, IDC_HISTORY_CHECK), BM_GETCHECK, 0, 0); - if (history) { - GetDefaultFName(ts.HomeDir, BROADCAST_LOGFILE, historyfile, sizeof(historyfile)); - if (LoadTTSET()) { - (*AddValueToList)(historyfile, buf, "BroadcastCommands", "Command", - ts.MaxBroadcatHistory); - FreeTTSET(); + // \x83u\x83\x8D\x81[\x83h\x83L\x83\x83\x83X\x83g\x83R\x83}\x83\x93\x83h\x82̗\x9A\x97\xF0\x82\xF0\x95ۑ\xB6 (2007.3.3 maya) + history = SendMessage(GetDlgItem(hWnd, IDC_HISTORY_CHECK), BM_GETCHECK, 0, 0); + if (history) { + GetDefaultFName(ts.HomeDir, BROADCAST_LOGFILE, historyfile, sizeof(historyfile)); + if (LoadTTSET()) { + char *bufA = ToCharW(buf); // TODO wchar_t \x91Ή\x9E + (*AddValueToList)(historyfile, bufA, "BroadcastCommands", "Command", + ts.MaxBroadcatHistory); + free(bufA); + FreeTTSET(); + } + ApplyBroadCastCommandHisotry(hWnd, historyfile); + ts.BroadcastCommandHistory = TRUE; } - ApplyBroadCastCommandHisotry(hWnd, historyfile); - ts.BroadcastCommandHistory = TRUE; - } - else { - ts.BroadcastCommandHistory = FALSE; - } - checked = SendMessage(GetDlgItem(hWnd, IDC_ENTERKEY_CHECK), BM_GETCHECK, 0, 0); - if (checked & BST_CHECKED) { // \x89\xFC\x8Ds\x83R\x81[\x83h\x82\xA0\x82\xE8 - if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_CRLF), BM_GETCHECK, 0, 0) & BST_CHECKED) { - strncat_s(buf, sizeof(buf), "\r\n", _TRUNCATE); + else { + ts.BroadcastCommandHistory = FALSE; + } + checked = SendMessage(GetDlgItem(hWnd, IDC_ENTERKEY_CHECK), BM_GETCHECK, 0, 0); + if (checked & BST_CHECKED) { // \x89\xFC\x8Ds\x83R\x81[\x83h\x82\xA0\x82\xE8 + if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_CRLF), BM_GETCHECK, 0, 0) & BST_CHECKED) { + wcsncat_s(buf, _countof(buf), L"\r\n", _TRUNCATE); - } else if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_CR), BM_GETCHECK, 0, 0) & BST_CHECKED) { - strncat_s(buf, sizeof(buf), "\r", _TRUNCATE); + } else if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_CR), BM_GETCHECK, 0, 0) & BST_CHECKED) { + wcsncat_s(buf, _countof(buf), L"\r", _TRUNCATE); - } else if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_LF), BM_GETCHECK, 0, 0) & BST_CHECKED) { - strncat_s(buf, sizeof(buf), "\n", _TRUNCATE); + } else if (SendMessage(GetDlgItem(hWnd, IDC_RADIO_LF), BM_GETCHECK, 0, 0) & BST_CHECKED) { + wcsncat_s(buf, _countof(buf), L"\n", _TRUNCATE); - } else { - strncat_s(buf, sizeof(buf), "\r", _TRUNCATE); + } else { + wcsncat_s(buf, _countof(buf), L"\r", _TRUNCATE); + } } } -skip:; // 337: 2007/03/20 \x83`\x83F\x83b\x83N\x82\xB3\x82\xEA\x82Ă\xA2\x82\xBD\x82\xE7\x90e\x83E\x83B\x83\x93\x83h\x83E\x82ɂ̂ݑ\x97\x90M checked = SendMessage(GetDlgItem(hWnd, IDC_PARENT_ONLY), BM_GETCHECK, 0, 0); - SendBroadcastMessageToSelected(HVTWin, hWnd, checked, buf, strlen(buf)); + SendBroadcastMessageToSelected(HVTWin, hWnd, (int)checked, buf); } // \x83\x82\x81[\x83h\x83\x8C\x83X\x83_\x83C\x83A\x83\x8D\x83O\x82͈\xEA\x93x\x90\xB6\x90\xAC\x82\xB3\x82\xEA\x82\xE9\x82ƁA\x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x82\xAA\x8FI\x97\xB9\x82\xB7\x82\xE9\x82܂\xC5 // \x94j\x8A\xFC\x82\xB3\x82\xEA\x82Ȃ\xA2\x82̂ŁA\x88ȉ\xBA\x82́u\x83E\x83B\x83\x93\x83h\x83E\x83v\x83\x8D\x83V\x81[\x83W\x83\x83\x96߂\xB5\x81v\x82͕s\x97v\x82Ǝv\x82\xED\x82\xEA\x82\xE9\x81B(yutaka) #if 0 - SetWindowLongPtr(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)OrigBroadcastEditProc); + _SetWindowLongPtrW(hwndBroadcastEdit, GWLP_WNDPROC, (LONG_PTR)OrigBroadcastEditProc); #endif //EndDialog(hDlgWnd, IDOK); @@ -684,8 +738,14 @@ goto activate; } + SetDialogFont(ts.DialogFontName, ts.DialogFontPoint, ts.DialogFontCharSet, + ts.UILanguageFile, "Tera Term", "DLG_SYSTEM_FONT"); + + // CreateDialogW() \x82Ő\xB6\x90\xAC\x82\xB5\x82\xBD\x83_\x83C\x83A\x83\x8D\x83O\x82́A + // \x83G\x83f\x83B\x83b\x83g\x83{\x83b\x83N\x83X\x82\xC9IME\x82\xA9\x82\xE7\x82̓\xFC\x97͂\xAA\x89\xBB\x82\xAF\x82邱\x82Ƃ\xAA\x82\xA0\x82\xE9 (20/05/27,Windows10 64bit) + // \x83y\x81[\x83X\x83g\x82\xCDok hDlgWnd = TTCreateDialog(hInst, MAKEINTRESOURCE(IDD_BROADCAST_DIALOG), - hWnd, (DLGPROC)BroadcastCommandDlgProc); + hWnd, BroadcastCommandDlgProc); if (hDlgWnd == NULL) { return; @@ -705,39 +765,49 @@ ::ShowWindow(hDlgWnd, SW_SHOW); } -BOOL BroadCastReceive(COPYDATASTRUCT *cds) +BOOL BroadCastReceive(const COPYDATASTRUCT *cds) { - char *buf, *msg, *name; - int buflen, msglen, nlen; - int sending = 0; + wchar_t *strW_ptr; + size_t strW_len = 0; - msglen = cds->cbData; - msg = (char *)cds->lpData; - if (cds->dwData == IPC_BROADCAST_COMMAND) { - buf = msg; - buflen = msglen; - sending = 1; + switch (cds->dwData) { + case IPC_BROADCAST_COMMAND: { + strW_len = cds->cbData / sizeof(wchar_t); + strW_ptr = (wchar_t *)malloc((strW_len + 1) * sizeof(wchar_t)); + wmemcpy_s(strW_ptr, strW_len, (wchar_t *)cds->lpData, strW_len); + strW_ptr[strW_len] = 0; // \x94O\x82̈\xD7 + break; + } + case IPC_MULTICAST_COMMAND: { + wchar_t *name = (wchar_t *)cds->lpData; - } else if (cds->dwData == IPC_MULTICAST_COMMAND) { - name = msg; - nlen = strlen(name) + 1; - buf = msg + nlen; - buflen = msglen - nlen; - // \x83}\x83\x8B\x83`\x83L\x83\x83\x83X\x83g\x96\xBC\x82\xF0\x83`\x83F\x83b\x83N\x82\xB7\x82\xE9 - if (CompareMulticastName(name) == 0) { // \x93\xAF\x82\xB6 - sending = 1; + if (CompareMulticastName(name) != 0) { + // \x96\xBC\x91O\x82\xAA\x88قȂ\xC1\x82Ă\xA2\x82\xE9\x82̂ʼn\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2 + return TRUE; } + + // \x83}\x83\x8B\x83`\x83L\x83\x83\x83X\x83g\x96\xBC\x82̎\x9F\x82̕\xB6\x8E\x9A\x97\xF1\x82\xF0\x8E擾 + size_t nlen = wcslen(name); + strW_len = cds->cbData / sizeof(wchar_t) - nlen - 1; // -1 = name \x82\xCC '\0' + strW_ptr = (wchar_t *)malloc((strW_len + 1) * sizeof(wchar_t)); + wmemcpy_s(strW_ptr, strW_len, (wchar_t *)cds->lpData + nlen + 1, strW_len); + strW_ptr[strW_len] = 0; // \x94O\x82̈\xD7 + break; } - if (sending) { - // \x92[\x96\x96\x82֕\xB6\x8E\x9A\x97\xF1\x82𑗂荞\x82\xDE - // DDE\x92ʐM\x82Ɏg\x82\xA4\x8A\x94\x82ɕύX\x81B(2006.2.7 yutaka) - CBStartSend(buf, buflen, FALSE); - // \x91\x97\x90M\x83f\x81[\x83^\x82\xAA\x82\xA0\x82\xE9\x8Fꍇ\x82͑\x97\x90M\x82\xB7\x82\xE9 - if (TalkStatus == IdTalkCB) { - CBSend(); - } + default: + // \x92m\x82\xE7\x82Ȃ\xA2\x83\x81\x83b\x83Z\x81[\x83W\x82̏ꍇ + return TRUE; } - return 1; + + // \x92[\x96\x96\x82֕\xB6\x8E\x9A\x97\xF1\x82𑗂荞\x82\xDE + SendMem *sm = SendMemTextW(strW_ptr, strW_len); + if (sm != NULL) { + SendMemInitEcho(sm, FALSE); + SendMemInitDelay(sm, SENDMEM_DELAYTYPE_PER_LINE, 10, 0); + SendMemStart(sm); + } + + return TRUE; } Modified: trunk/teraterm/teraterm/broadcast.h =================================================================== --- trunk/teraterm/teraterm/broadcast.h 2020-07-03 14:43:19 UTC (rev 8825) +++ trunk/teraterm/teraterm/broadcast.h 2020-07-03 14:43:28 UTC (rev 8826) @@ -35,10 +35,10 @@ extern "C" { #endif -void SendBroadcastMessage(HWND HVTWin, HWND hWnd, char *buf, int buflen); -void SendMulticastMessage(HWND HVTWin, HWND hWnd, char *name, char *buf, int buflen); -void SetMulticastName(char *name); -BOOL BroadCastReceive(COPYDATASTRUCT *cds); +void SendBroadcastMessage(HWND HVTWin, HWND hWnd, const wchar_t *buf); +void SendMulticastMessage(HWND HVTWin, HWND hWnd, const wchar_t *name, const wchar_t *buf); +void SetMulticastName(const wchar_t *name); +BOOL BroadCastReceive(const COPYDATASTRUCT *cds); void BroadCastShowDialog(HINSTANCE hInst, HWND hWnd); #ifdef __cplusplus Modified: trunk/teraterm/teraterm/ttdde.c =================================================================== --- trunk/teraterm/teraterm/ttdde.c 2020-07-03 14:43:19 UTC (rev 8825) +++ trunk/teraterm/teraterm/ttdde.c 2020-07-03 14:43:28 UTC (rev 8826) @@ -972,17 +972,36 @@ } break; - case CmdSendBroadcast: // 'sendbroadcast' - SendBroadcastMessage(HVTWin, HVTWin, ParamFileName, strlen(ParamFileName)); + case CmdSendBroadcast: { // 'sendbroadcast' + wchar_t *strW = ToWcharU8(ParamFileName); + if (strW != NULL) { + SendBroadcastMessage(HVTWin, HVTWin, strW); + free(strW); + } break; + } - case CmdSendMulticast: // 'sendmulticast' - SendMulticastMessage(HVTWin, HVTWin, ParamFileName, ParamSecondFileName, strlen(ParamSecondFileName)); + case CmdSendMulticast: { + // 'sendmulticast' + wchar_t *ParamFileNameW = ToWcharU8(ParamFileName); + wchar_t *ParamSecondFileNameW = ToWcharU8(ParamSecondFileName); + if (ParamFileNameW != NULL && ParamSecondFileNameW != NULL) { + SendMulticastMessage(HVTWin, HVTWin, ParamFileNameW, ParamSecondFileNameW); + } + free(ParamFileNameW); + free(ParamSecondFileNameW); break; + } - case CmdSetMulticastName: // 'setmulticastname' - SetMulticastName(ParamFileName); + case CmdSetMulticastName: { + // 'setmulticastname' + wchar_t *ParamFileNameW = ToWcharU8(ParamFileName); + if (ParamFileNameW != NULL) { + SetMulticastName(ParamFileNameW); + free(ParamFileNameW); + } break; + } case CmdDispStr: { wchar_t *strW = ToWcharU8(ParamFileName);