Results 1 to 10 of 10

Thread: [RESOLVED] display image from webbrowser in a picture box?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Resolved [RESOLVED] display image from webbrowser in a picture box?

    How can i do the above ^^

    Thanks

    edit: and oh yeh not just a link of an image i mean from a tagid like :

    Picture1.Image = WebBrowser1.Document.All.verificationImage

    If anyone knows how to do this that would be great thanks
    Last edited by Skunk1311; Dec 21st, 2008 at 09:01 AM.

  2. #2
    Addicted Member
    Join Date
    Apr 2008
    Posts
    198

    Re: display image from webbrowser in a picture box?

    one way to do that is to open ur webbroswer code ("the html") like txt file. to look at the picture url in that txt then
    download it to temp folder using DOWNLOADURLTOFILE. u can found it in KERNAL32.DLL. after u have the pic in the temp folder open it using pic.picture =loadpicture ("path")
    IT CTO & System Administrator.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Re: display image from webbrowser in a picture box?

    The picture URL is encrypted that is why i need to open it from its html tag

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: display image from webbrowser in a picture box?

    If you know the name of the image and it's complete URL then you can do something like below. Put a Inet control on your Form.
    Code:
    Private Sub Command1_Click()
     Dim s1() As Byte
      
     s1() = Inet1.OpenURL("http://www.website.com/image.jpg", icByteArray)
     
     Open App.Path & "\image.jpg" For Binary As #1
     Put #1, 1, s3
     Close #1
    
     Picture1.Picture = LoadPicture(App.Path & "\image.jpg")
    End Sub
    If you only know the name of the image but you do not know it's URL then you need to do something like this:
    Code:
    Private Sub Command2_Click()
     Dim s1 As String
     Dim s2 As String
     Dim s3() As Byte
    
     s1 = Inet1.OpenURL("http://www.website.com/")
     
     q1 = InStr(1, s1, "image.jpg")
     
     If q1 > 0 Then
       For i = q1 To 1 Step -1
         If Mid(s1, i, 7) = "http://" Then
           q1 = q1 + Len("image.jpg")
           s2 = Mid(s1, i, q1 - i)
           Exit For
         End If
       Next i
     End If
      
     s3() = Inet1.OpenURL(s2, icByteArray)
     
     Open App.Path & "\image.jpg" For Binary As #1
     Put #1, 1, s3
     Close #1
    
     Picture1.Picture = LoadPicture(App.Path & "\image.jpg")
    End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Re: display image from webbrowser in a picture box?

    Hi, thanks for your efforts

    But no, the picture does not have a specific name like image1.jpg , ill post the complete html code that covers the image and see if anyone can come up with anything.

    vb Code:
    1. <div id="verificationImage" name="verificationImage"  style="padding-right: 5px">
    2.  
    3.                                     <a href="#" onclick="document.verificationImg.src='/cimg?c=rxgb6NDa3Tun5uTk2xhVliD0PIKT9ZYixzPpVlG5LdNwAO3W8TG5IGlvckpABlI5XRjuP9QrgN0=&'+Math.random();return false"><img name="verificationImg" src="/cimg?c=rxgb6NDa3Tun5uTk2xhVliD0PIKT9ZYixzPpVlG5LdNwAO3W8TG5IGlvckpABlI5XRjuP9QrgN0=" align="texttop" border="0"></a>
    4.                                 </div>
    5.                             </td>
    6.                             <td style="vertical-align: bottom">
    7.                                 <div class="formFieldInfo">
    8.                                     <a href="#" onclick="document.verificationImg.src='/cimg?c=rxgb6NDa3Tun5uTk2xhVliD0PIKT9ZYixzPpVlG5LdNwAO3W8TG5IGlvckpABlI5XRjuP9QrgN0=&'+Math.random();return false">New image</a>
    9.                                 </div>
    10.                             </td>
    11.  
    12.                         </tr>
    13.                     </table>
    14.                 </td>
    15.             </tr>
    16.             <tr>
    17.                 <td class="loginFormLabel">
    18.                     <div id="verificationLabel" name="verificationLabel">
    19.                         <label for="verificationResponse">Word Verification:</label>
    20.  
    21.                     </div>
    22.                 </td>
    23.                 <td>
    24.                     <input id="verificationResponse" size="40" name="response" maxlength="10" value="" type="text">
    25.                     <div class="formFieldInfo">
    26.                         Enter the text in the image
    27.                     </div>
    28.                     <input type="hidden" name="challenge" value="rxgb6NDa3Tun5uTk2xhVliD0PIKT9ZYixzPpVlG5LdNwAO3W8TG5IGlvckpABlI5XRjuP9QrgN0="/>
    29.                 </td>
    30.  
    31.             </tr>
    32.             <tr>

  6. #6
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: display image from webbrowser in a picture box?

    Drop a picturebox control to your form. This code will force the webbrowser control to copy the image content to the clipboard, that you can easily paste by using the Clipboard object of vb6

    vb Code:
    1. Dim O as Object
    2.  
    3. Set O = WebBrowser1.Document.body.createControlRange()
    4. Call O.Add(WebBrowser1.Document.All("verificationImg"))
    5. Call O.execCommand("Copy")
    6.  
    7. Set Picture1.Picture = Clipboard.GetData

    Now what do you want to do with this (verification) image?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    177

    Re: display image from webbrowser in a picture box?

    Quote Originally Posted by Jim Davis
    Drop a picturebox control to your form. This code will force the webbrowser control to copy the image content to the clipboard, that you can easily paste by using the Clipboard object of vb6

    vb Code:
    1. Dim O as Object
    2.  
    3. Set O = WebBrowser1.Document.body.createControlRange()
    4. Call O.Add(WebBrowser1.Document.All("verificationImg"))
    5. Call O.execCommand("Copy")
    6.  
    7. Set Picture1.Picture = Clipboard.GetData

    Now what do you want to do with this (verification) image?
    Works like a charm Thank you so much.

    And i just want to let people fill it in on my app but i have that covered thanks

  8. #8
    New Member
    Join Date
    Mar 2010
    Posts
    10

    Re: [RESOLVED] display image from webbrowser in a picture box?

    And how to do this if verification img does not have a name:

    <img src="/sw/verification/verif.php?c=login" alt="captcha" class="captcha"/>

    Thanx a lot !

  9. #9
    Member ts96's Avatar
    Join Date
    Mar 2010
    Posts
    37

    Re: [RESOLVED] display image from webbrowser in a picture box?

    I get an error on this line:
    Call O.Add(WebBrowser1.Document.All("verificationImg"))

  10. #10
    New Member
    Join Date
    Sep 2009
    Location
    New Jersey
    Posts
    2

    Re: display image from webbrowser in a picture box?

    Quote Originally Posted by Jim Davis View Post
    Drop a picturebox control to your form. This code will force the webbrowser control to copy the image content to the clipboard, that you can easily paste by using the Clipboard object of vb6

    vb Code:
    1. Dim O as Object
    2.  
    3. Set O = WebBrowser1.Document.body.createControlRange()
    4. Call O.Add(WebBrowser1.Document.All("verificationImg"))
    5. Call O.execCommand("Copy")
    6.  
    7. Set Picture1.Picture = Clipboard.GetData

    Now what do you want to do with this (verification) image?
    Thank you so much for this CODE.

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