Skip to content

Commit

Permalink
送信ファイルの選択ダイアログの初期フォルダが FileDir になるようにした #379
Browse files Browse the repository at this point in the history
- File - Transfer - XXXXX - Send
- File - Send file - ...
  • Loading branch information
nmaya committed Nov 14, 2024
1 parent b7a03a3 commit 10cab2b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions doc/en/html/about/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h3 id="teraterm_5.4">YYYY.MM.DD (Ver 5.4 not released yet)</h3>
<li>Updated Unicode information to Unicode 16.0. Before update, Unicode 15.1 compliant since Tera Term 5.0.</li>
<li>All available character codes can be specified using command line options.</li>
<li>Supports "COM%d" style serial ports of com0com (virtual serial port driver), which are not Ports class.</li>
<li>Changed initial directory for file select dialog of send file to <a href="../setup/folder.html#FileDir">File transfer folder</a>.</li>
</ul>
</li>

Expand Down
1 change: 1 addition & 0 deletions doc/ja/html/about/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h3 id="teraterm_5.4">YYYY.MM.DD (Ver 5.4 not released yet)</h3>
<li>Unicode の文字情報を Unicode 16.0 に更新した。更新前、Tera Term 5.0 から Unicode 15.1 準拠だった。</li>
<li>コマンドラインオプションで使用可能文字コードを全て指定できるようにした。</li>
<li>com0com(virtual serial port driver) の Ports class ではない "COM%d" 形式のシリアルポートを選択できるようにした。</li>
<li>送信ファイルを選択するダイアログの初期ディレクトリが<a href="../setup/folder.html#FileDir">ファイル転送用のフォルダ</a>になるようにした。</li>
</ul>
</li>

Expand Down
22 changes: 11 additions & 11 deletions teraterm/teraterm/filesys_proto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,15 +688,15 @@ wchar_t **MakeFileArrayMultiSelect(const wchar_t *lpstrFile)

