|
|
Title | Download a picture from the Web and display it |
Keywords | download, Web, picture, URL, Inet, Internet Transfer Control |
Categories | Controls |
|
|
Use the Internet Transfer Control's OpenURL method to fetch the picture into a byte array. Use Put to write the bytes into a temporary file. Then use LoadPicture to load the results.
|
|
' Download the picture and display it.
Private Sub cmdGo_Click()
Dim bytes() As Byte
Dim fnum As Integer
' Provide feedback.
cmdGo.Enabled = False
txtFile.Enabled = False
txtURL.Enabled = False
picResult.Picture = Nothing
Screen.MousePointer = vbHourglass
DoEvents
' Get the file.
bytes() = inetDownload.OpenURL( _
txtURL.Text, icByteArray)
' Save the file.
fnum = FreeFile
Open txtFile.Text For Binary Access Write As #fnum
Put #fnum, , bytes()
Close #fnum
' Display the file.
picResult.Picture = LoadPicture(txtFile.Text)
If ScaleHeight < picResult.Top + picResult.Height + 120 _
Then
Height = picResult.Top + picResult.Height + _
120 + Height - ScaleHeight
End If
' Reenable controls.
cmdGo.Enabled = True
txtFile.Enabled = True
txtURL.Enabled = True
Screen.MousePointer = vbDefault
Beep
End Sub
|
|
 |
|
|