问题
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