显示带有进度栏和自定义按钮的任务对话框时出错
我正在 WindowsAPICodePack 中使用 TaskDialog。当我尝试创建一个没有 TaskDialogProgressBar 和 TaskDialogButton 的 TaskDialog 时,它会引发以下异常。
System.ComponentModel.Win32Exception 未处理 消息=Win32 调用的参数无效。 来源=Microsoft.WindowsAPICodePack 错误代码=-2147467259 本机错误代码=0 内部异常:System.ArgumentException Message=Value 不在预期范围内。 InnerException:
我想要一个带有进度条的任务对话框来报告状态,但我不希望用户在进度完成之前关闭对话框。所以我使用 TaskDialogButton 而不是标准关闭按钮。
这是我正在使用的代码。
_taskDialog = new TaskDialog();
_taskDialog.Cancelable = true;
_taskDialog.Caption = "Delete Account";
_taskDialog.InstructionText = "Deleting Account(s)";
_taskDialog.Text = "Please wait until the delete operation completes.";
TaskDialogProgressBar progressbar = new TaskDialogProgressBar();
progressbar.State = TaskDialogProgressBarState.Marquee;
_taskDialog.ProgressBar = progressbar;
TaskDialogButton btnClose = new TaskDialogButton();
btnClose.Click += new EventHandler(OnCloseClick);
_taskDialog.Controls.Add(btnClose);
//_taskDialog.StandardButtons = TaskDialogStandardButtons.Close;
_taskDialog.Icon = TaskDialogStandardIcon.Information;
_taskDialog.OwnerWindowHandle = this.Handle;
_taskDialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
_taskDialog.Show();
关闭按钮单击的事件处理程序
void OnCloseClick(object sender, EventArgs e)
{
if (_taskDialog != null)
_taskDialog.Close();
}
- Matt。
I am using the TaskDialog within WindowsAPICodePack. When I try to create a TaskDialog without just a TaskDialogProgressBar and TaskDialogButton it throws the follow exception.
System.ComponentModel.Win32Exception was unhandled
Message=Invalid arguments to Win32 call.
Source=Microsoft.WindowsAPICodePack
ErrorCode=-2147467259
NativeErrorCode=0
InnerException: System.ArgumentException
Message=Value does not fall within the expected range.
InnerException:
I wanted to have a TaskDialog with the ProgressBar to report the Status, but I dont want the user to close the dialog until the Progress is completed. So I am using a TaskDialogButton instead of the Standard Close button.
Here is the code I am using.
_taskDialog = new TaskDialog();
_taskDialog.Cancelable = true;
_taskDialog.Caption = "Delete Account";
_taskDialog.InstructionText = "Deleting Account(s)";
_taskDialog.Text = "Please wait until the delete operation completes.";
TaskDialogProgressBar progressbar = new TaskDialogProgressBar();
progressbar.State = TaskDialogProgressBarState.Marquee;
_taskDialog.ProgressBar = progressbar;
TaskDialogButton btnClose = new TaskDialogButton();
btnClose.Click += new EventHandler(OnCloseClick);
_taskDialog.Controls.Add(btnClose);
//_taskDialog.StandardButtons = TaskDialogStandardButtons.Close;
_taskDialog.Icon = TaskDialogStandardIcon.Information;
_taskDialog.OwnerWindowHandle = this.Handle;
_taskDialog.StartupLocation = TaskDialogStartupLocation.CenterOwner;
_taskDialog.Show();
EventHandler for Close Button Click
void OnCloseClick(object sender, EventArgs e)
{
if (_taskDialog != null)
_taskDialog.Close();
}
-Matt.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试两件事:
首先将 taskDialog StandardButtons 属性设置为 None:
其次给 btnClose 命名:
Try two things:
First set the taskDialog StandardButtons property to None:
Second give btnClose a name: