Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Changing Color of Selection/Highlight Bar??

62 views
Skip to first unread message

KCC GmbH

unread,
Aug 21, 2001, 6:32:28 AM8/21/01
to
Hi,

I already bothered Stephane with this, but maybe somebody else can tell me
how can I change the from windows 'pre-set' color of the selection bar in a
listview or any other control.
In "WinMX" (www.winmx.com) they've done it, so there must be a way.

(and I'm not talking about changing the background color)

BTW, whats the correct term: "selection bar" or "highlight bar"?


TIA,
Markus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
KCC - Krammer Computer Consulting GmbH
A- 3270 Scheibbs, Austria
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Stephen Quinn

unread,
Aug 21, 2001, 6:34:31 AM8/21/01
to
Markus

I think you'll need owner draw for that.

It's just a wrapper around the MS listview control which doesn't support it
AFAIK.

--
HTH
Steve Quinn
Maxims for the Internet Age
1. Home is where you hang your @
2. The E-mail of the species is more deadly than the mail.
3. A journey of a thousand sites begins with a single click.
4. You can't teach a new mouse old clicks.
5. Great groups from little icons grow.


Geoff Schaller

unread,
Aug 21, 2001, 6:51:52 AM8/21/01
to
Markus,

Yes, it is quite easy. Change the system colours.

But, if you don't want to do that, get hold of the back issues of SDT.
Dieter Crispien wrote an article in the 2000/02 issue about colouring
treeview items but the exact same procedure holds good for Listview. Ivo
Wessels then wrote a long series of articles on custom control techniques.
Again, you can take the ControlNotify() ideas and simply extend them to your
own control methods.

I have reproduced below the main method used to do the colouring but there
is much more to it. Once you have the listview control frmo the message, you
can determine if the current item is 'selected" and thus set the colour
appropriately. Almost any condition can be used to set and unset a colour.

Regards,

Geoff


From: Geoff Schaller <geof...@bigpond.net.au>
Subject: Re: colors in listview
Date: Friday, November 12, 1999 4:43 AM

Jan,

This might be of help:

*******************************************************

From: Michael Ferber <fer...@richsoftware.com>
Subject: Re: VO2 : ListView (ReportView)
Date: Friday, April 09, 1999 1:58 AM

Karl

> Is it possible to change the Background color & the Text color
> of a ListviewItem (entire row).

Yes it is. The technique is called CustomDraw. You have to hook into your
ControlNotify() event of the owner of the listview and respond to the
NM_CUSTOMDRAW code.

METHOD ControlNotify( oEvent ) CLASS CDListViewDialog

LOCAL pNMCustomDraw AS _WINNMLVCUSTOMDRAW
LOCAL dwDrawStage AS DWORD

DO CASE
CASE oEvent:NotifyCode = NM_CUSTOMDRAW
pNMCustomDraw := PTR( _CAST , oEvent:lParam )
dwDrawStage := pNMCustomDraw.nmcd.dwDrawStage
DO CASE
CASE dwDrawStage = CDDS_PREPAINT
SELF:EventReturnValue := CDRF_NOTIFYSUBITEMDRAW
CASE dwDrawStage = CDDS_ITEMPREPAINT
IF pNMCustomDraw.nmcd.dwItemSpec%2 = 0
pNMCustomDraw.clrTextBk := RGB( 255 , 0 , 0 ) // makes
background red
ENDIF
SELF:EventReturnValue := CDRF_NEWFONT
OTHERWISE
SELF:EventReturnValue := CDRF_DODEFAULT
ENDCASE
SetWindowLong( SELF:Handle() , DWL_MSGRESULT ,
SELF:EventReturnValue )
RETURN SELF:EventReturnValue
ENDCASE
RETURN 0

If you need miss some of the DEFINE's and STRUCTURE's here, then look at
http://ourworld.compuserve.com/homepages/FerberMichael where I have a file
COMCTRL.ZIP which has all of them.

Michael


Jan Van Calster <j...@share.be> wrote in message
news:382B63E2...@share.be...
> Hi,
>
> Does anybody know how to use coloring in a listview ??
>
> I would like to show some items (rows) in a different color.
> Is this possible ?? and how
>
> thanx
>
> Jan Van Calster

"KCC GmbH" <office.R...@kcc.at> wrote in message
news:3b82...@e-post.inode.at...

KCC GmbH

unread,
Aug 24, 2001, 11:02:31 AM8/24/01
to
> Hi Geoff, hi Stephane,

OH! I forgot Steven.

Hi Steven!

Thanks to you all.


Regards,
Markus


Stephane Hebert

unread,
Aug 24, 2001, 4:33:55 PM8/24/01
to
Markus,

Good for you ! And thanks for finding the article <g>


--
Stephane Hebert
=========================
stephhebert@yourpants~videotron.ca
Remove yourpants~ to reply
=========================

"KCC GmbH" <office.R...@kcc.at> wrote in message

news:3b866b99$1...@e-post.inode.at...
> Hi Geoff, hi Stephane,
>
> I can't believe it myself, but I've done it!
> I can now change the color of the Selection Bar in a ListView - without
> changing the SystemColors (*g*) and without OwnerDraw - all by a few
simple
> lines of CustomDraw!
>
> I'm so proud of myself.
> But I've to confess - I'm not the genious, I found some C-source on this
> page:
> http://codeguru.earthweb.com/listview/LVHighlight.shtml.
> But it seems, I was the first in this NG who found it! *g*
> (see attached file for VO-source)
>
> Hope someone else can need it too.
>
>
> Regards,

Miroslaw Gorbaczow

unread,
Aug 25, 2001, 12:07:59 AM8/25/01
to
Markus,

I am a beginner and I am not able yet to translate
C source into VO.
Change of the colour of the selection bar in a List View
seems to me to be an interesting possibility.
I'd be pleased if you'd share the code with me.
Attachments don't work here in the NG I guess,
so inserting the text here or posting me
the code directly to m_...@my-deja.com would be fine.

I hope I don't ask for too much.

Miroslaw Gorbaczow

POLAND, Gdynia, 2002.08.25 ; 06:10

--------------------------------------------------
Markus wrote:
[...]


I can now change the color of the Selection Bar in a ListView - without
changing the SystemColors (*g*) and without OwnerDraw - all by a few
simple lines of CustomDraw!

[ ... ]


(see attached file for VO-source)

Hope someone else can need it too.


Regards,
Markus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Geoff Schaller

unread,
Aug 25, 2001, 3:07:28 AM8/25/01
to
<g>

Well done! I'll have a play with it later.

Geoff


"KCC GmbH" <office.R...@kcc.at> wrote in message
news:3b866b99$1...@e-post.inode.at...
> Hi Geoff, hi Stephane,
>
> I can't believe it myself, but I've done it!

> I can now change the color of the Selection Bar in a ListView - without
> changing the SystemColors (*g*) and without OwnerDraw - all by a few
simple
> lines of CustomDraw!
>

> I'm so proud of myself.
> But I've to confess - I'm not the genious, I found some C-source on this
> page:
> http://codeguru.earthweb.com/listview/LVHighlight.shtml.
> But it seems, I was the first in this NG who found it! *g*

> (see attached file for VO-source)
>
> Hope someone else can need it too.
>
>
> Regards,

Dirk Herijgers

unread,
Aug 27, 2001, 11:36:46 AM8/27/01
to
Markus,

I have tried your code, and it works, but with some bugs ??

a) I come continuous in a cycle from CDDS_ITEMPREPAINT to CDDS_ITEMPOSTPAINT
and again CDDS_ITEMPREPAINT etc etc etc etc. So, this gives me some
flickering in the screen.

