10
votes

the Ctrl+Backspace keyboard shortcut normally deletes the word to the left from the caret. But it does not work in any of the standard Delphi controls you would expect (TEdit, TMemo, TComboBox ect.). Interestingly, Ctrl+Delete works just fine.

Does anybody know how to correct this behaviour easily?

I know that overriding the KeyDown procedure would do it, but this is a rather too complicated as KeyDown has to be overridden for every component.

1
This is not a Delphi-specific issue. Indeed, TEdit and the other controls are merely wrappers for the native Microsoft Windows controls, and they behave like this. Try, for instance, the edit box in Notepad's 'Select Font' dialog. Edit controls with auto-completion enabled, however, accept the Ctrl+Backspace hotkey.Andreas Rejbrand
Like Raymond said.TLama
Interesting, I didn't know that. But it is still a little bit annoying because the shortcut works at so many places including even MS software.oxo
@oxo: I agree, this is a shortcut I really expect and use daily, in most software. Probably the standard edit box hasn't got this feature by default because of some obscure and subtle compatibility issue with old (or misbehaving) software. Still one might wonder why there isn't a style one can use to enable this feature.Andreas Rejbrand
At the opposite side is RichEdit control where is this shortcut implemented by default.TLama

1 Answers

17
votes

This is not a Delphi-specific issue. Indeed, TEdit and the other controls are merely wrappers for the native Microsoft Windows controls, and they behave like this. Try, for instance, the edit box in Notepad's 'Select Font' dialog. Edit controls with auto-completion enabled, however, accept the Ctrl+Backspace hotkey. I think you can enable this easily by

SHAutoComplete(Edit1.Handle,
  SHACF_AUTOAPPEND_FORCE_OFF or SHACF_AUTOSUGGEST_FORCE_OFF)

(uses ShLwApi).