So this has bugged me one two many times. TIME TO SETTLE THE SCORE!
Have you ever wanted to create those vista-style dialog boxes in managed code with .NET?
These are the kind of dialogs I am talking about:


What you want is the new Vista TaskDialog. Very powerful, very versatile. But as you will see from the quote on www.wintaskdialog.com they are not as easy as they seem to create:
“Microsoft Windows Vista introduced a new standard dialog box, called task dialog, to present choices in a clear and consistent way, with a standardized look and layout. Task dialogs enable developers to create well-designed, consistent dialogs boxes efficiently and it is a versatile alternative to the old message box which has often been used to create dialog boxes that are difficult to understand and use. There are no standard classes in .NET framework to work with task dialogs and in order to work with task dialogs on Windows Vista operating system .NET developers needed to work directly with the task dialog API (unmanaged code) that is provided with Windows Vista operating system. Applications written for .NET framework are supposed to work on every platform (operating system) that is supported by the .NET framework. Since task dialogs were introduced with Windows Vista there was obviously a problem what to do when an application is run on other operating systems like Windows XP for example.”
After reading that and doing a bit of research, it had become clear that there was no inherent support within the .NET Framework to perform such an operation in a managed code way; you must invoke the native Windows API and make a call to TaskDialog available in the COMCTL32.dll v6 (which ships with Vista).
Of course I personally like things very clean and did not want external API calls riddled throughout my code, so I immediately wished to make a standard library/wrapper for this, but then realised a library like this would no doubt exist already out there, so after doing a bit of searching I came across a bunch of great libraries that were already created to handle the task.
After looking through a bunch of sample code from the various projects I narrowed down the choices to these three:
- Vista TaskDialog Wrapper and Emulator – Very light weight, written in C#, provides non-vista system emulation which is also visually very close to the real thing, but offers limited functionality.
- VDialog (Vista TaskDialog for Windows XP) – Little heavier, more functionality, also provides non-vista system emulation with a very close visual match and written in VB.NET.
- Win Task Dialog – Complete functionality, quite heavy, also emulated almost visually identically but comes at a small price (albeit fairly cheap).
- Using Windows Vista’s TaskDialog API in managed code (C#) - First article I came across, but is explicitly for Vista/Windows Server 2007+ deployment only.
Remember, the benefit with the top three libraries above is primarily their Windows XP emulation support, as unless you are developing strictly for Windows Vista or Windows Server 2007+, utilising the TaskDialog API will break. The above projects use TaskDialog where available, otherwise they emulate this behaviour by rolling-out their own form with a near identical substitute.
I decided to go with the C# library as I prefer that it is lightweight and I do not need complex functionality, but would like my dialogs to be displayed in the newer, and preferred way as set out in the Vista Design Guidelines for Dialogs.
2 Comments
Did you take a look at the Avalon library available on CodePlex?
http://www.codeplex.com/wpfcontrib
I used it in several projects and it seems to do the trick.
No I haven’t Dawid, but from reading the project description it seems to only apply to WPF. I required this code-base to function in Windows Forms also
Thanks for your comments!
2 Trackbacks/Pingbacks
Vista-style dialog using TaskDialog (with Windows XP emulation!) « {Programming} & Life…
Thank you for submitting this cool story – Trackback from DotNetShoutout…
[...] for the suite of Vista controls, namely TaskDialog and Command Links. I have already blogged about the Vista TaskDialog which is a cool multi-purpose message dialog window which is highly customisable and offers a [...]
Post a Comment