Revision: 8943 https://osdn.net/projects/ttssh2/scm/svn/commits/8943 Author: zmatsuo Date: 2020-10-03 00:45:27 +0900 (Sat, 03 Oct 2020) Log Message: ----------- ファイルを開くダイアログ用のファイル名フィルタ作成を共通関数に置き換え - GetOpenFileName(), GetSaveFileName() 用 - GetCommonDialogFilterW() - sendfiledlg.cpp から dglib_cpp.cpp へ移動 - ANSI版 GetCommonDialogFilterA() 追加 - ttfile.c optw = 0 を追加 - Run-Time Check Failure #3 - The variable 'optw' is being used without being initialized. Ticket Links: ------------ https://osdn.net/projects/ttssh2/tracker/detail/3 Modified Paths: -------------- trunk/teraterm/common/dlglib.h trunk/teraterm/common/dlglib_cpp.cpp trunk/teraterm/teraterm/filesys_log.cpp trunk/teraterm/teraterm/sendfiledlg.cpp trunk/teraterm/ttpfile/ftlib.h trunk/teraterm/ttpfile/ttfile.c trunk/teraterm/ttpmacro/ttl_gui.cpp -------------- next part -------------- Modified: trunk/teraterm/common/dlglib.h =================================================================== --- trunk/teraterm/common/dlglib.h 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/common/dlglib.h 2020-10-02 15:45:27 UTC (rev 8943) @@ -101,6 +101,8 @@ wchar_t *AllocControlTextW(HWND hWnd); char *AllocControlTextA(HWND hWnd); void ExpandCBWidth(HWND dlg, int ID); +wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile); +char *GetCommonDialogFilterA(const char *user_filter_mask, const char *UILanguageFile); #ifdef __cplusplus } Modified: trunk/teraterm/common/dlglib_cpp.cpp =================================================================== --- trunk/teraterm/common/dlglib_cpp.cpp 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/common/dlglib_cpp.cpp 2020-10-02 15:45:27 UTC (rev 8943) @@ -34,10 +34,12 @@ #endif #include <stdlib.h> #include <crtdbg.h> +#include <wchar.h> #include "dlglib.h" #include "ttlib.h" #include "layer_for_unicode.h" +#include "codeconv.h" /** * EndDialog() \x8C݊\xB7\x8A\x94 @@ -212,3 +214,110 @@ SelectObject(TmpDC, hFont); ReleaseDC(hCtrlWnd, TmpDC); } + +/** + * GetOpenFileName(), GetSaveFileName() \x97p\x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1\x8E擾 + * + * @param[in] user_filter_mask \x83\x86\x81[\x83U\x81[\x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1 + * "*.txt", "*.txt;*.log" \x82Ȃ\xC7 + * NULL\x82̂Ƃ\xAB\x8Eg\x97p\x82\xB5\x82Ȃ\xA2 + * @param[in] UILanguageFile + * @param[out] len \x90\xB6\x90\xAC\x82\xB5\x82\xBD\x95\xB6\x8E\x9A\x97\xF1\x92\xB7(wchar_t\x92P\x88\xCA) + * NULL\x82̂Ƃ\xAB\x82͕Ԃ\xB3\x82Ȃ\xA2 + * @retval "User define(*.txt)\0*.txt\0All(*.*)\0*.*\0" \x82Ȃ\xC7 + * \x8FI\x92[\x82\xCD "\0\0" \x82ƂȂ\xE9 + */ +wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile, size_t *len) +{ + // "\x83\x86\x81[\x83U\x92\xE8\x8B`(*.txt)\0*.txt" + wchar_t *user_filter_str = NULL; + size_t user_filter_len = 0; + if (user_filter_mask != NULL && user_filter_mask[0] != 0) { + wchar_t user_filter_name[MAX_UIMSG]; + GetI18nStrW("Tera Term", "FILEDLG_USER_FILTER_NAME", user_filter_name, sizeof(user_filter_name), L"User define", + UILanguageFile); + size_t user_filter_name_len = wcslen(user_filter_name); + wchar_t *user_filter_maskW = ToWcharA(user_filter_mask); + size_t user_filter_mask_len = wcslen(user_filter_maskW); + user_filter_len = user_filter_name_len + 1 + user_filter_mask_len + 1 + 1 + user_filter_mask_len + 1; + user_filter_str = (wchar_t *)malloc(user_filter_len * sizeof(wchar_t)); + wchar_t *p = user_filter_str; + wmemcpy(p, user_filter_name, user_filter_name_len); + p += user_filter_name_len; + *p++ = '('; + wmemcpy(p, user_filter_maskW, user_filter_mask_len); + p += user_filter_mask_len; + *p++ = ')'; + *p++ = '\0'; + wmemcpy(p, user_filter_maskW, user_filter_mask_len); + p += user_filter_mask_len; + *p++ = '\0'; + free(user_filter_maskW); + } + + // "\x82\xB7\x82ׂẴt\x83@\x83C\x83\x8B(*.*)\0*.*" + wchar_t all_filter_str[MAX_UIMSG]; + GetI18nStrW("Tera Term", "FILEDLG_ALL_FILTER", all_filter_str, _countof(all_filter_str), L"All(*.*)\\0*.*", UILanguageFile); + size_t all_filter_len; + { + size_t all_filter_title_len = wcsnlen(all_filter_str, _countof(all_filter_str)); + if (all_filter_title_len == 0 || all_filter_title_len == _countof(all_filter_str)) { + all_filter_str[0] = 0; + all_filter_len = 0; + } else { + size_t all_filter_mask_max = _countof(all_filter_str) - all_filter_title_len - 1; + size_t all_filter_mask_len = wcsnlen(all_filter_str + all_filter_title_len + 1, all_filter_mask_max); + if (all_filter_mask_len == 0 || all_filter_mask_len == _countof(all_filter_str)) { + all_filter_str[0] = 0; + all_filter_len = 0; + } else { + all_filter_len = all_filter_title_len + 1 + all_filter_mask_len + 1; + } + } + } + + // \x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8D\xEC\x82\xE9 + size_t filter_len = user_filter_len + all_filter_len; + wchar_t* filter_str; + if (filter_len != 0) { + filter_len++; + filter_str = (wchar_t*)malloc(filter_len * sizeof(wchar_t)); + wchar_t *p = filter_str; + if (user_filter_len != 0) { + wmemcpy(p, user_filter_str, user_filter_len); + p += user_filter_len; + } + wmemcpy(p, all_filter_str, all_filter_len); + p += all_filter_len; + *p = '\0'; + } else { + filter_len = 2; + filter_str = (wchar_t*)malloc(filter_len * sizeof(wchar_t)); + filter_str[0] = 0; + filter_str[1] = 0; + } + + if (user_filter_len != 0) { + free(user_filter_str); + } + + if (len != NULL) { + *len = filter_len; + } + + return filter_str; +} + +wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile) +{ + return GetCommonDialogFilterW(user_filter_mask, UILanguageFile, NULL); +} + +char *GetCommonDialogFilterA(const char *user_filter_mask, const char *UILanguageFile) +{ + size_t filterW_len; + wchar_t *filterW_ptr = GetCommonDialogFilterW(user_filter_mask, UILanguageFile, &filterW_len); + char *filterA_ptr = _WideCharToMultiByte(filterW_ptr, filterW_len, CP_ACP, NULL); + free(filterW_ptr); + return filterA_ptr; +} Modified: trunk/teraterm/teraterm/filesys_log.cpp =================================================================== --- trunk/teraterm/teraterm/filesys_log.cpp 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/teraterm/filesys_log.cpp 2020-10-02 15:45:27 UTC (rev 8943) @@ -585,8 +585,7 @@ wchar_t fname[MAX_PATH]; GetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, fname, _countof(fname)); - wchar_t FNFilter[128*3]; - get_lang_msgW("FILEDLG_ALL_FILTER", FNFilter, sizeof(FNFilter), L"All(*.*)\\0*.*\\0\\0", UILanguageFile); + wchar_t *FNFilter = GetCommonDialogFilterW(NULL, UILanguageFile); wchar_t caption[MAX_PATH]; wchar_t uimsg[MAX_UIMSG]; @@ -608,6 +607,7 @@ ofn.nMaxFile = _countof(fname); ofn.lpstrTitle = caption; BOOL Ok = GetSaveFileNameW(&ofn); + free(FNFilter); if (Ok) { SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, fname); } Modified: trunk/teraterm/teraterm/sendfiledlg.cpp =================================================================== --- trunk/teraterm/teraterm/sendfiledlg.cpp 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/teraterm/sendfiledlg.cpp 2020-10-02 15:45:27 UTC (rev 8943) @@ -48,98 +48,6 @@ #define TitSendFileW L"Send file" // TODO ttftype.h\x93\xE0\x82\xC9ANSI\x94ł\xAA\x82\xA0\x82\xE9 -/** - * GetOpenFileName(), GetSaveFileName() \x97p\x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1\x8E擾 - * - * @param[in] user_filter_mask \x83\x86\x81[\x83U\x81[\x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1 - * "*.txt", "*.txt;*.log" \x82Ȃ\xC7 - * NULL\x82̂Ƃ\xAB\x8Eg\x97p\x82\xB5\x82Ȃ\xA2 - * @param[in] UILanguageFile - * @param[out] len \x90\xB6\x90\xAC\x82\xB5\x82\xBD\x95\xB6\x8E\x9A\x97\xF1\x92\xB7(wchar_t\x92P\x88\xCA) - * NULL\x82̂Ƃ\xAB\x82͕Ԃ\xB3\x82Ȃ\xA2 - * @retval "User define(*.txt)\0*.txt\0All(*.*)\0*.*\0" \x82Ȃ\xC7 - * \x8FI\x92[\x82\xCD "\0\0" \x82ƂȂ\xE9 - */ -static wchar_t *GetCommonDialogFilterW(const char *user_filter_mask, const char *UILanguageFile, size_t *len) -{ - // "\x83\x86\x81[\x83U\x92\xE8\x8B`(*.txt)\0*.txt" - wchar_t *user_filter_str = NULL; - size_t user_filter_len = 0; - if (user_filter_mask != NULL && user_filter_mask[0] != 0) { - wchar_t user_filter_name[MAX_UIMSG]; - get_lang_msgW("FILEDLG_USER_FILTER_NAME", user_filter_name, sizeof(user_filter_name), L"User define", - UILanguageFile); - size_t user_filter_name_len = wcslen(user_filter_name); - wchar_t *user_filter_maskW = ToWcharA(user_filter_mask); - size_t user_filter_mask_len = wcslen(user_filter_maskW); - user_filter_len = user_filter_name_len + 1 + user_filter_mask_len + 1 + 1 + user_filter_mask_len + 1; - user_filter_str = (wchar_t *)malloc(user_filter_len * sizeof(wchar_t)); - wchar_t *p = user_filter_str; - wmemcpy(p, user_filter_name, user_filter_name_len); - p += user_filter_name_len; - *p++ = '('; - wmemcpy(p, user_filter_maskW, user_filter_mask_len); - p += user_filter_mask_len; - *p++ = ')'; - *p++ = '\0'; - wmemcpy(p, user_filter_maskW, user_filter_mask_len); - p += user_filter_mask_len; - *p++ = '\0'; - free(user_filter_maskW); - } - - // "\x82\xB7\x82ׂẴt\x83@\x83C\x83\x8B(*.*)\0*.*" - wchar_t all_filter_str[MAX_UIMSG]; - get_lang_msgW("FILEDLG_ALL_FILTER", all_filter_str, _countof(all_filter_str), L"All(*.*)\\0*.*", UILanguageFile); - size_t all_filter_len; - { - size_t all_filter_title_len = wcsnlen(all_filter_str, _countof(all_filter_str)); - if (all_filter_title_len == 0 || all_filter_title_len == _countof(all_filter_str)) { - all_filter_str[0] = 0; - all_filter_len = 0; - } else { - size_t all_filter_mask_max = _countof(all_filter_str) - all_filter_title_len - 1; - size_t all_filter_mask_len = wcsnlen(all_filter_str + all_filter_title_len + 1, all_filter_mask_max); - if (all_filter_mask_len == 0 || all_filter_mask_len == _countof(all_filter_str)) { - all_filter_str[0] = 0; - all_filter_len = 0; - } else { - all_filter_len = all_filter_title_len + 1 + all_filter_mask_len + 1; - } - } - } - - // \x83t\x83B\x83\x8B\x83^\x95\xB6\x8E\x9A\x97\xF1\x82\xF0\x8D\xEC\x82\xE9 - size_t filter_len = user_filter_len + all_filter_len; - wchar_t* filter_str; - if (filter_len != 0) { - filter_len++; - filter_str = (wchar_t*)malloc(filter_len * sizeof(wchar_t)); - wchar_t *p = filter_str; - if (user_filter_len != 0) { - wmemcpy(p, user_filter_str, user_filter_len); - p += user_filter_len; - } - wmemcpy(p, all_filter_str, all_filter_len); - p += all_filter_len; - *p = '\0'; - } else { - filter_len = 2; - filter_str = (wchar_t*)malloc(filter_len * sizeof(wchar_t)); - filter_str[0] = 0; - filter_str[1] = 0; - } - - if (user_filter_len != 0) { - free(user_filter_str); - } - - if (len != NULL) { - *len = filter_len; - } - return filter_str; -} - static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) { static const DlgTextInfo TextInfos[] = { @@ -241,9 +149,7 @@ free(uimsg); uimsg = NULL; - size_t filter_len; - wchar_t *filterW = GetCommonDialogFilterW(data->filesend_filter, data->UILanguageFile, &filter_len); - + wchar_t *filterW = GetCommonDialogFilterW(data->filesend_filter, data->UILanguageFile); wchar_t filename[MAX_PATH]; filename[0] = 0; OPENFILENAMEW ofn = {}; Modified: trunk/teraterm/ttpfile/ftlib.h =================================================================== --- trunk/teraterm/ttpfile/ftlib.h 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/ttpfile/ftlib.h 2020-10-02 15:45:27 UTC (rev 8943) @@ -39,4 +39,3 @@ void FTLog1Byte(PFileVar fv, BYTE b); void FTSetTimeOut(PFileVar fv, int T); BOOL FTCreateFile(PFileVar fv); -void GetFileSendFilter(PCHAR dest, PCHAR src, int size); Modified: trunk/teraterm/ttpfile/ttfile.c =================================================================== --- trunk/teraterm/ttpfile/ttfile.c 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/ttpfile/ttfile.c 2020-10-02 15:45:27 UTC (rev 8943) @@ -193,9 +193,9 @@ BOOL WINAPI GetTransFname(PFileVar fv, PCHAR CurDir, WORD FuncId, LPLONG Option) { char uimsg[MAX_UIMSG]; - char FNFilter[sizeof(FileSendFilter)*3], *pf; + char *FNFilter; OPENFILENAME ofn; - WORD optw; + WORD optw = 0; char TempDir[MAXPATHLEN]; BOOL Ok; char FileName[MAX_PATH]; @@ -203,40 +203,23 @@ /* save current dir */ _getcwd(TempDir,sizeof(TempDir)); - memset(FNFilter, 0, sizeof(FNFilter)); /* Set up for double null at end */ memset(&ofn, 0, sizeof(OPENFILENAME)); strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); - pf = FNFilter; switch (FuncId) { case GTF_SEND: get_lang_msg("FILEDLG_TRANS_TITLE_SENDFILE", uimsg, sizeof(uimsg), TitSendFile, UILanguageFile); strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); - if (strlen(FileSendFilter) > 0) { - get_lang_msg("FILEDLG_USER_FILTER_NAME", uimsg, sizeof(uimsg), "User define", UILanguageFile); - _snprintf_s(FNFilter, sizeof(FNFilter), _TRUNCATE, "%s(%s)", uimsg, FileSendFilter); - pf = pf + strlen(FNFilter) + 1; - strncpy_s(pf, sizeof(FNFilter)-(pf - FNFilter) ,FileSendFilter, _TRUNCATE); - pf = pf + strlen(pf) + 1; - } break; case GTF_BP: get_lang_msg("FILEDLG_TRANS_TITLE_BPSEND", uimsg, sizeof(uimsg), TitBPSend, UILanguageFile); strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); - if (strlen(FileSendFilter) > 0) { - get_lang_msg("FILEDLG_USER_FILTER_NAME", uimsg, sizeof(uimsg), "User define", UILanguageFile); - _snprintf_s(FNFilter, sizeof(FNFilter), _TRUNCATE, "%s(%s)", uimsg, FileSendFilter); - pf = pf + strlen(FNFilter) + 1; - strncpy_s(pf, sizeof(FNFilter)-(pf - FNFilter) ,FileSendFilter, _TRUNCATE); - pf = pf + strlen(pf) + 1; - } break; - default: return FALSE; + default: + return FALSE; } - get_lang_msg("FILEDLG_ALL_FILTER", uimsg, sizeof(uimsg), "All(*.*)\\0*.*\\0\\0", UILanguageFile); - // \0\0 \x82ŏI\x82\xED\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9\x82̂\xC5 2 \x83o\x83C\x83g - memcpy(pf, uimsg, sizeof(FNFilter) - (pf - FNFilter + 2)); + FNFilter = GetCommonDialogFilterA(FileSendFilter, UILanguageFile); ExtractFileName(fv->FullName, FileName ,sizeof(FileName)); strncpy_s(fv->FullName, sizeof(fv->FullName), FileName, _TRUNCATE); @@ -270,6 +253,7 @@ ofn.hInstance = hInst; Ok = GetOpenFileName(&ofn); + free(FNFilter); if (Ok) { *Option = (long)optw; @@ -362,14 +346,12 @@ { int i, len; char uimsg[MAX_UIMSG]; - char FNFilter[sizeof(FileSendFilter)*2+128], *pf; + char *FNFilter; OPENFILENAME ofn; char TempDir[MAXPATHLEN]; BOOL Ok; char defaultFName[MAX_PATH]; - memset(FNFilter, 0, sizeof(FNFilter)); /* Set up for double null at end */ - /* save current dir */ _getcwd(TempDir,sizeof(TempDir)); @@ -376,7 +358,6 @@ fv->NumFname = 0; strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); - pf = FNFilter; switch (FuncId) { case GMF_KERMIT: get_lang_msg("FILEDLG_TRANS_TITLE_KMTSEND", uimsg, sizeof(uimsg), TitKmtSend, UILanguageFile); @@ -397,13 +378,6 @@ default: return FALSE; } - if (strlen(FileSendFilter) > 0) { - get_lang_msg("FILEDLG_USER_FILTER_NAME", uimsg, sizeof(uimsg), "User define", UILanguageFile); - _snprintf_s(FNFilter, sizeof(FNFilter), _TRUNCATE, "%s(%s)", uimsg, FileSendFilter); - pf = pf + strlen(FNFilter) + 1; - strncpy_s(pf, sizeof(FNFilter)-(pf - FNFilter) ,FileSendFilter, _TRUNCATE); - pf = pf + strlen(pf) + 1; - } /* moemory should be zero-initialized */ fv->FnStrMemHandle = GlobalAlloc(GHND, FnStrMemSize); @@ -421,9 +395,7 @@ } } - get_lang_msg("FILEDLG_ALL_FILTER", uimsg, sizeof(uimsg), "All(*.*)\\0*.*\\0\\0", UILanguageFile); - // \0\0 \x82ŏI\x82\xED\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9\x82̂\xC5 2 \x83o\x83C\x83g - memcpy(pf, uimsg, sizeof(FNFilter) - (pf - FNFilter + 2)); + FNFilter = GetCommonDialogFilterA(FileSendFilter, UILanguageFile); memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = get_OPENFILENAME_SIZE(); @@ -464,6 +436,8 @@ } Ok = GetOpenFileName(&ofn); + free(FNFilter); + if (Ok) { /* count number of file names */ len = strlen(fv->FnStrMem); @@ -798,23 +772,19 @@ BOOL WINAPI GetXFname(HWND HWin, BOOL Receive, LPLONG Option, PFileVar fv, PCHAR CurDir) { char uimsg[MAX_UIMSG]; - char FNFilter[sizeof(FileSendFilter)*2+128], *pf; + char *FNFilter; OPENFILENAME ofn; LONG opt; char TempDir[MAXPATHLEN]; BOOL Ok; - memset(FNFilter, 0, sizeof(FNFilter)); /* Set up for double null at end */ - /* save current dir */ _getcwd(TempDir,sizeof(TempDir)); fv->FullName[0] = 0; - memset(FNFilter, 0, sizeof(FNFilter)); /* Set up for double null at end */ memset(&ofn, 0, sizeof(OPENFILENAME)); strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE); - pf = FNFilter; if (Receive) { get_lang_msg("FILEDLG_TRANS_TITLE_XRCV", uimsg, sizeof(uimsg), TitXRcv, UILanguageFile); strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); @@ -822,15 +792,12 @@ else { get_lang_msg("FILEDLG_TRANS_TITLE_XSEND", uimsg, sizeof(uimsg), TitXSend, UILanguageFile); strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE); + } + + // \x83t\x83B\x83\x8B\x83^\x82\xAA\x83\x8F\x83C\x83\x8B\x83h\x83J\x81[\x83h\x82ł͂Ȃ\xAD\x81A\x82\xBB\x82̃t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB7\x82\xE9\x8Fꍇ + // \x82\xA0\x82炩\x82\xB6\x82߃f\x83t\x83H\x83\x8B\x83g\x82̃t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x93\xFC\x82\xEA\x82Ă\xA8\x82\xAD (2008.5.18 maya) + if (!Receive) { if (strlen(FileSendFilter) > 0) { - get_lang_msg("FILEDLG_USER_FILTER_NAME", uimsg, sizeof(uimsg), "User define", UILanguageFile); - _snprintf_s(FNFilter, sizeof(FNFilter), _TRUNCATE, "%s(%s)", uimsg, FileSendFilter); - pf = pf + strlen(FNFilter) + 1; - strncpy_s(pf, sizeof(FNFilter)-(pf - FNFilter) ,FileSendFilter, _TRUNCATE); - pf = pf + strlen(pf) + 1; - - // \x83t\x83B\x83\x8B\x83^\x82\xAA\x83\x8F\x83C\x83\x8B\x83h\x83J\x81[\x83h\x82ł͂Ȃ\xAD\x81A\x82\xBB\x82̃t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB7\x82\xE9\x8Fꍇ - // \x82\xA0\x82炩\x82\xB6\x82߃f\x83t\x83H\x83\x8B\x83g\x82̃t\x83@\x83C\x83\x8B\x96\xBC\x82\xF0\x93\xFC\x82\xEA\x82Ă\xA8\x82\xAD (2008.5.18 maya) if (!isInvalidFileNameChar(FileSendFilter)) { char file[MAX_PATH]; strncpy_s(file, sizeof(file), CurDir, _TRUNCATE); @@ -843,9 +810,7 @@ } } - get_lang_msg("FILEDLG_ALL_FILTER", uimsg, sizeof(uimsg), "All(*.*)\\0*.*\\0\\0", UILanguageFile); - // \0\0 \x82ŏI\x82\xED\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9\x82̂\xC5 2 \x83o\x83C\x83g - memcpy(pf, uimsg, sizeof(FNFilter) - (pf - FNFilter + 2)); + FNFilter = GetCommonDialogFilterA(Receive == TRUE ? NULL : FileSendFilter, UILanguageFile); ofn.lStructSize = get_OPENFILENAME_SIZE(); ofn.hwndOwner = HWin; @@ -878,6 +843,7 @@ else { Ok = GetSaveFileName(&ofn); } + free(FNFilter); if (Ok) { fv->DirLen = ofn.nFileOffset; Modified: trunk/teraterm/ttpmacro/ttl_gui.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttl_gui.cpp 2020-10-02 15:45:15 UTC (rev 8942) +++ trunk/teraterm/ttpmacro/ttl_gui.cpp 2020-10-02 15:45:27 UTC (rev 8943) @@ -48,6 +48,7 @@ #include "codeconv.h" #include "layer_for_unicode.h" #include "ttlib.h" +#include "dlglib.h" // add 'clipb2var' (2006.9.17 maya) WORD TTLClipb2Var() @@ -157,7 +158,8 @@ SetInputStr(""); if (CheckVar("inputstr", &ValType, &VarId) && (ValType==TypString)) { - wchar_t uimsg[MAX_UIMSG]; + wchar_t *FNFilter = GetCommonDialogFilterW(NULL, UILanguageFile); + OPENFILENAMEW ofn = {}; wchar_t filename[MAX_PATH]; filename[0] = 0; @@ -166,8 +168,7 @@ ofn.lpstrTitle = Str1T; ofn.lpstrFile = filename; ofn.nMaxFile = _countof(filename); - get_lang_msgW("FILEDLG_ALL_FILTER", uimsg, _countof(uimsg), L"All(*.*)\\0*.*\\0\\0", UILanguageFile); - ofn.lpstrFilter = uimsg; + ofn.lpstrFilter = FNFilter; ofn.lpstrInitialDir = NULL; if (strlen(InitDir) > 0) { ofn.lpstrInitialDir = InitDirT; @@ -182,7 +183,7 @@ ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; ret = _GetOpenFileNameW(&ofn); } - + free(FNFilter); char *filenameU8 = ToU8W(filename); SetStrVal(VarId, filenameU8); free(filenameU8);