programming:windows:WM_COMMANDWhat links here?
The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.

Syntax
    WM_COMMAND
        WPARAM wParam
        LPARAM lParam;


Return Value
If an application processes this message, it should return zero.

Remarks
Use of the wParam and lParam parameters are summarized here.

Message SourcewParam
(high word)
wParam
(low word)
lParam
Menu 0 Menu identifier (IDM_*)0
Accelerator 1 Accelerator identifier (IDM_*)0
Control Control-defined notification code Control identifier Handle to the control window


Menus
If an application enables a menu separator, the system sends a WM_COMMAND message with the low-word of the wParam parameter set to zero when the user selects the separator.

Windows 98/Me, Windows 2000/XP: If a menu is defined with a MENUINFO.dwStyle value of [MNS_NOTIFYBYPOS], [WM_MENUCOMMAND] is sent instead of WM_COMMAND.

Accelerators
Accelerator keystrokes that select items from the window menu are translated into WM_SYSCOMMAND messages.

If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, no WM_COMMAND message is sent. However, if an accelerator keystroke occurs that does not match any of the items in the window's menu or in the window menu, a WM_COMMAND message is sent, even if the window is minimized.

Notification Requirements


Prototype for Message Handler
//////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK on_command(HWND hwnd, int id, HWND hwnd_cntl, UINT notify_code)
{
    if (notify_code == 0) { // its from the menu
    }
    else if (notify_code == 1) { // its from an accelerator
    }
    else { // its from a control
    }
    return 0;
}


programming:windows:WM_COMMAND
filename:programming:windows:WM_COMMAND
filename:programming%3Awindows%3AWM_COMMAND
last edit:March 27 2010 17:24:28 (5153 days ago)
ct = 1714946626.000000 = May 05 2024 18:03:46
ft = 1269725068.000000 = March 27 2010 17:24:28
dt = 445221558.000000