-
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.
-
The exact syntax should be:
Code:
LoadResData(101, "CUSTOM")
-
but how do I store the jpeg files in the resource editor in the first place??
-
-
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
-
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
-
thanx Serge, that worked! :o)