We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


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.

Header: afxwin.h