Private Declare Function oleLoadPicturePath lib "oleaut32.dll" (ByVal szURLorPath As Long,ByVal punkCaller As Long,ByVal DWReserved As Long,ByVal clrReserved As olE_color,ByRef riID As TGUID,ByRef ppvRet As IPicture) As Long
Private Type TGUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
'加载函数
Public Function LoadPicture(ByVal strfilename As String) As Picture
Dim IID As TGUID
With IID
.Data1 = &H7BF80980
.Data2 = &HBF32
.Data3 = &H101A
.Data4(0) = &H8B
.Data4(1) = &HBB
.Data4(2) = &H0
.Data4(3) = &HAA
.Data4(4) = &H0
.Data4(5) = &H30
.Data4(6) = &HC
.Data4(7) = &HAB
End With
On Error GoTo LocalErr
oleLoadPicturePath StrPtr(strfilename),0&,IID,LoadPicture
Exit Function
LocalErr:
Set LoadPicture = VB.LoadPicture(strfilename)
Err.Clear
End Function
使用方法:
Set 控件名.Pictue = LoadPicture(图片网络路径)
上面这个是无缓存加载的
下面这个是下载到硬盘后加载的
去除加载部分 就是下载了
Private Sub Command1_Click()
Dim b() As Byte
Dim strURL As String
strURL = "http://www.baidu.com/img/baidu_sylogo1.gif" b() = Inet2.OpenURL(strURL,icByteArray) Open "c:/csdn.jpg" For Binary Access _ Write As #1 Put #1,b() Close #1 Image1.Picture = LoadPicture("c:/csdn.jpg") End Sub
以上是内存溢出为你收集整理的vb picturebox 加载网络图片的两种方法,分无缓存加载和有缓存加载全部内容,希望文章能够帮你解决vb picturebox 加载网络图片的两种方法,分无缓存加载和有缓存加载所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)