Click to See Complete Forum and Search --> : How do I change the background color of CListBox


May 14th, 1999, 12:35 PM
I tried this but nothing happens:

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

// TODO: Change any attributes of the DC here

if ( nCtlColor == CTLCOLOR_LISTBOX )
hbr = (HBRUSH)(LTGRAY_BRUSH);

// TODO: Return a different brush if the default is not desired
return hbr;
}

How is it done?

D.B.

Dan Haddix
May 17th, 1999, 03:03 AM
Use this instead

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

// TODO: Change any attributes of the DC here

if ( nCtlColor == CTLCOLOR_LISTBOX )
pDC->SetBkColor(GetSysColor(LTGRAY_BRUSH));

// TODO: Return a different brush if the default is not desired
return hbr;
}