Results 1 to 12 of 12

Thread: INSERT image in subitems of lisvtview

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    INSERT image in subitems of lisvtview

    I need to insert a Gif image(is a little image) in subitems of lisview from dir c:\dir1\image.gif, not from imagelist.
    How to?

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: INSERT image in subitems of lisvtview

    Why can't you use the ImageList control?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,580

    Re: INSERT image in subitems of lisvtview

    Ho bro
    My request is Clear.
    Tks

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: INSERT image in subitems of lisvtview

    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.

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: INSERT image in subitems of lisvtview

    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.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: INSERT image in subitems of lisvtview

    @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"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: INSERT image in subitems of lisvtview

    Quote Originally Posted by luca90 View Post
    Ho bro
    My request is Clear.
    Tks
    Based on the other replies I say you are out of luck.
    So my question stays and is valid, why can't you use the ImageList control?

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: INSERT image in subitems of lisvtview

    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.

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: INSERT image in subitems of lisvtview

    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?

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: INSERT image in subitems of lisvtview

    See as if the latter is true. ImageList is fine but ListView is broken, and probably TreeView too.

    Name:  sshot.png
Views: 297
Size:  2.6 KB

    The GIFs loaded at run time have differing palettes and transparent colors. They render as expected to PictureBox and Image however.

    Yes, those were meant to be circles but I drew them and got flats on the outside. Just my poor drawing skills.
    Attached Files Attached Files

  11. #11
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,647

    Re: INSERT image in subitems of lisvtview

    ListView is broken?
    Last edited by fafalone; May 23rd, 2017 at 03:29 AM.

  12. #12
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: INSERT image in subitems of lisvtview

    I answered a similar question 8 years ago

    Is this what you want?

    http://www.vbforums.com/showthread.p...=1#post3478144
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width