Ejemplo n.º 1
0
        public static void TestTaskDialog(string caption, string[] argv)
        {
            int c1, c2, c3;

            TaskDialog(IntPtr.Zero, IntPtr.Zero, caption, "无效的命令行参数", string.Join(" ", argv), TaskDialogCommonButton.TDCBF_OK_BUTTON | TaskDialogCommonButton.TDCBF_CANCEL_BUTTON | TaskDialogCommonButton.TDCBF_RETRY_BUTTON, TaskDialogIcons.TD_WARNING_ICON, out c1);

            TASKDIALOGCONFIG task = new TASKDIALOGCONFIG();

            task.cbSize  = SIZEOF_TASKDIALOGCONFIG;
            task.dwFlags = TaskDialogFlags.TDF_ENABLE_HYPERLINKS | TaskDialogFlags.TDF_CALLBACK_TIMER | TaskDialogFlags.TDF_CAN_BE_MINIMIZED
                           | TaskDialogFlags.TDF_EXPANDED_BY_DEFAULT
                           | TaskDialogFlags.TDF_USE_COMMAND_LINKS
                           | TaskDialogFlags.TDF_VERIFICATION_FLAG_CHECKED
                           | TaskDialogFlags.TDF_SHOW_MARQUEE_PROGRESS_BAR
                           | TaskDialogFlags.TDF_EXPAND_FOOTER_AREA
            ;
            // TaskDialogFlags.TDF_USE_HICON_MAIN | TaskDialogFlags.TDF_USE_HICON_FOOTER  |
            task.dwCommonButtons        = TaskDialogCommonButton.TDCBF_OK_BUTTON | TaskDialogCommonButton.TDCBF_CANCEL_BUTTON | TaskDialogCommonButton.TDCBF_RETRY_BUTTON;
            task.pszWindowTitle         = caption;
            task.hMainIcon              = TaskDialogIcons.TD_ERROR_ICON;
            task.pszMainInstruction     = "无效的命令行参数";
            task.pszContent             = string.Join(" ", argv);
            task.cButtons               = 2;
            task.nDefaultButton         = DialogButtonIds.IDOK;
            task.pszVerificationText    = "关闭后以默认参数运行程序";
            task.pszExpandedInformation =
                @"以下是有效的命令行参数:
    /designer
    /report
    /help, /?";
            task.pszExpandedControlText  = "隐藏更多内容";
            task.pszCollapsedControlText = "显示更多内容";
            task.hFooterIcon             = TaskDialogIcons.TD_INFORMATION_ICON;
            task.pszFooter  = @"<A HREF=""http://localhost/"">点击这里</A>查看相关说明。";
            task.cxWidth    = 300;
            task.pfCallback = TaskDialogCallback;

            task.pButtons = TASKDIALOGCONFIG.MarshalButtons(new[]
            {
                new TaskDialogButton()
                {
                    nButtonID = DialogButtonIds.IDOK, pszButtonText = "OKOKOKOKOKOK\n**HA-HA-HA-HA-HA"
                },
                new TaskDialogButton()
                {
                    nButtonID = DialogButtonIds.IDNO, pszButtonText = "NONONONONONO\n**YE-YE-YE-YE-YE"
                }
            });

            using (task)
            {
                var    sz = Marshal.SizeOf(typeof(TASKDIALOGCONFIG));
                IntPtr v  = TaskDialogIndirect(ref task, out c1, out c2, out c3);
            }
        }
Ejemplo n.º 2
0
 public static extern IntPtr TaskDialogIndirect(ref TASKDIALOGCONFIG task, out int button, out int radioButton, out int verificationChecked);