|
-
Mar 11th, 2010, 05:22 AM
#1
Thread Starter
New Member
Saving background image settings
Last edited by billgate128; Mar 13th, 2010 at 04:26 AM.
-
Mar 11th, 2010, 07:02 PM
#2
Re: Saving background image settings
Hi Billgate, welcome to the forum. This is a fast-moving forum so messages sometimes slip off the front page rather quickly.
You need to look at Settings. Right click on the project name in Solution Explorer and select Properties from the menu. Then click the Settings tab. Now add a setting to the table. Fill in a name (e.g. FormBackground), the type =String, scope = User, and the path/filename of an image file (e.g. C:\Pictures\Sky.jpg).
Now you can code your form's Load event sub.
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackgroundImage = Image.FromFile(My.Settings.FormBackground)
End Sub
Finally, add this line to the MouseClick sub:
Code:
My.Settings.FormBackground = image file
and fill in the path and filename of the chosen background image.
bye, BB
-
Mar 11th, 2010, 07:34 PM
#3
Re: Saving background image settings
One point to note about boops' solution is that it relies on the image file being in the same place next time you start up. If you don't want to rely on the user not moving or deleting the file, you might want to copy it to the Application Data folder and then access it from there. This is what Windows does with wallpaper.
-
Mar 11th, 2010, 07:53 PM
#4
Junior Member
Re: Saving background image settings
 Originally Posted by jmcilhinney
One point to note about boops' solution is that it relies on the image file being in the same place next time you start up. If you don't want to rely on the user not moving or deleting the file, you might want to copy it to the Application Data folder and then access it from there. This is what Windows does with wallpaper.
Good call!
Also you might want to add an IF THEN statement to.
I did this for a program I wrote so that the user can select their own picture and if it is deleted, to VB meaning non existent then it will use it's default background.
Here is a snippet:
Code:
On Error GoTo erbg
If My.Settings.SaveBG = Nothing Then GoTo vend Else GoTo gb
GoTo vend
erbg:
MsgBox("Your personal backround picture has either changed or has been moved. The default background will be used.", , "Error getting background picture.")
GoTo vend
gb:
Me.BackgroundImage = Image.FromFile(My.Settings.SaveBG)
vend:
End Sub
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
|