Results 1 to 10 of 10

Thread: Displaying an url

  1. #1

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371

    Question Displaying an url

    Hi there,

    I don't know if the title is apropriate but what I intend to do is create an area linked to an url... that is, an area where it is shown an image that is available online when I define a link...

    example: I want to insert in a picturebox (or whatever) the image available in this link: "https://mail.ua.pt/header_60_300.gif"

    I hope I have been clear..

    Any help is most apreciated.. thanks in advance

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

    Re: Displaying an url

    You will need to download the image file manually. For that, you can use URLDownloadToFile().

    VB Code:
    1. ' Declaration:
    2. Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileW" ( _
    3.   ByVal pCaller As Long, _
    4.   ByVal szURL As Long, _
    5.   ByVal szFileName As Long, _
    6.   ByVal dwReserved As Long, _
    7.   ByVal lpfnCB As Long _
    8. )
    9.  
    10. 'Usage:
    11. URLDownloadToFile( _
    12.   0, _
    13.   StrPtr("https://mail.ua.pt/header_60_300.gif"), _
    14.   StrPtr(App.Path & "\temp\header_60_300.gif"), _
    15.   0, _
    16.   0 _
    17. )

    HTH.

  3. #3

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371

    Re: Displaying an url

    Thanks,

    I'll try it as soon as I can...

    However, won't it make a bit slow.. since I intend to call the image many times..
    is there a faster way to do it?

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

    Re: Displaying an url

    The function actually uses Internet Explorer's cache. So as long as there is space in the cache, it will be retrieved from there rather than being re-downloaded.

  5. #5
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Displaying an url

    There are other ways of getting the file, but the URLDownloadToFile API is the easiest.

    You could alternatively use the Inet control or Winsock
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Displaying an url

    you could also use the Webbrowser control and write HTML directly to it.. using the creating the link and grabbing the image in the HTML...
    no download needed then..
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  7. #7

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371

    Re: Displaying an url

    Do you have a working example for the Webbrowser control?

    I'm still new in VB and I understand better when I can see the code ...

    thanks in advance

  8. #8
    Lively Member
    Join Date
    Jan 2006
    Posts
    114

    Re: Displaying an url

    Quote Originally Posted by Static
    you could also use the Webbrowser control and write HTML directly to it.. using the creating the link and grabbing the image in the HTML...
    no download needed then..
    that uses ie control and ie chache lol

  9. #9
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Displaying an url

    No it doesnt as you can force it not to.. but this way will give you your clickable image all in one

    VB Code:
    1. Private Sub Form_Load()
    2.     WebBrowser1.Navigate "about:blank"
    3.    
    4.     Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE
    5.         DoEvents: DoEvents
    6.     Loop
    7.    
    8.     Dim HTML As String
    9.     HTML = "<HTML>" & vbCrLf & _
    10.             "<style type=text/css>" & vbCrLf & _
    11.             "html,body {" & vbCrLf & _
    12.             "height:100%;" & vbCrLf & _
    13.             "width:100%;" & vbCrLf & _
    14.             "overflow:hidden;" & vbCrLf & _
    15.             "}" & vbCrLf & _
    16.             "</style>" & vbCrLf & _
    17.             "<BODY><A HREF=http://www.vbforums.com>" & vbCrLf & _
    18.             "<IMG SRC=" & Chr(34) & "http://www.google.com/intl/en/images/logo.gif" & Chr(34) & " border=0>" & vbCrLf & _
    19.             "</A></BODY></HTML>"
    20.     WebBrowser1.Document.write HTML
    21. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10

    Thread Starter
    Hyperactive Member segrobiur's Avatar
    Join Date
    May 2004
    Location
    Portugal
    Posts
    371

    Re: Displaying an url

    Hi there...

    I'm sorry I could only got back to you guys just now.. but only this morning I had a chance to test it...

    I wasn't able to make it work... (I used Static's code - seemed easier to me)..

    Do you have any working example? (compile version also - I don't have VB right now and this way I could get back to you imediatly)

    ... I know I always ask too much.. .. but please, any help is most welcome

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