望高手指点,指点!VB的picturebox如何转载网页的图片

canic 2006-01-07 10:08:16
我现在用webbroswer打开一个页面,里面有一个<img scr="http://www.knowsky.com/inc/code.asp"></img>
。只要求用vb的PictureBox来转载这一个图片?有什么号方法,请高手指点,指点啊。
...全文
170 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
canic 2006-01-07
  • 打赏
  • 举报
回复
这当然要求自动运行。
因为我的程序是每隔一段时间就刷新一次页面,因为<img>标记里面的图片每次都在变的。
TechnoFantasy 2006-01-07
  • 打赏
  • 举报
回复
保存到本地文件再打开
rainstormmaster 2006-01-07
  • 打赏
  • 举报
回复
上面程序的要点是利用IPersistStream接口和IStream接口实现了byte数组和stdpicture对象的转换,避免了临时文件的生成
rainstormmaster 2006-01-07
  • 打赏
  • 举报
回复
'利用IPersistStream接口和IStream接口实现
'可以从http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip下载文件,下载后解压,并注册、引用olelib.tlb
'窗体上1个inet控件(工程 部件 找到Microsoft Internet Transfer Control 6.0,选中它,确定),一个timer控件,一个picturebox
Option Explicit
Const GMEM_MOVEABLE = &H2
Const GMEM_ZEROINIT = &H40
Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Private Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long

Const PictureID = &H746C&
Private Type PictureHeader
Magic As Long
Size As Long
End Type


Public Sub Picture2Array(ByVal oObj As StdPicture, aBytes() As Byte)
Dim oIPS As IPersistStream
Dim oStream As IStream
Dim hGlobal As Long
Dim lPtr As Long
Dim lSize As Long
Dim Hdr As PictureHeader
Set oIPS = oObj
Set oStream = CreateStreamOnHGlobal(0, True)
oIPS.Save oStream, True
hGlobal = GetHGlobalFromStream(oStream)
lSize = GlobalSize(hGlobal)
lPtr = GlobalLock(hGlobal)
If lPtr Then
lSize = lSize - Len(Hdr)
ReDim aBytes(0 To lSize - 1)
MoveMemory aBytes(0), ByVal lPtr + Len(Hdr), lSize
End If
GlobalUnlock hGlobal
Set oStream = Nothing

End Sub


Public Function Array2Picture(aBytes() As Byte) As StdPicture
Dim oIPS As IPersistStream
Dim oStream As IStream
Dim hGlobal As Long
Dim lPtr As Long
Dim lSize As Long
Dim Hdr As PictureHeader
Set Array2Picture = New StdPicture
Set oIPS = Array2Picture
lSize = UBound(aBytes) - LBound(aBytes) + 1
hGlobal = GlobalAlloc(GHND, lSize + Len(Hdr))
If hGlobal Then
lPtr = GlobalLock(hGlobal)
Hdr.Magic = PictureID
Hdr.Size = lSize
MoveMemory ByVal lPtr, Hdr, Len(Hdr)
MoveMemory ByVal lPtr + Len(Hdr), aBytes(0), lSize
GlobalUnlock hGlobal
Set oStream = CreateStreamOnHGlobal(hGlobal, True)
oIPS.Load oStream
Set oStream = Nothing
End If
End Function

Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Dim buff() As Byte
buff = Inet1.OpenURL("http://www.knowsky.com/inc/code.asp", icByteArray)
Set Picture1.Picture = Array2Picture(buff)
End Sub

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