You cannot do this with a simple CEdit, you need to override a few bits.
Add your own ON_WM_CTLCOLOR_REFLECT handler, and then return the color CBrush to the handler:
(roughly speaking, you need to put the usual resource management there, rememebr, to remove the 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); } }
source share