vb窗体上如何调用网上的图片?
vb可以通过Image1.Picture=LoadPicture(App.Path&"\img\2011.jpg")调用程序安装目录中的图片。如果想调用网上的图片呢,比如...
vb可以通过Image1.Picture = LoadPicture(App.Path & "\img\2011.jpg")调用程序安装目录中的图片。如果想调用网上的图片呢,比如调用这个图片:http://www.baidu.com/img/baidu_logo.gif,如何实现呢?请给出代码
展开
展开全部
'用来下载文件的API函数
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Form_Load()
'将图片下载到本地硬盘
URLDownloadToFile 0, "http://www.baidu.com/img/baidu_logo.gif", "c:\temp.jpg", 0, 0
'设置image控件的picture属性显示该图片
Image1.Picture = LoadPicture("c:\temp.jpg")
'删除临时文件
Kill "c:\temp.jpg"
End Sub
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Form_Load()
'将图片下载到本地硬盘
URLDownloadToFile 0, "http://www.baidu.com/img/baidu_logo.gif", "c:\temp.jpg", 0, 0
'设置image控件的picture属性显示该图片
Image1.Picture = LoadPicture("c:\temp.jpg")
'删除临时文件
Kill "c:\temp.jpg"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询