Click here to Skip to main content
6,595,854 members and growing! (17,226 online)
Email Password   helpLost your password?
Languages » VBScript » General     Intermediate

Loading Bitmap pictures from external DLL on VB 6.0

By Willian.BR

Loading Bitmap pictures from external DLL on VB 6.0 - (run-time).
VBScript, VB 6Win2K, WinXP, Win2003, Dev
Posted:4 May 2004
Views:37,093
Bookmarked:10 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
7 votes for this article.
Popularity: 3.28 Rating: 3.88 out of 5

1

2
3 votes, 42.9%
3
1 vote, 14.3%
4
3 votes, 42.9%
5

Bitmap ID 131 fromm Shell32.dll

Bitmap ID 130 fromm Shell32.dll

Bitmap ID 132 fromm Shell32.dll

Introduction

With this sample, you can use Bitmap stored on external file (DLL). Then you can use bitmaps from Windows system or you create your bitmap repository inside VB DLL. It's useful to create bitmap library without keep a lot of files on hard disk. On that case, anyone can erase the pictures.

Module Code

Type GUID
     Data1 As Long
     Data2 As Integer
     Data3 As Integer
     Data4(7) As Byte
End Type

Type PicBmp
     Size As Long
     Type As Long
     hBmp As Long
     hPal As Long
     Reserved As Long
End Type

Declare Function OleCreatePictureIndirect Lib "olepro32.dll" _
           (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnHandle As Long, _
           IPic As IPicture) As Long
Declare Function LoadBitmap Lib "user32" Alias "LoadBitmapA" _
               (ByVal hInstance As Long, ByVal lpBitmapID As Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
               (ByVal lpLibFileName As String) As Long
Declare Function FreeLibrary Lib "kernel32" _
               (ByVal hLibModule As Long) As Long

'Exemplo em SHELL32.DLL com ID 131               

Public Function LoadPictureDLL(sResourceFileName As String, _
                        ByVal lResourceId As Long) As Picture
     Dim hInst As Long
     Dim hBmp  As Long
     Dim Pic As PicBmp
     
     Dim IPic As IPicture
     Dim IID_IDispatch As GUID
     Dim lRC As Long
     
     
     hInst = LoadLibrary(sResourceFileName)
     If hInst <> 0 Then
          hBmp = LoadBitmap(hInst, lResourceId)
          If hBmp <> 0 Then
               IID_IDispatch.Data1 = &H20400
               IID_IDispatch.Data4(0) = &HC0
               IID_IDispatch.Data4(7) = &H46
               Pic.Size = Len(Pic)
               Pic.Type = vbPicTypeBitmap
               Pic.hBmp = hBmp
               Pic.hPal = 0
               lRC = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic)
               If lRC = 0 Then
                    Set LoadPictureDLL = IPic
                    Set IPic = Nothing
               Else
                    Call DeleteObject(hBmp)
               End If
          End If
          FreeLibrary (hInst)
          hInst = 0
     End If
End Function

Sample

The sample application has a better code sample. Download it to get more information.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Willian.BR


Member
Developer:
- MS VB
- C/C++/C#
- VBScript
- JScript
- Clipper
- Cobol
- Natural
- Pascal

Occupation: Web Developer
Location: Brazil Brazil

Other popular VBScript articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
  (Refresh) 
-- There are no messages in this forum --

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 4 May 2004
Editor: Smitha Vijayan
Copyright 2004 by Willian.BR
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project