Skip to content

Conversation

@TetraTheta
Copy link
Contributor

Enabling AutoComplete will also enable 'Delete Whole Word'(Ctrl+Backspace) feature as side-effect.

Source: https://stackoverflow.com/a/30269663

Enabling AutoComplete will also enable 'Delete Whole Word'(Ctrl+Backspace) feature as side-effect.

Source: https://stackoverflow.com/a/30269663
@zufuliu
Copy link
Owner

zufuliu commented Oct 26, 2025

Related issue for Notepad4: zufuliu/notepad4#904 and zufuliu/notepad4@51fe97e
which use following code:

SHAutoComplete(hwnd, SHACF_FILESYS_ONLY | SHACF_AUTOAPPEND_FORCE_OFF | SHACF_AUTOSUGGEST_FORCE_OFF);

rough equivalent to following (?):

// .AutoCompleteMode = AutoCompleteMode.None; // default None
.AutoCompleteSource = AutoCompleteSource.FileSystem;

Same change could be applied to outer/top FindInFilesForm.Designer.cs.

@TetraTheta
Copy link
Contributor Author

TetraTheta commented Oct 26, 2025

Setting .AutoCompleteMode to None will prevent Ctrl+Backspace side-effect in .NET Fw 4.8, which makes this PR useless.
I think AutoCompleteMode.Suggest is mandatory.

Calling Windows API directly to those controls might work, but ComboBox requires extra 'touch' to get handle of TextBox(or something similar) underlying of it, or SHAutoComplete won't work on it.
Here is AutoHotkey function that I use to enable Ctrl+Backspace to both type of controls.

EnableAutoCompleteOnComboBox(hCombo, option := 0x20000000) {
  CBEM_GETEDITCONTROL := 0x0407 ; WM_USER + 7
  hEdit := DllCall("SendMessageW", "ptr", hCombo, "uint", CBEM_GETEDITCONTROL, "ptr", 0, "ptr", 0, "ptr")
  if !hEdit
    hEdit := DllCall("FindWindowExW", "ptr", hCombo, "ptr", 0, "wstr", "Edit", "wstr", "", "ptr")

  if !hEdit
    return

  EnableAutoCompleteOnEdit(hEdit, option)
}

EnableAutoCompleteOnEdit(hEdit, option := 0x20000000) {
  ; https://devblogs.microsoft.com/oldnewthing/20071011-00/?p=24823
  ; https://learn.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-shautocomplete
  ; SHACF_AUTOSUGGEST_FORCE_OFF (0x20000000)
  ;   Ignore the registry default and force the AutoSuggest feature off.
  ;   This flag must be used in combination with one or more of the SHACF_FILESYS* or SHACF_URL* flags.
  ; AKA. It won't autocomplete anything, but it will allow functionality such as Ctrl+Backspace deleting a word.
  DllCall("ole32\CoInitialize", "uint", 0)
  DllCall("shlwapi\SHAutoComplete", "uint", hEdit, "uint", option)
  DllCall("ole32\CoUninitialize")
}

I'll update the PR to suggest FileSystem to comboBoxSearchPath. I don't think other controls needs any suggestion, at least from what I've understood.

@zufuliu
Copy link
Owner

zufuliu commented Oct 26, 2025

Setting .AutoCompleteMode to None will prevent Ctrl+Backspace side-effect in .NET Fw 4.8, which makes this PR useless.
I think AutoCompleteMode.Suggest is mandatory.

OK, thanks for the clarify.

@zufuliu
Copy link
Owner

zufuliu commented Oct 26, 2025

Same change could be applied to outer/top FindInFilesForm.Designer.cs.

Are going to add commits to apply similar change to:
https://github.com/zufuliu/FindInFiles/blob/main/FindInFilesForm.Designer.cs

@TetraTheta
Copy link
Contributor Author

TetraTheta commented Oct 26, 2025

Done!
.NET WinForm part didn't show up as WinForm file, so I couldn't understand what you mean at the first time.

Is this what you've meant?

@zufuliu
Copy link
Owner

zufuliu commented Oct 27, 2025

.NET WinForm part didn't show up as WinForm file, so I couldn't understand what you mean at the first time.

You need to install .NET SDK to view in designer.

@TetraTheta
Copy link
Contributor Author

That's weird, because it is already installed.
I think that's a problem of my environment.

Anyway, I've modified WinForm Designer file for .NET too. Can you check it, please?

@zufuliu
Copy link
Owner

zufuliu commented Oct 27, 2025

The changes are in effect.
image

image

@zufuliu zufuliu merged commit 1471981 into zufuliu:main Oct 27, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants