跳到主要内容

VB6加载网络静态图片

·

说明:加载网络图片,无缓存加载,直接写加载到程序里面挺好用的,一个Image1和Command1

1、Image1图片控件

 1Private 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
 2Private Type TGUID
 3Data1 As Long
 4Data2 As Integer
 5Data3 As Integer
 6Data4(0 To 7) As Byte
 7End Type
 8Public Function LoadPicture(ByVal strFileName As String) As Picture '加载函数
 9Dim IID As TGUID
10With IID
11.Data1 = &H7BF80980
12.Data2 = &HBF32
13.Data3 = &H101A
14.Data4(0) = &H8B
15.Data4(1) = &HBB
16.Data4(2) = &H0
17.Data4(3) = &HAA
18.Data4(4) = &H0
19.Data4(5) = &H30
20.Data4(6) = &HC
21.Data4(7) = &HAB
22End With
23Print
24On Error GoTo LocalErr
25Print
26OleLoadPicturePath StrPtr(strFileName), 0&, 0&, 0&, IID, LoadPicture
27Exit Function
28LocalErr:
29Set LoadPicture = VB.LoadPicture(strFileName)
30Err.Clear
31End Function

2、Command1按钮

1Private Sub Command1_Click()
2Image1.Stretch = True '自动缩放
3Set Image1 = LoadPicture("http://www.hkfx.net/img/scan.gif")
4End Sub
白日映照满天星
作者
白日映照满天星
订阅我频道让你站在上帝角度观察视野! QQ:3925993 有尝解决技术问题【备注你的问题】 🐑

阅读量:评论:
赞赏码图