怎样在richedit控件中,追加一条新的信息。(在不改变原来字体大小颜色的,基础上再加内容)急用!!!!

解决方案 »

  1.   

    CString sLine="test contents";
    //把光标总是设置到view的末尾处。
    CRichEditCtrl* pRichEditCtrl = &GetRichEditCtrl();
    long nLineIndex = pRichEditCtrl->GetLineCount()-1;
    long nCharStart = pRichEditCtrl->LineIndex(nLineIndex);
    long nLen = GetRichEditCtrl().LineLength(nCharStart);
    long pos = nCharStart + nLen;
    pRichEditCtrl->SetSel(pos,pos);
            //然后追加内容
            pRichEditCtrl->ReplaceSel(sLine);
      

  2.   

    用SetSel函数和ReplaceSel函数配合一下。
    比如:
    SetSel(-1,-1);//不知道行不行。就是相当于将光标移到最后
    ReplaceSel("***");