Solved

Getting associated Icons of Files

Posted on 2000-05-09
5
205 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

Industry Leaders: 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

Title # Comments Views Activity
How does CurrentUser work? 10 44
Prevent user closing word document opened with VB6 6 89
Win 10 Automation Error with .doCmd in Access 2 93
Modify Text File with Excel Macro 13 51
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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

752 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