From c403b87ac035c9d7678a60764e0f39cbaf85c435 Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Tue, 5 Dec 2017 12:21:12 -0500 Subject: [PATCH setup] Fix response to enter in the chooser search textbox Make 'enter' after we've started typing into the search textbox cause the search filter to immediately take effect. Note that we don't change the default control immediately on EN_SETFOCUS, but wait for ENCHANGE, so pressing 'enter' before typing anything into the search textbox still moves to the next page. Also improve a bit of debug output from ChooserPage::OnMessageCmd() --- choose.cc | 20 +++++++++++++++++--- res.rc | 2 ++ resource.h | 1 + 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/choose.cc b/choose.cc index 1bc4c0b..4219a81 100644 --- a/choose.cc +++ b/choose.cc @@ -381,12 +381,19 @@ bool ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code) { #if DEBUG - Log (LOG_BABBLE) << "OnMesageCmd " << id << " " << hwndctl << " " << code << endLog; + Log (LOG_BABBLE) << "OnMessageCmd " << id << " " << hwndctl << " " << std::hex << code << endLog; #endif - if (code == EN_CHANGE && id == IDC_CHOOSE_SEARCH_EDIT) + if (id == IDC_CHOOSE_SEARCH_EDIT) { - SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL); + if (code == EN_CHANGE) + { + SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) IDC_CHOOSE_DO_SEARCH, 0); + SetTimer(GetHWND (), timer_id, SEARCH_TIMER_DELAY, (TIMERPROC) NULL); + } + else if (code == EN_KILLFOCUS) + SendMessage (GetHWND (), DM_SETDEFID, (WPARAM) 0x3024 /* ID_WIZNEXT */, 0); + return true; } else if (code == BN_CLICKED) @@ -402,6 +409,13 @@ ChooserPage::OnMessageCmd (int id, HWND hwndctl, UINT code) } break; + case IDC_CHOOSE_DO_SEARCH: + // invisible pushbutton which is the default pushbutton while typing into + // the search textbox, so that 'enter' causes the filter to be applied + // immediately, rather than activating the next page + SendMessage (GetHWND (), WM_TIMER, (WPARAM) timer_id, 0); + break; + case IDC_CHOOSE_KEEP: if (IsButtonChecked (id)) keepClicked(); diff --git a/res.rc b/res.rc index a4d7e70..901cf76 100644 --- a/res.rc +++ b/res.rc @@ -342,6 +342,8 @@ BEGIN CBS_DROPDOWNLIST | WS_TABSTOP RTEXT "&Search", IDC_STATIC, SETUP_SEARCH_X, 33, SETUP_SEARCH_W, 10, SS_CENTERIMAGE, WS_EX_RIGHT + CONTROL "Search ", IDC_CHOOSE_DO_SEARCH, "Button", BS_PUSHBUTTON | NOT + WS_VISIBLE, SETUP_SEARCH_X, 33, SETUP_SEARCH_W, 14 EDITTEXT IDC_CHOOSE_SEARCH_EDIT, SETUP_SEARCHTEXT_X, 30, SETUP_SEARCHTEXT_W, 14, ES_AUTOHSCROLL PUSHBUTTON "&Clear", IDC_CHOOSE_CLEAR_SEARCH, SETUP_CLEAR_X, 30, diff --git a/resource.h b/resource.h index a2e867f..79b876d 100644 --- a/resource.h +++ b/resource.h @@ -177,3 +177,4 @@ #define IDC_FILE_INUSE_HELP 592 #define IDC_NET_DIRECT_LEGACY 593 #define IDC_DOWNLOAD_EDIT 594 +#define IDC_CHOOSE_DO_SEARCH 595 -- 2.15.1