Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load picturebox with http server gif with IC control 1

Status
Not open for further replies.

cc4mail

Technical User
Jan 8, 2002
47
US
I'm trying to import HTTP gif's to a local VB picturebox
via execure GET or OpenURL with no success:

graphURL = "
Inet1.AccessType = icUseDefault
imgGraph.picture = Inet1.OpenURL(graphURL)

or

Inet1.Execute graphURL, "GET", imgGraph.Picture

what is the right way?

Thanks
 
JohnYingling is right. The practical way to do this to write the gif to disk and load it into the image control:
Code:
Dim b() As Byte, graphURL As String
graphURL = "[URL unfurl="true"]http://chart.yahoo.com/c/1y/e/e.gif"[/URL]
Inet1.AccessType = icUseDefault
b() = Inet1.OpenURL(graphURL, icByteArray)
Open "tmp.gif" For Binary Access Write As #1
Put #1, , b()
Close #1
imgGraph.Picture = LoadPicture("tmp.gif")
Kill "tmp.gif"
Really... this is probably just as convenient as any other method.
VCA.gif
 
Thanks John & alt255,

Sometimes something as simple as importing a graphic to an application brings development to a halt.

Your effort is appreciated!

Craig

craig@perfectform.com
 
Check out thread222-93819, Here's a function that returns a Picture object given a URL of an image. Note that it happens to exactly match JohnYingling's recommendations, and bears a passing resemblance to Alt255's code. It is a slightly modified version of code I orginally presented in thread222-93819:
[tt]
Option Explicit

Private Declare Function GetTempPath Lib "kernel32" _
Alias "GetTempPathA" (ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long

Private Declare Function GetTempFileName Lib "kernel32" _
Alias "GetTempFileNameA" (ByVal lpszPath As String, _
ByVal lpPrefixString As String, ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long





Public Function GetPicFromHTTP(strURL As String) As StdPicture
Dim strTempPath As String * 512
Dim strTempFileBuff As String * 576
Dim strTempFile As String

Dim hFile As Long

Dim result As Long

Dim bytearray() As Byte
Dim strData As String

' Generate unique temporary filename
result = GetTempPath(512, strTempPath)
GetTempFileName strTempPath, "VBT", 0, strTempFileBuff
strTempFile = Left$(strTempFileBuff, InStr(strTempFileBuff, vbNullChar) - 4) + Right$(strURL, 3)

bytearray() = Inet1.OpenURL(strURL, icByteArray)
'Wait for download complete
Do Until Inet1.StillExecuting = False ' WAIT Downloading..
DoEvents
Loop

hFile = FreeFile
Beep
Open strTempFile For Binary As hFile
Put hFile, , bytearray
Close hFile

Set GetPicFromHTTP = LoadPicture(strTempFile)
Kill strTempFile
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top