VB高手进,VB怎样调用DLL中图片资源在Image控件中显示

来源:百度知道 编辑:UC知道 时间:2024/06/08 10:38:19
我只会调用资源图片在PictureBox控件中显示,无让其图片也在Image控件中显示。
这是我的调用代码:
Public Sub LoadResPicture(ByVal strDllName As String, ByVal intPicName As Integer)
Dim hDLL As Long
Dim hdcMemory, hLoadedbitmap, hOldBitmap As Long
Dim retVal As Long
Dim bmpInfo As BITMAP
hDLL = LoadLibrary(App.Path & "\" & strDllName)
hLoadedbitmap = LoadBitmap(hDLL, intPicName)
retVal = GetObject(hLoadedbitmap, Len(bmpInfo), bmpInfo)
hdcMemory = CreateCompatibleDC(frmForm.Picture1.hdc)
hOldBitmap = SelectObject(hdcMemory, hLoadedbitmap)
retVal = BitBlt(frmForm.Picture1.hdc, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, hdcMemory, 0, 0, SRCCOPY)
retVal = SelectObject(hdcMemory, hOldBitmap)
retVal = DeleteObject(hLoadedbitmap)
retVal = DeleteDC(hdcMemory)
FreeLibrary (hDLL)
End Sub

Public Sub LoadResPicture(ByVal strDllName As String, ByVal intPicName As Integer)
Dim hDLL As Long
Dim hdcMemory, hLoadedbitmap, hOldBitmap As Long
Dim retVal As Long
Dim bmpInfo As BITMAP
hDLL = LoadLibrary(App.Path & "\" & strDllName)
hLoadedbitmap = LoadBitmap(hDLL, intPicName)
retVal = GetObject(hLoadedbitmap, Len(bmpInfo), bmpInfo)
hdcMemory = CreateCompatibleDC(frmForm.Image1.hDC)
hOldBitmap = SelectObject(hdcMemory, hLoadedbitmap)
retVal = BitBlt(frmForm.Image1.hDC, 0, 0, bmpInfo.bmWidth, bmpInfo.bmHeight, hdcMemory, 0, 0, SRCCOPY)
retVal = SelectObject(hdcMemory, hOldBitmap)
retVal = DeleteObject(hLoadedbitmap)
retVal = DeleteDC(hdcMemory)
FreeLibrary (hDLL)
End Sub

试试这个语句行不行,

当图片加载在PictureBox中后..

image1.picture=picturebox.picture