You code is working perfectly fine for me
I did this
Defined a public Brush
CBrush *brush;
in
CTestDlg
which is my Dialog Class
Then Initialized this in constructor
brush = new CBrush(RGB(49,49,49));
And then this goes into
Code:
HBRUSH CTestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
if(pWnd->GetDlgCtrlID()==IDC_CHECK1)
{
pDC->SetTextColor(RGB(0, 255, 0));
pDC->SetBkColor(RGB(0, 0, 0));
return (HBRUSH)(brush->GetSafeHandle());
}
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}