Sound - Did you know that a message box automatically plays a beep?

Loading last updated info...

A message box automatically provides this functionality so there is no need to manually put a beep right before a message box pops up.

Image

✅ Figure: Good example - Windows message boxes plays a sound... which cannot be captured in screenshot form.

string message = "You did not enter a server name. Cancel this operation?";
string caption = "No Server Name Specified";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
System.Media.SystemSounds.Beep.Play();
DialogResult result = MessageBox.Show(this, message, caption, buttons);

❌ Figure: Figure: Bad example - The sound on the button is hardcoded in this code snippet

string message = "You did not enter a server name. Cancel this operation?";
string caption = "No Server Name Specified";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result = MessageBox.Show(this, message, caption, buttons);

✅ Figure: Figure: Good example - The code is not present in this example as it is automatically done

Authors

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star