My current project sets and gets registry values to retain user preferences. One of these preferences are the contents of a picturebox. Below I have included all code that interacts with the picturebox in question. Keep in mind that I have the picturebox's InitialImage set to a placeholder image, which then is changed by the user and saved to the registry (path to the file). The registry shows these values are saved properly, yet upon loading the program, the picturebox shows the saved image, but when transferring the image contents to another picturebox (via picturebox.image) it usually transfers the initialimage value, not the image value. This ofcourse can be fixed if the user sets the imagelocation at the launch every time the app is started, defeating the purpose of saving these settings via registry. I am at a loss, lol.
(MergeImages is a separate function that overlays picturebox3.image over picturebox1.image.)
*Note, in pulling the below code out of the entire project, I may have inadvertently found the problem, please enlighten me! I am pulling the file path previously saved in the registry, which is setting the image value to what is expected. But when pulling the image value it provides its initialimage value. Could this be the issue, and if it is, can I somehow force imagelocation/image/initialimage to all be the same? (in theory, I know in the literal sense this would be impossible, being imagelocation is a string value, but you know what I mean)
(MergeImages is a separate function that overlays picturebox3.image over picturebox1.image.)
*Note, in pulling the below code out of the entire project, I may have inadvertently found the problem, please enlighten me! I am pulling the file path previously saved in the registry, which is setting the image value to what is expected. But when pulling the image value it provides its initialimage value. Could this be the issue, and if it is, can I somehow force imagelocation/image/initialimage to all be the same? (in theory, I know in the literal sense this would be impossible, being imagelocation is a string value, but you know what I mean)
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
PictureBox3.ImageLocation = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\DJMCReHost", "Overlay", ToString)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Image = MergeImages(PictureBox1.Image, PictureBox3.Image)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
My.Computer.Registry.SetValue("HKEY_CURRENT_USER\DJMCReHost", "Overlay", PictureBox3.ImageLocation)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Dim dialog As New OpenFileDialog()
If DialogResult.OK = dialog.ShowDialog Then
PictureBox3.Image.Dispose()
PictureBox3.Image = Nothing
PictureBox3.ImageLocation = dialog.FileName
End If
End Sub