I m using PictureBox Control
and want to load picture from internet address.
http://www.google.com.br/intl/pt-BR_br/images/logo.gif
how to load it .....???
** dont advice me to use Web Browser Control :)
thx in Advance
Printable View
I m using PictureBox Control
and want to load picture from internet address.
http://www.google.com.br/intl/pt-BR_br/images/logo.gif
how to load it .....???
** dont advice me to use Web Browser Control :)
thx in Advance
Why don't you download the picture first?
Use an API to download the file and then LoadPicture display it in the PictureBox.
Or use a function returning an StdPicture type as I have done below.
Code:Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) _
As Long
Private Function DownloadImage(ByVal pstrImageURL as String, ByVal pstrLocalFile As String) as StdPicture
Dim lngRetVal As Long
URLDownloadToFile 0&, pstrImageURL, pstrLocalFile, 0&, 0&
If (Not lngRetVal) Then
DownloadImage = LoadPicture(pstrLocalFile)
Else
MsgBox "The remote file could not be downloaded"
End If
End Function
' To load into a picturebox use this code
Picture1.Image = DownloadImage([URL], [Tempfilename])
' after that you can kill the local file if you wish
Quote:
Originally Posted by penagate
sorry but second last line is not working .....
Sorry, it should be
Set DownloadImage = LoadPicture etc.
y we have to use "set"
..?
Set is used when assigning an object reference to a variable. In this case we need to use Set when returning the function as it is an object reference. If it was just a string or long integer then there would be no need because it would just be a straight value.
Generally, when you use Set to assign an object reference to a variable, no copy of the object is created for that variable. The Dim, Private, Public, or ReDim statements only declare a variable that refers to an object. No actual object is referred to until you use the Set statement to assign a specific object.
Set is used to set a reference to a control in the variable. This example will explain the difference
By the way, in .Net there's no default property... so the Set keyword does not exist because you don't have to differenciate one way or the other.VB Code:
Dim myVar As Variant myVar = Text1 'The line above will save the Text1.Text contents in the variable. This is 'because Text is the default property. Set myVar = Text1 'The line above will save the reference to the TextBox into the variable. You 'could use the Text, Tag, etc. later (by doing myVar.Text, myVar.Tag, etc). 'This is because myVar is a "pointer to the object".
Quote:
Originally Posted by penagate
Then y v not use it with
Picture1.picture= loadpicture("c:\something.bmp")
like
set picture1.picture=loadpicture("c:\something.bmp")
because as i know
loadpicture function does not point towards path of the picture
but instead make copy of picture in memory ...
that is why i asked about "SET" ... with
picture1.picture = etc
why not?:
Picture1.picture = loadpicture("http://www.google.com.br/intl/pt-BR_br/images/logo.gif")
OOPs i didn't understand it ..
I was asking about usage of "Set"
that y we do not use it with loadpicture function because it also specifes to object of picture..
_____
"SET" | picture1.picture=loadpicture("Any Path")
____