我在CRichEdit控件中点击右键时生成了一个菜单,里面有复制和全选,但接下来却实不了不这两个操作,高手们指点下

解决方案 »

  1.   

    调用CRichEditCtrl的函数即可:CRichEditCtrl::Copy,CRichEditCtrl::SetSel(-1, 0)
      

  2.   

    但用CRichEditCtrl::SetSel(-1, 0)这个后,控件中的文本不会有蓝底显示,看不出来是被全选了,
    还有就是,当我选中后,按右键时,选中的文本也就没蓝底,这些问题要怎么解决呢
      

  3.   


    #if !defined(AFX_MYRICHEDIT_H__FCCA69DA_B946_41E2_9D28_FDF410CADD1B__INCLUDED_)
    #define AFX_MYRICHEDIT_H__FCCA69DA_B946_41E2_9D28_FDF410CADD1B__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // MyRichEdit.h : header file
    ///////////////////////////////////////////////////////////////////////////////
    // CMyRichEdit windowclass CMyRichEdit : public CRichEditCtrl
    {
    // Construction
    public:
    CMyRichEdit();// Attributes
    public:// Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CMyRichEdit)
    //}}AFX_VIRTUAL// Implementation
    public:
    virtual ~CMyRichEdit(); // Generated message map functions
    protected:
    //{{AFX_MSG(CMyRichEdit)
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnCopy() { Copy(); }
    afx_msg void OnCut() { Cut(); }
    afx_msg void OnPaste() { Paste(); }
    afx_msg void OnSelectall() { SetSel(0, -1); }
    // afx_msg void OnUndo() { Undo(); }
    afx_msg void OnClear() { Clear(); }
    afx_msg void OnSelectfont();
    //}}AFX_MSG DECLARE_MESSAGE_MAP()
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYRICHEDIT_H__FCCA69DA_B946_41E2_9D28_FDF410CADD1B__INCLUDED_)#if !defined(AFX_MYRICHEDIT_H__FCCA69DA_B946_41E2_9D28_FDF410CADD1B__INCLUDED_)
    #define AFX_MYRICHEDIT_H__FCCA69DA_B946_41E2_9D28_FDF410CADD1B__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    // MyRichEdit.h : header file
    ///////////////////////////////////////////////////////////////////////////////
    // CMyRichEdit windowclass CMyRichEdit : public CRichEditCtrl
    {
    // Construction
    public:
    CMyRichEdit();// Attributes
    public:// Operations
    public:// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CMyRichEdit)
    //}}AFX_VIRTUAL// Implementation
    public:
    virtual ~CMyRichEdit(); // Generated message map functions
    protected:
    //{{AFX_MSG(CMyRichEdit)
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnCopy() { Copy(); }
    afx_msg void OnCut() { Cut(); }
    afx_msg void OnPaste() { Paste(); }
    afx_msg void OnSelectall() { SetSel(0, -1); }
    // afx_msg void OnUndo() { Undo(); }
    afx_msg void OnClear() { Clear(); }
    afx_msg void OnSelectfont();
    //}}AFX_MSG DECLARE_MESSAGE_MAP()
    };///////////////////////////////////////////////////////////////////////////////{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_MYRICHEDIT_H__FCCA69DA_B946_41E2_9D28_FDF410CADD1B__INCLUDED_)
      

  4.   

    TrackPopupMenu函数里判断菜单项,然后
    SendMessage(hwnd, WM_COMMAND, IDM_SELECTALL, NULL);
    SendMessage(hwnd, WM_COMMAND, IDM_COPY, NULL);
      

  5.   

    错了一点:
    由TrackPopupMenu得到菜单项,发送消息,使用系统消息处理
    全选粘贴系统有完善的操作
      

  6.   

    IDM_SELECTALL 未声明的标识符..
      

  7.   

    我在用CRichEdit的时候遇到过此类问题,可能跟盗版软件有关,用CEdit就行了
      

  8.   

    不好意思,记错了,IDM是web里的,试试wm_copy吧