富文本框,,可以对颜色和字体进行设置的文本框
颜色设置
void CRichEditDemoDlg::OnBnClickedBtnColor() { // TODO: 在此添加控件通知处理程序代码 CHARFORMAT cf = { 0 }; cf.cbSize = sizeof(CHARFORMAT); m_edit.GetSelectionCharFormat(cf); CColorDialog color_dialog(cf.crTextColor); if (color_dialog.DoModal() == IDOK) { cf.crTextColor = color_dialog.GetColor(); cf.dwMask = CFM_COLOR; cf.dwEffects = 0; m_edit.SetSelectionCharFormat(cf); } }字体设置
void CRichEditDemoDlg::OnBnClickedBtnFont() { // TODO: 在此添加控件通知处理程序代码 CHARFORMAT cf = { 0 }; cf.cbSize = sizeof(CHARFORMAT); m_edit.GetSelectionCharFormat(cf); CFontDialog font_dialog(cf); if(font_dialog.DoModal() == IDOK) { font_dialog.GetCharFormat(cf); m_edit.SetSelectionCharFormat(cf); } }