Delphi控件中的Ctrl + Backspace [英] Ctrl+Backspace in Delphi Controls
问题描述
Ctrl + Backspace
键盘快捷键通常会从插入符号左侧删除该单词。但是它不适用于您期望的任何标准Delphi控件( TEdit
, TMemo
, TComboBox
ect。)。有趣的是, Ctrl + Delete
工作正常。
有没有人知道如何轻松纠正这个行为? >
我知道覆盖 KeyDown
程序会做到这一点,但这是一个相当复杂的 KeyDown
必须覆盖每个组件。
这不是一个特定于Delphi的问题。实际上, TEdit
,其他控件只是本机Microsoft Windows控件的包装器,它们的行为如此。例如,尝试在记事本的选择字体对话框中的编辑框。编辑自动完成启用的控件,但是,请接受Ctrl + Backspace热键。我想你可以通过
SHAutoComplete(Edit1.Handle,
SHACF_AUTOAPPEND_FORCE_OFF或SHACF_AUTOSUGGEST_FORCE_OFF)轻松启用此功能
(使用 ShLwApi
)。
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.
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
).
这篇关于Delphi控件中的Ctrl + Backspace的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!