Using TaskDialogIndirect in C #
I've been working with a regular Windows Vista / 7 TaskDialog for a while, and I wanted to add some additional functionality (like custom buttons and footer), so I need to use TaskDialogIndirect .
Following the MSDN documentation for TaskDialogIndirect I got this signature:
[DllImport("comctl32.dll",CharSet = CharSet.Unicode,EntryPoint="TaskDialogIndirect")]
static extern int TaskDialogIndirect (TASKDIALOGCONFIG pTaskConfig, out int pnButton, out int pnRadioButton, out bool pfVerificationFlagChecked);
Below is the TASKDIALOGCONFIG class :
public class TASKDIALOGCONFIG
{
public UInt16 cbSize;
public IntPtr hwndParent;
public IntPtr hInstance;
public String dwFlags;
public String dwCommonButtons;
public IntPtr hMainIcon;
public String pszMainIcon;
public String pszMainInstruction;
public String pszContent;
public UInt16 cButtons;
public TASKDIALOG_BUTTON pButtons;
public int nDefaultButton;
public UInt16 cRadioButtons;
public TASKDIALOG_BUTTON pRadioButtons;
public int nDefaultRadioButton;
public String pszVerificationText;
public String pszExpandedInformation;
public String pszExpandedControlText;
public String pszCollapsedControlText;
public IntPtr hFooterIcon;
public IntPtr pszFooterText;
public String pszFooter;
// pfCallback;
// lpCallbackData;
public UInt16 cxWidth;
}
Implementation of TASKDIALOG_BUTTON:
public class TASKDIALOG_BUTTON
{
public int nButtonID;
public String pszButtonText;
}
I'm not entirely sure if I'm correct here. Has anyone used TaskDialogIndirect from managed code directly through WinAPI (no VistaBridge or Windows Code Code Pack)? I am curious about possible implementations as well as callback declarations (I'm not really sure how to implement TaskDialogCallbackProc ).
PS: I'm looking for a direct WinAPI implementation, not a single wrapper.
a source to share
PInvoke.NET is a great resource for PInvoke technologies. Unfortunately, they only have a TODO stub for the TaskDialogIndirect .
a source to share
Take a look at http://www.codeproject.com/Articles/21276/Vista-TaskDialog-Wrapper-and-Emulator . Specifically, the VistaUnsafeNativeMethods.cs file has the appropriate bits DllImport
including VistaTaskDialogCallback
, which I think is the callback you are interested in.
a source to share