Custom WinForm with MessageBox Icon and Sound

I want to create a modal dialog box with more controls than the standard .NET MessageBox . I created my own windows form that will be called using ShowDialog () to give modal behavior. However, I would like to use the graphics that comes with MessageBox through MesageBoxIcon . Is it possible? Can I also reproduce the error / warning sounds associated with the message box icons (as they are set in the custom window settings)?

+4
source share
2 answers

See the System.Drawing.SystemIcons class to display system icons used by the MessageBox class, such as Question , Information and Warning .

 e.Graphics.DrawImage(SystemIcons.Question.ToBitmap(), new Point(0, 0)); 

For sounds, see the System.Media.SystemSounds class for playing related sounds.

 System.Media.SystemSounds.Asterisk.Play(); 
+9
source

MessageBox is provided by the OS, I'm afraid. You can expand it, but it takes a lot of work (see this in the CodeProject article for a tutorial). Your best bet is probably to start again with a control that inherits the form, as you suggest.

To access the icons is as simple as using the System.Drawing.SystemIcons class (the documentation for this is here .)

+1
source

Source: https://habr.com/ru/post/1403950/


All Articles