tags:

views:

140

answers:

2

Whenever I close a particular context menu and have changed the value in a particular ToolStrip TextBox my application plays "Default Beep" (Windows Ding.wav)

I have stepped through my code line by line until the "Ding" is heard but I cant find anything.

How does one go about finding out what makes my application go "Ding"?

Edit:
Well it turns out that this wasn't so simple as I thought (I suspected a rouge MessageBox or something). The ding only plays on my Vista, my colleague tells me it doesn't play on his XP.

+1  A: 

You can debug your program in Visual Studio, and set a breakpoint on the System.Media.SystemSound.Play method. When the breakpoint hits, look at the current call stack to see what called the method.

The breakpoint can be set through the "breakpoints" window of Visual Studio, don't forget to set the language as "Unknown" or the IDE won't find the function.

Mathieu Garstecki
I'm accepting this because it answered the question I thought I had.
Nifle
+1  A: 

Whenever you press enter on a Form the default behavior is to execute the click event of the Accept (AKA OK) Button. If no OK Button is defined a Beep is issued as no default action can be executed.

To override this beep you can:

1.- Define an Accept button on your form. 2.- Handle the keypress event on the TextBox, check if ENTER or RETURN key has been pressed and set e.handled=True

If option 2 then take notice that it will only work for TextBoxes, ENTER in other controls can cause a Beep if not handled there.

Regards,

MarianoC

Mariano