Connecting Tech Pros Worldwide Help | Site Map

How to "Custom row color for list control"-Win prog?

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 22nd, 2008, 05:11 AM
osfreak's Avatar
Newbie
 
Join Date: Oct 2008
Posts: 17
Default How to "Custom row color for list control"-Win prog?

Hi,

Am using a list control in my application, and i need to change the colour of one or more rows on users request(thro a push button).

Somebody pls help me , how it can be done??


P.s: Am not to use MFC, just windows API's
Reply
  #2  
Old December 22nd, 2008, 10:49 AM
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 5,731
Default

You would need to create an owner drawn control and draw the entire thing yourself.
Reply
  #3  
Old December 22nd, 2008, 02:07 PM
Newbie
 
Join Date: Jul 2008
Posts: 19
Default

No, you don't need to owner draw for a List Control (LV)
You can ask on Adv. Win32 ng
news://comp.os.ms-windows.programmer.win32
for the code (C & Win32 api)
Reply
  #4  
Old December 22nd, 2008, 02:41 PM
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 5,731
Default

I suggest you read about the List View.

The only colours you can set in a standard control is control background and item text back ground and text colour. You can not set colours for specific items this state data is not held by the control.

If you read this About List-View Controls you will find it specifically says about colouring

Quote:
Originally Posted by msdn
List-View Colors

An application can retrieve and set three colors for a list-view control.
Color Messages used to retrieve and set colors
Text color LVM_GETTEXTCOLOR, LVM_SETTEXTCOLOR
Text background color LVM_GETTEXTBKCOLOR, LVM_SETTEXTBKCOLOR
Window background color LVM_GETBKCOLOR, LVM_SETBKCOLOR

To customize the appearance of a list-view control more significantly, use NM_CUSTOMDRAW (list view). For applications that run on the Windows XP operating system you can apply visual styles to customize the control's appearance. For information on using visual styles see Visual Styles and Enabling Visual Styles.
Reply
  #5  
Old December 22nd, 2008, 03:30 PM
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Age: 48
Posts: 14,330
Default

Quote:
Originally Posted by george666 View Post
No, you don't need to owner draw for a List Control (LV)
You can ask on Adv. Win32 ng
news://comp.os.ms-windows.programmer.win32
for the code (C & Win32 api)
George,

There will often be situations where members disagree on the technicalities of a question. We would nevertheless ask that you always treat others with respect. Contradiction is something that is to be avoided, especially without providing a lot stronger evidence than an apparently simple difference of opinion.

If you do have an alternative option, then presenting it here is always acceptable (much more so than a link elsewhere). If there are known problems with any solution you provide, they can be highlighted, but with respect. We all benefit from clearer understanding. This is never achieved by bad manners or simple contradiction.

Please bear this in mind in future.

-NeoPa (Administrator).
Reply
  #6  
Old December 23rd, 2008, 04:18 AM
osfreak's Avatar
Newbie
 
Join Date: Oct 2008
Posts: 17
Default

Guys,,, Thanks for all your help...


It does seem that the programmer has to custom draw the list to have it that way..

Since i just wanted the colour change to show difference in entries i shall better have one more list control separately..


George i could not make out ur link.. Though am not using it in my application , i might as well try ...
Reply
Reply

Bookmarks

Tags
c++, list control, windows api

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.