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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.