|
-
Apr 8th, 2005, 04:32 AM
#1
Thread Starter
New Member
Bitmaps from DLL
Hi,
I saw thread regarding Bitmaps In DLL.But i face following problem...
I have the dll which contains only bitmaps, i should not include any class or functions other than that resource file.
So how to retrive the images from DLL now,
I am using the following code, but it returns long data type..no idea how to proceed next..
"LoadBitmap" is API
Dim hInst As Long, lResult As Long
Dim Img As Image
Dim resString As String * 255
IntLocation = 301
hInst = LoadLibrary("MyDLL.dll")
lResult = LoadBitmap(hInst, "301")
lResult = StrPtr(lResult)
Picture1.Picture = lResult
Pls Help me out...
Thanks
Harish
-
Apr 8th, 2005, 08:23 AM
#2
Fanatic Member
Re: Bitmaps from DLL
Try this:
VB Code:
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type PicBmp
Size As Long
Type As Long
hBmp As Long
hPal As Long
Reserved As Long
End Type
Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" _
(PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnHandle As Long, _
IPic As IPicture) As Long
Private Declare Function LoadBitmap Lib "user32" Alias "LoadBitmapA" _
(ByVal hInstance As Long, ByVal lpBitmapID As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(ByVal lpLibFileName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" _
(ByVal hLibModule As Long) As Long
'Exemplo em SHELL32.DLL com ID 131
Private 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
Private Sub Command1_Click()
Set Picture1.Picture = LoadPictureDLL("cards.dll", 1)
End Sub
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
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
|