MessageBox on Steroids

The good old MessageBox has served us well, but provides us with a very limited set of features. Thankfully those developing for the more recent Windows operating systems can start using the new and stylish TaskDialog.

Unfortunately, at least for now,  it’s not available in the .NET Framework so you’ll have to download the Windows API Code Pack to take advantage of this and other interesting features.

I’ll leave you with two examples of what you can do with the TaskDialog.

var dialog = new TaskDialog();

dialog.Caption = "Application Error";
dialog.InstructionText = "Crash Report";
dialog.Text = "Something totally unexpected just happened.";
dialog.Icon = TaskDialogStandardIcon.Error;
dialog.Cancelable = true;
dialog.StandardButtons = TaskDialogStandardButtons.Ok;
dialog.DetailsExpanded = false;
dialog.ExpansionMode = TaskDialogExpandedDetailsLocation.ExpandFooter;
dialog.DetailsCollapsedLabel = "View Details";
dialog.DetailsExpandedLabel = "Hide Details";
dialog.DetailsExpandedText = "The requested file is nowhere to be seen.";

dialog.Show();

var dialog = new TaskDialog();

dialog.Caption = "Application Error";
dialog.InstructionText = "Crash Report";
dialog.Text = "Something totally unexpected just happened.";
dialog.Icon = TaskDialogStandardIcon.Error;
dialog.Cancelable = true;

var send = new TaskDialogCommandLink(
 "SendFeedbackCommandLink",
 "Send Feedback",
 "Please send feedback to the team.");

send.Click += (sender, e) =>
{
 // send feedback

 dialog.Close();
};

var ignore = new TaskDialogCommandLink(
 "IgnoreCommandLink",
 "Ignore",
 "Please ignore this error.");

ignore.Click += (sender, e) => { dialog.Close(); };

dialog.Controls.Add(send);
dialog.Controls.Add(ignore);

dialog.Show();

Advertisements

2 thoughts on “MessageBox on Steroids”

    1. The TaskDialog is supported in Windows Vista and Windows 7 operating systems and IIRC the transparency effect will be dependent on Aero being enabled.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s