Results 1 to 5 of 5

Thread: .picture = Loadpicture("online")

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    425

    .picture = Loadpicture("online")

    Hello,

    I'm making an app that uses online graphics. I first used the webbowser control to load the images, but than I had an Idea. I would try picture1.picture = loadpicture(OnlineImageURL). This only worked when I put it directly in the proprties of the Picture1. When I try to run this code, it gives an error File / Path Access error...

    Can anybody help me out?
    "Experience is something you don't get until just after you need it."

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Here, put this in its own module:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
    4. "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
    5. szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
    6. Public TempPath As String
    7.  
    8. Public Function LoadPictureInet(URL As String) As StdPicture
    9. Dim rval As Long
    10.  
    11.    If TempPath = "" Then TempPath = App.Path
    12.    rVal = URLDownloadToFile(0, URL, TempPath & "\temp.dat", 0, 0)
    13.    Set LoadPictureInet = LoadPicture(TempPath & "\temp.dat")
    14.    Kill TempPath & "\temp.dat"
    15.  
    16. End Function

    Usage:

    VB Code:
    1. TempPath = "C:\Temp"
    2. Set Picture1.Picture = LoadPictureInet("http://www.crystal-rain.com/art/lizardman.jpg")
    Last edited by Sastraxi; May 26th, 2002 at 06:18 PM.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    425
    Thank you very much.. I though It would be possible to load it directly from the web, but it seems not... Well, I'll use your method. Thank you very much...
    "Experience is something you don't get until just after you need it."

  4. #4
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    In any way it'll [most likely] be saved temporarily in Windows/Temp first, so this way is just as good. Plus, it ensures the file is deleted after its displayed.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    The code's fixed now. Before, it would give an invalid use of property error.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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