static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPLONG Option)
{
wchar_t *CurDir = GetFileDir(&ts);
wchar_t *FileDir = GetFileDir(&ts);
wchar_t *filterW = ToWcharA(ts.FileSendFilter);
wchar_t *FNFilter = GetCommonDialogFilterWW(!Receive ? filterW : NULL, ts.UILanguageFileW);
free(filterW);

wchar_t FullName[MAX_PATH];
FullName[0] = 0;
if (!Receive) {
wchar_t *default_filename = GetCommonDialogDefaultFilenameW(CurDir);
wchar_t *default_filename = GetCommonDialogDefaultFilenameW(FileDir);
if (default_filename != NULL) {
wcsncpy_s(FullName, _countof(FullName), default_filename, _TRUNCATE);
free(default_filename);
Expand All @@ -710,7 +710,7 @@ static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPL
ofn.nFilterIndex = 1;
ofn.lpstrFile = FullName;
ofn.nMaxFile = _countof(FullName);
ofn.lpstrInitialDir = CurDir;
ofn.lpstrInitialDir = FileDir;
LONG opt = *Option;
if (! Receive)
{
Expand Down Expand Up @@ -740,7 +740,7 @@ static wchar_t **_GetXFname(HWND HWin, BOOL Receive, const wchar_t *caption, LPL
Ok = GetSaveFileNameW(&ofn);
}
free(FNFilter);
free(CurDir);
free(FileDir);
SetCurrentDirectoryW(TempDir);

wchar_t **ret = NULL;
Expand Down Expand Up @@ -940,7 +940,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
#define FnStrMemSize 4096
wchar_t TempDir[MAX_PATH];
const wchar_t *UILanguageFileW = ts.UILanguageFileW;
wchar_t *CurDir = GetFileDir(&ts);
wchar_t *FileDir = GetFileDir(&ts);

/* save current dir */
GetCurrentDirectoryW(_countof(TempDir), TempDir);
Expand All @@ -956,7 +956,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
wchar_t *FNFilter = GetCommonDialogFilterWW(filterW, UILanguageFileW);
free(filterW);

wchar_t *default_filename = GetCommonDialogDefaultFilenameW(CurDir);
wchar_t *default_filename = GetCommonDialogDefaultFilenameW(FileDir);
if (default_filename != NULL) {
wcsncpy_s(FnStrMem, FnStrMemSize, default_filename, _TRUNCATE);
free(default_filename);
Expand All @@ -970,7 +970,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
ofn.lpstrFile = FnStrMem;
ofn.nMaxFile = FnStrMemSize;
ofn.lpstrTitle= caption;
ofn.lpstrInitialDir = CurDir;
ofn.lpstrInitialDir = FileDir;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.Flags |= OFN_ALLOWMULTISELECT | OFN_EXPLORER;
ofn.Flags |= OFN_SHOWHELP;
Expand All @@ -996,7 +996,7 @@ static wchar_t **_GetMultiFname(HWND hWnd, WORD FuncId, const wchar_t *caption,
ret = MakeFileArrayMultiSelect(FnStrMem);
}
free(FnStrMem);
free(CurDir);
free(FileDir);

/* restore dir */
SetCurrentDirectoryW(TempDir);
Expand Down Expand Up @@ -1504,7 +1504,7 @@ static wchar_t **_GetTransFname(HWND hWnd, const wchar_t *DlgCaption)
wchar_t TempDir[MAX_PATH];
wchar_t FileName[MAX_PATH];
const wchar_t *UILanguageFileW = ts.UILanguageFileW;
wchar_t *CurDir = GetFileDir(&ts);
wchar_t *FileDir = GetFileDir(&ts);

/* save current dir */
GetCurrentDirectoryW(_countof(TempDir), TempDir);
Expand All @@ -1521,14 +1521,14 @@ static wchar_t **_GetTransFname(HWND hWnd, const wchar_t *DlgCaption)
ofn.nFilterIndex = 1;
ofn.lpstrFile = FileName;
ofn.nMaxFile = _countof(FileName);
ofn.lpstrInitialDir = CurDir;
ofn.lpstrInitialDir = FileDir;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_SHOWHELP;
ofn.lpstrTitle = DlgCaption;
ofn.hInstance = hInst;

BOOL Ok = GetOpenFileNameW(&ofn);
free(FNFilter);
free(CurDir);
free(FileDir);

wchar_t **ret = NULL;
if (Ok) {
Expand Down
5 changes: 5 additions & 0 deletions teraterm/teraterm/sendfiledlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "i18n.h"
#include "tt_res.h"
#include "ttlib.h"
#include "ttlib_types.h"
#include "dlglib.h"
#include "tttypes.h" // for WM_USER_DLGHELP2
#include "helpid.h"
Expand Down Expand Up @@ -178,6 +179,8 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA
free(uimsg);
uimsg = NULL;

TTTSet *ts = data->pts;
wchar_t *FileDir = GetFileDir(ts);
wchar_t *filterW = GetCommonDialogFilterWW(data->filesend_filter, data->UILanguageFileW);
wchar_t filename[MAX_PATH];
filename[0] = 0;
Expand All @@ -189,8 +192,10 @@ static INT_PTR CALLBACK SendFileDlgProc(HWND hDlgWnd, UINT msg, WPARAM wp, LPARA
ofn.lpstrFilter = filterW;
ofn.nFilterIndex = 0;
ofn.lpstrTitle = title;
ofn.lpstrInitialDir = FileDir;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_SHOWHELP | OFN_HIDEREADONLY;
BOOL Ok = GetOpenFileNameW(&ofn);
free(FileDir);
free(filterW);
free(title);

Expand Down
1 change: 1 addition & 0 deletions teraterm/teraterm/sendfiledlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct {
// in
const wchar_t* UILanguageFileW;
const wchar_t *filesend_filter;
TTTSet *pts;
// out
wchar_t* filename; // IDOK時、選択ファイル名が返る,使用後free()すること
BOOL binary; // TRUE/FALSE = バイナリ/テキスト
Expand Down
1 change: 1 addition & 0 deletions teraterm/teraterm/vtwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3972,6 +3972,7 @@ void CVTWindow::OnFileSend()
data.UILanguageFileW = ts.UILanguageFileW;
wchar_t *filterW = ToWcharA(ts.FileSendFilter);
data.filesend_filter = filterW;
data.pts = &ts;
INT_PTR ok = sendfiledlg(m_hInst, m_hWnd, &data);
free(filterW);
if (ok != IDOK) {
Expand Down

0 comments on commit 10cab2b

Please sign in to comment.