//将选中文本变成蓝色
CHARFORMAT cfm;
cfm.dwEffects   = ~CFE_AUTOCOLOR;
cfm.dwMask      = CFM_COLOR; 
cfm.crTextColor = RGB(0, 0, 255);// 改变颜色
m_edit.SetSelectionCharFormat(cfm);按理说如果变成默认的话GetDefaultCharFormat()应该好使但是我没成功
还有一个方法就是去掉dwEffects和dwEffects的效果,也没成功~~
谁来看看啊!

解决方案 »

  1.   

    GetDefaultCharFormat()是得到默认色吧 ?
      

  2.   

    CRichEditCtrl里面你设置了选中文本颜色后好像就把当前这段文本的默认值改了。我以前做法是在改变之前取出默认值。要恢复的时候引用就可以了。
      

  3.   

    我用api是这样写的
    CHARFORMAT cf2;ZeroMemory( &cf2, sizeof( CHARFORMAT ));
    cf2.cbSize = sizeof( CHARFORMAT );
    cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
    cf2.dwEffects = CFE_AUTOCOLOR ;
    SendMessage( hrichedit, EM_GETCHARFORMAT, 0,( LPARAM)&cf2 );
    cf2.crTextColor  = RGB(255,0,0 );
    cf2.dwEffects -= CFE_AUTOCOLOR;
    SendMessage( hrichedit, EM_SETCHARFORMAT, SCF_ALL,(LPARAM)&cf2 );
      

  4.   

    yes,it has changed the default color,so i think you should record the former color in OldCor(using  GetDefaultCharFormat()),then change the color,if you want to change to the former color later,then cfm.crTextColor = OldCor;