Skip to content

Commit

Permalink
Use SHAutoComplete() to enable Ctrl+Backspace on edit control, is…
Browse files Browse the repository at this point in the history
…sue #904.
  • Loading branch information
zufuliu committed Nov 7, 2024
1 parent f85471e commit 51fe97e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions matepath/src/Dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,9 @@ INT_PTR CALLBACK GotoDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
}
}

// from WinUser.h: GetComboBoxInfo() since Windows Vista, but CB_GETCOMBOBOXINFO since Windows XP.
COMBOBOXINFO cbi;
memset(&cbi, 0, sizeof(COMBOBOXINFO));
cbi.cbSize = sizeof(COMBOBOXINFO);
if (SendMessage(hwndGoto, CB_GETCOMBOBOXINFO, 0, AsInteger<LPARAM>(&cbi))) {
if (GetComboBoxInfo(hwndGoto, &cbi)) {
SHAutoComplete(cbi.hwndItem, SHACF_FILESYSTEM);
}
CenterDlgInParent(hwnd);
Expand Down
9 changes: 5 additions & 4 deletions src/Edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4590,12 +4590,13 @@ static LRESULT CALLBACK AddBackslashEditProc(HWND hwnd, UINT umsg, WPARAM wParam
return DefSubclassProc(hwnd, umsg, wParam, lParam);
}

void AddBackslashComboBoxSetup(HWND hwndDlg, int nCtlId) noexcept {
HWND hwnd = GetDlgItem(hwndDlg, nCtlId);
void AddBackslashComboBoxSetup(HWND hwnd) noexcept {
COMBOBOXINFO info;
info.cbSize = sizeof(COMBOBOXINFO);
if (GetComboBoxInfo(hwnd, &info)) {
SetWindowSubclass(info.hwndItem, AddBackslashEditProc, 0, 0);
// Ctrl+Backspace
SHAutoComplete(info.hwndItem, SHACF_FILESYS_ONLY | SHACF_AUTOAPPEND_FORCE_OFF | SHACF_AUTOSUGGEST_FORCE_OFF);
}
}

Expand Down Expand Up @@ -4734,7 +4735,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
ResizeDlg_InitX(hwnd, cxFindReplaceDlg, IDC_RESIZEGRIP2);

HWND hwndFind = GetDlgItem(hwnd, IDC_FINDTEXT);
AddBackslashComboBoxSetup(hwnd, IDC_FINDTEXT);
AddBackslashComboBoxSetup(hwndFind);

// Load MRUs
mruFind.AddToCombobox(hwndFind);
Expand All @@ -4754,7 +4755,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar

HWND hwndRepl = GetDlgItem(hwnd, IDC_REPLACETEXT);
if (hwndRepl) {
AddBackslashComboBoxSetup(hwnd, IDC_REPLACETEXT);
AddBackslashComboBoxSetup(hwndRepl);
mruReplace.AddToCombobox(hwndRepl);
ComboBox_LimitText(hwndRepl, NP2_FIND_REPLACE_LIMIT);
ComboBox_SetExtendedUI(hwndRepl, TRUE);
Expand Down
5 changes: 4 additions & 1 deletion src/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,10 @@ static LRESULT CALLBACK MultilineEditProc(HWND hwnd, UINT umsg, WPARAM wParam, L
}

void MultilineEditSetup(HWND hwndDlg, int nCtlId) noexcept {
SetWindowSubclass(GetDlgItem(hwndDlg, nCtlId), MultilineEditProc, 0, 0);
HWND hwnd = GetDlgItem(hwndDlg, nCtlId);
SetWindowSubclass(hwnd, MultilineEditProc, 0, 0);
// Ctrl+Backspace
SHAutoComplete(hwnd, SHACF_FILESYS_ONLY | SHACF_AUTOAPPEND_FORCE_OFF | SHACF_AUTOSUGGEST_FORCE_OFF);
}

//=============================================================================
Expand Down

0 comments on commit 51fe97e

Please sign in to comment.