Why is CMFCMenuBar not utilizing the accelerator table?

梦想的初衷 提交于 2019-12-01 00:44:39

Having just spent far too much time wrestling with this problem I thought I'd post the solution that appears to work for me.

I call :

theApp.GetKeyboardManager()->ResetAll();

after the MDI framework stuff has been loaded from the registry (I've created a specific function called PostLoadFrame() which I call immediately after calling LoadFrame() which is where the registry seems to get read).

This function call ignores any accelerators loaded from the registry (which is fine for me because I don't allow customisation of them anyway) and uses the accelerators in your resource file instead.

Like I said, it seems to be working for me in my application. If you do allow customisation of the accelerator keys, then it looks like it's possible to merge your resource file and the registry stored values with other functions in CKeyboardManager, but it's a bit more complicated.

I hope that helps somebody somewhere save some of the time I've lost!!

Apparently some CMFCMenuBar settings are persisted to the registry (HKCU I think.) Try clearing your application's registry settings and see if the correct accelerators are shown.

See this MSDN thread for some related CMFCMenuBar troubleshooting.

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