Search Tools Links Login

Custom Drawn ListView



This Will allow the programmer to customise the individual foreground background colours of the different listview items, and can give a listview a custom highlight colour, with out modification to this code.
Any votes and/or comments will be much appreciated.

Original Author: Citizen_Suicide

Inputs

Add this code in the Form_Load event:
Attach Me.hWnd, ListView
And don't forget to UnAttach in your form_unload event:
UnAttach me.hWnd

To set whether a custom highlight colour is used call:
UseCustomHighLight True
or
UseCustomHighLight false
To Set whether a listviews items will have alternating colours call:
UseAlternatingColour True
or
UseAlternatingColour False
To set the custom highlight colour use this code:
Dim NewColours as ItemColourType
NewColours.ForeGround = Your Colour Code Here
NewColours.BackGround = Your Colour Code Here
SetHighLightColour NewColours
To Set the custom alternating colour (the first colour is the default foreground/background colours) call:
Dim NewColours as ItemColourType
NewColours.ForeGround = Your Colour Code Here
NewColours.BackGround = Your Colour Code Here
SetCustomColour NewColours

Assumptions

Nothing really, may help to read the readme.txt file and understand the concepts before trying to customise this code.

Returns

A Custom Drawn ListView control

Side Effects

With multi selection on and more than one item highlighted there is an intrusive refresh flicker, caused by continual refresh.
You'll have to be careful when running in the IDE, as subclassing can crash your computer.
Obviously this is slower than letting the listview look after itself.
There can be problems getting the colours to display right during scrolling, they can appear missaligned - i know not why.
Highlight colour tends to dissapear on coloumns that are being resized, and will not reappear until the item is clicked, even though the item is still flagged as selected. Again i'm not sure what causes this.
The selection is always hidden when the listView doesn't have the focus, no matter what value is set in hideselection.
Any other listviews on the same form will not display correctly.
Setting alternating colours will overlay any background picture.

API Declarations

Many - see code ModAPIDeclares

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 82 times

Categories

Visual Basic 6

Attachments

Custom_Dra556832172002.zip
Posted: 9/3/2020 3:45:00 PM
Size: 67,458 bytes


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.