views:

1175

answers:

4
+4  A: 

Check out Dissecting the MessageBox on CodeProject. The project is a bit dated, but it's pretty much exactly what you're looking for and it shouldn't take much to update it.

Jim Lamb
This does, indeed, look good. It includes several of the "extras" that my co-workers may need or like. And since it is in source, it can even be tailored/extended. Thanks.
Mark T
+2  A: 

Depending on your target platform, a task dialog may be a good way of doing this. There is a .NET wrapper for task dialogs in the Windows API Code Pack. However these are provided only in Windows Vista and above, not in XP or 2003.

itowlson
Thanks, but we definitely need to support XP right now. But the response may help others!
Mark T
+2  A: 

Frankly, it is not that difficult to create such a Messagebox yourself, we have such a thing working in the current app we are developing.

What you need is a FlowLayout for the buttons that will auto-align any buttons you create. Our API then has something like (params Tuple<string,DialogResult>[] buttons)

Tuple is a helper class that contains two values. The string is the Text of the button, the Dialogresult is the one our messagebox returns when the button with said text is clicked.

flq
A: 

I agree with Frank. It wouldn't be too difficult to create your own generic form that handles this for you. Without getting into code, the form should do the following

1) Have a property to set the message you want to show to the user.

2) Have a method for adding buttons, with 2 arguments, one for the button text, and one for the dialog result

3) When the form is displayed, it should be in modal dialog mode so that the rest of the application is inactive while until one of the options is clicked.

So, to create a Save As/Don't Save/Cancel, you would add 3 buttons in step 2, all with the appropriate button text and dialog result.

Using Flow layout, you should be able to get it to display properly regardless of the size of the message, or the number of buttons.

Kibbee