为什么我的CRichEditCtrl控件得到的是乱码?
hhb 2001-08-05 11:35:29 当我调用CRichEditCtrl控件m_richedit的以下代码时,得到的汉字是乱码,
CString strTemp = msg;
CHARFORMAT m_charformat;
int i=colint;//colint已知。
m_charformat.cbSize=sizeof(CHARFORMAT);
m_charformat.dwMask=CFM_COLOR|CFM_ITALIC|CFM_CHARSET;
m_charformat.dwEffects=CFE_ITALIC;
switch(i)
{
case 1:
m_charformat.crTextColor=RGB(255,0,0);
break;
case 2:
m_charformat.crTextColor=RGB(255,255,0);
break;
case 3:
m_charformat.crTextColor=RGB(0,255,0);
break;
case 4:
m_charformat.crTextColor=RGB(0,0,0);
break;
case 5:
m_charformat.crTextColor=RGB(0,255,255);
break;
case 0:
m_charformat.crTextColor=RGB(0,0,0);
}
CHARRANGE cr;
cr.cpMax=0;
cr.cpMin=0;
m_rich.SetSel(0,0);
strTemp += _T("\r\n");
m_rich.SetSelectionCharFormat(m_charformat);
m_rich.ReplaceSel(strTemp)//得到的汉字是乱码!
我的m_rich.create()调用如下:
m_rich.Create(ES_WANTRETURN|ES_AUTOVSCROLL|ES_MULTILINE|WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_HSCROLL,rect,this,1);
不知道是为什么?