|
-
June 15th, 2001, 09:20 AM
#1
Get bitmap resource from DLL
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 !
-
June 15th, 2001, 10:14 AM
#2
Re: Get bitmap resource from DLL
The MAKEINTRESOURCE returns a long value with the value passed in in the bottom 16 bits and the top 16 bits empty.
This can be done in VB by the following:
public Function vbMakeIntResource(byval nRes as Integer) as Long
vbMakeIntResource = CLng(nRes)
End Function
HTH,
D.
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
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
|