SetSelectionCharFormat不能替换字体

SetSelectionCharFormat老是替换字体不成功,但是颜色可以更改,原来代码是

	CHARFORMAT cf;
	cf.cbSize = sizeof(CHARFORMAT);
	cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD | CFM_SIZE;
	cf.dwEffects = (unsigned long)~(CFE_AUTOCOLOR | CFE_UNDERLINE | CFE_BOLD);
	cf.crTextColor = RGB(0, 128, 0);
	cf.yHeight = 12*15;
	strcpy(cf.szFaceName, _T("宋体"));

	int iTotalTextLength = m_richMsg.GetWindowTextLength();
	m_richMsg.SetSel(iTotalTextLength, iTotalTextLength);
	BOOL bs = m_richMsg.SetSelectionCharFormat(cf);
	m_richMsg.ReplaceSel(csStartTime);

百度,回头一看 dwMask少字体,改成

cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD | CFM_SIZE | CFM_FACE;

居然好了。。。

参考:http://topic.csdn.net/u/20100101/00/6d1f0556-2c28-4a7e-bbaa-884a0c397ef9.html?81078

你可能感兴趣的:(c,百度,2010)