Connecting Tech Pros Worldwide Help | Site Map

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

osfreak's Avatar
Newbie
 
Join Date: Oct 2008
Posts: 17
#1: Dec 22 '08
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
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,148
#2: Dec 22 '08

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


You would need to create an owner drawn control and draw the entire thing yourself.
Newbie
 
Join Date: Jul 2008
Posts: 26
#3: Dec 22 '08

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


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)
Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,148
#4: Dec 22 '08

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


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.

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,662
#5: Dec 22 '08

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


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).
osfreak's Avatar
Newbie
 
Join Date: Oct 2008
Posts: 17
#6: Dec 23 '08

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


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

Tags
c++, list control, windows api