Click here to Skip to main content
15,867,880 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to remove the standard background color of my checkbox text as well as my groupbox captions. Does anyone know how to go about this in MFC application?

I'm currently trying to work with CTLCOLOR but I can't seem to get it to work.

Thanks in Advance,
:]
Posted
Updated 5-Dec-14 9:47am
v2

1 solution

I figured it this way:


ON_WM_ERASEBKGND()

BOOL CMyDialog::OnEraseBkgnd(CDC* pDC)
{
CRect r;
GetClientRect(&r);
if ((HBRUSH)m_brush == NULL)
m_brush.CreateSolidBrush(RGB(100, 100, 100));
pDC->FillRect(&r, &m_brush);
return TRUE;
}

ON_WM_CTLCOLOR()

HBRUSH CMyDialog::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

TCHAR classname[MAX_PATH];
if (::GetClassName(pWnd->m_hWnd, classname, MAX_PATH) == 0)
return hbr;
if (_tcsicmp(classname, _T("EDIT")) == 0)
return hbr;
if (_tcsicmp(classname, _T("COMBOBOX")) == 0)
return hbr;
if (_tcsicmp(classname, _T("COMBOLBOX")) == 0)
return hbr;
if (_tcsicmp(classname, _T("LISTBOX")) == 0)
return hbr;
if (_tcsicmp(classname, WC_TREEVIEW) == 0)
return hbr;


pDC->SetBkColor(RGB(100, 100, 100));

if ((HBRUSH)m_brush == NULL)
m_brush.CreateSolidBrush(RGB(192, 192, 192));
return (HBRUSH)m_brush;
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900