用这个怎么会清掉前面的字符?
例如 我这么写 SelSel(0,-1);
然后输入的say 中的sa就会被y清掉。
就是说只剩下y了。msdn里面我没看到SetSel有清字符的功能呀?

解决方案 »

  1.   

    我是先检测关键字是不是say 然后再运行的SelSel for(int i=0;i<INDEX_SENTINEL;i++){
    if(g_KeyWords[i]==m_EnterString){
    CHARFORMAT cf;
    cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD;
    cf.crTextColor=RGB(0,0,255);
    cf.dwEffects &= ~CFE_AUTOCOLOR;
    int start=GetTextLength()-m_EnterString.GetLength()+1;
    int end=GetTextLength();
    this->GetRichEditCtrl().SetSelectionCharFormat(cf);
    this->GetRichEditCtrl().ReplaceSel(m_EnterString);
    }
    }
      

  2.   

    To select all the text in this CRichEditCtrl object, call SetSel with a start index of 0 and an end index of  – 1.
      

  3.   

    SetSel(0,-1),是全部选择。要加到原来的字符后可以这样。int len = GetTextLength();
    SetSel(len,len);ReplaceSel(str);
      

  4.   

    我发现了,是因为当响应OnChar的时候,视图并没有更新。也就是说得到的KeyWord虽然是"say",但是视图上实际是"sa",这应该如何处理?UpdateData没用试过了。我不想当键入下一个字符的时候,才改变颜色
      

  5.   

    明白了,原来应该先响应继承的OnChar,结贴!