|
-
Sep 6th, 2001, 03:09 PM
#1
Thread Starter
Hyperactive Member
Load Icon From *.icl
Does anyone know an easy way to extract and load an icon from an icon library (.icl) by index number? For instance:
Picture1.Picture=LoadPicture ("C:\Windows\System\shell32.dll,4")
Of course the previous statement by itself returns 'path not found'
Thanks
-
Sep 6th, 2001, 07:33 PM
#2
Fanatic Member
You can use this to get them:
VB Code:
Public Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long
Public Declare Function ExtractIcon Lib "shell32" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
Public Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
'to get an icon out
Dim hIcon As Long
'remove the first icon in the file
hIcon = ExtractIcon(App.hInstance, "c:\someicons.icl", 0)
'draw it on the form
DrawIcon Me.hDC, 0, 0, hIcon
'destroy the icon (don't forget this)
DestroyIcon hIcon
If you give ExtractIcon a -1 for the nIconIndex param, you'll get back the number of icons inside the file (exe/dll/icl/ico). This example just gives you the handle and a way to draw them somewhere, but if you want an actual StdPicture object with the icon info, you can use the IconToPicture() function I posted in this thread.
http://www.vbforums.com/showthread.p...threadid=87710
Last edited by Kaverin; Sep 6th, 2001 at 07:36 PM.
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
-
Sep 7th, 2001, 07:24 AM
#3
Thread Starter
Hyperactive Member
Thank you, I'll try that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|