Can I customize standard MessageBox ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to display message box with custom message. If I use standard
MessageBox class as follows everyting works OK.

MessageBox.Show("Sample Text", "Sample Caption", MessageBoxButtons.OKCancel,
MessageBoxIcon.None);

The only problem is that can't get rid of control button in the caption ( X
button in top right corner) and I don't want display button in the Windows
taskbar corresponding to this dialog. In other words I can't customize this
dialog.

I can easily customize these features if I create my own form, but it
doesn't look to me right approach if I need to display only simple message.

So my questions: Is there way to customize standard MessageBox?

Thanks
 
Steve,

No, you can't costumize this dialog. Actually you can to some degree using
windows hooks, but this involves usign PInvoke and more effort that creating
your own form.

As far as it goes to the button on the task bar you shouldn't get one. The
only one case that you should get this button is if the main form is in
minimized state. In this case (or probably in any case if you get this
button) pass reference to the form as a fist parameter.
E.g.

MessageBox.Show(this, "Sample Text", "Sample Caption",
MessageBoxButtons.OKCancel, MessageBoxIcon.None);


HTH
Stoitcho Goutsev (100) [C# MVP]
 
Back
Top