Override CWnd::OnContextMenu by adding a WM_CONTEXTMENU handler to your CEdit derived class. From within this handler, you must load your own popup menu, call TrackPopupMenu and call the menu functions according to the returned ID.
Example:
void CMyEdit::OnContextMenu(CWnd* , CPoint point)
{
CMenu menu;
VERIFY(menu.LoadMenu(IDR_MYEDIT_POPUP_MENU));
CMenu *pSub = menu.GetSubMenu(0);
if (GetFocus() != this)
SetFocus();
if (point.x < 0 && point.y < 0)
{
CRect rect;
GetWindowRect(rect);
point.x = rect.left;
point.y = rect.bottom;
}
int nCommand = pSub->TrackPopupMenuEx(
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_VERPOSANIMATION | TPM_RETURNCMD | TPM_NONOTIFY,
point.x, point.y,
AfxGetMainWnd(), NULL);
switch (nCommand)
{
case ID_EDIT_COPY : OnCopy(); break;
case ID_EDIT_CUT : OnCut(); break;
}
}