Delphi:我可以区分小键盘的回车键和回车键吗?
我有一个古色古香的小应用程序,可以弹出一个用 Delphi 编写的屏幕数字键盘/计算器。我想让它这样,如果您按“输入”(在数字键盘上),您将按“=”,如果您按“返回”(在主键盘上),您将按“确定”。
有一个“确定”按钮,它是表单的默认按钮,可响应按 Enter 或 Return 键。 还有一个 onkeydown 事件处理程序,它可能会捕获 Enter 并作为 vk_return 返回。但它的职责被默认的“确定”按钮所取代。
如果我能知道 return 和 Enter 之间的区别,那么我可以摆脱“确定”按钮上的默认属性,只需在表单按键功能上单击“确定”按钮的单击事件处理程序,但可惜它们都是 VK_RETURN。
I've got a quaint little app that pops up an on screen numberpad/calculator written in Delphi. I'd like to make it so if you pressed 'enter' (on the number pad) you'd be pressing '=' and if you pressed 'return' (on the main keyboard) you'd be pressing 'OK'.
There's an OK button who is the form's default guy which responds to hitting enter or return.
There is also an onkeydown event handler which potentially might capture both Enter and return as vk_return. But its duties are usurped by the default 'OK' button.
If I could know the difference between return and enter, then I could get rid of my default property on the OK button and just do hit the OK button's click event handler on the form key down function, but alas they are both VK_RETURN.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
覆盖 WM_KEYDOWN 消息处理程序:
实现它,以便它调用除您感兴趣之外的任何内容的祖先。您可以通过键数据消息字段中的“扩展”位来检测返回键和回车键之间的差异:
Override the WM_KEYDOWN message handler:
Implement it so that it calls the ancestor for anything but what you're interested in. You can detect the difference between the return key and the enter key by the "extended" bit in the key data message field: