C#   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了c# – 在Taskdialog中使用隐藏的安全图标大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在TaskDialog消息框中显示安全成功图标(带蓝色背景).这不是TaskDialogStandarDicon的枚举值之一.参http://dotnet.dzone.com/articles/using-new-taskdialog-winapi.

如何将这些非标准值分配给((TaskDialog)发送者).Icon?它甚至可以在C#中使用吗? C#

任何指针都会非常有用.

问候,
阿什温

解决方法

我想你需要自己从comctl32.dll导入 TaskDialog函数

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,}

要从文件中使用您自己的图标,您需要导入TaskDialogIndirect.

(顺便说一下,我为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,// ...
}

大佬总结

以上是大佬教程为你收集整理的c# – 在Taskdialog中使用隐藏的安全图标全部内容,希望文章能够帮你解决c# – 在Taskdialog中使用隐藏的安全图标所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。