In the parent edit control, handle the WM_CTLCOLORSTATIC message , the wParam of this message is the HDC that the Edit control draws with, for most CTLCOLOR messages, if you set the text and background colors to this DC, the control will use the colors you set.
You can also return HBRUSH, and contol will use this for any brush it will do, but many controls don’t use brushes much, so this will have a limited effect for some CTLCOLOR Messages. It is best here to return the DC brush and set the color of the DC brush in accordance with BkColor DC.
LRESULT lRet = 0;
COLORREF crBk = RGB(255,0,0);
...
case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC)wParam;
HWND hwnd = (HWND)lParam;
if (GetDlgCtrlId(hwnd) == IDC_EDIT_RECOLOR)
{
SetBkColor(hdc, crBk);
SetDCBrushColor(hdc, crBk);
lRet = (LRESULT) GetStockObject(DC_BRUSH);
}
else
{
lRet = DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
break;
source
share