Click here to Skip to main content
15,868,141 members

Sound of mouse click and hover

blueye89 asked:

Open original thread
Hello to all,
I have two buttons:
1. Start System Asterisk Sound button which plays system asterisk sound:
VB
Private Sub btnSystemAsteriskSound_Click(sender As Object, e As EventArgs) Handles btnSystemAsteriskSound.Click
        My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Asterisk)
    End Sub

2. MyButton is a button which has two events:
VB
Private Sub btnMyButton_MouseEnter(sender As Object, e As EventArgs) Handles btnMyButton.MouseEnter
        My.Computer.Audio.Play(My.Resources.High1, AudioPlayMode.Background)
    End Sub

    Private Sub btnMyButton_MouseDown(sender As Object, e As MouseEventArgs) Handles btnMyButton.MouseDown
        If e.Button = MouseButtons.Left Then
            My.Computer.Audio.Play(My.Resources.Click1, AudioPlayMode.Background)
        Else
        End If
    End Sub

If I click on Asterisk button just before mouse hover and click of MyButton, I clearly hear mouse hovering and clicking, but at the end of playing sound of Asterisk button, I hear something but in the background and it is too quiet even if my sound speakers are on 100%. I realize that my events works only if there is a background sound which is behind pressing of Asterisk Button.
If I just click or hover over the MyButton, without previous clicking on the Asterisk button, it doesn't work correctly-sound is too quiet.

How to solve that even if there is not a background sound or music, hovers and clicks on/over the MyButton must emittate a specific sound that I set.

Preview of my form:
https://s2.postimg.org/im0k27zrt/Capture.png

What I have tried:

Private Sub btnMyButton_MouseEnter(sender As Object, e As EventArgs) Handles btnMyButton.MouseEnter
    My.Computer.Audio.Play(My.Resources.High1, AudioPlayMode.Background)
End Sub

Private Sub btnMyButton_MouseDown(sender As Object, e As MouseEventArgs) Handles btnMyButton.MouseDown
    If e.Button = MouseButtons.Left Then
        My.Computer.Audio.Play(My.Resources.Click1, AudioPlayMode.Background)
    Else
    End If
End Sub

Private Sub btnSystemAsteriskSound_Click(sender As Object, e As EventArgs) Handles btnSystemAsteriskSound.Click
    My.Computer.Audio.PlaySystemSound(System.Media.SystemSounds.Asterisk)
End Sub
Tags: Visual Studio 2015

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900