How do I make my custom treeview accept the Enter key?

别等时光非礼了梦想. 提交于 2019-12-12 16:01:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!