void CListCtlView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
UINT nFlags;
CPoint curPoint,point; CListCtrl &pListCtrl = GetListCtrl(); GetCursorPos(&curPoint);
point = curPoint;
ScreenToClient(&curPoint);
int pos = pListCtrl.HitTest(curPoint, &nFlags);
pListCtrl.SetItemState(pos,LVIS_SELECTED,-1); if(pListCtrl.GetItemData(pos)!=NULL)
{
if (point.x == -1 && point.y == -1)
{
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
CMenu* pPopup;
menu.LoadMenu(IDR_POPUPMENU);
pPopup = menu.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y,AfxGetMainWnd());
}

*pResult = 0;
}