Add popup menu for right click

It is said that popup menu is one of the great creatures by Microsoft. And it is easy to add the popup menu in your MFC application. In fact, there are only 2 steps you need to do:
1. Create the menu resource for the popup menu, like this:
  MENUITEM "Poisson Image Editing",       ID_DSTVIEW_POISSON
  MENUITEM "Drag and Drop Pasting",       ID_DSTVIEW_DDPASTING
2. Overwrite the message handler for WM_CONTEXMENU, then it is done.
void CDstView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
      CMenu   popupmenu;  
      CMenu*   popup=popupmenu.GetSubMenu(0);  

2 thoughts on “Add popup menu for right click

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s