Results 1 to 13 of 13

Thread: PictureBox

  1. #1

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    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

  2. #2
    vbuggy krtxmrtz's Avatar
    Join Date
    May 2002
    Location
    In a probability cloud
    Posts
    5,573

    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)

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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

  4. #4

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: PictureBox

    Quote 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 .....

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: PictureBox

    Sorry, it should be
    Set DownloadImage = LoadPicture etc.

  6. #6

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: PictureBox

    y we have to use "set"

    ..?

  7. #7
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808

    Re: PictureBox

    Set is used to set a reference to a control in the variable. This example will explain the difference

    VB Code:
    1. Dim myVar As Variant
    2.  
    3. myVar = Text1
    4. 'The line above will save the Text1.Text contents in the variable. This is
    5. 'because Text is the default property.
    6.  
    7. Set myVar = Text1
    8. 'The line above will save the reference to the TextBox into the variable. You
    9. 'could use the Text, Tag, etc. later (by doing myVar.Text, myVar.Tag, etc).
    10. '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.

  10. #10

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    Re: PictureBox

    Quote 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")

  11. #11

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    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

  12. #12
    Junior Member
    Join Date
    Jan 2005
    Posts
    26

    Re: PictureBox

    why not?:

    Picture1.picture = loadpicture("http://www.google.com.br/intl/pt-BR_br/images/logo.gif")

  13. #13

    Thread Starter
    Fanatic Member vbPoet's Avatar
    Join Date
    Feb 2005
    Location
    Searching ..
    Posts
    669

    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
  •  



Click Here to Expand Forum to Full Width