Results 1 to 3 of 3

Thread: Load Icon From *.icl

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Posts
    414

    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

  2. #2
    Fanatic Member Kaverin's Avatar
    Join Date
    Oct 2000
    Posts
    930
    You can use this to get them:
    VB Code:
    1. Public Declare Function DrawIcon Lib "user32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal hIcon As Long) As Long
    2. Public Declare Function ExtractIcon Lib "shell32" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    3. Public Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
    4.  
    5. 'to get an icon out
    6. Dim hIcon As Long
    7. 'remove the first icon in the file
    8. hIcon = ExtractIcon(App.hInstance, "c:\someicons.icl", 0)
    9. 'draw it on the form
    10. DrawIcon Me.hDC, 0, 0, hIcon
    11. 'destroy the icon (don't forget this)
    12. 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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Posts
    414
    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
  •  



Click Here to Expand Forum to Full Width