Click to See Complete Forum and Search --> : Get bitmap resource from DLL


October 29th, 1999, 10:25 AM
Hi,

I use this subroutine to get a bitmap resource from a DLL. Before I built an only-resource DLL.


private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
(byval lpLibFileName as string) as Long

private Declare Function LoadBitmap Lib "user32" Alias "LoadBitmapA" _
(byval hInstance as Long, byval lpBitmapName as Long) as Long

Sub GetBitmap(sDllName as string, oPic1 as Object, sBMPName as Long)
Dim tmpDC as Long
Dim objhandle as Long, oldobject as Long
Dim Ret as Long
Dim bmpInfo as BITMAP
Dim lhInst as Long

lhInst = LoadLibrary(sDllName)

If lhInst = 0 then
' error
Exit Sub
End If

oPic1.Picture = LoadPicture()

' Create a memory device context compatible with
' the picture control and load the bitmap.
tmpDC = CreateCompatibleDC(oPic1.hdc)
objhandle = LoadBitmap(lhInst, CLng(sBMPName))
...

End Sub




Second parameter of LoadBitmap function is a long type!
In VC I used LoadBitmap function in this mode :

hBitmap=LoadBitmap(hMod, MAKEINTRESOURCE(resid))

How can I convert an long value to a resource type compatible with the LoadBitmap function in Visual Basic environment ??

Early Thanks !