0

Hi to all...
In a MFC application,
I need to change the background color of a drop down list - combo box control.

IDC_MYCOMBO is the resource id and
m_myCombo is the name of the control.

I need to change the backcolor programmatically.
Is there a way to achieve that?

Thanks

1
Contributor
1
Reply
2
Views
10 Years
Discussion Span
Last Post by fulyaoner
0

I will answer to myself :)

HBRUSH CMYDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
 
 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
 
 CPaintDC dc(this);
 if(nCtlColor == CTLCOLOR_EDIT && pWnd->GetDlgCtrlID() == IDC_MYCOMBO)  {
  pDC->SetTextColor(RGB(0, 0, 0));
  pDC->SetBkColor(RGB(255, 90, 90));
  hbr = m_myBrush;
 }
 
 return hbr;
}

may be it will help to others someday.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.