Skip to content

Commit

Permalink
ログダイアログの修正 #402
Browse files Browse the repository at this point in the history
- ログファイル名が更新されなかったので修正
- [...] ボタンの位置を調整
  • Loading branch information
zmatsuo committed Dec 21, 2024
1 parent 077e9b9 commit f1d84b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion teraterm/teraterm/filesys_log.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 21 additions & 8 deletions teraterm/teraterm/logdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ typedef struct {
bool available_timer;
bool enable_timer;
bool on_initdialog;
HWND file_edit;
WNDPROC proc;
TTTSet *pts;
TComVar *pcv;
Expand Down Expand Up @@ -322,18 +323,23 @@ 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);
free(fname);

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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit f1d84b7

Please sign in to comment.