When a keyboard accelerator corresponds to a menu item in the system menu, TranslateAccelerator sends the window procedure a WM_SYSCOMMAND message. If you need to, you can differentiate between a direct system menu selection and a keyboard accelerator for that system menu item by the high word of lParam:
wParam | LOWORD (lParam) | HIWORD (lParam) |
Accelerator: | Accelerator ID | 0 | 1 |
Menu: | Menu ID | 0 | 0 |
If the accelerator ID corresponds to a menu item (or does not correspond to any item on the menu or system menu), TranslateAccelerator sends the window procedure a WM_COMMAND message. The following table shows the types of WM_COMMAND messages you can receive for keyboard accelerators, menu commands, and child window controls:
wParam | LOWORD (lParam) | HIWORD (lParam) |
Accelerator: | Accelerator ID | 0 | 1 |
Menu: | Menu ID | 0 | 0 |
Control: | Control ID | Child window handle | Notification code |
If the keyboard accelerator corresponds to a menu item, the window procedure also receives WM_INITMENU, WM_INITMENUPOPUP, and WM_MENUSELECT messages, just as if the menu option had been chosen. Programs usually enable and disable items in a popup menu when processing WM_INITMENUPOPUP, so you still have that facility when using keyboard accelerators. If the keyboard accelerator corresponds to a disabled or grayed menu item, however, TranslateAccelerator does not send the window procedure a WM_COMMAND or WM_SYSCOMMAND message.
If the active window is minimized, TranslateAccelerator sends the window procedure WM_SYSCOMMAND messages—but not WM_COMMAND messages—for keyboard accelerators that correspond to enabled system menu items. TranslateAccelerator also sends that window procedure WM_COMMAND messages for accelerators that do not correspond to any menu items.