将功能键分配给对话框的简单方法?
我有一个 MFC 对话框,我想将功能键分配给不同的方法。这可能吗?
例如,我想输入 F9 并获得与按下按钮相同的结果。
I have a MFC dialog and I would like to assign function keys to different methods. Is that possible?
For example I would like to type F9 and have the same result as pressing a button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于基于对话框的应用程序。在资源编辑器中为您的对话框创建一个 IDR_ACCELERATOR1。添加您想要的键,并为对话框的键创建一个事件。
在sampledlg.h中,请添加
在sampledlg.cpp中,在OnInitDialog()中,请添加
在sampledlg.cpp中,请添加 在PreTranslateMessage(MSG *pMsg)中,请添加
For Dialog Based application. Create a IDR_ACCELERATOR1 in resource editor for your dialog. And add the Key you wanted and create a Event for the Key for your dialog.
In sampledlg.h please add
In sampledlg.cpp In OnInitDialog() please add
In sampledlg.cpp In PreTranslateMessage(MSG *pMsg) please add
如果您的意思是在基于对话框的应用程序的主对话框中,您可以检查
http://www.codeproject.com /Articles/37130/Implement-Accelerators-in-a-Dialog-Based-Applicati.aspx
如果用于文档/视图应用程序中的对话框:
http://support.microsoft.com/kb/117500/en-us
http://support.microsoft.com/kb/222829/en-us
If you mean in the main dialog of a dialog based application, you can check
http://www.codeproject.com/Articles/37130/Implement-Accelerators-in-a-Dialog-Based-Applicati.aspx
If it's for dialogs in a doc/view application:
http://support.microsoft.com/kb/117500/en-us
http://support.microsoft.com/kb/222829/en-us
比我想象的容易。我不知道这是否是最好的解决方案,但这就是我所做的:
现在,每次按下功能键 F9 时都会调用函数 OnBClickedButton1() 。
Easier than I thought. I don't know if this is the best solution but this is what I did:
Now, every time Function Key F9 is pressed function OnBClickedButton1() is called.