Solved

Getting associated Icons of Files

Posted on 2000-05-09
5
204 Views
Last Modified: 2010-05-02
I want to store the associated Icons of Files in an VB ImageList.

I'm using the DLL-Function ExtractAssociatedIcon and get a hadle to the icon.

But I don't know how to continue to store these icons in an ImageList.
Must I use another DLL-Function to do this or is there a VB-Function I can use?
0
Comment
Question by:rainerHOLZ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 3

Accepted Solution

by:
paulstamp earned 100 total points
ID: 2795731
This is code I wrote, after raising a similar question here on EE

Public Sub ExtractIconToImageList(ByVal sFileName As String, ByRef imlTarget As ImageList, ByRef picTarget As PictureBox, nImageIndex As Integer, Optional nIconIndex As Integer = 0)
    '~^--------------------------------------------------------------------------------
    '~ Extracts an icon from the passed in file and adds to the specified imagelist. The
    '~ index specifies which icon to retrieve if there is more than one. PicTarget is
    '~ used to store the image prior to storing in the listview, nImageIndex is the index
    '~ to use in the imagelist.
    '~^
    '~^  #     DATE      USER     CHANGE
    '~^ -------------------------------------------------------------------------------
    '~%  1  16-Feb-2000 pauls     Created
    '~^
    '~^--------------------------------------------------------------------------------

    Dim lIcon As Long
   
    lIcon = ExtractIcon(App.hInstance, sFileName, nIconIndex)
    Set picTarget.Picture = LoadPicture("")
    picTarget.AutoRedraw = True
    Call DrawIcon(picTarget.hdc, 0, 0, lIcon)
    picTarget.Refresh
    picTarget.AutoRedraw = False
    Set picTarget.Picture = picTarget.Image
    Call imlTarget.ListImages.Add(, "i" & nImageIndex, picTarget.Picture)
       
   
End Sub
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2795734
Just one note of explanation... you need a temporary picture box as an intermediate stage - I have an invisible picture box on a form and use that.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2795735
Another comment - to extract associated icon you'll need to change the first line of the procedure - my code gets the icon from the file itself.
0
 

Author Comment

by:rainerHOLZ
ID: 2796162
Thanks, you helped me a lot.
0
 
LVL 3

Expert Comment

by:paulstamp
ID: 2796260
No problem.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question