Using hidden security icons in Taskdialog

I am trying to show a security success icon (with a blue background) in the TaskDialog message box. This is not one of the values ​​of the TaskDialogStandardIcon enumeration. Link: http://dotnet.dzone.com/articles/using-new-taskdialog-winapi .

How do I assign these custom values ​​to the sender ((TaskDialog)). Icon? Is this possible in C #? WITH#

Any pointers would be really helpful.

Regards, Ashwin

+3
source share
2 answers

It seems to me that you need to import TaskDialogfrom comctl32.dllyourself:

static class TaskDialogWrapper
{
    [DllImport("comctl32.dll", CharSet = CharSet.Unicode, EntryPoint = "TaskDialog")]
    static extern int TaskDialog(IntPtr hWnd, IntPtr hInstance, string pszWindowTitle, string pszMainInstruction, string pszContent, TaskDialogCommonButton dwCommonButtons, IntPtr pszIcon, out IntPtr pnButton);

    public static TaskDialogCommonButton Show(IntPtr handle, IntPtr instance, string title, string instructionText, string content, TaskDialogCommonButton commonButtons, TaskDialogCommonIcon commonIcon)
    {
        IntPtr resultButton;
        if (TaskDialog(handle, instance, title, instructionText, content, commonButtons, new IntPtr((int)commonIcon), out resultButton) != 0)
            throw new InvalidOperationException();
        return (TaskDialogCommonButton)resultButton;
    }
}

[Flags()]
enum TaskDialogCommonButton
{
    Ok = 0x1,
    Yes = 0x2,
    No = 0x4,
    Cancel = 0x8,
    Retry = 0x10,
    Close = 0x20
}

enum TaskDialogCommonIcon
{
    ShieldGrey = 65527,
    ShieldOk = 65528,
    ShieldError = 65529,
    ShieldWarning = 65530,
    ShieldBlue = 65531,
    Shield = 65532,
    Information = 65533,
    Error = 65534,
    Warning = 65535,
}

To use your own icon from the file, you will need to import TaskDialogIndirect.


(Btw., TaskDialogCommonIcon. , :

enum TaskDialogCommonIcon
{
    None = 0,
    Sheet = 2,
    ExplorerFolderOpen = 3,
    ExplorerFolderFlat = 5,
    ExplorerFolderLeft = 6,
    Search = 8,
    ExplorerFolderClosed = 10,
    ExplorerGames = 14,
    Application = 15,
    TransparentSpace = 17,
    ExplorerSearch = 18,
    TextFile = 19,
    Letter = 20,
    Picture = 21,
    Diashow = 103,
    // ...
}
+4

, , - , , , . , @KnorxThieus, "" TaskDialog, DLLImport, . , TaskDialogCommonIcon, , (.. TaskDialogCommonIcon), .

: 1.1AP WindowsAPICodePack 1.1 Nuget (nuget.org/packages/WindowsAPICodePack-Core), Visual Basic Telerik (http://converter.telerik.com/), , , #:

if (TaskDialog.IsPlatformSupported) {
    using (TaskDialog dialog = new TaskDialog()) {
        dialog.Caption = "TESTING";
        dialog.InstructionText = "THIS IS A TEST";
        dialog.Text = "This is a test of casting a value to the desired Icon type for a TaskDialog.";

        // Produces the green shield with green background
        dialog.Icon = (TaskDialogStandardIcon)65528;
        dialog.OwnerWindowHandle = this.Handle;
        dialog.Show();
    }
}

, , @KnorxThieus, , . , Icon () , . , , .

+3

All Articles