none
Next NewBee question (Icons and TreeView)

    Question

  • I am working with a treeview control and I want to be able to display the icons next to each node depending on the file type.

    First I want to say that I am not working with a Windows File System files. I am working on files that are referenced through a proprietary file system that enables the revision history’s and other file attributes. It is for a Engineering software similar to Solidworks.

     

    Anyway my first problem is extracting the Icons from the dll.

    I can’t seem to figure out how to do that I have been searching the net for 3 days and none of the code I find seems to work.

     

            Dim lIcon As Long

     

            lIcon = ExtractIcon(0&, <path>, 109)

            Call DrawIcon(Picture1.Handle, 0, 0, lIcon)

            Call DestroyIcon(lIcon)

     

    Can someone at least point my in the right direction? I haven’t even started trying to display an icon in the Treeview yet. I would appreciate a little help in that area too.

     

    Thanks in Advance

    Clint

    Friday, May 13, 2005 3:20 PM

Answers

  • Try this code which I changed from here:


     Public Function GetIcon() As Icon
      Dim instance As IntPtr = Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0))
      Dim hIcon As IntPtr = ExtractIcon(instance, "shell32.dll", 10)

      If Not hIcon.Equals(IntPtr.Zero) Then
       Return Icon.FromHandle(hIcon)
      End If

      Return Nothing

     End Function


     

    Monday, May 16, 2005 4:07 PM
    Moderator

All replies

  • What dll are you trying to get the icons from?

    Is it a .NET assembly (ie VB.NET)?
    Friday, May 13, 2005 5:40 PM
    Moderator
  • It is an ActiveX dll. From a third party. I know that the Icons are there I have viewied them with an icon grabber.


    Clint
    Monday, May 16, 2005 3:52 PM
  • Try this code which I changed from here:


     Public Function GetIcon() As Icon
      Dim instance As IntPtr = Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly.GetModules()(0))
      Dim hIcon As IntPtr = ExtractIcon(instance, "shell32.dll", 10)

      If Not hIcon.Equals(IntPtr.Zero) Then
       Return Icon.FromHandle(hIcon)
      End If

      Return Nothing

     End Function


     

    Monday, May 16, 2005 4:07 PM
    Moderator
  • Thanks, I will give that a shot.
    Monday, May 16, 2005 8:57 PM