TaskDialog - Windows 10上没有图标

时间:2015-10-18 10:33:37

标签: vb.net

想确认一些事情,因为我使用的是Windows 10,而TaskDialog似乎没有显示任何可用的TaskDialogStandardIcon。有人可以确认在Windows 7上是否有相同的行为?如果是这样,如何在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中解决这个问题?

1 个答案:

答案 0 :(得分:0)

对于我找到解决方案的主题感到抱歉:

对于每个TaskDialog,我们必须按如下方式创建Opened的事件处理程序:

 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 Sub