Results 1 to 3 of 3

Thread: [2005] Display image from axwebbrowser in picture box

  1. #1

    Thread Starter
    Lively Member RickyH's Avatar
    Join Date
    Oct 2007
    Posts
    92

    [2005] Display image from axwebbrowser in picture box

    i want to display picture from website in a text box. However, this picture already shows up in the browser prior to my wanting to display it in a picturebox. My problem is, i dont want my app to download the image file a second time as many images are very large.

    Is there anyway to dynamically grab the reference to the file from the axwebbrowser control's contents?

    Currently i have no problem displaying the picture in the picbox using the following code:

    vb Code:
    1. Friend Sub ImageDisplayInPictureBox(ByRef myPicturebox As PictureBox, ByVal strUrl As String)
    2.         myPicturebox.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(strUrl)))
    3. End Sub

    I would imagine I would need to reference the axwebbrowser controls html doc and somehow find the substring of the picturebox, but how to display data in a seperate container outside of the web browser?

    Any help would be appreciated.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [2005] Display image from axwebbrowser in picture box

    See this link for code on how to display an image in a picturebox simply by specifying the URL of the image

    http://www.vbforums.com/showthread.php?t=387841

    You could use the webclient.downloadstring() method to grab the source code of a given URL website, and then parse the image link out of there. However there is no way I know of to intercept the image as the browser loads it and not display it in the browser, but only display it in a picturebox.

    I would think the image would be cached in the temporary internet files though, perhaps you could get it that way..

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] Display image from axwebbrowser in picture box

    It's getting tedious but you could do as kleinma says, then edit the HTML code to remove the image, then load the new HTML into your Web browser.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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