Click here to Skip to main content
15,860,859 members
Articles / Programming Languages / C#
Tip/Trick

TaskDialog via Windows API Code Pack for Microsoft .NET Framework

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
29 Aug 2011CPOL2 min read 20.6K   6   2
Using the TaskDialog API as an attactive alternative to the standard windows MessageBox.


TaskDialog quick reference



I'm currently developing an application and I got so tired of looking at the same old MessageBox that I've been looking at for years and thought surely someone on CP has a better mouse trap. I found a few fairly decent solutions but then discovered that when Vista came out Microsoft included a very nifty TaskDialog control and provided an API but it was in unmanaged code. So I looked around a little more and
found an excellent article by KevinGre TaskDialog for WinFormsthat was basically a wrapper but when I tried to run it I had problems and as opposed to diving into old code (written in Jan 2007) I looked around for something more recent.


What I ran accoss is the Windows API Code Pack for Microsoft .NET Framework that included among a lot of other things a managed TaskDialog. So I download the code and included a reference in my code and followed the instructions that I had found on a couple of sites and when I ran it I got a "Unable to find an entry point name 'TaskDialogIndirect' in DLL 'comctl32.dll'" exception so it was back to google and it took quite a while but I found this article that proposed a trick that solved this problem and by gum it worked. In a nut shell this is what is needed to resolve the problem with the exception.


  • Open Project Properties
  • Go to Security Tab and click the Enable ClickOnce Security Settings don't
    close window yet
  • This will create an app.manifest file in the Properties solution folder.
  • Edit this file and under the </trustInfo> insert the code shown below.
  • Compile your soution, you will get an error
  • Go back to the ClickOnce option and deselect it.
  • Recompile your code. This time it will compile without errors and your code will
    run without exception.

<dependency>
  <dependentAssembly>
    <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
  </dependentAssembly>
</dependency>


I was so glad to find that article and it really is nice to be able to interact with the user using the new TaskDialog. It is so much more flexible and easy to
use.



As an added bonus during my googling I ran across this articledescribing some undocumented/hidden icons that are available for use in the TaskDialog.
The icon definitions are listed here;




Value
Description
0
None
65535
Warning
65535
Warning
65534
Error
65533
Information
65532
Shield
65531
SecurityShieldBlue
65530
SecurityWarning
65529
SecurityError
65528
SecuritySuccess
65527
SecurityShieldGray


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired
United States United States
Currently enjoying retirement and working on projects without pressure, deadlines or any kind of management.

Comments and Discussions

 
PraiseFantastic! Pin
chris_mackay8-Jul-21 16:19
chris_mackay8-Jul-21 16:19 
GeneralRe: Fantastic! Pin
Mike Hankey9-Jul-21 2:09
mveMike Hankey9-Jul-21 2:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.