15,979
社区成员
发帖
与我相关
我的任务
分享
CHARFORMAT cf;
memset(&cf, 0, sizeof(CHARFORMAT));
BOOL bSelect = (GetSelectionType() != SEL_EMPTY) ? TRUE : FALSE;
GetSelectionCharFormat(cf);
COLORREF clrinit = cf.crTextColor;
CColorDialog dlg(clrinit);
if (dlg.DoModal() == IDOK)
{
BOOL bIsColorValid = cf.dwMask & CFM_COLOR;
if (!bIsColorValid)
{
cf.dwMask |= CFM_COLOR;
}
cf.crTextColor = dlg.GetColor();
if (bSelect)
SetSelectionCharFormat(cf); //为选定的内容设定所选字体
else
SetWordCharFormat(cf); //为将要输入的内容设定字体
}