TranslateAccelerator and Disabled Menu Items

亡梦爱人 提交于 2019-12-12 15:24:40

问题


In my application, I'm enabling/disabling menu items based on context - and if a text area has focus, I disable accelerators that would conflict with the navigation keys (e.g. Ctrl-Left/Right).

According to Microsoft's documentation:

If an accelerator has the same identifier as a menu item and the menu item is grayed or disabled, the accelerator is disabled and does not generate a WM_COMMAND or WM_SYSCOMMAND message.

However, if the associated menu accelerator is still in the accelerator table, then TranslateAccelerator still returns true, despite not dispatching any message (thus "eating" the keyboard event).

I'm wondering if there's a way to determine if TranslateAccelerator actually dispatched a message? I'm trying to avoid rebuilding the accelerator table each time a menu item is enabled or disabled.

来源:https://stackoverflow.com/questions/15192551/translateaccelerator-and-disabled-menu-items

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