|
-
Jun 3rd, 2007, 11:37 PM
#1
Thread Starter
Member
[2005] Saving a background Image
Hey, quick question if someone could answer.
I have 2 forms.
The user selects an Image in form 1, and that image becomes the background for form 1.
When the user click 'save' (button) I want when the form is closed and then re-opened it will automatically load that image to form 1.
I also need to have the background image of form 1 to become the background image of Form 2.
Basically Form 1 is used to change the appearance of form 2.
I have been able to do this for the Forecolour, Font, and Backcolor.
So far i have used the Property Bindings for this. But i can't find an option in there to do this.
Hope that makes sense
Thanks
Last edited by Wulfgur; Jun 19th, 2007 at 11:42 PM.
-
Jun 4th, 2007, 12:39 AM
#2
Re: [2005] Saving a background Image
write it to the registry.
then retrieve it when you start your program + save it (filepath) to a variable
then you can set backgroundimage = variable
-
Jun 4th, 2007, 12:51 AM
#3
Re: [2005] Saving a background Image
Use application settings rather than the registry. Lookup My.Settings on MSDN for moro information.
Last edited by jmcilhinney; Jun 4th, 2007 at 12:54 AM.
-
Jun 4th, 2007, 01:00 AM
#4
Thread Starter
Member
Re: [2005] Saving a background Image
k thanks, i'll post if i need more help.
-
Jun 18th, 2007, 08:23 PM
#5
Thread Starter
Member
Re: [2005] Saving a background Image
Ok, still stuck with the Saving Background Image.
I have used Application Settings --> Property Bindings, for saving the back color, fore color, font ect. But i cannot find a setting in Property Bindings for Background Image, i see BackgroundImage style.
I have had a search in MSDN, maybe i missed it there.
I must be missing something.
Thanks.
-
Jun 18th, 2007, 10:52 PM
#6
Re: [2005] Saving a background Image
Save the path to the image in My.Settings and then set the Background image of the form when it loads.
-
Jun 19th, 2007, 04:27 AM
#7
Thread Starter
Member
Re: [2005] Saving a background Image
Sorry i still don't understand. "Save the path to the image in my.settings" What "Type" am i meant to use?
Sorry i just don't understand what you are saying.
-
Jun 19th, 2007, 04:30 AM
#8
Re: [2005] Saving a background Image
How would you normally specify a file path? With a String, so you need to create a setting of type String to store the path of the image file. You can then load it like so:
vb.net Code:
Me.BackgroundImage = Image.FromFile(My.Settings.FormBackgroundImagePath)
-
Jun 19th, 2007, 04:43 AM
#9
Re: [2005] Saving a background Image
a directory + a filename is a string (of characters)
i.e.
dim filename as string = "c:\windows\paint.exe"
-
Jun 19th, 2007, 05:06 AM
#10
Thread Starter
Member
Re: [2005] Saving a background Image
Ok. This is what i am looking for. I want a user to select an image, that image becomes the backgroundimage of the form, when the user clicks a button named "Save" the image will be saved so next time the user opens the form the backgroundimage will still be set to what he saved it to last time.
jmcilhinney does the method you stated above do this?
vb Code:
Private Sub BtnImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnImage.Click
OpenFileDialog1.ShowDialog()
If OpenFileDialog1.FileNames.Length > 0 Then
Dim Img As New Bitmap(OpenFileDialog1.FileName.ToString())
Me.BackgroundImage = Img
Me.Refresh()
End If
(When BtnImage is clicked it prompts the user to select an image which when selected becomes the background of the form)
This is what i have done for the selecting an image for the background i just don't know how to save it.
-
Jun 19th, 2007, 05:10 AM
#11
Re: [2005] Saving a background Image
All your code does is select an image and set it as the form's background. It doesn't do any saving for next time or loading at startup. Have you created a setting to store the file's path as we have already suggested?
-
Jun 19th, 2007, 05:15 AM
#12
Thread Starter
Member
Re: [2005] Saving a background Image
Yea thats what i needed help with saving for the next load up.
I have created a setting in Project Settings named: Image
Really sorry for not understanding, just never done this before.
-
Jun 19th, 2007, 05:24 AM
#13
Re: [2005] Saving a background Image
circuits2 has already told you what to do:
Save the path to the image in My.Settings
I have shown you how to use that path to load the image next time you start the app.
-
Jun 19th, 2007, 05:28 AM
#14
Thread Starter
Member
Re: [2005] Saving a background Image
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
|