CListBox Greying
-
Grey the background of a CListBox on the selection of a button, Currently using WM_CTLCOLOR returing diff brushes work. But I have the style Extended for the ClistBox. with this style. when I grey out the list, if the list has items it wil grey only that part of the list that is empty. The filled part still has the Background as white The below code will work for Single selection style, but not for extended style. HBRUSH CTestaDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); //Set background transparent pDC->SetBkMode(TRANSPARENT); if (pWnd->GetDlgCtrlID() == IDC_MYLISTBOX) { if(m_bGrayed) return (HBRUSH)GetStockObject(GRAY_BRUSH); else return (HBRUSH)GetStockObject(WHITE_BRUSH); } return hbr; } void CTestaDlg::OnRadio1() { m_bGrayed = FALSE; m_MyListBox.EnableWindow(TRUE); } void CTestaDlg::OnRadio2() { m_bGrayed = TRUE; m_MyListBox.EnableWindow(FALSE); }