From f1d84b73acdab888f8bdb7edfc48c15272a0b74f Mon Sep 17 00:00:00 2001 From: zmatsuo <6488847+zmatsuo@users.noreply.github.com> Date: Sun, 22 Dec 2024 02:07:40 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=83=80=E3=82=A4=E3=82=A2?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3=20#402?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ログファイル名が更新されなかったので修正 - [...] ボタンの位置を調整 --- teraterm/teraterm/filesys_log.rc | 2 +- teraterm/teraterm/logdlg.cpp | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/teraterm/teraterm/filesys_log.rc b/teraterm/teraterm/filesys_log.rc index 79e592973..856105450 100644 --- a/teraterm/teraterm/filesys_log.rc +++ b/teraterm/teraterm/filesys_log.rc @@ -67,7 +67,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "&Filename (drop file in this dialog)",IDC_SENDFILE_FILENAME_TITLE,9,7,172,8 COMBOBOX IDC_FOPT_FILENAME_EDIT,19,21,224,93,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "...",IDC_FOPT_FILENAME_BUTTON,245,21,14,14 + PUSHBUTTON "...",IDC_FOPT_FILENAME_BUTTON,245,20,14,14 GROUPBOX "Write mode",IDC_APPEND_GROUP,7,42,250,45 CONTROL "&New / Overwrite",IDC_NEW_OVERWRITE,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,19,55,150,10 CONTROL "&Append",IDC_APPEND,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,19,70,150,10 diff --git a/teraterm/teraterm/logdlg.cpp b/teraterm/teraterm/logdlg.cpp index 6c358dd13..3409ba6b6 100644 --- a/teraterm/teraterm/logdlg.cpp +++ b/teraterm/teraterm/logdlg.cpp @@ -63,6 +63,7 @@ typedef struct { bool available_timer; bool enable_timer; bool on_initdialog; + HWND file_edit; WNDPROC proc; TTTSet *pts; TComVar *pcv; @@ -322,9 +323,16 @@ static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPAR // WM_COMMAND, EN_CHANGE が発生する wchar_t *fname = FLogGetLogFilename(work->info->filename); SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, fname); - HWND file_edit = GetDlgItem(Dialog, IDC_FOPT_FILENAME_EDIT); - SetWindowLongPtr(file_edit, GWLP_USERDATA, (LONG_PTR)work); - work->proc = (WNDPROC)SetWindowLongPtrW(file_edit, GWLP_WNDPROC, (LONG_PTR)FNameEditProc); + + // ドロップダウンのエディットコントロールのウィンドウハンドルを取得 + COMBOBOXINFO cbi; + cbi.cbSize = sizeof(COMBOBOXINFO); + GetComboBoxInfo(GetDlgItem(Dialog, IDC_FOPT_FILENAME_EDIT), &cbi); + work->file_edit = cbi.hwndItem; + + // サブクラス化 + SetWindowLongPtrW(work->file_edit, GWLP_USERDATA, (LONG_PTR)work); + work->proc = (WNDPROC)SetWindowLongPtrW(work->file_edit, GWLP_WNDPROC, (LONG_PTR)FNameEditProc); HistoryStoreSetControl(hs, Dialog, IDC_FOPT_FILENAME_EDIT); ExpandCBWidth(Dialog, IDC_FOPT_FILENAME_EDIT); @@ -332,8 +340,6 @@ static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPAR CenterWindow(Dialog, GetParent(Dialog)); - SetFocus(GetDlgItem(Dialog, IDC_FOPT_FILENAME_EDIT)); - work->enable_timer = true; work->available_timer = true; SetTimer(Dialog, ID_EVENT, 1000, NULL); @@ -411,7 +417,8 @@ static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPAR ArrangeControls(Dialog, work); break; case IDC_FOPT_FILENAME_EDIT: - if (HIWORD(wParam) == EN_CHANGE){ + switch (HIWORD(wParam)) { + case EN_CHANGE: { wchar_t *filename; hGetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, &filename); const bool file_exist_prev = work->file_exist; @@ -429,6 +436,12 @@ static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPAR } ArrangeControls(Dialog, work); } + break; + } + case CBN_DROPDOWN: { + work->enable_timer = false; + break; + } } break; } @@ -452,8 +465,8 @@ static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPAR break; } wchar_t *fname = FLogGetLogFilename(work->info->filename); - SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, fname); - SendDlgItemMessageW(Dialog, IDC_FOPT_FILENAME_EDIT, EM_SETSEL, 0, -1); + SetWindowTextW(work->file_edit, fname); + SendMessageW(work->file_edit, EM_SETSEL, 0, -1); free(fname); break; }