问题
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.
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?
回答1:
I always do
WM_GETDLGCODE: Message.Result := Message.Result or DLGC_WANTCHARS or
DLGC_WANTARROWS or DLGC_WANTTAB or
DLGC_WANTALLKEYS;
when writing text editors. Maybe you just forgot DLGC_WANTARROWS
?
来源:https://stackoverflow.com/questions/5070573/how-do-i-make-my-custom-treeview-accept-the-enter-key