Anybody know a quick and simple way to change the background color of a CStatic control? If you do please include a snip-it of code in reply.
Printable View
Anybody know a quick and simple way to change the background color of a CStatic control? If you do please include a snip-it of code in reply.
This topic has been covered many, many times.
Override the static's parent's OnCtlColor() like this:
---
HBRUSH CSomeWndOrDlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
{
HBRUSH hBrBkgnd = CBaseClass::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC)
{
hBrBkgnd = get_your_HBRUSH_for_back_colour_here ;
pDC->SetBkColor(same_colour_as_above_but_as_COLORREF);
}
return hBrBkgnd ;
}
---
OK?