• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Quick Question: VB (1 Viewer)

DeathB4Life

Bánned
Joined
Feb 4, 2006
Messages
590
Gender
Male
HSC
2006
how would i go about adding a picture so its "permanently" within the .exe file once the program is compiled.

im using the lines:

Picture1.Picture = LoadPicture("C:\picture.jpg")

but once the program is compiled into an .exe, itll only run if the file "picture.jpg" is always in the right directory.

anyone know how to solve this? ive seen another few projects with pictures saved in them and not simply a line of text saying how to find the pictures, but after about 3 hours of googling i still have no idea how to do it.
 

sasquatch

Member
Joined
Aug 15, 2005
Messages
384
Gender
Male
HSC
2006
If you want the picture embedded within your application there are two main ways of achieving this.

First, the most simpilest way is the following:

Method 1.
1. Select the picturebox you wish to place the picture in (in this case picture 1).
2. Scroll down to the property "Picture" in the properties window, if its not visible press F4 to show it.
3. Click the ellipses next to the property data (next to the default "(None)") and you will be prompted to locate the source of the picture you wish to insert.

As long as you do not clear the picture box, or load another picture during the running of your application, the picture will stay there. You will have a crappy border around the picture by default which will make it seem like its "in". Erm that was the crappiest explination ive ever given, but yeah you should know what im talking about. You can set the property 'Appearance" to "1-Flat" to get rid of this 3D effect, and remove the border too if you require.

The second method involves adding the picture to a resource file, and then setting the picture through the resource ID at runtime. If you would like to know how to do this, please post again. It is useful if you wish to store multiple images within your application such that you can change crap at run-time.

If you wish to have the file external, but do not require it at the location "C:\...whatever" you can use the segment of code:

Code:
Picture1.Picture = App.Path & "\folder1\picture.jpg")
This will load the file from the path "\folder1\picture.jpg" relative to the location of the EXE file.

Hope i helped.
 

DeathB4Life

Bánned
Joined
Feb 4, 2006
Messages
590
Gender
Male
HSC
2006
ahh thanks

the first method isnt quite going to work since theres going to be multiple images being displayed in a single picturebox during the programs use, but that App Path tip should do the trick (was having some probs with the different drives between all the comps being used)

thanks again :D
 

JBakaka

Member
Joined
Jun 26, 2006
Messages
39
Gender
Male
HSC
2006
yea the app.path trick works pretty well, but when i was making my project (an RPG), to look more professional, and to get more marks, i used an API call:
BitBlt or the newer one: TransparentBlt. if you want help i can tell you about it but i think i learnt from random tutorials online
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top