关于RichEdit控件怎么设置字体颜色
展开全部
以下代码,仅供参考:
CString CharFormat;
CharFormat=ini->GetValue ("main","cf");
if(CharFormat.GetLength ()==0)
CharFormat.Format ("%s","cf=134|2|60|0|3221225456|3758096399|隶书|250|0");//我把cf的所有数据保存在ini里,运行的时候获取,然后在下面分配
//所以,你只要设对cf的值,就可以了。
//MessageBox(CharFormat);
char *stopstring;
cf.bCharSet= (BYTE)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.bPitchAndFamily= (BYTE)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.cbSize= (BYTE)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.crTextColor= (COLORREF)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.dwEffects= strtoul(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer (),&stopstring,10);
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.dwMask= strtoul(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer (),&stopstring,10);
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
sprintf(cf.szFaceName,"%s", CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.yHeight=atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.yOffset = atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
m_text.SetSel (0,-1);
m_text.SetSelectionCharFormat (cf);
CString CharFormat;
CharFormat=ini->GetValue ("main","cf");
if(CharFormat.GetLength ()==0)
CharFormat.Format ("%s","cf=134|2|60|0|3221225456|3758096399|隶书|250|0");//我把cf的所有数据保存在ini里,运行的时候获取,然后在下面分配
//所以,你只要设对cf的值,就可以了。
//MessageBox(CharFormat);
char *stopstring;
cf.bCharSet= (BYTE)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.bPitchAndFamily= (BYTE)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.cbSize= (BYTE)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.crTextColor= (COLORREF)atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.dwEffects= strtoul(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer (),&stopstring,10);
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.dwMask= strtoul(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer (),&stopstring,10);
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
sprintf(cf.szFaceName,"%s", CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.yHeight=atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
cf.yOffset = atoi(CharFormat.Left (CharFormat.Find ('|',0)).GetBuffer ());
CharFormat.Format ("%s",CharFormat.Mid (CharFormat.Find ('|',0)+1,CharFormat.GetLength ()+1));
m_text.SetSel (0,-1);
m_text.SetSelectionCharFormat (cf);
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询