Board index » delphi » ListView:draw images without imagelist

ListView:draw images without imagelist

I would like to use a TListView (or something similar)
but I don't want to use an TImageList and ImageIndex because
it seems to be very cost intensive to fill the image list
and then use the index (the used images a only known at runtime).
So instead of defining an ImageIndex for every item I just would like to
have a function like "GetImage: TBitmap" for the list items.

Is there a way to achieve this with TListView?
Is there some other control available?

Heiko

 

Re:ListView:draw images without imagelist


Quote
Heiko Tappe wrote:
> I would like to use a TListView (or something similar)
> but I don't want to use an TImageList and ImageIndex because
> it seems to be very cost intensive to fill the image list
> and then use the index (the used images a only known at runtime).
> So instead of defining an ImageIndex for every item I just would like
> to have a function like "GetImage: TBitmap" for the list items.

You could create a dummy imagelist of the desired dimensions with only
one blank image, set each item's ImageIndex to 0 and then custom-draw
your own image over the blank one in the event
OnAdvancedCustomDrawItem. This is also a very good technique for
creating a listview with "thumbnails" like in Explorer's thumbnail view.

Re:ListView:draw images without imagelist


Creating a bitmap for each and every item in the listview is way more cost
intensive than filling an imagelist and using the imageindex. You can still
render them yourself if you like (OnCustomDraw etc).

--
Regards,

Peter Thornqvist (JVCL Coordinator)
http://jvcl.sourceforge.net

Re:ListView:draw images without imagelist


That sounds good.
Are there any source samples available?

--Heiko

Quote
> You could create a dummy imagelist of the desired dimensions with only
> one blank image, set each item's ImageIndex to 0 and then custom-draw
> your own image over the blank one in the event
> OnAdvancedCustomDrawItem. This is also a very good technique for
> creating a listview with "thumbnails" like in Explorer's thumbnail view.

Other Threads