thanx to JohnH and MattP I was able to allow a user to change and save the jpg file that is used as a button background image---now I would like to do the same with a wav file that plays when the button is pushed on a touchscreen here is my code so far:
trying to use the using/end using is not working out--I have that section commenting out--How do I accomplish this?
VB.NET:
Public Class SavIm
Dim image1 As Bitmap
Dim soundPlayer1 As New System.Media.SoundPlayer("C:\Users\pb\Desktop\vb.net experiments\but1Sound.wav")
Private Sub SavIm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Retrieve the image.
Using fileLocked As New Bitmap("C:\Users\pb\Desktop\vb.net experiments\but1Image.jpg")
image1 = New Bitmap(fileLocked)
End Using
' Using fileLocked As New System.Media.SoundPlayer("C:\Users\pb\Desktop\vb.net experiments\but1Sound.wav")
'soundPlayer1 = fileLocked
' End Using
Button1.BackgroundImage = image1
End Sub
Private Sub ChangeImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeImageToolStripMenuItem.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
image1 = New Bitmap(OpenFileDialog1.FileName)
Button1.BackgroundImage = image1
End If
End Sub
Private Sub SaveCurrentImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveCurrentImageToolStripMenuItem.Click
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
image1.Save("C:\Users\pb\Desktop\vb.net experiments\but1Image.jpg",
System.Drawing.Imaging.ImageFormat.Jpeg)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
soundPlayer1.Play()
End Sub