Results 1 to 3 of 3

Thread: Displaying associated icons

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Geelong, Victoria, Australia
    Posts
    8

    Question

    Thanks to these forums I now know how to extract and display an icon from a given file, and place it in a picture box. However, how can I get that same icon into an ImageList and therefore use it in a ListView (ie. Like a list of files with the correct icon in the listview.)

    Any help would be much appreciated.
    Thanks in advance.
    Stu.
    Stu.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Extract the icon and paint to a picture box and make it persistent by assigning the image property to the picture property.
    Then use the Add method of the ListImages collection.
    Code:
        Static iIconCount As Integer
        
    'code to extract and paint an icon
    'to the picIcon PictureBox goes here
        picIcon.Picture = picIcon.Image
        iIconCount = iIconCount + 1
        With imlIcons
            'the following two properties can
            'be set during design time
            .MaskColor = picIcon.BackColor
            .UseMaskColor = True
            .ListImages.Add , "Icon" & iIconCount, picIcon.Picture
        End With
    The iIconCount in the above example is only there so we can give the icon a unique key in the ListImages collection.

    Good luck!

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Geelong, Victoria, Australia
    Posts
    8

    Smile Extrating Icons

    Great, thanks.

    It was the use of Image property I was missing. It now works nicely and my list views have meaningful icons.

    Thanks again.
    Stu.

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