在CEdit上右键能弹出系统菜单,如撤消,粘贴等,请问在CRichEditCtrl中如何才能弹出系统菜单

解决方案 »

  1.   

    在其父窗体上处理OnNotify函数即可
    BOOL CFormViewRecordEditor::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
    {
    // TODO: Add your specialized code here and/or call the base class
    MSGFILTER * lpMsgFilter = (MSGFILTER *)lParam;  if ((wParam == IDC_RICHEDIT_FULLTEXT) && (lpMsgFilter->nmhdr.code == EN_MSGFILTER)   
    && (lpMsgFilter->msg == WM_RBUTTONDOWN))                                       
      
    {
    //if we get through here, we have trapped the right click event of the richeditctrl! 
    CPoint point;                                         
       ::GetCursorPos(&point); //where is the mouse?
      CMenu menu; //lets display out context menu :) 
      UINT dwSelectionMade;                                       
    VERIFY(menu.LoadMenu(IDR_MENU_FULLTEXT) );  
       CMenu *pmenuPopup = menu.GetSubMenu(0);
       ASSERT(pmenuPopup != NULL);
       dwSelectionMade = pmenuPopup->TrackPopupMenu( (TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD),
       point.x, point.y, this
             );                                
      
      pmenuPopup->DestroyMenu(); 
    PostMessage(dwSelectionMade,0,0);
      }
    // m_ctlRichEditFullText.SendMessage(lpMsgFilter->msg, wParam, lParam);

    return CFormView::OnNotify(wParam, lParam, pResult);
    }