|
-
Nov 10th, 1999, 06:55 AM
#1
Thread Starter
Registered User
Can VB save JPGs or GIFs in .res files?
Thanks in advance.
Jefferson
-
Nov 10th, 1999, 06:50 PM
#2
VB6 comes with Resource Editor Add-In. Select Add-In manager from the Add-In menu and double click on VB6 Resource Editor. Then select Add New Resource File from Project menu. You'll be given a choice to give a name for your new resource file. Then you will notice that your Project Browser will have that new resource file. Double click on it. Then click on the Add Custom Resource... button on the toolbar. Again, you will get the Common Dialog to select the file you want. Now, comes the the programming part. For testing purposes just drop a PictureBox and Command button on the form. (I inserted a GIF file into Resource File). Put this on Command1_Click event
Code:
Private Sub Command1_Click()
Dim arrByte() As Byte
Dim iFFN As Integer
Dim strTempPath As String
arrByte = LoadResData(101, "CUSTOM")
strTempPath = App.Path & "\~pictemp.gif"
iFFN = FreeFile
Open strTempPath For Binary As iFFN
Put #iFFN, , arrByte
Close #iFFN
Picture1.Picture = LoadPicture(strTempPath)
Kill strTempPath
End Sub
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
[This message has been edited by Serge (edited 11-11-1999).]
-
Sep 13th, 2000, 07:24 AM
#3
Hyperactive Member
Is it possble to store JPEGs in the resource editor?
-
Sep 13th, 2000, 04:45 PM
#4
Put this in your RC file.
Code:
1000 CUSTOM PRELOAD myjpg.jpg
-
Sep 13th, 2000, 05:04 PM
#5
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
-
Sep 13th, 2000, 11:18 PM
#6
Fanatic Member
Serge,
How do you get all the numbers{101,102,103,104) in the res file?
I want to add it to a listbox and just click on it.
Thanks!
Chemically Formulated As:
Dr. Nitro
-
Sep 14th, 2000, 09:17 AM
#7
Unfortunately, you can't enumerate resources, because you have to know their IDs before hand. But you can create IDs in the resource as plain numbers like 1, 2, 3 ...etc and then populate ListBox with available numbers. Then you can use the function that I've provided to show an image in Image control based on the ID in the ListBox.
-
Sep 14th, 2000, 11:59 AM
#8
Fanatic Member
Chemically Formulated As:
Dr. Nitro
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|