Can I customize standard MessageBox ?

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
 
S

Stoitcho Goutsev \(100\) [C# MVP]

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top