You have to use an ImageList. Think of them as part of the ListView, just a part that was factored out of several Common Controls for sharing because they all had similar needs.
ImageList has a ListImages collection with an Add method. It accepts either bitmap or icon StdPicture objects. They must all have the same height and width.
When you use LoadPicture() on a GIF the result is a bitmap StdPicture object.
Can you even put an image in a subitem? Even with the ImageList? I don't think I've ever seen it done. Not saying you can't, but something tells me that it involves making the LV owerdrawn. I know that setting the image index of the item will add the image from the list view to the item, but it appears in the first col.
@techgnome. Yes, via the ListView.ListItems(x).ListSubItems collection (v6 not v5); also restricted to just report view if I recall.
Edited: So I don't get flamed a bit. It is likely doable on v5 also, via SendMessage LVM_SETITEM, but not tried it.
@luca. You can render the GIF over a solid color (same backcolor as your listview), then add that to the imagelist. This can be done at runtime or via PAINT or another graphics tool, saved as a bitmap, and added to the imagelist in design-time.
Last edited by LaVolpe; May 22nd, 2017 at 02:56 PM.
Insomnia is just a byproduct of, "It can't be done"
The somewhat broken MSCOMCTL.OCX ImageList doesn't handle GIF transparency.
Is that the issue?
Didn't occur to me since I hardly ever use MSCOMCTL.OCX anymore. If you can live with the ugliness of those controls you may as well use a FlexGrid and be done with it unless you want to use the various ListView view types. So see post #6 to render a solid image matching the ListView BackColor.
For all I know the broken MSCOMCTL.OCX ImageList still might work if the GIFs all have identical palettes and the same transparent color but I haven't tested that.
Oddly, if you add GIFs via the designer they'll appear to recognize GIF transparency there but fail at run time. Maybe the flaw is in the ListView, TreeView, etc. instead of in the ImageList?