is it possible to load a picture into a project, but not into an item(so a person wouldn't have to have the picture files AND the .exe just one big exe(i want to be able to change the picture of objects inside)?
Printable View
is it possible to load a picture into a project, but not into an item(so a person wouldn't have to have the picture files AND the .exe just one big exe(i want to be able to change the picture of objects inside)?
Just create a resource file (*.res) and copy all your graphics into it, then use the LoadResPicture function to load it at runtime.
Code:Picture1.Picture = LoadResPictire(101,vbResBitmap)
im still fairly new to vb....could you talk like i am 4?(no, i am not 4) how do i create the .res file, how do i copy graphics to it?(i figured out how to load graphics from a normal file, so i think i can fake the loading with what you gave me)
You need to load the Reasource File Editor at the begining when you load your VB IDE. This can be done with the following step:
- Goto Add-ins|Add-In Manager.
- Select the VB 6 Resource Editor.
- Check the Loaded/Unloaded CheckBox.
- Check the Load On Startup.
After this few step, you will be able to see the Resource Editor Icon in you toolbar.
Hence, To add image into the resource editor just do the following few step:
- Load the resource Editor.
- Add a new image by click on the Add bitmap icon.
- Select your desire bitmap image file, the editor will adutomatic assign a ID for the image (E.g. 101)
- Save the resource file in your project folder.
- Add the resource file into your project. Right Click your mouse in the Project Browser Window and chose Add|Add File. Just point to your resource file and click OK.
At this stage, all you need is to load the image by using the Picture1.Picture = LoadResPicture (101,vbResBitmap)
Noo!
Use a res file but store the files in
JPEG. BITMAPS are too large.
Then use this code to retreive the
JPEG.
Code:
Public Sub LoadPic(Index As Integer)
Dim arrByte() As Byte
Dim IFFN As Integer
Dim strTempPath As String
arrByte = LoadResData(Index, "Custom")
strTempPath = App.path & "\Loading.jpg"
IFFN = FreeFile
Open strTempPath For Binary As IFFN
Put #IFFN, , arrByte
Close #IFFN
form1.picture1.Picture = LoadPicture(strTempPath)
Kill strTempPath
End Sub
To show you how I did that..
VB will only accept a bitmap
so I converted the jpeg and
then saved it to the disk,
and loaded it..
If you have any problems with
that code mail me,
Or just reply.
I am using VB6.0 and im using .gif (due to size mainly), is that a problem?
Nope..
use the same code.
just load the picture as a custom
resource and then in a command button
put this
Loadpic 101
Then your need a picture box on the
form and the picture should load.
Tell be what happens.
Is there any way I can use the resource editor to store jpeg files??????