您的位置:首页 > 其它

richedit添加两段颜色不同的文字

2015-11-11 16:50 260 查看
void CWndDetail::AppendText(const CFString& strTime, const CFString& strContent)
{
CHARFORMAT2 cf;
::ZeroMemory(&cf, sizeof(CHARFORMAT2));
cf.cbSize = sizeof(CHARFORMAT2);
cf.crTextColor = RGB(0xff,0,0);
cf.dwMask = CFM_COLOR;

CHARFORMAT2 cf1;
::ZeroMemory(&cf1, sizeof(CHARFORMAT2));
cf1.cbSize = sizeof(CHARFORMAT2);
cf1.crTextColor = RGB(0,0,0);
cf1.dwMask = CFM_COLOR;

m_editHistory->AppendText("[ " + strTime + " ]");
int nLineCount = m_editHistory->GetLineCount();
m_editHistory->SetSel(m_editHistory->LineIndex(nLineCount - 1), -1);
m_editHistory->SetSelectionCharFormat(cf);

m_editHistory->AppendText("\n" + strContent + "\n\n");
m_editHistory->SetSel(m_editHistory->LineIndex(nLineCount), -1);
m_editHistory->SetSelectionCharFormat(cf1);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: