A version of this page is also available for
This message notifies a window that the user clicked the right mouse button (right-clicked) in the window.
WM_CONTEXTMENU WPARAM wParam; LPARAM lParam;
Handle to the window in which the user right-clicked the mouse. This can be a child window of the window receiving the message. For more information about processing this message, see the Remarks section.
The low-order word specifies the horizontal position of the cursor, in screen coordinates, at the time of the mouse click.
The high-order word specifies the vertical position of the cursor, in screen coordinates, at the time of the mouse click.
xPos = GET_X_LPARAM(lParam); yPos = GET_Y_LPARAM(lParam);
If a window does not display a shortcut menu it should pass this message to the DefWindowProc function. For child windows, DefWindowProc sends the message to the parent. Otherwise, DefWindowProc displays a default shortcut menu if the specified position is in the window's caption.
DefWindowProc generates the WM_CONTEXTMENU message when it processes the WM_RBUTTONUP message or when the user presses and releases the VK_APPS key.
If the context menu is generated from the keyboard, then the x- and y-coordinates are –1 and the application should display the context menu at the location of the current selection rather than at (
|Windows Embedded CE||Windows CE .NET 4.2 and later|
|Windows Mobile||Windows Mobile Version 5.0 and later|