Revision: 9339 https://osdn.net/projects/ttssh2/scm/svn/commits/9339 Author: zmatsuo Date: 2021-08-01 14:36:53 +0900 (Sun, 01 Aug 2021) Log Message: ----------- setup directory dialog を別ソースに分離 - setupdirdlg.cpp,h を追加 Modified Paths: -------------- trunk/teraterm/teraterm/CMakeLists.txt trunk/teraterm/teraterm/ttermpro.v16.vcxproj trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters trunk/teraterm/teraterm/ttermpro.v8.vcproj trunk/teraterm/teraterm/vtwin.cpp Added Paths: ----------- trunk/teraterm/teraterm/setupdirdlg.cpp trunk/teraterm/teraterm/setupdirdlg.h -------------- next part -------------- Modified: trunk/teraterm/teraterm/CMakeLists.txt =================================================================== --- trunk/teraterm/teraterm/CMakeLists.txt 2021-08-01 05:36:42 UTC (rev 9338) +++ trunk/teraterm/teraterm/CMakeLists.txt 2021-08-01 05:36:53 UTC (rev 9339) @@ -47,6 +47,8 @@ prnabort.h protodlg.cpp protodlg.h + setupdirdlg.cpp + setupdirdlg.h sizetip.c sizetip.h teklib.c Added: trunk/teraterm/teraterm/setupdirdlg.cpp =================================================================== --- trunk/teraterm/teraterm/setupdirdlg.cpp (rev 0) +++ trunk/teraterm/teraterm/setupdirdlg.cpp 2021-08-01 05:36:53 UTC (rev 9339) @@ -0,0 +1,570 @@ +/* + * Copyright (C) 1994-1998 T. Teranishi + * (C) 2004- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* IPv6 modification is Copyright(C) 2000 Jun-ya Kato <kato****@win6*****> */ + +/* TERATERM.EXE, VT window */ + +// SDK7.0\x82̏ꍇ\x81AWIN32_IE\x82\xAA\x93K\x90ɒ\xE8\x8B`\x82\xB3\x82\xEA\x82Ȃ\xA2 +#if _MSC_VER == 1400 // VS2005\x82̏ꍇ\x82̂\xDD +#if !defined(_WIN32_IE) +#define _WIN32_IE 0x0501 +#endif +#endif + +#include "teraterm.h" +#include "tttypes.h" +#include "tttypes_key.h" + +#include "ttcommon.h" +#include "ttwinman.h" // +//#include "ttsetup.h" +//#include "keyboard.h" +//#include "buffer.h" +//#include "vtterm.h" +//#include "vtdisp.h" +#include "ttdialog.h" +//#include "ttime.h" +#include "commlib.h" +//#include "clipboar.h" +//#include "filesys.h" +//#include "telnet.h" +//#include "tektypes.h" +//#include "ttdde.h" +#include "ttlib.h" +#include "dlglib.h" +#include "helpid.h" +//#include "teraprn.h" +//#include <winsock2.h> +//#include <ws2tcpip.h> +//#include "ttplug.h" /* TTPLUG */ +#include "teraterml.h" +//#include "buffer.h" + +#include <stdio.h> +#define _CRTDBG_MAP_ALLOC +#include <stdlib.h> +#include <crtdbg.h> +#include <string.h> +#include <io.h> +#include <errno.h> + +#include <shlobj.h> +#include <windows.h> +#include <windowsx.h> +//#include <imm.h> +#include <dbt.h> +#include <assert.h> +#include <wchar.h> +#include <htmlhelp.h> + +#include "tt_res.h" +#include "vtwin.h" +//#include "addsetting.h" +//#include "winjump.h" +#include "sizetip.h" +//#include "dnddlg.h" +//#include "tekwin.h" +#include "compat_win.h" +//#include "unicode_test.h" +#if UNICODE_DEBUG +#include "tipwin.h" +#endif +#include "codeconv.h" +#include "sendmem.h" +//#include "sendfiledlg.h" +#include "setting.h" +//#include "broadcast.h" +#include "asprintf.h" +//#include "teraprn.h" + +#include "setupdirdlg.h" + +// +// \x8Ew\x92肵\x82\xBD\x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x82Ńt\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD\x81B +// +// return TRUE: success +// FALSE: failure +// +static BOOL openFileWithApplication(char *pathname, char *filename, char *editor) +{ + char command[1024]; + char fullpath[1024]; + STARTUPINFO si; + PROCESS_INFORMATION pi; + BOOL ret = FALSE; + wchar_t buf[80]; + wchar_t uimsg[MAX_UIMSG]; + wchar_t uimsg2[MAX_UIMSG]; + + SetLastError(NO_ERROR); + + _snprintf_s(fullpath, sizeof(fullpath), "%s\\%s", pathname, filename); + if (_access(fullpath, 0) != 0) { // \x83t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB5\x82Ȃ\xA2 + DWORD no = GetLastError(); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("DLG_SETUPDIR_NOFILE_ERROR", uimsg2, _countof(uimsg2), + L"File does not exist.(%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no); + ::MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + goto error; + } + + _snprintf_s(command, sizeof(command), _TRUNCATE, "%s \"%s\"", editor, fullpath); + + memset(&si, 0, sizeof(si)); + GetStartupInfo(&si); + memset(&pi, 0, sizeof(pi)); + + if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, + NULL, NULL, &si, &pi) == 0) { // \x8BN\x93\xAE\x8E\xB8\x94s + DWORD no = GetLastError(); + get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); + get_lang_msgW("DLG_SETUPDIR_OPENFILE_ERROR", uimsg2, _countof(uimsg2), + L"Cannot open file.(%d)", ts.UILanguageFile); + _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no); + ::MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); + goto error; + } else { + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + } + + ret = TRUE; + +error:; + return (ret); +} + +// +// \x83G\x83N\x83X\x83v\x83\x8D\x81[\x83\x89\x82Ńp\x83X\x82\xF0\x8AJ\x82\xAD\x81B +// +// return TRUE: success +// FALSE: failure +// +static BOOL openDirectoryWithExplorer(const wchar_t *path) +{ + LPSHELLFOLDER pDesktopFolder; + LPMALLOC pMalloc; + LPITEMIDLIST pIDL; + SHELLEXECUTEINFO si; + BOOL ret = FALSE; + + if (SHGetDesktopFolder(&pDesktopFolder) == S_OK) { + if (SHGetMalloc(&pMalloc) == S_OK) { + if (pDesktopFolder->ParseDisplayName(NULL, NULL, (LPWSTR)path, NULL, &pIDL, NULL) == S_OK) { + ::ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SEE_MASK_IDLIST; + si.lpVerb = "open"; + si.lpIDList = pIDL; + si.nShow = SW_SHOWNORMAL; + ::ShellExecuteEx(&si); + pMalloc->Free((void *)pIDL); + + ret = TRUE; + } + + pMalloc->Release(); + } + pDesktopFolder->Release(); + } + + return (ret); +} + +// +// \x83t\x83H\x83\x8B\x83_\x82\xE0\x82\xB5\x82\xAD\x82̓t\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD\x81B +// +static void openFileDirectory(char *path, char *filename, BOOL open_directory_only, char *open_editor) +{ + if (open_directory_only) { + wchar_t *pathW = ToWcharA(path); + openDirectoryWithExplorer(pathW); + free(pathW); + } + else { + openFileWithApplication(path, filename, open_editor); + } +} + +// +// Virtual Store\x83p\x83X\x82ɕϊ\xB7\x82\xB7\x82\xE9\x81B +// +// path: IN +// filename: IN +// vstore_path: OUT +// vstore_pathlen: IN +// +// return TRUE: success +// FALSE: failure +// +static BOOL convertVirtualStore(char *path, char *filename, char *vstore_path, int vstore_pathlen) +{ + BOOL ret = FALSE; + const char *s, **p; + const char *virstore_env[] = { + "ProgramFiles", + "ProgramData", + "SystemRoot", + NULL + }; + char shPath[1024] = ""; + char shFullPath[1024] = ""; + LPITEMIDLIST pidl; + int CSIDL; + + OutputDebugPrintf("[%s][%s]\n", path, filename); + + if (cv.VirtualStoreEnabled == FALSE) + goto error; + + // Virtual Store\x91ΏۂƂȂ\xE9\x83t\x83H\x83\x8B\x83_\x82\xA9\x81B + p = virstore_env; + while (*p) { + s = getenv(*p); + if (s != NULL && strstr(path, s) != NULL) { + break; + } + p++; + } + if (*p == NULL) + goto error; + + CSIDL = CSIDL_LOCAL_APPDATA; + if (SHGetSpecialFolderLocation(NULL, CSIDL, &pidl) != S_OK) { + goto error; + } + SHGetPathFromIDList(pidl, shPath); + CoTaskMemFree(pidl); + + // Virtual Store\x83p\x83X\x82\xF0\x8D\xEC\x82\xE9\x81B + strncat_s(shPath, sizeof(shPath), "\\VirtualStore", _TRUNCATE); + + // \x95s\x97v\x82ȃh\x83\x89\x83C\x83u\x83\x8C\x83^\x81[\x82\xF0\x8F\x9C\x8B\x8E\x82\xB7\x82\xE9\x81B + // \x83h\x83\x89\x83C\x83u\x83\x8C\x83^\x81[\x82͈ꕶ\x8E\x9A\x82Ƃ͌\xC0\x82\xE7\x82Ȃ\xA2\x93_\x82ɒ\x8D\x88ӁB + s = strstr(path, ":\\"); + if (s != NULL) { + strncat_s(shPath, sizeof(shPath), s + 1, _TRUNCATE); + } + + // \x8DŌ\xE3\x82ɁAVirtual Store\x82Ƀt\x83@\x83C\x83\x8B\x82\xAA\x82\xA0\x82邩\x82ǂ\xA4\x82\xA9\x82ׂ\xE9\x81B + _snprintf_s(shFullPath, sizeof(shFullPath), "%s\\%s", shPath, filename); + if (_access(shFullPath, 0) != 0) { + goto error; + } + + strncpy_s(vstore_path, vstore_pathlen, shPath, _TRUNCATE); + + ret = TRUE; + return (ret); + +error: + return (ret); +} + +static INT_PTR CALLBACK OnSetupDirectoryDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) +{ + static const DlgTextInfo TextInfos[] = { + { 0, "DLG_SETUPDIR_TITLE" }, + { IDC_INI_SETUPDIR_GROUP, "DLG_SETUPDIR_INIFILE" }, + { IDC_KEYCNF_SETUPDIR_GROUP, "DLG_SETUPDIR_KEYBOARDFILE" }, + { IDC_CYGTERM_SETUPDIR_GROUP, "DLG_SETUPDIR_CYGTERMFILE" }, + { IDC_SSH_SETUPDIR_GROUP, "DLG_SETUPDIR_KNOWNHOSTSFILE" }, + }; + static char teratermexepath[MAX_PATH]; + static char inipath[MAX_PATH], inifilename[MAX_PATH], inipath_vstore[1024]; + static char keycnfpath[MAX_PATH], keycnffilename[MAX_PATH], keycnfpath_vstore[1024]; + static char cygtermpath[MAX_PATH], cygtermfilename[MAX_PATH], cygtermpath_vstore[1024]; +// static char eterm1path[MAX_PATH], eterm1filename[MAX_PATH], eterm1path_vstore[1024]; + char temp[MAX_PATH]; + char tmpbuf[1024]; + typedef int (CALLBACK *PSSH_read_known_hosts_file)(char *, int); + PSSH_read_known_hosts_file func = NULL; + HMODULE h = NULL; + static char hostsfilepath[MAX_PATH], hostsfilename[MAX_PATH], hostsfilepath_vstore[1024]; + char *path_p, *filename_p; + BOOL open_dir, ret; + int button_pressed; + HWND hWnd; + + switch (msg) { + case WM_INITDIALOG: + // I18N + SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile); + + if (GetModuleFileNameA(NULL, temp, sizeof(temp)) != 0) { + ExtractDirName(temp, teratermexepath); + } + + // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B(teraterm.ini)\x82̃p\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B + /// (1) + ExtractFileName(ts.SetupFName, inifilename, sizeof(inifilename)); + ExtractDirName(ts.SetupFName, inipath); + //SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_STATIC, inifilename); + SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_EDIT, ts.SetupFName); + /// (2) Virutal Store\x82ւ̕ϊ\xB7 + memset(inipath_vstore, 0, sizeof(inipath_vstore)); + ret = convertVirtualStore(inipath, inifilename, inipath_vstore, sizeof(inipath_vstore)); + if (ret) { + hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, TRUE); + hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, TRUE); + _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", inipath_vstore, inifilename); + SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE, tmpbuf); + } + else { + hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, FALSE); + SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE, ""); + } + + // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B(KEYBOARD.CNF)\x82̃p\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B + /// (1) + ExtractFileName(ts.KeyCnfFN, keycnffilename, sizeof(keycnfpath)); + ExtractDirName(ts.KeyCnfFN, keycnfpath); + //SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_STATIC, keycnffilename); + SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT, ts.KeyCnfFN); + /// (2) Virutal Store\x82ւ̕ϊ\xB7 + memset(keycnfpath_vstore, 0, sizeof(keycnfpath_vstore)); + ret = convertVirtualStore(keycnfpath, keycnffilename, keycnfpath_vstore, sizeof(keycnfpath_vstore)); + if (ret) { + hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, TRUE); + hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, TRUE); + _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", keycnfpath_vstore, keycnffilename); + SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE, tmpbuf); + } + else { + hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, FALSE); + SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE, ""); + } + + + // cygterm.cfg \x82\xCD ttermpro.exe \x94z\x89\xBA\x82Ɉʒu\x82\xB7\x82\xE9\x81B + /// (1) + strncpy_s(cygtermfilename, sizeof(cygtermfilename), "cygterm.cfg", _TRUNCATE); + strncpy_s(cygtermpath, sizeof(cygtermpath), teratermexepath, _TRUNCATE); + //SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_STATIC, cygtermfilename); + _snprintf_s(temp, sizeof(temp), "%s\\%s", cygtermpath, cygtermfilename); + SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT, temp); + /// (2) Virutal Store\x82ւ̕ϊ\xB7 + memset(cygtermpath_vstore, 0, sizeof(cygtermpath_vstore)); + ret = convertVirtualStore(cygtermpath, cygtermfilename, cygtermpath_vstore, sizeof(cygtermpath_vstore)); + if (ret) { + hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, TRUE); + hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, TRUE); + _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", cygtermpath_vstore, cygtermfilename); + SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE, tmpbuf); + } + else { + hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, FALSE); + SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE, ""); + } + + // ssh_known_hosts + if (func == NULL) { + if (((h = GetModuleHandle("ttxssh.dll")) != NULL)) { + func = (PSSH_read_known_hosts_file)GetProcAddress(h, "TTXReadKnownHostsFile"); + if (func) { + int ret = func(temp, sizeof(temp)); + if (ret) { + char *s = strstr(temp, ":\\"); + + if (s) { // full path + ExtractFileName(temp, hostsfilename, sizeof(hostsfilename)); + ExtractDirName(temp, hostsfilepath); + } + else { // relative path + strncpy_s(hostsfilepath, sizeof(hostsfilepath), teratermexepath, _TRUNCATE); + strncpy_s(hostsfilename, sizeof(hostsfilename), temp, _TRUNCATE); + _snprintf_s(temp, sizeof(temp), "%s\\%s", hostsfilepath, hostsfilename); + } + + SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT, temp); + + /// (2) Virutal Store\x82ւ̕ϊ\xB7 + memset(hostsfilepath_vstore, 0, sizeof(hostsfilepath_vstore)); + ret = convertVirtualStore(hostsfilepath, hostsfilename, hostsfilepath_vstore, sizeof(hostsfilepath_vstore)); + if (ret) { + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, TRUE); + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, TRUE); + _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", hostsfilepath_vstore, hostsfilename); + SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE, tmpbuf); + } + else { + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, FALSE); + SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE, ""); + } + + } + } + } + else { + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT); + EnableWindow(hWnd, FALSE); + SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT, ""); + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_BUTTON); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_BUTTON_FILE); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_STATIC_VSTORE); + EnableWindow(hWnd, FALSE); + hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE); + EnableWindow(hWnd, FALSE); + SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE, ""); + } + } + + return TRUE; + + case WM_COMMAND: + button_pressed = 0; + switch (LOWORD(wp)) { + case IDC_INI_SETUPDIR_BUTTON | (BN_CLICKED << 16) : + open_dir = TRUE; + path_p = inipath; + if (inipath_vstore[0]) + path_p = inipath_vstore; + filename_p = inifilename; + button_pressed = 1; + break; + case IDC_INI_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : + open_dir = FALSE; + path_p = inipath; + if (inipath_vstore[0]) + path_p = inipath_vstore; + filename_p = inifilename; + button_pressed = 1; + break; + + case IDC_KEYCNF_SETUPDIR_BUTTON | (BN_CLICKED << 16) : + open_dir = TRUE; + path_p = keycnfpath; + if (keycnfpath_vstore[0]) + path_p = keycnfpath_vstore; + filename_p = keycnffilename; + button_pressed = 1; + break; + case IDC_KEYCNF_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : + open_dir = FALSE; + path_p = keycnfpath; + if (keycnfpath_vstore[0]) + path_p = keycnfpath_vstore; + filename_p = keycnffilename; + button_pressed = 1; + break; + + case IDC_CYGTERM_SETUPDIR_BUTTON | (BN_CLICKED << 16) : + open_dir = TRUE; + path_p = cygtermpath; + if (cygtermpath_vstore[0]) + path_p = cygtermpath_vstore; + filename_p = cygtermfilename; + button_pressed = 1; + break; + case IDC_CYGTERM_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : + open_dir = FALSE; + path_p = cygtermpath; + if (cygtermpath_vstore[0]) + path_p = cygtermpath_vstore; + filename_p = cygtermfilename; + button_pressed = 1; + break; + + case IDC_SSH_SETUPDIR_BUTTON | (BN_CLICKED << 16) : + open_dir = TRUE; + path_p = hostsfilepath; + if (hostsfilepath_vstore[0]) + path_p = hostsfilepath_vstore; + filename_p = hostsfilename; + button_pressed = 1; + break; + case IDC_SSH_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : + open_dir = FALSE; + path_p = hostsfilepath; + if (hostsfilepath_vstore[0]) + path_p = hostsfilepath_vstore; + filename_p = hostsfilename; + button_pressed = 1; + break; + + case IDCANCEL: + TTEndDialog(hDlgWnd, IDCANCEL); + return TRUE; + break; + + default: + return FALSE; + } + + if (button_pressed) { + char *app = NULL; + + if (open_dir) + app = NULL; + else + app = ts.ViewlogEditor; + + openFileDirectory(path_p, filename_p, open_dir, app); + return TRUE; + } + return FALSE; + + case WM_CLOSE: + TTEndDialog(hDlgWnd, 0); + return TRUE; + + default: + return FALSE; + } + return TRUE; +} + +void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd) +{ + TTDialogBox(hInst, MAKEINTRESOURCE(IDD_SETUP_DIR_DIALOG), + hWnd, OnSetupDirectoryDlgProc); +} Added: trunk/teraterm/teraterm/setupdirdlg.h =================================================================== --- trunk/teraterm/teraterm/setupdirdlg.h (rev 0) +++ trunk/teraterm/teraterm/setupdirdlg.h 2021-08-01 05:36:53 UTC (rev 9339) @@ -0,0 +1,34 @@ +/* + * Copyright (C) 1994-1998 T. Teranishi + * (C) 2004- TeraTerm Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include <windows.h> + +void SetupDirectoryDialog(HINSTANCE hInst, HWND hWnd); Modified: trunk/teraterm/teraterm/ttermpro.v16.vcxproj =================================================================== --- trunk/teraterm/teraterm/ttermpro.v16.vcxproj 2021-08-01 05:36:42 UTC (rev 9338) +++ trunk/teraterm/teraterm/ttermpro.v16.vcxproj 2021-08-01 05:36:53 UTC (rev 9339) @@ -161,6 +161,7 @@ <ClCompile Include="ftdlg.cpp" /> <ClCompile Include="keyboard.c" /> <ClCompile Include="sendfiledlg.cpp" /> + <ClCompile Include="setupdirdlg.cpp" /> <ClCompile Include="sizetip.c" /> <ClCompile Include="prnabort.cpp" /> <ClCompile Include="protodlg.cpp" /> @@ -260,6 +261,7 @@ <ClInclude Include="keyboard.h" /> <ClInclude Include="prnabort.h" /> <ClInclude Include="protodlg.h" /> + <ClInclude Include="setupdirdlg.h" /> <ClInclude Include="sizetip.h" /> <ClInclude Include="teklib.h" /> <ClInclude Include="tekwin.h" /> @@ -311,4 +313,4 @@ <UserProperties RESOURCE_FILE="ttermpro.rc" /> </VisualStudio> </ProjectExtensions> -</Project> +</Project> \ No newline at end of file Modified: trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters =================================================================== --- trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters 2021-08-01 05:36:42 UTC (rev 9338) +++ trunk/teraterm/teraterm/ttermpro.v16.vcxproj.filters 2021-08-01 05:36:53 UTC (rev 9339) @@ -189,6 +189,9 @@ <ClCompile Include="..\ttpset\ttset_keyboard.c"> <Filter>Source Files %28C%29</Filter> </ClCompile> + <ClCompile Include="setupdirdlg.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <Image Include="..\..\cygterm\cygterm.ico"> @@ -444,5 +447,8 @@ <ClInclude Include="ttdebug.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="setupdirdlg.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> -</Project> +</Project> \ No newline at end of file Modified: trunk/teraterm/teraterm/ttermpro.v8.vcproj =================================================================== --- trunk/teraterm/teraterm/ttermpro.v8.vcproj 2021-08-01 05:36:42 UTC (rev 9338) +++ trunk/teraterm/teraterm/ttermpro.v8.vcproj 2021-08-01 05:36:53 UTC (rev 9339) @@ -239,6 +239,10 @@ > </File> <File + RelativePath=".\setupdirdlg.cpp" + > + </File> + <File RelativePath="tekwin.cpp" > </File> @@ -449,6 +453,10 @@ > </File> <File + RelativePath=".\setupdirdlg.h" + > + </File> + <File RelativePath="sizetip.h" > </File> Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2021-08-01 05:36:42 UTC (rev 9338) +++ trunk/teraterm/teraterm/vtwin.cpp 2021-08-01 05:36:53 UTC (rev 9339) @@ -102,6 +102,7 @@ #include "broadcast.h" #include "asprintf.h" #include "teraprn.h" +#include "setupdirdlg.h" #include "initguid.h" //#include "Usbiodef.h" @@ -4806,470 +4807,7 @@ } } - // -// \x8Ew\x92肵\x82\xBD\x83A\x83v\x83\x8A\x83P\x81[\x83V\x83\x87\x83\x93\x82Ńt\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD\x81B -// -// return TRUE: success -// FALSE: failure -// -static BOOL openFileWithApplication(char *pathname, char *filename, char *editor) -{ - char command[1024]; - char fullpath[1024]; - STARTUPINFO si; - PROCESS_INFORMATION pi; - BOOL ret = FALSE; - wchar_t buf[80]; - wchar_t uimsg[MAX_UIMSG]; - wchar_t uimsg2[MAX_UIMSG]; - - SetLastError(NO_ERROR); - - _snprintf_s(fullpath, sizeof(fullpath), "%s\\%s", pathname, filename); - if (_access(fullpath, 0) != 0) { // \x83t\x83@\x83C\x83\x8B\x82\xAA\x91\xB6\x8D݂\xB5\x82Ȃ\xA2 - DWORD no = GetLastError(); - get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); - get_lang_msgW("DLG_SETUPDIR_NOFILE_ERROR", uimsg2, _countof(uimsg2), - L"File does not exist.(%d)", ts.UILanguageFile); - _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no); - ::MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); - goto error; - } - - _snprintf_s(command, sizeof(command), _TRUNCATE, "%s \"%s\"", editor, fullpath); - - memset(&si, 0, sizeof(si)); - GetStartupInfo(&si); - memset(&pi, 0, sizeof(pi)); - - if (CreateProcess(NULL, command, NULL, NULL, FALSE, 0, - NULL, NULL, &si, &pi) == 0) { // \x8BN\x93\xAE\x8E\xB8\x94s - DWORD no = GetLastError(); - get_lang_msgW("MSG_ERROR", uimsg, _countof(uimsg), L"ERROR", ts.UILanguageFile); - get_lang_msgW("DLG_SETUPDIR_OPENFILE_ERROR", uimsg2, _countof(uimsg2), - L"Cannot open file.(%d)", ts.UILanguageFile); - _snwprintf_s(buf, _countof(buf), _TRUNCATE, uimsg2, no); - ::MessageBoxW(NULL, buf, uimsg, MB_OK | MB_ICONWARNING); - goto error; - } else { - CloseHandle(pi.hThread); - CloseHandle(pi.hProcess); - } - - ret = TRUE; - -error:; - return (ret); -} - - -// -// \x83G\x83N\x83X\x83v\x83\x8D\x81[\x83\x89\x82Ńp\x83X\x82\xF0\x8AJ\x82\xAD\x81B -// -// return TRUE: success -// FALSE: failure -// -static BOOL openDirectoryWithExplorer(const wchar_t *path) -{ - LPSHELLFOLDER pDesktopFolder; - LPMALLOC pMalloc; - LPITEMIDLIST pIDL; - SHELLEXECUTEINFO si; - BOOL ret = FALSE; - - if (SHGetDesktopFolder(&pDesktopFolder) == S_OK) { - if (SHGetMalloc(&pMalloc) == S_OK) { - if (pDesktopFolder->ParseDisplayName(NULL, NULL, (LPWSTR)path, NULL, &pIDL, NULL) == S_OK) { - ::ZeroMemory(&si, sizeof(si)); - si.cbSize = sizeof(si); - si.fMask = SEE_MASK_IDLIST; - si.lpVerb = "open"; - si.lpIDList = pIDL; - si.nShow = SW_SHOWNORMAL; - ::ShellExecuteEx(&si); - pMalloc->Free((void *)pIDL); - - ret = TRUE; - } - - pMalloc->Release(); - } - pDesktopFolder->Release(); - } - - return (ret); -} - -// -// \x83t\x83H\x83\x8B\x83_\x82\xE0\x82\xB5\x82\xAD\x82̓t\x83@\x83C\x83\x8B\x82\xF0\x8AJ\x82\xAD\x81B -// -static void openFileDirectory(char *path, char *filename, BOOL open_directory_only, char *open_editor) -{ - if (open_directory_only) { - wchar_t *pathW = ToWcharA(path); - openDirectoryWithExplorer(pathW); - free(pathW); - } - else { - openFileWithApplication(path, filename, open_editor); - } -} - - -// -// Virtual Store\x83p\x83X\x82ɕϊ\xB7\x82\xB7\x82\xE9\x81B -// -// path: IN -// filename: IN -// vstore_path: OUT -// vstore_pathlen: IN -// -// return TRUE: success -// FALSE: failure -// -static BOOL convertVirtualStore(char *path, char *filename, char *vstore_path, int vstore_pathlen) -{ - BOOL ret = FALSE; - const char *s, **p; - const char *virstore_env[] = { - "ProgramFiles", - "ProgramData", - "SystemRoot", - NULL - }; - char shPath[1024] = ""; - char shFullPath[1024] = ""; - LPITEMIDLIST pidl; - int CSIDL; - - OutputDebugPrintf("[%s][%s]\n", path, filename); - - if (cv.VirtualStoreEnabled == FALSE) - goto error; - - // Virtual Store\x91ΏۂƂȂ\xE9\x83t\x83H\x83\x8B\x83_\x82\xA9\x81B - p = virstore_env; - while (*p) { - s = getenv(*p); - if (s != NULL && strstr(path, s) != NULL) { - break; - } - p++; - } - if (*p == NULL) - goto error; - - CSIDL = CSIDL_LOCAL_APPDATA; - if (SHGetSpecialFolderLocation(NULL, CSIDL, &pidl) != S_OK) { - goto error; - } - SHGetPathFromIDList(pidl, shPath); - CoTaskMemFree(pidl); - - // Virtual Store\x83p\x83X\x82\xF0\x8D\xEC\x82\xE9\x81B - strncat_s(shPath, sizeof(shPath), "\\VirtualStore", _TRUNCATE); - - // \x95s\x97v\x82ȃh\x83\x89\x83C\x83u\x83\x8C\x83^\x81[\x82\xF0\x8F\x9C\x8B\x8E\x82\xB7\x82\xE9\x81B - // \x83h\x83\x89\x83C\x83u\x83\x8C\x83^\x81[\x82͈ꕶ\x8E\x9A\x82Ƃ͌\xC0\x82\xE7\x82Ȃ\xA2\x93_\x82ɒ\x8D\x88ӁB - s = strstr(path, ":\\"); - if (s != NULL) { - strncat_s(shPath, sizeof(shPath), s + 1, _TRUNCATE); - } - - // \x8DŌ\xE3\x82ɁAVirtual Store\x82Ƀt\x83@\x83C\x83\x8B\x82\xAA\x82\xA0\x82邩\x82ǂ\xA4\x82\xA9\x82ׂ\xE9\x81B - _snprintf_s(shFullPath, sizeof(shFullPath), "%s\\%s", shPath, filename); - if (_access(shFullPath, 0) != 0) { - goto error; - } - - strncpy_s(vstore_path, vstore_pathlen, shPath, _TRUNCATE); - - ret = TRUE; - return (ret); - -error: - return (ret); -} - - - -static LRESULT CALLBACK OnSetupDirectoryDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARAM lp) -{ - static const DlgTextInfo TextInfos[] = { - { 0, "DLG_SETUPDIR_TITLE" }, - { IDC_INI_SETUPDIR_GROUP, "DLG_SETUPDIR_INIFILE" }, - { IDC_KEYCNF_SETUPDIR_GROUP, "DLG_SETUPDIR_KEYBOARDFILE" }, - { IDC_CYGTERM_SETUPDIR_GROUP, "DLG_SETUPDIR_CYGTERMFILE" }, - { IDC_SSH_SETUPDIR_GROUP, "DLG_SETUPDIR_KNOWNHOSTSFILE" }, - }; - static char teratermexepath[MAX_PATH]; - static char inipath[MAX_PATH], inifilename[MAX_PATH], inipath_vstore[1024]; - static char keycnfpath[MAX_PATH], keycnffilename[MAX_PATH], keycnfpath_vstore[1024]; - static char cygtermpath[MAX_PATH], cygtermfilename[MAX_PATH], cygtermpath_vstore[1024]; -// static char eterm1path[MAX_PATH], eterm1filename[MAX_PATH], eterm1path_vstore[1024]; - char temp[MAX_PATH]; - char tmpbuf[1024]; - typedef int (CALLBACK *PSSH_read_known_hosts_file)(char *, int); - PSSH_read_known_hosts_file func = NULL; - HMODULE h = NULL; - static char hostsfilepath[MAX_PATH], hostsfilename[MAX_PATH], hostsfilepath_vstore[1024]; - char *path_p, *filename_p; - BOOL open_dir, ret; - int button_pressed; - HWND hWnd; - - switch (msg) { - case WM_INITDIALOG: - // I18N - SetDlgTexts(hDlgWnd, TextInfos, _countof(TextInfos), ts.UILanguageFile); - - if (GetModuleFileNameA(NULL, temp, sizeof(temp)) != 0) { - ExtractDirName(temp, teratermexepath); - } - - // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B(teraterm.ini)\x82̃p\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B - /// (1) - ExtractFileName(ts.SetupFName, inifilename, sizeof(inifilename)); - ExtractDirName(ts.SetupFName, inipath); - //SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_STATIC, inifilename); - SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_EDIT, ts.SetupFName); - /// (2) Virutal Store\x82ւ̕ϊ\xB7 - memset(inipath_vstore, 0, sizeof(inipath_vstore)); - ret = convertVirtualStore(inipath, inifilename, inipath_vstore, sizeof(inipath_vstore)); - if (ret) { - hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, TRUE); - hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, TRUE); - _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", inipath_vstore, inifilename); - SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE, tmpbuf); - } - else { - hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, FALSE); - SetDlgItemText(hDlgWnd, IDC_INI_SETUPDIR_EDIT_VSTORE, ""); - } - - // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B(KEYBOARD.CNF)\x82̃p\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B - /// (1) - ExtractFileName(ts.KeyCnfFN, keycnffilename, sizeof(keycnfpath)); - ExtractDirName(ts.KeyCnfFN, keycnfpath); - //SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_STATIC, keycnffilename); - SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT, ts.KeyCnfFN); - /// (2) Virutal Store\x82ւ̕ϊ\xB7 - memset(keycnfpath_vstore, 0, sizeof(keycnfpath_vstore)); - ret = convertVirtualStore(keycnfpath, keycnffilename, keycnfpath_vstore, sizeof(keycnfpath_vstore)); - if (ret) { - hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, TRUE); - hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, TRUE); - _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", keycnfpath_vstore, keycnffilename); - SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE, tmpbuf); - } - else { - hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, FALSE); - SetDlgItemText(hDlgWnd, IDC_KEYCNF_SETUPDIR_EDIT_VSTORE, ""); - } - - - // cygterm.cfg \x82\xCD ttermpro.exe \x94z\x89\xBA\x82Ɉʒu\x82\xB7\x82\xE9\x81B - /// (1) - strncpy_s(cygtermfilename, sizeof(cygtermfilename), "cygterm.cfg", _TRUNCATE); - strncpy_s(cygtermpath, sizeof(cygtermpath), teratermexepath, _TRUNCATE); - //SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_STATIC, cygtermfilename); - _snprintf_s(temp, sizeof(temp), "%s\\%s", cygtermpath, cygtermfilename); - SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT, temp); - /// (2) Virutal Store\x82ւ̕ϊ\xB7 - memset(cygtermpath_vstore, 0, sizeof(cygtermpath_vstore)); - ret = convertVirtualStore(cygtermpath, cygtermfilename, cygtermpath_vstore, sizeof(cygtermpath_vstore)); - if (ret) { - hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, TRUE); - hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, TRUE); - _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", cygtermpath_vstore, cygtermfilename); - SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE, tmpbuf); - } - else { - hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, FALSE); - SetDlgItemText(hDlgWnd, IDC_CYGTERM_SETUPDIR_EDIT_VSTORE, ""); - } - - // ssh_known_hosts - if (func == NULL) { - if (((h = GetModuleHandle("ttxssh.dll")) != NULL)) { - func = (PSSH_read_known_hosts_file)GetProcAddress(h, "TTXReadKnownHostsFile"); - if (func) { - int ret = func(temp, sizeof(temp)); - if (ret) { - char *s = strstr(temp, ":\\"); - - if (s) { // full path - ExtractFileName(temp, hostsfilename, sizeof(hostsfilename)); - ExtractDirName(temp, hostsfilepath); - } - else { // relative path - strncpy_s(hostsfilepath, sizeof(hostsfilepath), teratermexepath, _TRUNCATE); - strncpy_s(hostsfilename, sizeof(hostsfilename), temp, _TRUNCATE); - _snprintf_s(temp, sizeof(temp), "%s\\%s", hostsfilepath, hostsfilename); - } - - SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT, temp); - - /// (2) Virutal Store\x82ւ̕ϊ\xB7 - memset(hostsfilepath_vstore, 0, sizeof(hostsfilepath_vstore)); - ret = convertVirtualStore(hostsfilepath, hostsfilename, hostsfilepath_vstore, sizeof(hostsfilepath_vstore)); - if (ret) { - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, TRUE); - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, TRUE); - _snprintf_s(tmpbuf, sizeof(tmpbuf), _TRUNCATE, "%s\\%s", hostsfilepath_vstore, hostsfilename); - SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE, tmpbuf); - } - else { - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, FALSE); - SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE, ""); - } - - } - } - } - else { - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT); - EnableWindow(hWnd, FALSE); - SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT, ""); - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_BUTTON); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_BUTTON_FILE); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_STATIC_VSTORE); - EnableWindow(hWnd, FALSE); - hWnd = GetDlgItem(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE); - EnableWindow(hWnd, FALSE); - SetDlgItemText(hDlgWnd, IDC_SSH_SETUPDIR_EDIT_VSTORE, ""); - } - } - - return TRUE; - - case WM_COMMAND: - button_pressed = 0; - switch (LOWORD(wp)) { - case IDC_INI_SETUPDIR_BUTTON | (BN_CLICKED << 16) : - open_dir = TRUE; - path_p = inipath; - if (inipath_vstore[0]) - path_p = inipath_vstore; - filename_p = inifilename; - button_pressed = 1; - break; - case IDC_INI_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : - open_dir = FALSE; - path_p = inipath; - if (inipath_vstore[0]) - path_p = inipath_vstore; - filename_p = inifilename; - button_pressed = 1; - break; - - case IDC_KEYCNF_SETUPDIR_BUTTON | (BN_CLICKED << 16) : - open_dir = TRUE; - path_p = keycnfpath; - if (keycnfpath_vstore[0]) - path_p = keycnfpath_vstore; - filename_p = keycnffilename; - button_pressed = 1; - break; - case IDC_KEYCNF_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : - open_dir = FALSE; - path_p = keycnfpath; - if (keycnfpath_vstore[0]) - path_p = keycnfpath_vstore; - filename_p = keycnffilename; - button_pressed = 1; - break; - - case IDC_CYGTERM_SETUPDIR_BUTTON | (BN_CLICKED << 16) : - open_dir = TRUE; - path_p = cygtermpath; - if (cygtermpath_vstore[0]) - path_p = cygtermpath_vstore; - filename_p = cygtermfilename; - button_pressed = 1; - break; - case IDC_CYGTERM_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : - open_dir = FALSE; - path_p = cygtermpath; - if (cygtermpath_vstore[0]) - path_p = cygtermpath_vstore; - filename_p = cygtermfilename; - button_pressed = 1; - break; - - case IDC_SSH_SETUPDIR_BUTTON | (BN_CLICKED << 16) : - open_dir = TRUE; - path_p = hostsfilepath; - if (hostsfilepath_vstore[0]) - path_p = hostsfilepath_vstore; - filename_p = hostsfilename; - button_pressed = 1; - break; - case IDC_SSH_SETUPDIR_BUTTON_FILE | (BN_CLICKED << 16) : - open_dir = FALSE; - path_p = hostsfilepath; - if (hostsfilepath_vstore[0]) - path_p = hostsfilepath_vstore; - filename_p = hostsfilename; - button_pressed = 1; - break; - - case IDCANCEL: - TTEndDialog(hDlgWnd, IDCANCEL); - return TRUE; - break; - - default: - return FALSE; - } - - if (button_pressed) { - char *app = NULL; - - if (open_dir) - app = NULL; - else - app = ts.ViewlogEditor; - - openFileDirectory(path_p, filename_p, open_dir, app); - return TRUE; - } - return FALSE; - - case WM_CLOSE: - TTEndDialog(hDlgWnd, 0); - return TRUE; - - default: - return FALSE; - } - return TRUE; -} - -// // \x8C\xBB\x8Dݓǂݍ\x9E\x82܂\xEA\x82Ă\xA2\x82\xE9 teraterm.ini \x83t\x83@\x83C\x83\x8B\x82\xAA\x8Ai\x94[\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9 // \x83t\x83H\x83\x8B\x83_\x82\xF0\x83G\x83N\x83X\x83v\x83\x8D\x81[\x83\x89\x82ŊJ\x82\xAD\x81B // @@ -5277,8 +4815,7 @@ // void CVTWindow::OnOpenSetupDirectory() { - TTDialogBox(m_hInst, MAKEINTRESOURCE(IDD_SETUP_DIR_DIALOG), - HVTWin, (DLGPROC)OnSetupDirectoryDlgProc); + SetupDirectoryDialog(m_hInst, HVTWin); } void CVTWindow::OnSetupLoadKeyMap()