clistbox greying
-
Need to grey out the background of a ClistBox on pressing button grey on a dialog. The list can contain items which should also be greyed out and on pressing button enable list the list should be enabled with all its items using wm_ctlcolor message with appropriate brush works, but when the list has items the portion with those items are white while rest is grey.
-
Need to grey out the background of a ClistBox on pressing button grey on a dialog. The list can contain items which should also be greyed out and on pressing button enable list the list should be enabled with all its items using wm_ctlcolor message with appropriate brush works, but when the list has items the portion with those items are white while rest is grey.
You have to enable the transparent background mode for the DC in the
WM_CTLCOLOR
method BEFORE returning the new brush:HBRUSH CSampleDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// !!! Set background transparent !!!
pDC->SetBkMode(TRANSPARENT); // <<<<<<<<< Items will be transparent, showing the new bk brush
if (pWnd->GetDlgCtrlID() == IDC_MYLISTBOX)
{
if(m_bGrayed)
return (HBRUSH)GetStockObject(GRAY_BRUSH);
else
return (HBRUSH)GetStockObject(WHITE_BRUSH);
}
// TODO: Return a different brush if the default is not desired
return hbr;
}Regards, mYkel