Hi guys.

Im trying to get a wav file to play on a mouse over event.
I want a wavefile to play when the mouse pointer moves over a label and stop wen it is moved off the label.

I believe this can be done using the sndPlaySound, i have tried and the wav does play, but i need it to stop if the mouse is not on the label.

Thanks in advance.

Recommended Answers

All 2 Replies

I don't know if this is very effective.

My theory is that if the label detects a mouse_move event then it starts playing. when the mouse moves anywhere else on the form, then stops playing.

So maybe add a mouse_move event on the form it self to stop the music playing

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Debug.Print "stop playing"
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Debug.Print "play"
End Sub

Hi, thanks for reply, but it seems to be working when i added the ffg:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
sndPlaySound vbNullString, SND_NODEFAULT
End Sub
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.