Hello--
I am not sure if I should have three separate postings for these questions or just the one, since they all deal with VB.NET. I will list them here and if they should be separated, I understand and hope that I can get help with them.
1) Is it possible to have a series of buttons at the top of a form and have the action taken by clicking on one of the buttons to position the cursor at a different location on the form?
2) Is it possible to play *.MP3 files in the background when a form is displayed?
3) If it is possible to play *.MP3 files, can I set it up to play one on one form, then on a second one randomly select from 20 different ones to play in the backgound when the form is displayed.
Thank you very much.

Question 1

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    Cursor.Position = MousePosition + Button2.Location - Button1.Location
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    Cursor.Position = MousePosition + Button3.Location - Button2.Location
End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    Cursor.Position = MousePosition + Button1.Location - Button3.Location
End Sub

Control locations are relative to the form whereas MousePosition is relative to the screen so we calculate the new cursor location by using the difference between the current control being clicked and the target control.

You can play mp3 (or wav) files in the background by embedding the windows media player.

Add a project reference (COM tab) to Windows Media Player

Add Imports WMPLib

At the class level declare

Private Player As New WMPLib.WindowsMediaPlayer

You play a file by

Player.URL = "D:\My Music\SomeFile.mp3"
Player.Controls.Play()

I added a handler to show the current state in the title bar

AddHandler Player.PlayStateChange, AddressOf PlayStateChanged

    Private Sub PlayStateChanged(newstate As Integer)

    Select Case newstate
        Case WMPPlayState.wmppsStopped
            Me.Text = "Stopped"
        Case WMPPlayState.wmppsPlaying
            Me.Text = "Playing"
        Case Else
            Me.Text = Player.playState
    End Select

End Sub

If, for example, you had a list of sound files and you wanted to immediately play the next one when the current one ends you could add that code to the wmppsStopped Case clause. You could add other controls for things like mute, volume, etc.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.