RichEdit中如何设置指定字符串的颜色? SetSelectionCharFormat要求你先有选择区域,有么? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 SetSelectionCharFormat要求你先有选择区域Google "COleRichEdit" codeproject 会有满意的答案 pedit->SetSel( 1000000, 1000000 ); g____cf.crTextColor = RGB( t->r, t->g, t->b ); pedit->SetSelectionCharFormat( g____cf ); pedit->ReplaceSel( text + sizeof( COLORTEXT ) );第一句就是设置选区,俺是用这个常量选到后面,一般时候这个值都是最后了。 怎么可以选到最后呢,我是要设置指定字符串的颜色呀,我现在改了,还是不行我现在的代码是 CHARFORMAT cf; ZeroMemory(&cf, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE; cf.dwEffects = 0; cf.crTextColor = RGB(255,0,0); strcpy(cf.szFaceName ,_T("隶书"));//设置字体 int n = sStr.GetLength(); m_cSegResult.SetSel(1, n); //设置处理区域 m_cSegResult.SetSelectionCharFormat(cf); // sStr += _T(" "); m_cSegResult.ReplaceSel( sStr );各位看看,还要怎么办,谢谢了 俺的程序中,在程序走动时先 memset( &g____cf, 0, sizeof( g____cf ) ); g____cf.cbSize = sizeof( g____cf ); g____cf.dwMask = CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_SPACING | CFM_COLOR | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE; g____cf.yHeight = 210; g____cf.bCharSet = GB2312_CHARSET; g____cf.bPitchAndFamily = 0; strcpy( g____cf.szFaceName, "宋体" );然后在用的时候 pedit->SetSel( 1000000, 1000000 ); while( size > 0 ) { t = ( COLORTEXT * )text; g____cf.crTextColor = RGB( t->r, t->g, t->b ); pedit->SetSelectionCharFormat( g____cf ); pedit->ReplaceSel( text + sizeof( COLORTEXT ) ); text += t->len; size -= t->len; }选到哪里,由你决定。 void C***Dlg::OnButton1() { // TODO: Add your control notification handler code here CHARFORMAT cf; DWORD dwMask = m_richedit.GetSelectionCharFormat (cf); cf.dwMask = CFM_COLOR; m_richedit.SetSel(0,10); cf.crTextColor = RGB(125,12,12); m_richedit.SetSelectionCharFormat(cf); } 变量就一个CHARFORMAT g____cf; 直接调用按钮响应函数出错了,请教! 40分悬赏WM_SetFocus 例子给了马上给分 通过类向导派生类后,若直接更改它所继承的基类名编译报错 难道设备坐标也就是所谓的客户区坐标 !!!关于ADO的_RecordsetPtr对象的三个问题!!! 求视频聊天室源代码。 ado的open 问题 istream_iterator<int> input(cin)怎么结束输入? 关于在internet上两台机器(拨号上网)之间互传文件的问题! 有人研究过金山卫士公布的源码吗? 时间控件 使用dll以及dll嵌套调用,原则上影响应用程序总体运行速度吗?
Google "COleRichEdit" codeproject 会有满意的答案
g____cf.crTextColor = RGB( t->r, t->g, t->b );
pedit->SetSelectionCharFormat( g____cf );
pedit->ReplaceSel( text + sizeof( COLORTEXT ) );第一句就是设置选区,俺是用这个常量选到后面,一般时候这个值都是最后了。
我现在的代码是
CHARFORMAT cf;
ZeroMemory(&cf, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE |
CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE; cf.dwEffects = 0;
cf.crTextColor = RGB(255,0,0);
strcpy(cf.szFaceName ,_T("隶书"));//设置字体
int n = sStr.GetLength();
m_cSegResult.SetSel(1, n); //设置处理区域 m_cSegResult.SetSelectionCharFormat(cf);
// sStr += _T(" ");
m_cSegResult.ReplaceSel( sStr );
各位看看,还要怎么办,谢谢了
memset( &g____cf, 0, sizeof( g____cf ) );
g____cf.cbSize = sizeof( g____cf );
g____cf.dwMask = CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_SPACING | CFM_COLOR | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
g____cf.yHeight = 210;
g____cf.bCharSet = GB2312_CHARSET;
g____cf.bPitchAndFamily = 0;
strcpy( g____cf.szFaceName, "宋体" );然后在用的时候
pedit->SetSel( 1000000, 1000000 );
while( size > 0 )
{
t = ( COLORTEXT * )text;
g____cf.crTextColor = RGB( t->r, t->g, t->b );
pedit->SetSelectionCharFormat( g____cf );
pedit->ReplaceSel( text + sizeof( COLORTEXT ) );
text += t->len;
size -= t->len;
}选到哪里,由你决定。
{
// TODO: Add your control notification handler code here
CHARFORMAT cf;
DWORD dwMask = m_richedit.GetSelectionCharFormat (cf);
cf.dwMask = CFM_COLOR;
m_richedit.SetSel(0,10);
cf.crTextColor = RGB(125,12,12);
m_richedit.SetSelectionCharFormat(cf);
}