问题描述:

I found this tutorial http://msdn.microsoft.com/en-us/vstudio/Cc514027 to help me create a menu.

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.

When I debug I end up with error code C2084: function 'void CContextMenusView::OnContextMenu(CWnd*, CPoint)' already has a body.

 // CContextMenusView message handlers

void CContextMenusView::OnContextMenu(CWnd* /*pWnd*/, CPoint point)

{

//TODO: Add your message handler code here

CMenu PopupMenu;

CPoint ptClient;

m_nBox = -1;

ptClient = point;

ScreenToClient(&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 && point.y == -1)

{

point.x = 5;

point.y = 5;

ClientToScreen(&point);

}

pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,

point.x, point.y, this);

}

}

}

相关阅读:
Top