Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Collapse the table of content
Expand the table of content


Called by the framework when the user has clicked the right mouse button (right clicked) in the window.

afx_msg void OnContextMenu(
   CWnd* pWnd,
   CPoint pos 


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.
Position of the cursor, in screen coordinates, at the time of the mouse click.


You can process this message by displaying a context menu using the TrackPopupMenu.

If you do not display a context menu you should pass this message onto the DefWindowProc function. If your window is a child window, DefWindowProc sends the message to the parent. Otherwise, DefWindowProc displays a default context menu if the specified position is in the window's caption.

See Also

CWnd Overview | Class Members | Hierarchy Chart

© 2015 Microsoft