|
|
Title | Make an ActiveX control that asynchronously downloads images directly into a PictureBox |
Keywords | picture, PictureBox, download |
Categories | Graphics, Controls, Internet |
|
|
Use the AsyncRead method. When the AsyncReadComplete event indicates the download is complete, load the downloaded picture into the control's Picture property and raise an event so the main program knows the picture is ready.
|
|
Public Sub DownloadPicture(ByVal picture_url As String)
On Error GoTo DownloadPictureError
AsyncRead picture_url, vbAsyncTypePicture
Exit Sub
DownloadPictureError:
MsgBox "Error " & Err.Number & " starting download." & _
vbCrLf & Err.Description
Exit Sub
End Sub
Private Sub UserControl_AsyncReadComplete(AsyncProp As _
AsyncProperty)
On Error GoTo AsyncReadCompleteError
Set UserControl.Picture = AsyncProp.Value
RaiseEvent PictureReady
Exit Sub
AsyncReadCompleteError:
MsgBox "Error " & Err.Number & " reading result." & _
vbCrLf & Err.Description
Exit Sub
End Sub
|
|
|
|
|
|