Hi all,

I got an application witha a RichEditCtrl, but it didn't support unicode texts.

In my class (CMyRtfRichEditCtrl : public CRichEditCtrl), I used to print formatted text like this:

-------------------------------------------------------
// Received text (Cstring), colorref (COLORREF)

CString strRTF;
strRTF.Append(_T("{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3082"));
strRTF.Append(_T("{\\fonttbl{\\f0\\fnil\\fcharset0 %s;}}"));
strRTF.Append(_T("{\\colortbl ;\\red%d\\green%d\\blue%d;}"));
strRTF.Append(_T("\\viewkind4\\uc1\\pard\\cf1\\f0\\fs16 %s}"));

CString strRTFFinish;
strRTFFinish.Format(strRTF,_T("VERDANA"),GetRValue(colorref),GetGValue(colorref),GetBValue(colorref),text);

ReplaceSel(strRTFFinish);
-------------------------------------------------------



Now I need to print formatted texts in unicode. I have changed the RichEditCtrl and after several different codes:

- I can read unicode text (typed Chinese character in a richedit, just to test):

-------------------------------------------------------
WCHAR lParam[100] = {0};

GETTEXTEX wParamIN;
wParamIN.cb = (m_rtf.GetWindowTextLength()+1)*2;
wParamIN.flags = GT_RAWTEXT;
wParamIN.codepage = 1200;
wParamIN.lpDefaultChar = NULL;
wParamIN.lpUsedDefChar = NULL;

LRESULT lResult = ::SendMessage(m_RichEditCtrl.m_hWnd, // handle to destination control
EM_GETTEXTEX,
(WPARAM) &wParamIN,
(LPARAM) lParam);

CString str = (CString)lParam; // Unicode text in 'str'
-------------------------------------------------------

- I can write this unicode text in the RichEditCtrl:

-------------------------------------------------------
WCHAR lParam[100] = {0};

SETTEXTEX wParamOUT;
wParamOUT.codepage = 1200;
wParamOUT.flags = ST_SELECTION;

LRESULT lResult = ::SendMessage(m_rtf.m_hWnd, // handle to destination control
EM_SETTEXTEX,
(WPARAM) &wParamOUT,
(LPARAM) (LPCTSTR)str); 'str' is the previous unicode text
-------------------------------------------------------

But how can I print this text with format, like in the first code (color, bold,...)?

I hope I have explained my problem. I don't know from where to start...

Thanks in advance

Diego