Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / June 2008



Tip: Looking for answers? Try searching our database.

Icon in Windows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ChangChiTheGraphics - 14 Jun 2008 20:24 GMT
I need to access the icons that window uses for my file management dialog,
similar to OPENFILENAME dialog.

For example the icon for directory, icon for directory, icon for backup to
higher directory, etc in order to have consistant look as in Windows

Would you tell me how I can access these windows icons?

Thank you,
ChangChiThegraphics
philippe - 14 Jun 2008 20:48 GMT
> I need to access the icons that window uses for my file management dialog,
> similar to OPENFILENAME dialog.
[quoted text clipped - 6 lines]
> Thank you,
> ChangChiThegraphics

It's a usenet FAQ.
(mainly comp.os.ms-windows.programmer.win32...)
ChangChiTheGraphics - 15 Jun 2008 08:22 GMT
> > I need to access the icons that window uses for my file management dialog,
> > similar to OPENFILENAME dialog.
[quoted text clipped - 9 lines]
> It's a usenet FAQ.
> (mainly comp.os.ms-windows.programmer.win32...)

Would you kindly tell me a little more how I can get to this location?
I tried windows APi, Windows APIgraphics, windows32
I tried "comp.os.ms-windows.programmer.win32..." address and It says it
cannot find the address.

Please understand that some of us are not as good as you are about these
locations.

Thank you very much, for your generousity,
ChangChiThe Graphics
philippe - 15 Jun 2008 11:02 GMT
> Would you kindly tell me a little more how I can get to this location?
> I tried windows APi, Windows APIgraphics, windows32
[quoted text clipped - 3 lines]
> Please understand that some of us are not as good as you are about these
> locations.

Of course, if you use MS news server, you won't find usenet newsgroups  !
Use any free news server like
news://194.177.96.26/comp.os.ms-windows.programmer.win32
or http://groups.google.com/ ...
Thorsten Albers - 15 Jun 2008 17:37 GMT
> It's a usenet FAQ.
> (mainly comp.os.ms-windows.programmer.win32...)

I have participated now for several years in various newsgroups conerning
application development. IMHO this question is neither a frequently nor an
often asked one. Maybe you mixed it up with the question about how to get
the icon for a file associated with a certain application which indeed is a
FAQ.

Signature

----------------------------------------------------------------------
Thorsten Albers                               albers(a)uni-freiburg.de
----------------------------------------------------------------------

Thorsten Albers - 16 Jun 2008 00:02 GMT
Thorsten Albers <albersRE@MOVEuni-freiburg.de> schrieb im Beitrag
<01c8cf06$3b7d9b20$af01a8c0@Router>...
> > It's a usenet FAQ.
> > (mainly comp.os.ms-windows.programmer.win32...)
[quoted text clipped - 4 lines]
> the icon for a file associated with a certain application which indeed is a
> FAQ.

I have to correct myself: 'ChangChiThegraphics' obviously also wants to
know how to get the icon of the application associated with certain file
types...

Signature

----------------------------------------------------------------------
Thorsten Albers                               albers(a)uni-freiburg.de
----------------------------------------------------------------------

Karl E. Peterson - 16 Jun 2008 19:20 GMT
>> I need to access the icons that window uses for my file management dialog,
>> similar to OPENFILENAME dialog.
[quoted text clipped - 6 lines]
> It's a usenet FAQ.
> (mainly comp.os.ms-windows.programmer.win32...)

What planet are you from, anyway?  That's not an Earth FAQ, by any measure.
Signature

.NET: It's About Trust!
http://vfred.mvps.org

Thorsten Albers - 15 Jun 2008 12:45 GMT
ChangChiTheGraphics <ChangChiTheGraphics@discussions.microsoft.com> schrieb
im Beitrag <01E0085F-5911-4582-9253-5F766B58009E@microsoft.com>...
> I need to access the icons that window uses for my file management dialog,
> similar to OPENFILENAME dialog.
> For example the icon for directory, icon for directory, icon for backup to
> higher directory, etc in order to have consistant look as in Windows
> Would you tell me how I can access these windows icons?

See the Windows API procedure SHGetFileInfo() with
SHGFI_ICON/SHGFI_ICONINDEX.

Signature

----------------------------------------------------------------------
Thorsten Albers                               albers(a)uni-freiburg.de
----------------------------------------------------------------------

ChangChiTheGraphics - 15 Jun 2008 19:17 GMT
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----------------------------------------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.