b) When closing the application, with still the listview in the splitwindow
open, the queryclose is done (I answer "yes"), but the close is not
executed. Then I close my splitwindow, and the whole application close on
that moment.

-----> Do you have a solution for this ???

Dirk

============================================================================
========

"KCC GmbH" <office.R...@kcc.at> wrote in message
news:3b866b99$1...@e-post.inode.at...
> Hi Geoff, hi Stephane,
>
> I can't believe it myself, but I've done it!
> I can now change the color of the Selection Bar in a ListView - without
> changing the SystemColors (*g*) and without OwnerDraw - all by a few
simple
> lines of CustomDraw!
>
> I'm so proud of myself.
> But I've to confess - I'm not the genious, I found some C-source on this
> page:
> http://codeguru.earthweb.com/listview/LVHighlight.shtml.
> But it seems, I was the first in this NG who found it! *g*
> (see attached file for VO-source)
>
> Hope someone else can need it too.
>
>
> Regards,

KCC GmbH

unread,
Aug 28, 2001, 2:10:43 AM8/28/01
to
I'm sorry Dirk, I can't offer you a solution for that problem,
I've used it with a usual ListView in a Datawindow (VO2.5b-2) and it worked
pretty well.
Maybe it has something to do with using it in a splitwindow?
I don't often use them and so I can't tell how far they behave differently.
And I'm afraid I can't check it out in the moment, because I'm stucked in a
lot of work to to.

maybe someone else can help you?


Regards,
Markus


"Dirk Herijgers" <di...@fujitron.be> schrieb im Newsbeitrag
news:3b8a8e34$0$21088$ba62...@news.skynet.be...

0 new messages