I am reviving this OLD thread for one reason:
I had the same problem myself today, and I figured it out.
First of all, my suggestion of doing ClientToScreen or ScreenToClient was wrong. It does not give the right coordinates for some reason.
Basically, you have to do a GetClientRect, and compare it to the mouse coordinates. You get the mouse coordinates already in a form compatible to GetClientRect.
Here is what I did:
void CTestView:: onRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
RECT spacing;
if (popup == NULL)
popup = new CMenu;
else
popup->DestroyMenu();
popup->CreatePopupMenu();
GetClientRect(&spacing);
if (point.x < (abs(spacing.right-spacing.left)/2))
{
ClientToScreen(&point);
p_Doc->contextmenu(popup,1,&point);
}
else
{
ClientToScreen(&point);
p_Doc->contextmenu(popup,2,&point);
}
//CView:: onRButtonUp(nFlags, point);
}
This works beautifully for me.
Edit: Had to insert a space after :: to avoid smiley face