EasyRhino
October 7th, 1999, 08:35 PM
Hi all,
I've got a simple class that colors the background and text of edit boxes. I'm writing a program in which I want to change those colors dynamically during execution. Here is the class implementation:
CColoredEdit::CColoredEdit()
{
// default colors //
m_colorText = RGB( 255, 255, 255 );
m_colorBkgnd = RGB( 70, 85, 120 );
m_brBkgnd.CreateSolidBrush( m_colorBkgnd );
}
CColoredEdit::CColoredEdit(unsigned long colorText, unsigned long colorBkgnd)
{
m_colorText = colorText;
m_colorBkgnd = colorBkgnd;
m_brBkgnd.CreateSolidBrush( m_colorBkgnd );
}
CColoredEdit::~CColoredEdit()
{
}
void CColoredEdit::SetColors(unsigned long colorText, unsigned long colorBkgnd)
{
m_colorText = colorText;
m_colorBkgnd = colorBkgnd;
}
BEGIN_MESSAGE_MAP(CColoredEdit, CEdit)
//{{AFX_MSG_MAP(CColoredEdit)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColoredEdit message handlers
HBRUSH CColoredEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
pDC -> SetTextColor( m_colorText );
pDC -> SetBkColor( m_colorBkgnd );
return m_brBkgnd;
}
The SetColors() function shown above does not have the desired effect. Can anyone tell me how to accomplish this??
BONUS QUESTION: how do I make the text in the edit box bold?
Thanks for any and all help!
Regards,
Chris
I've got a simple class that colors the background and text of edit boxes. I'm writing a program in which I want to change those colors dynamically during execution. Here is the class implementation:
CColoredEdit::CColoredEdit()
{
// default colors //
m_colorText = RGB( 255, 255, 255 );
m_colorBkgnd = RGB( 70, 85, 120 );
m_brBkgnd.CreateSolidBrush( m_colorBkgnd );
}
CColoredEdit::CColoredEdit(unsigned long colorText, unsigned long colorBkgnd)
{
m_colorText = colorText;
m_colorBkgnd = colorBkgnd;
m_brBkgnd.CreateSolidBrush( m_colorBkgnd );
}
CColoredEdit::~CColoredEdit()
{
}
void CColoredEdit::SetColors(unsigned long colorText, unsigned long colorBkgnd)
{
m_colorText = colorText;
m_colorBkgnd = colorBkgnd;
}
BEGIN_MESSAGE_MAP(CColoredEdit, CEdit)
//{{AFX_MSG_MAP(CColoredEdit)
ON_WM_CTLCOLOR_REFLECT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CColoredEdit message handlers
HBRUSH CColoredEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
pDC -> SetTextColor( m_colorText );
pDC -> SetBkColor( m_colorBkgnd );
return m_brBkgnd;
}
The SetColors() function shown above does not have the desired effect. Can anyone tell me how to accomplish this??
BONUS QUESTION: how do I make the text in the edit box bold?
Thanks for any and all help!
Regards,
Chris