
Signature
----------------------------------------------------------------------
Thorsten Albers albers(a)uni-freiburg.de
----------------------------------------------------------------------
Thorstten,
Thank you for your comment.
I offer to clarify my question as you suggested,
In "Windows Explorer" we see the icon for directory, icon for data file,
icon for BMP file, icon for JPEG file etc. There are also icons for for
backward and forward change in directory.
I am developing a file management module similar to the Windows Explorer"
because it is not easy to modify it the way I need to, but I like my module
to be consistent to the look of windows explorer.
If I can find a way to access the "Windows Explorer" icons, I can use them
in my module.
If you would give me help to get the information I would be most appreciative,
Thank you
ChangChiTheGraphics
> ChangChiTheGraphics <ChangChiTheGraphics@discussions.microsoft.com> schrieb
> im Beitrag <01E0085F-5911-4582-9253-5F766B58009E@microsoft.com>...
[quoted text clipped - 8 lines]
> See the Windows API procedure SHGetFileInfo() with
> SHGFI_ICON/SHGFI_ICONINDEX.
Thorsten Albers - 16 Jun 2008 00:08 GMT
ChangChiTheGraphics <ChangChiTheGraphics@discussions.microsoft.com> schrieb
im Beitrag <6BC54A3E-6390-4EC4-BC74-156F43D80F56@microsoft.com>...
> I offer to clarify my question as you suggested,
> In "Windows Explorer" we see the icon for directory, icon for data file,
> icon for BMP file, icon for JPEG file etc. There are also icons for for
> backward and forward change in directory.
> I am developing a file management module similar to the Windows Explorer"
> because it is not easy to modify it the way I need to, but I like my module
> to be consistent to the look of windows explorer.
> If I can find a way to access the "Windows Explorer" icons, I can use them
> in my module.
> If you would give me help to get the information I would be most appreciative,
a) Some icons (files, directories) used by the Windows Explorer may be
retrieved by using SHGetFileInfo() as I have suggested before. To get more
information on this please refer to the documentation on SHGetFileInfo().
b) Other icons used by the Windows Explorer are included as resources in
the executable of the Windows Explorer. These icons can be extracted by
certain procedures in the Windows API at run time, or with a resource
editor at design time. But AFAIK their use in other applications is not
covered by the end user license agreement (EULA) shipped with the explorer.

Signature
----------------------------------------------------------------------
Thorsten Albers albers(a)uni-freiburg.de
----------------------------------------------------------------------
DanS - 18 Jun 2008 23:55 GMT
=?Utf-8?B?Q2hhbmdDaGlUaGVHcmFwaGljcw==?=
> Thorstten,
> Thank you for your comment.
[quoted text clipped - 28 lines]
>> > higher directory, etc in order to have consistant look as in
>> > Windows Would you tell me how I can access these windows icons?
Well, here's a bas module I use to get icons. It has 2 functions,
GetIcon, which returns an IPictureDisplay...
ex. - Picture1.Picture = GetIcon("c:\windows\",SHGFI_SMALLICON)
And GetIconIcon, which returns a handle to an icon...an hIcon.
In the code you will see a couple of API calls/Constants with a win(dot)
prefix, like win.SHFILEINFO. I use a Windows API typelib, so that is why
it is like that. To use straight API, you would need to add declarations
for each.
You can also pass a CSLID to retreive icons of 'virtual' folders, like
the Recycle Bin, Network Hood, etc.
This page a CSLID's for many shellspace objects...
http://www.webtropy.com/articles/art14-2.asp?Interop=Shell32
Note though, the better way to do this is to attach to the
SystemImageList.
Why ? For instance, if you call GetIcon on a directory filled with .jpg
images, you would be getting the same icon over and over again. You would
need to keep track of what you already have extracted and use the
existing ones. If not, you can quickly fill up an imagelist and use gobs
more memmory than necessary.
You can google for systemimagelist if you want. I'm sure there's an
example over at mvps.org.
Begin modIcons.bas----------------------------------------------
Public Type TypeIcon
cbSize As Long
picType As PictureTypeConstants
hIcon As Long
End Type
Public Type CLSID
ID(16) As Byte
End Type
Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll"
(pDicDesc As TypeIcon, _
riid As CLSID, ByVal fown As Long, lpUnk As Object) As Long
Public Function GetIcon(Filename As String, icon_size As Long) As
IPictureDisp
'Dim Index As Long
Dim hIcon As Long
'Dim item_num As Long
Dim icon_pic As IPictureDisp
Dim sh_info As win.SHFILEINFO
Call win.SHGetFileInfo(Filename, 0, sh_info, _
Len(sh_info), win.SHGFI_ICON + icon_size)
hIcon = sh_info.hIcon
Set icon_pic = IconToPicture(hIcon)
Set GetIcon = icon_pic
'win.DestroyIcon hIcon
End Function
Public Function GetIconIcon(Filename As String, icon_size As Long) As
Long
'Dim Index As Long
Dim hIcon As Long
'Dim item_num As Long
'Dim icon_pic As IPictureDisp
Dim sh_info As win.SHFILEINFO
Call win.SHGetFileInfo(Filename, 0, sh_info, _
Len(sh_info), win.SHGFI_ICON + icon_size)
hIcon = sh_info.hIcon
GetIconIcon = hIcon
End Function
Public Function IconToPicture(hIcon As Long) As IPictureDisp
Dim cls_id As CLSID
Dim hRes As Long
Dim new_icon As TypeIcon
Dim lpUnk As IUnknown
With new_icon
.cbSize = Len(new_icon)
.picType = vbPicTypeIcon
.hIcon = hIcon
End With
With cls_id
.ID(8) = &HC0
.ID(15) = &H46
End With
hRes = OleCreatePictureIndirect(new_icon, _
cls_id, 1, lpUnk)
If hRes = 0 Then Set IconToPicture = lpUnk
End Function
End modIcons.bas----------------------------------------------