In my application I have CPaneDialog with controls (e.g. Text control). I try to set background color for this CPanelDialog. For this purpose, I overwrited OnEraseBkgnd
BOOL CBgPaneDialog::OnEraseBkgnd(CDC* pDC)
{
CBrush backBrush(RGB(255, 128, 128));
CBrush* pOldBrush = pDC->SelectObject(&backBrush);
CRect rect;
pDC->GetClipBox(&rect); // Erase the area needed
pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(),PATCOPY);
pDC->SelectObject(pOldBrush);
return TRUE;
}
Unfortunately, controls on this CPaneDialog have other background. http://fotoo.pl//out.php?t=964580_text.png
I overwrot next method: OnCtlColor to set caontrol's backgorund.
HBRUSH CBgPaneDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
CBrush br;
br.CreateSolidBrush(RGB(255,255,255));
HBRUSH hbr = (HBRUSH)br;
CWnd *pCheckBox = GetDlgItem(IDC_STATIC); // put ID of your checkbox here.
int a;
if (*pCheckBox == *pWnd)
{
br.DeleteObject();
br.CreateSolidBrush(a=pDC->SetBkColor(RGB(255, 128, 128)));
hbr = (HBRUSH)br;
}
else
hbr = CPaneDialog::OnCtlColor(pDC, pWnd, nCtlColor);
return hbr;
}
The control's background have changed, but not completely. Please see in the picture: http://fotoo.pl//out.php?i=964579_textcontrol.jpg
How can I change background completely for the text control?