|
-
Apr 28th, 2005, 08:53 AM
#1
Thread Starter
Fanatic Member
PictureBox
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
-
Apr 28th, 2005, 09:04 AM
#2
Re: PictureBox
Why don't you download the picture first?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Apr 28th, 2005, 09:05 AM
#3
Re: PictureBox
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
-
Apr 28th, 2005, 10:14 AM
#4
Thread Starter
Fanatic Member
Re: PictureBox
 Originally Posted by penagate
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
sorry but second last line is not working .....
-
Apr 29th, 2005, 03:13 AM
#5
Re: PictureBox
Sorry, it should be
Set DownloadImage = LoadPicture etc.
-
Apr 29th, 2005, 08:07 AM
#6
Thread Starter
Fanatic Member
Re: PictureBox
y we have to use "set"
..?
-
Apr 29th, 2005, 08:13 AM
#7
Re: PictureBox
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.
-
Apr 29th, 2005, 08:14 AM
#8
Re: PictureBox
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.
-
Apr 29th, 2005, 08:29 AM
#9
Need-a-life Member
Re: PictureBox
Set is used to set a reference to a control in the variable. This example will explain the difference
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".
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.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Apr 29th, 2005, 08:58 AM
#10
Thread Starter
Fanatic Member
Re: PictureBox
 Originally Posted by penagate
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.
Then y v not use it with
Picture1.picture= loadpicture("c:\something.bmp")
like
set picture1.picture=loadpicture("c:\something.bmp")
-
Apr 30th, 2005, 05:01 AM
#11
Thread Starter
Fanatic Member
Re: PictureBox
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
-
Apr 30th, 2005, 05:53 AM
#12
Junior Member
Re: PictureBox
why not?:
Picture1.picture = loadpicture("http://www.google.com.br/intl/pt-BR_br/images/logo.gif")
-
Apr 30th, 2005, 06:05 AM
#13
Thread Starter
Fanatic Member
Re: PictureBox
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")
____
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|