Results 1 to 8 of 8

Thread: bitmap in a dll

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    24

    Question bitmap in a dll

    How do I extract a bitmap in a .dll file and display it in a picture box? I can extract text but have been unable to do anything with a bitmap.

  2. #2
    Megatron
    Guest
    Which kind of DLL is it? ActiveX? or Standard?

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    The ExtractIcon function retrieves the handle of an icon from the specified executable file, dynamic-link library (DLL), or icon file.
    Example

    VB Code:
    1. 'This project needs a PictureBox, called 'Picture1'
    2.  
    3. 'In general section
    4. Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    5. Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    6. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    7.  
    8. Private Sub Form_Load()
    9.  
    10. Dim Path As String, strSave As String
    11. 'Create a buffer string
    12. strSave = String(200, Chr$(0))
    13. 'Get the windows directory and append '\REGEdit.exe' to it
    14. Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave))) + "\REGEdit.exe"
    15. 'No pictures
    16. Picture1.Picture = LoadPicture()
    17. 'Set graphicmode to 'persistent
    18. Picture1.AutoRedraw = True
    19. 'Extract the icon from REGEdit
    20. return1& = ExtractIcon(Me.hWnd, Path, 2)
    21. 'Draw the icon on the form
    22. return2& = DrawIcon(Picture1.hdc, 0, 0, return1&)
    23.    
    24. End Sub

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    24

    for megatron

    it is a standard .dll file. And how do I specify which .dll I extract the bitmap from?

  5. #5
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    in the
    VB Code:
    1. Path = ....
    example I gave above

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    24
    so i changed the path to the location of my dll, now no picture will show up.

  7. #7
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Did you change the icon index in ExtractIcon...

    In the example it's 2, that will get the 3rd icon. if you only have 1 icon, set it to 0.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Oct 2001
    Posts
    24
    ok, it works now, thanks. How can I apply this to bitmaps though...and, is there any way to load a new icon and replace the current one?

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