
multiline CEdit background color
I derived a new class from CEdit called CColorEdit to handle text color
and background color (see below)
It works fine except when the control is multiline, it does not repaint
the background of the whole control.
If I'm doing:
mycoloredit.SetWindowtext("This is a test");
Only the line displaying "This is a test" will be displayed with the
correct background color while the other ones will be displayed as
white|gray.
My edit box is read-only, visible, and transparent.
Anyone know how to do this ?
CColorEdit::CColorEdit()
{
m_TextColor = RGB(0,0,0);
m_BkColor = ::GetSysColor(COLOR_3DFACE);
m_Bkgnd.CreateSolidBrush(m_BkColor);
Quote:
}
void CColorEdit::SetTextColor(COLORREF color)
{
m_TextColor = color;
Invalidate();
Quote:
}
void CColorEdit::SetBkColor(COLORREF color)
{
m_BkColor = color;
m_Bkgnd.DeleteObject();
m_Bkgnd.CreateSolidBrush(color);
Invalidate();
Quote:
}
BEGIN_MESSAGE_MAP(CColorEdit, CEdit)
//{{AFX_MSG_MAP(CColorEdit)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
HBRUSH CColorEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
pDC->SetTextColor(m_TextColor);
pDC->SetBkColor(m_BkColor);
return (HBRUSH) m_Bkgnd;
Quote:
}
--
\\\\
o,,,(o o)
8(o o)(_)Ooo
----ooO--(_)---Ooo------------------------------------------------------
Stephane BAILLIEZ Ph : +33 1 47 78 67 67
Software Engineer Fax : +33 1 47 78 67 68
TECSI WWW : http://www.*-*-*.com/
If you want creative workers, give them enough time to play.
~ John Cleese ~
DISCLAIMER
All statements above are NOT the opinion or policy of my employer,
they are actually mine and were told to me by Ferdinand and Luthor, the
five-inch tall space aliens who live under my desk. In return for these
ideas I gave them permission to eat any dust-cookies they may find.
------------------------------------------------------------------------