Background text color in RichEditCtrl
-
Hello to all, I have my application developed is C++/MFC using Visual Studio 6.0. I am using a RichEdit Control (CRichEditCtrl), and this is a chat window when different users put in their chat messages. and for some cases, i need to highlight the chat messages with the background set to RED, in case of certain special users only. The problem i am facing here is that I am unable to set the background text to RED. Initial code was developed using CHARFORMAT, and now I am using CHARFORMAT2. But with this also, the background text doesnot get set. And very surprising to note was that I was not able to set any additional parameters that are defined in CHARFORMAT2 over CHARFORMAT. Any help would be highly appreciated. Thanks and regards, Anwar.
-
Hello to all, I have my application developed is C++/MFC using Visual Studio 6.0. I am using a RichEdit Control (CRichEditCtrl), and this is a chat window when different users put in their chat messages. and for some cases, i need to highlight the chat messages with the background set to RED, in case of certain special users only. The problem i am facing here is that I am unable to set the background text to RED. Initial code was developed using CHARFORMAT, and now I am using CHARFORMAT2. But with this also, the background text doesnot get set. And very surprising to note was that I was not able to set any additional parameters that are defined in CHARFORMAT2 over CHARFORMAT. Any help would be highly appreciated. Thanks and regards, Anwar.
Use method
AfxInitRichEdit2
instead ofAfxInitRichEdit
to initialize controls.Prasad Notifier using ATL | Operator new[],delete[][^]
-
Hello to all, I have my application developed is C++/MFC using Visual Studio 6.0. I am using a RichEdit Control (CRichEditCtrl), and this is a chat window when different users put in their chat messages. and for some cases, i need to highlight the chat messages with the background set to RED, in case of certain special users only. The problem i am facing here is that I am unable to set the background text to RED. Initial code was developed using CHARFORMAT, and now I am using CHARFORMAT2. But with this also, the background text doesnot get set. And very surprising to note was that I was not able to set any additional parameters that are defined in CHARFORMAT2 over CHARFORMAT. Any help would be highly appreciated. Thanks and regards, Anwar.
Try a couple of things: 1 - use the following message: ::SendMessage( m_hwndText, //Handle to edit control. EM_SETBKGNDCOLOR, 0, clrBackground) ; //e.g., ULONG clrBackground = RGB(255, 0, 0) ; 2 - Also, I seem to remember some time ago having to first put some text into a rich edit before I could change the background. You first have to select the text using CHARRANGE, then use CHARFOMAT2 to format the text. I have a vague recollection of putting a single space character into the rich edit to get it to work, but you may not have to. Scott