Results 1 to 7 of 7

Thread: can this be done?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298

    Question

    Hi,

    Is it possible to load .jpg files into a resource file and then take them into an image control?

    I managed to place then into a resource file. but how do I read them from there?? Tried using the LoadResData function, but I get an error

    "Resource with identifier 101 not found"

    I've stored the .jpg files in rhe resource file as "custom resource" and the id is 101.

    any ideas???

    Thanx.






  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The exact syntax should be:
    Code:
    LoadResData(101, "CUSTOM")

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    but how do I store the jpeg files in the resource editor in the first place??

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    Check out Previous Post

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    If I want to set the picture property of an image control to a jpeg file from the resource file, what am I to do?
    tried

    Image1.Picture = LoadResPicture(101, "CUSTOM")

    but that didn't work.

    what am I doing wrong???

    Thanx

  6. #6
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    You can use this function I wrote a while back:
    Code:
    Public Function GetPictureFromResource(p_lngResourceID As Integer) As IPictureDisp
        Dim bytArr() As Byte
        Dim intFFN As Integer
        Dim strPath As String
    
        bytArr = LoadResData(p_lngResourceID, "CUSTOM")
        strPath = App.Path & IIf(Right(App.Path, 1) = "\", "MyPicture.tmp", "\MyPicture.tmp")
        intFFN = FreeFile
        Open strPath For Binary As intFFN
        Put #intFFN, , bytArr
        Close #intFFN
        Set GetPictureFromResource = LoadPicture(strPath)
        Kill strPath
    End Function
    Now you can use this function like this:
    Code:
    Private Sub Command2_Click()
        Image1.Picture = GetPictureFromResource(101)
    End Sub

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    thanx Serge, that worked! )

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