【问题标题】:TaskDialog - no icon present on windows 10TaskDialog - Windows 10 上没有图标
【发布时间】:2015-10-18 18:52:37
【问题描述】:

想确认一些事情,因为我正在使用 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 中解决?

【问题讨论】:

    标签: vb.net


    【解决方案1】:

    抱歉,我找到了解决方案:

    对于每个 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
    

    【讨论】:

      猜你喜欢
      • 2014-04-28
      • 2017-09-04
      • 1970-01-01
      • 2021-01-30
      • 1970-01-01
      • 2015-10-25
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      相关资源
      最近更新 更多