?
Solved

Coloring a list control and not the controls within it

Posted on 2006-11-30
10
Medium Priority
?
191 Views
Last Modified: 2013-11-20
How do i change the default color of a list control to a specific color of my choice.
0
Comment
Question by:Anisha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
10 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 18044678
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
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18044825
correction -
  pDC->FillSolidRect(&rc, RGB(0, 0, 128));  //change the values to give the colour you want
0
 
LVL 19

Assisted Solution

by:alb66
alb66 earned 500 total points
ID: 18052007
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
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 18372959
OnEraseBkgnd is a simple way to do it (Coloring a list control and not the controls within it) and stop any nasty flickering
0
 
LVL 19

Expert Comment

by:alb66
ID: 18450667
CListCtrl already has all the methods Anisha need.
0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month11 days, 14 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question