以下代码:
m_ctrlRichEdit和m_ctrTestInfo都是同一个控件,为什么不能实现将hello变为红色(其他文本颜色不变)的效果?
CHARFORMAT cf;
memset(&cf, 0, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
m_ctrlRichEdit.GetSelectionCharFormat(cf);
cf.dwMask = CFM_COLOR;
cf.crTextColor = RGB(255, 0, 255); //文字颜色
if(cf.dwEffects & CFE_AUTOCOLOR)
cf.dwEffects -= CFE_AUTOCOLOR;
m_strTestInfo="hello ,this is me";
m_ctrlRichEdit.SetSel(1, 5); //设置处理区域
m_ctrlRichEdit.SetSelectionCharFormat(cf);
m_ctrlRichEdit和m_ctrTestInfo都是同一个控件,为什么不能实现将hello变为红色(其他文本颜色不变)的效果?
CHARFORMAT cf;
memset(&cf, 0, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
m_ctrlRichEdit.GetSelectionCharFormat(cf);
cf.dwMask = CFM_COLOR;
cf.crTextColor = RGB(255, 0, 255); //文字颜色
if(cf.dwEffects & CFE_AUTOCOLOR)
cf.dwEffects -= CFE_AUTOCOLOR;
m_strTestInfo="hello ,this is me";
m_ctrlRichEdit.SetSel(1, 5); //设置处理区域
m_ctrlRichEdit.SetSelectionCharFormat(cf);
SetSel(nStart, nEnd);//要改变的字符
m_ctrlRichEdit.GetSelectionCharFormat(cf);//选择
cf.crTextColor = RGB(0, 0, 0);
cf.dwEffects = CFE_AUTOBACKCOLOR;
m_ctrlRichEdit.SetSelectionCharFormat(cf);//设置颜色
SetSel(nStart, nEnd);//要改变的字符
m_ctrlRichEdit.GetSelectionCharFormat(cf);//选择
cf.crTextColor = RGB(0, 0, 0);
cf.dwEffects = CFE_AUTOBACKCOLOR;
m_ctrlRichEdit.SetSelectionCharFormat(cf);//设置颜色
用了你的代码跟我的代码结果是一样的。