如何改变CRichEdit字体颜色 vc
//该应用程序可以直接使用
m_richEdit 是CRichEdit控件变量
void ModifyRichTextColor()
{
CHARFORMAT cf;
memset(&cf,0,sizeof(CHARFORMAT));
this->m_richEdit.SetWindowText("弹道弹道弹道弹道弹道弹道导弹对弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道弹道导弹浮动幅度冻豆腐对幅度浮动幅度奋斗奋斗奋斗奋斗发地方地方非凡非凡非凡非凡非凡非凡非凡方法小阳等级发动机防空洞几分恐惧地方 地方地方地方的奋斗奋斗奋斗奋斗发地方地方地方的发 ");
m_richEdit.SendMessage(WM_VSCROLL,SB_BOTTOM,0);
this->m_richEdit.GetDefaultCharFormat(cf);
cf.dwMask=CFM_COLOR;
cf.dwEffects &=~CFE_AUTOCOLOR; // 这个最重要,设选中文字颜色的时候也要注意,dwEffects一定不能有CEF_AUTOCOLOR的属性
cf.crTextColor=RGB(255,0,0);
this->m_richEdit.SetDefaultCharFormat(cf);
CHARFORMAT cf1;
this->m_richEdit.GetDefaultCharFormat(cf1);
cf1.dwMask=CFM_COLOR|CFM_OFFSET|CFM_SIZE|CFM_FACE;
cf1.dwEffects =CFE_BOLD|CFE_ITALIC;
cf1.crTextColor = RGB(0,255,0);//设置颜色
cf1.yHeight =200;//设置高度
strcpy(cf.szFaceName ,_T("隶书"));//设置字体
m_richEdit.SetSel(10,50);
m_richEdit.SetSelectionCharFormat(cf1);
m_richEdit.SetSel(120,200);
m_richEdit.SetSelectionCharFormat(cf1);
}