Click to Rate and Give Feedback
MSDN
MSDN Library
User Interface
Resources
Menus
Menu Reference
Notifications
 WM_CONTEXTMENU Notification
WM_CONTEXTMENU Notification

The WM_CONTEXTMENU message notifies a window that the user clicked the right mouse button (right-clicked) in the window.

Syntax

WM_CONTEXTMENU

    WPARAM wParam
    LPARAM lParam;

Parameters

wParam
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.
lParam
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.

Return Value

No return value.

Remarks

A window can process this message by displaying a shortcut menu using the TrackPopupMenu or TrackPopupMenuEx functions. To obtain the horizontal and vertical positions, use the following code.

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. If a window is a child window, 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 or WM_NCRBUTTONUP message or when the user types SHIFT+F10. The WM_CONTEXTMENU message is also generated when the user presses and releases the VK_APPS key.

If the context menu is generated from the keyboard—for example, if the user types SHIFT+F10—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 (xPos, yPos).

Notification Requirements

Minimum DLL Version None
HeaderDeclared in Winuser.h, include Windows.h
Minimum operating systems Windows 95, Windows NT 3.51

See Also

Menus Overview, DefWindowProc, GET_X_LPARAM, GET_Y_LPARAM, TrackPopupMenu, TrackPopupMenuEx, WM_NCRBUTTONUP, WM_RBUTTONUP
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Value      Đonny   |   Edit   |  
WM_CONTEXTMENU = &H7B
Flag as ContentBug
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker