mattiaso
asked on
BackgroundColor on a CRichEditCtrl
How do I change the backgroundcolor on a CRichEditCtrl??
I've tried to call SetBackgroundColor in OninitialUpdate and in OninitDialog.
I've tried to call SetBackgroundColor in OninitialUpdate and in OninitDialog.
You might try handling WM_ERASEBKGRND and paint the entire area using something like FillRect()
Use CWnd::OnCtlColor() to return brush to paint background og your control. You can check detail information about this function in VC++ help.
ASKER
If i want to change the backgroundcolor of an editcontrol I can
catch the message like this:
// m_Brush is the desired backgroundcolor
if(nCtlColor==CtlColor_Edi t)
{
return m_Brush;
}
But there is no message for a RichEditCtrl.
catch the message like this:
// m_Brush is the desired backgroundcolor
if(nCtlColor==CtlColor_Edi
{
return m_Brush;
}
But there is no message for a RichEditCtrl.
mattiaso,
CRichEditCtrl::SetBackgrou ndColor() should do exactly what you need. Have you tried instructing the rich edit control to redraw itself after the method invocation?
BTW, have you tried changing the back color in other points of your app?
Davide Marcato.
CRichEditCtrl::SetBackgrou
BTW, have you tried changing the back color in other points of your app?
Davide Marcato.
ASKER
I've tried Invalidate(), but that will not help.
Can I redraw the control in other ways than with Invalidate and InvalidateRect???
Can you give me an example of that and of how you change the background of an Richedit???
I've succed with editboxes and listboxes in OnCtlColor.
Can I redraw the control in other ways than with Invalidate and InvalidateRect???
Can you give me an example of that and of how you change the background of an Richedit???
I've succed with editboxes and listboxes in OnCtlColor.
Did you call UpdateWindow() after Invalidate()/InvalidateRec t()?
It sends the WM_PAINT message to the window (the rich edit control in this case) immediately.
Davide Marcato.
It sends the WM_PAINT message to the window (the rich edit control in this case) immediately.
Davide Marcato.
ASKER
Now I've tried that, but it will not work.
In OnInitDialog :
m_Rich.SetBackgroundColor( FALSE,RGB( 255,255,19 2));
Invalidate();
UpdateWindow();
In OnInitDialog :
m_Rich.SetBackgroundColor(
Invalidate();
UpdateWindow();
Last attempt:
m_Rich.SetBackgroundColor( FALSE, RGB(128,128,128));
m_Rich.Invalidate();
m_Rich.UpdateWindow();
Davide Marcato.
m_Rich.SetBackgroundColor(
m_Rich.Invalidate();
m_Rich.UpdateWindow();
Davide Marcato.
ASKER
Now I've tried that to but it's not working.
This problem is documented somewhere in MSDN...
Your trying to do the same thing as what VB does, right? You're trying to just change the background color of a single control?
If that's what you're doing, search MSDN for changing the color of an Edit control and you should find the code snippet. I remember because the author said that it was a pain in the ass to do it in C/C++.
Your trying to do the same thing as what VB does, right? You're trying to just change the background color of a single control?
If that's what you're doing, search MSDN for changing the color of an Edit control and you should find the code snippet. I remember because the author said that it was a pain in the ass to do it in C/C++.
ASKER
I know how to change the backgroundcolor of an EditCtrl.
But it looks like changing the backgroundcolor of a RichEditCtrl is different.
I will check i MSDN.
But it looks like changing the backgroundcolor of a RichEditCtrl is different.
I will check i MSDN.
ASKER
Adjusted points to 70
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My graphiccard(Cirrus Logic) couldn't show the colour i used (RGB(255,255,192)) with 256 colours).
But your answer was rigth....
But your answer was rigth....