RichEdit

xiaoxiao2021-02-27  366

富文本框,,可以对颜色和字体进行设置的文本框

颜色设置

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); } }
转载请注明原文地址: https://www.6miu.com/read-3614.html

最新回复(0)