Coloring a list control and not the controls within it

How do i change the default color of a list control to a specific color of my choice.
AnishaAsked:
Who is Participating?
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
Make your own class based on a list control  (class wizard will help you)

Trap the WM_ERASEBKGND message

BOOL CMyListCtrl::OnEraseBkgnd(CDC* pDC)
{
  CRect rc;
  GetClientRect(&rc);
  pDC->FillSolidRect(RGB(0, 0, 128));  //change the values to give the colour you want
  return TRUE;   //IMPORTANT else it will not be changed
}
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
correction -
  pDC->FillSolidRect(&rc, RGB(0, 0, 128));  //change the values to give the colour you want
0
 
alb66Connect With a Mentor Commented:
To change the window background color you can use SetBkColor( RGB( ..., ..., ... ))
To change the text background color you can use SetTextBkColor( RGB( ..., ..., ... ))
To change the text color you can use SetTextColor( RGB( ..., ..., ... ))
All the functions above are methods of the CListCtrl class.



0
 
AndyAinscowFreelance programmer / ConsultantCommented:
OnEraseBkgnd is a simple way to do it (Coloring a list control and not the controls within it) and stop any nasty flickering
0
 
alb66Commented:
CListCtrl already has all the methods Anisha need.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.