请教:
我在Richedit中按下tab键时会全选控件中的文本,而不是输入'\t',
应该如何设置多多帮忙!

解决方案 »

  1.   

    if(nChar == 0x09)
    {
    CString str="\t";
    CHARRANGE crPos;
    GetSel(crPos);
    if (crPos.cpMin != crPos.cpMax)
    {
    SetSel(crPos.cpMin, crPos.cpMax);
    }
    else
    {
    SetSel(crPos.cpMax, crPos.cpMax);
    } ReplaceSel(str);
    return;
    }
    代码加入到onkeydown()消息中.
      

  2.   

    重载PreTranslateMessage(MSG* pMsg) 
    BOOL CTestDlg::PreTranslateMessage(MSG* pMsg) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(pMsg->message==WM_KEYDOWN && pMsg->wParam == VK_TAB)
    {
    if(m_rich.GetSafeHwnd()==GetFocus()->GetSafeHwnd())
    {
    m_rich.ReplaceSel("\t");
    return TRUE;
    }
    }
    return CDialog::PreTranslateMessage(pMsg);
    }