如何使我的自定义树视图接受Enter键? [英] How do I make my custom treeview accept the Enter key?
问题描述
我有一个自定义控件,它来自TTreeView。我试图通过给它一个响应VK_RETURN的WM_CHAR处理程序,使用户在控件处于焦点状态时按ENTER来赋予它特殊的行为。
I've got a custom control that descends from TTreeView. I'm trying to give it special behavior when the user presses ENTER while the control is focused, by giving it a WM_CHAR handler that responds to VK_RETURN, but it never gets called.
我尝试通过添加一个表示 msg.Result:= msg.Result或DLGC_WANTALLKEYS;
的WM_GETDLGCODE处理程序来确保它接受所有键盘输入。现在它收到了ENTER键,但箭头键不再起作用!
I tried making sure that it would accept all keyboard input by adding a WM_GETDLGCODE handler that says msg.Result := msg.Result or DLGC_WANTALLKEYS;
. Now it receives the ENTER key, but the arrow keys no longer work!
任何人都知道如何正确解决此问题吗?
Anyone have any idea how I can fix this correctly?
推荐答案
我总是这样做
WM_GETDLGCODE: Message.Result := Message.Result or DLGC_WANTCHARS or
DLGC_WANTARROWS or DLGC_WANTTAB or
DLGC_WANTALLKEYS;
。也许您只是忘记了 DLGC_WANTARROWS
?
这篇关于如何使我的自定义树视图接受Enter键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!