1

我想在 Visual Studio 2010 中为 MFC SDI 应用程序添加键盘快捷键。这是我所做的:

  1. 将所需的密钥作为虚拟密钥添加到加速器资源(例如,ID 为 ID_NEWGAME 的 VK_SPACE)
  2. 将 COMMAND 的事件处理程序连接到 CMyGameView 类中的 ID_NEWGAME
  3. 通过尝试使用调试器在事件处理程序内停止来进行测试

结果:当我按下空格键时程序没有反应。

但是,在 Visual Studio 6.0 中,相同的过程按预期工作。

我错过了什么?

4

1 回答 1

3

I have a hunch you're experiencing a problem I've also come across - when you create an SDI application using the latest version of MFC, by default the application loads the accelerator table from the registry at runtime therefore overwriting anything that you've specified in the resource table. I posted a solution in a previous thread here which I think is the same as what you're seeing. Hope that helps.

于 2012-04-20T11:02:08.870 回答