Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CRichEditCtrl

Status
Not open for further replies.

esdee

Programmer
Apr 12, 2001
143
US
hi
i have a CRichEditCtrl in my app and it can't open UNICODE files properly (opens ANSI files ok). what do i have to do ?
here's part of my code:
CRichEditCtrl * richedit = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT1);
CFile file(filename, CFile::modeRead);

EDITSTREAM es;

es.dwCookie = (DWORD) &file;
es.pfnCallback = MyStreamInCallback;
richedit->StreamIn(SF_TEXT, es);

richedit->SetReadOnly();


the callback is straight from msdn i think ..
static DWORD CALLBACK
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;

*pcb = pFile->Read(pbBuff, cb);

return 0;
}
 
Could be a number of things.

1) Are you running Windows 95/98/ME? Those OSes don't support unicode at all.

2) By "unicode" do you mean UTF-8? If so, you will have to decode the UTF-8 before passing it into the rich edit.

3) MFC's Rich Edit control means Version 1 of the control, whose WNDCLASS is called "RichEdit". The newer version 2 has a WNDCLASS called "RichEdit20A" or "RichEdit20W" (for ANSI or Unicode, respectively). If you want a newer richedit, you can't use the convenient MFC classes, but the "RichEdit20W" might provide proper support for Unicode data.

4) Richedit has always been buggy.

Cheers!

[sub]I REALLY hope that helps.[/sub]
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top