O
OpticTygre
Hi folks. I'm currently in the midst of building an explorer - like viewer
for a bigger project I'm going to be working on soon. When building the
class for my Treeview and Listview controls, I'm using the ExtractIconEx API
function (see code below). I found that all the icons windows uses are not
necessarily in the Shell32.dll file, though. I did some digging, and found
a few other places where Icon files are being pulled from to be displayed in
explorer. I'm just curious about the best way one would go about pulling
the icon files out of multiple places, based upon either the folder icon (or
control panel icon) or the files in the folders (for the listview). I'd
rather not create my own library of icons to release with the program, as it
can get big, and I don't see the point when most of them come with windows
anyway. What's the best way to go about getting (from the correct place)
and displaying icons in a treeview (for folders, drives, etc...) and
listview (for folders and files) controls?
Thanks for any advice.
-Jason
Private Declare Function ExtractIconEx Lib "Shell32.dll" Alias
"ExtractIconExA" _
(ByVal lpszFile As String, ByVal nIconIndex As Integer, _
<[In](), Out()> ByVal phIconLarge() As Integer, _
<[In](), Out()> ByVal phIconSmall() As Integer, _
ByVal nIcons As Integer) As Integer
Private Sub GetSystemIconList()
Try
Dim iIndex As Integer
Dim strPath As String
Const iArrUB As Integer = 250
Dim hLargeIcon(iArrUB) As Integer
Dim hSmallIcon(iArrUB) As Integer
Dim IconHnd As IntPtr
Dim iFetchIcons As Integer
strPath = "%systemroot%\system32\shell32.dll"
iFetchIcons = ExtractIconEx(strPath, 0, hLargeIcon, hSmallIcon,
iArrUB)
For iIndex = 0 To iFetchIcons - 1
SmallSystemIconList.Images.Add(Bitmap.FromHicon(IconHnd.op_Explicit(hSmallIcon(iIndex))))
LargeSystemIconList.Images.Add(Bitmap.FromHicon(IconHnd.op_Explicit(hLargeIcon(iIndex))))
Next
Catch ex As Exception
End Try
End Sub
for a bigger project I'm going to be working on soon. When building the
class for my Treeview and Listview controls, I'm using the ExtractIconEx API
function (see code below). I found that all the icons windows uses are not
necessarily in the Shell32.dll file, though. I did some digging, and found
a few other places where Icon files are being pulled from to be displayed in
explorer. I'm just curious about the best way one would go about pulling
the icon files out of multiple places, based upon either the folder icon (or
control panel icon) or the files in the folders (for the listview). I'd
rather not create my own library of icons to release with the program, as it
can get big, and I don't see the point when most of them come with windows
anyway. What's the best way to go about getting (from the correct place)
and displaying icons in a treeview (for folders, drives, etc...) and
listview (for folders and files) controls?
Thanks for any advice.
-Jason
Private Declare Function ExtractIconEx Lib "Shell32.dll" Alias
"ExtractIconExA" _
(ByVal lpszFile As String, ByVal nIconIndex As Integer, _
<[In](), Out()> ByVal phIconLarge() As Integer, _
<[In](), Out()> ByVal phIconSmall() As Integer, _
ByVal nIcons As Integer) As Integer
Private Sub GetSystemIconList()
Try
Dim iIndex As Integer
Dim strPath As String
Const iArrUB As Integer = 250
Dim hLargeIcon(iArrUB) As Integer
Dim hSmallIcon(iArrUB) As Integer
Dim IconHnd As IntPtr
Dim iFetchIcons As Integer
strPath = "%systemroot%\system32\shell32.dll"
iFetchIcons = ExtractIconEx(strPath, 0, hLargeIcon, hSmallIcon,
iArrUB)
For iIndex = 0 To iFetchIcons - 1
SmallSystemIconList.Images.Add(Bitmap.FromHicon(IconHnd.op_Explicit(hSmallIcon(iIndex))))
LargeSystemIconList.Images.Add(Bitmap.FromHicon(IconHnd.op_Explicit(hLargeIcon(iIndex))))
Next
Catch ex As Exception
End Try
End Sub