duilib的RichEdit控件的文本背景色设置,参考下面代码
CRichEditUI* pRichEdit = static_cast<CRichEditUI*>(FindControl("description"));
if (pRichEdit == NULL) return false;
long lSelBegin = 0, lSelEnd = 0;
CHARFORMAT2 cf;
ZeroMemory(&cf, sizeof(CHARFORMAT2));
cf.cbSize = sizeof(cf);
cf.dwReserved = 0;
cf.dwMask = CFM_COLOR | CFM_LINK | CFM_UNDERLINE | CFM_UNDERLINETYPE | CFM_BACKCOLOR| EM_SETBKGNDCOLOR;
cf.dwEffects = CFE_LINK;
cf.bUnderlineType = CFU_UNDERLINE;
cf.crTextColor = RGB(220, 50, 0);
cf.crBackColor = RGB(120, 130, 230);
lSelEnd = pRichEdit->GetTextLength();
pRichEdit->SetSel(lSelBegin, lSelEnd);
pRichEdit->SetSelectionCharFormat(cf);
CFM_BACKCOLOR用于设置选中文本的背景色,CFM_COLOR用于设置文本前景色,不过有个问题,如果想设置整一行的背景色,就无法设置了,在codeguru也有个提问,只设置某一行不设置整个控件的背景,但没有得到有效的回答
https://forums.codeguru.com/showthread.php?499674-How-to-set-richedit-ctrl-full-line-s-background-color