|
-
March 13th, 2005, 03:45 AM
#1
RichEdit color problem
Hello.
I would like to add message (insert at the end) to my RichEdit control. But each one can have a different color. Moreover, I want that scroll bar follow the last inserted line :
Here is what I have code yet :
Code:
void SendMessageToViewer(const CString & msg, const COLORREF & crNewColor)
{
long iTotalTextLength = m_Rec_Viewer.GetTextLength();
m_Rec_Viewer.SetSel( -1, -1);
m_Rec_Viewer.ReplaceSel( msg );
long iStartPos = iTotalTextLength;
CHARFORMAT cf;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR | CFM_UNDERLINE | CFM_BOLD;
cf.dwEffects = (unsigned long)~( CFE_AUTOCOLOR | CFE_UNDERLINE | CFE_BOLD);
cf.crTextColor = crNewColor;
long iEndPos = m_Rec_Viewer.GetTextLength();
m_Rec_Viewer.SetSel(iStartPos, iEndPos);
m_Rec_Viewer.SetSelectionCharFormat(cf);
m_Rec_Viewer.HideSelection(TRUE, FALSE);
m_Rec_Viewer.LineScroll( this->m_SequencerDialog->m_Rec_Viewer.GetLineCount() - 1 );
m_Rec_Viewer.UpdateWindow();
}
All works, except that color is applied to my text but not starting at the first letter after inserting 2, 3, 4, 5 lines.... Also, my scrollbar is not following well my text.
PS : Sorry for my poor english 
Thank for you support.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|