You cannot do it with a plain CEdit, you need to override a few bits.
Implement your own ON_WM_CTLCOLOR_REFLECT handler, then return your coloured CBrush in the handler:
(roughly, you'll need to put the usual resource management in there, rememebr to delete your brush in the destructor)
class CColorEdit : public CEdit
{
....
CBrush m_brBkgnd;
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor)
{
m_brBkgnd.DeleteObject();
m_brBkgnd.CreateSolidBrush(nCtlColor);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…