I have extended it to getRTF, setRTF and to AppendText to find that I have
to get/set in the whole document everytime I want to edit the document.
Is there a way I can add formating to strings in real time? The Append Text
works fine. I just want to add color.
For example:
SetColor(<color i want>)
AppendText("Joined Chat")
SetColor(<new color>);
SetBold()
AppendText("QUIT chat")
Otherwise if you simply want to change the color of the text then keep track
of the last index of the text in the edit control before you insert your
text, then after you insert the text call SetSel
(SetSel(Index,Index+LengthIJustAdded)) and then change the formating as
usual using SetSelectionCharFormat or EM_SETCHARFORMAT.
AliR.
"Scott Kraemer" <skra...@cox.net> wrote in message
news:uHdd7Rt0...@TK2MSFTNGP02.phx.gbl...
SETTEXTEX setTextEx;
setTextEx.codepage=1250;
setTextEx.flags=ST_DEFAULT;
CChatRichEd *caption=(CChatRichEd*)GetDlgItem(IDC_CHAT);
if(caption!=NULL)
caption->SendMessage(EM_SETTEXTEX, (WPARAM)&setTextEx, (LPARAM)"This is a
test \b BOLD \b0 ");
"AliR (VC++ MVP)" <Al...@online.nospam> wrote in message
news:Baqri.46404$YL5....@newssvr29.news.prodigy.net...
CString RTF = m_Source.GetRTF();
SETTEXTEX SetTextEx;
SetTextEx.codepage = 1200;
SetTextEx.flags = ST_SELECTION;
m_Dest.SetSel(-1,-1);
m_Dest.SendMessage(EM_SETTEXTEX,(WPARAM)&SetTextEx,(LPARAM)RTF.GetBuffer());
RTF.ReleaseBuffer();
you can download the sample from here (VS2003). the bottom edit control is
where you type, you can change the text to bold and italic and change its
color, press send and it will get appended to the end of the top edit
control, and keeps the exact formating. (just like a chat window)
http://www.learnstar.com/AliR/AppendRTF.zip
AliR.
"Scott Kraemer" <skra...@cox.net> wrote in message
news:uQNVMOu0...@TK2MSFTNGP02.phx.gbl...
So I am working now :) thanks!
"AliR (VC++ MVP)" <Al...@online.nospam> wrote in message
news:Baqri.46404$YL5....@newssvr29.news.prodigy.net...