title: Create Context-Sensitive Menus in MFC
body: <p>I found this tutorial <a href="http://msdn.microsoft.com/en-us/vstudio/Cc514027" rel="nofollow">http://msdn.microsoft.com/en-us/vstudio/Cc514027</a> to help me create a menu.</p>
  
  <p>I followed the tutorial step by step. I have the two red boxes, but I am unable to right click on the two boxes to have the menu show. </p>
  
  <p>When I debug I end up with error code C2084: function 'void CContextMenusView::OnContextMenu(CWnd*, CPoint)' already has a body. </p>
  
  <pre><code>  // CContextMenusView message handlers
     void CContextMenusView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
  </code></pre>
  
  <p>{
      //TODO: Add your message handler code here </p>
  
  <pre><code>CMenu PopupMenu;
  CPoint ptClient;
  m_nBox = -1;
  
  ptClient = point;
  ScreenToClient(&amp;ptClient);
  
  if (rect1.PtInRect(ptClient))
      m_nBox = 0;
  else if (rect2.PtInRect(ptClient))
      m_nBox = 1;
  
  if (m_nBox != -1)
  {
      if (PopupMenu.LoadMenu(IDR_CONTEXTMENU))
      {
          CMenu* pPopupMenu = PopupMenu.GetSubMenu(0);
          if (point.x == -1 &amp;&amp; point.y == -1)
          {
              point.x = 5;
              point.y = 5;
              ClientToScreen(&amp;point);
          }
          pPopupMenu-&gt;TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
              point.x, point.y, this);
      }
  }
  </code></pre>
  
  <p>}</p>