Display error dialog (MessageBox) with Only "Close" or "Cancel" buttons?

2.1k views Asked by At

I read in Windows Experience Guidelines: Error Messages that "OK" is an incorrect button to display on an error dialog.

...provide a Close button. Don't use OK for error messages, because this wording implies that problems are OK.

So, how can I display a simple error dialog with a single Close/Cancel button?

Is this possible with the standard MessageBox class or must I resort to custom dialog (or library) or other Win32 message / p-invoke "hacks"?

(There doesn't seem to be anything relevant in the MessageBoxButtons enumeration.)

Thanks.

1

There are 1 answers

4
perfectionist On BEST ANSWER

You want the all-improved TaskDialog.

Available from here with description on usage here

TaskDialog allows you to specify in more detail the buttons and icons that show and is microsoft's own solution to your problem in .Net.

-- update to answer @pst's comment

If you have to support Winows XP or earlier then there is a very stable and reliable library on codeproject which wraps and emulates the microsoft taskdialog class when you are using an earlier version of windows, and uses MS's own version if you are on Vista or later.

I have relied on this codeproject library approx 2 years ago, and it was stable then, so there should be no reliability issues at all.