我在WindowsAPICodePack中使用TaskDialog。当我尝试创建一个不带TaskDialogProgressBar和TaskDialogButton的TaskDialog时,它抛出了以下异常。
System.ComponentModel.Win32Exception未处理Win32调用的Message=Invalid参数。Source=Microsoft.WindowsAPICodePack ErrorCode=-2147467259 NativeErrorCode=0 InnerException: System.ArgumentException Message=Value不在预期范围内。InnerException:
我希望有一个带有ProgressBar的TaskDialog来报告状态,但我不希望用户在进度完成之前关闭对话框。所以我使用的是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();用于单击关闭按钮的EventHandler
void OnCloseClick(object sender, EventArgs e)
{
if (_taskDialog != null)
_taskDialog.Close();
}-Matt。
发布于 2011-08-30 22:05:28
尝试两种方法:
首先将taskDialog StandardButtons属性设置为None:
_taskDialog.StandardButtons = TaskDialogStandardButtons.None;第二,给btnClose起个名字:
TaskDialogButton btnClose = new TaskDialogButton() { Text = "I'm a button" };https://stackoverflow.com/questions/6598274
复制相似问题