mfc 仿qq聊天框显示不同颜色字体,怎么实现
1个回答
展开全部
用richedit可实现。
CString strMessage = "Chat Message here."
//获取显示区域空白处,以免他之前选择的格式覆盖之后要显示的字体和颜色
GetDlgItem(IDC_RICHEDIT)->SetSel(-1, -1);
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
cfm.crTextColor = clr;
cfm.dwEffects = CFE_BOLD;
cfm.dwMask = bBold ? (CFM_BOLD | CFM_COLOR) : CFM_COLOR;
GetDlgItem(IDC_RICHEDIT)->.SetSelectionCharFormat(cfm);
//添加字符串并设置格式
GetDlgItem(IDC_RICHEDIT)->.SetSel(-1, -1);
GetDlgItem(IDC_RICHEDIT)->.ReplaceSel(strMessage);
CString strMessage = "Chat Message here."
//获取显示区域空白处,以免他之前选择的格式覆盖之后要显示的字体和颜色
GetDlgItem(IDC_RICHEDIT)->SetSel(-1, -1);
CHARFORMAT2 cfm;
cfm.cbSize = sizeof(cfm);
cfm.crTextColor = clr;
cfm.dwEffects = CFE_BOLD;
cfm.dwMask = bBold ? (CFM_BOLD | CFM_COLOR) : CFM_COLOR;
GetDlgItem(IDC_RICHEDIT)->.SetSelectionCharFormat(cfm);
//添加字符串并设置格式
GetDlgItem(IDC_RICHEDIT)->.SetSel(-1, -1);
GetDlgItem(IDC_RICHEDIT)->.ReplaceSel(strMessage);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询