我想确认一些事情,因为我使用的是Windows10,而TaskDialog似乎没有显示任何可用的TaskDialogStandardIcon。例如,有没有人能确认Windows7是否也有同样的行为?如果是这样的话,如何在WIndows 10上修复这个问题?
示例代码:
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim dialog As New TaskDialog()
dialog.Caption = "Application Error"
dialog.InstructionText = "CRASH AND BURN!"
dialog.Text = "The application has performed an illegal action. Thisaction has been logged and reported."
dialog.Icon = TaskDialogStandardIcon.Error
dialog.Cancelable = False
dialog.DetailsExpanded = False
dialog.DetailsCollapsedLabel = "Show Expanded Text"
dialog.DetailsExpandedLabel = "Hide Expanded Text"
dialog.DetailsExpandedText = "### Start of Expanded Text ###" & Environment.NewLine & "" + Environment.NewLine + "### End of Expanded Text ###"
Dim minValue As Integer = 0
Dim maxValue As Integer = 100
Dim currentValue As Integer = 20
dialog.ProgressBar = New TaskDialogProgressBar(minValue, maxValue, currentValue)
dialog.Show()
End Sub我找到了这个主题:Windows API Code Pack TaskDialog missing icon
你知道这是否可以解决我的问题,以及如何在vb.net中解决它?
发布于 2015-10-18 18:52:37
很抱歉这个话题我找到了解决方案:
对于每个TaskDialog,我们必须使事件处理程序打开,如下所示:
Public Sub taskDialog_Opened(sender As Object, e As EventArgs)
Dim taskDialog As TaskDialog = TryCast(sender, TaskDialog)
taskDialog.Icon = taskDialog.Icon
taskDialog.FooterIcon = taskDialog.FooterIcon
taskDialog.InstructionText = taskDialog.InstructionText
End Sub然后,它将如下所示:
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim mydialog As New TaskDialog
mydialog.Caption = "Application Error"
mydialog.InstructionText = "CRASH AND BURN!"
mydialog.Text = "The application has performed an illegal action. Thisaction has been logged and reported."
mydialog.Icon = TaskDialogStandardIcon.Error
AddHandler mydialog.Opened, AddressOf taskDialog_Opened '<========
mydialog.Show()
End Subhttps://stackoverflow.com/questions/33196913
复制相似问题