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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

download picture but do not save file? 2

Status
Not open for further replies.

idtstudios2

Programmer
Joined
Aug 12, 2005
Messages
35
Location
US
I need to be able to pull an image off of a server and load it into a picture box fairly quickly. I have figured out how to download the picture then load it. Now, my problem is that a lot of time is being wasted by saving the file. Is there anyway to pull an image off the internet and load it directly into a picturebox?

Thanks
 
Hi and welcome to Tek-Tips. To get the best from these forums, please read faq222-2244 first.

For this question, does the picture need to be in a picture box control, or could you display it in a webbrowser control? If so, add the Microsoft Internet Controls to your project, and use a WebBrowser control. Then in code use:

webbrowser1.Navigate "
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
And if you really want to load it directly in a picturebox, without saving to disk, see thread222-708828.
 
Thanks for the welcome. i've actually been on here for years but two days ago I submitted a question to the wrong forum by accident and then submitted the exact same question to the correct forum. I guess the site thought I was spamming because my account was froze.

As for the question. yeah, it needs to be in a picture box because it wil be played with a bit. I think the code from the thread Hypetia posted will work.

Thanks to both of you.
 
Hypetia,

I'm trying to use the following code and everything was going very well untill I tried to put it on a timer and load the picture every five seconds. Nothing happens after the first load. Is there anyway to fix this?


Option Explicit
Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpstrCLSID As Long, lpCLSID As Any) As Long
Private Declare Function OleLoadPicturePath Lib "oleaut32" (ByVal szURLorPath As Long, ByVal punkCaller As Long, ByVal dwReserved As Long, ByVal clrReserved As OLE_COLOR, ByRef riid As Any, ByRef ppvRet As Any) As Long

Public Function LoadPictureFromURL(ByVal url As String) As Picture
Dim IPic(15) As Byte 'holds the IPicture interface
CLSIDFromString StrPtr("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"), IPic(0)
OleLoadPicturePath StrPtr(url), 0&, 0&, 0&, IPic(0), LoadPictureFromURL
End Function


Private Sub Timer1_Timer()
Picture1.Picture = LoadPictureFromURL("End Sub

the picture i'm using is just a friends webcam so I can see if the picture actually changes.
 
oops, sorry. forgot about redraw. works now, thanks for the great code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top