【问题标题】:Jumplists in VB.NET Windows Form ApplicationVB.NET Windows 窗体应用程序中的跳转列表
【发布时间】:2021-04-26 20:05:44
【问题描述】:

有没有办法在 VB.NET Windows 窗体应用程序中创建 Windows 任务栏跳转列表?我想将我上次打开的文件添加到列表中。

我做了很多搜索,可以找到这个:https://docs.microsoft.com/en-us/dotnet/api/system.windows.shell.jumplist?redirectedfrom=MSDN&view=net-5.0,但我不知道如何让 System.Windows.Shell 在我的应用程序中可以访问。它说找不到命名空间。

您可以指出我的任何方向,我们将不胜感激!

【问题讨论】:

  • 您的项目中是否引用了 PresentationFramework.dll?
  • 该页面适用于 WPF/UWP,因此我不确定它是否可以在 WinForms 中运行。值得一试,但您可能至少需要做出重大改变。
  • Microsoft-WindowsAPICodePack-Shell(目标.Net Framework 4.8)
  • 我不确定这是否适合提出后续问题。如果没有,请告诉我。我可以通过添加对 PresentationFramework.dll 的引用来实现这种工作。现在发生的事情是每当我调用与 System.Windows.Application 相关的东西时,我的 gui 字体看起来比正常的要小得多。这是 WPF 与 Winforms 的区别吗?
  • 在此处阅读注释:DPI Awareness - Unaware in one Release, System Aware in the Other。如果要禁用通过引用 PresentationFramework 程序集引入的自动 DpiAwarenes,请跳到最后一段。 -- 我建议无论如何都要让你的应用 DpiAware。

标签: vb.net winforms jump-list


【解决方案1】:

这是我的工作:

Dim a As System.Windows.Application = System.Windows.Application.Current
If a Is Nothing Then a = New System.Windows.Application

Dim currJumpList As System.Windows.Shell.JumpList = JumpList.GetJumpList(a)
If currJumpList Is Nothing Then
    currJumpList = New JumpList
    JumpList.SetJumpList(a, currJumpList)
Else
    currJumpList.JumpItems.Clear()
End If

Dim jumpTask As JumpTask

jumpTask = New JumpTask
jumpTask.Title = "This is what gets shown to the user"
jumpTask.Description = "This is what the user sees if they hover or the item"
jumpTask.ApplicationPath = "pathToYourEXE"
jumpTask.Arguments = "Your arguments"
jumpTask.CustomCategory = "The category header"
currJumpList.JumpItems.Add(jumpTask)

currJumpList.Apply()

重要提示:

  • 您需要添加对 PresentationFramework.dll 的引用。如果您在 Visual Studio 中,则它在框架部分中。
  • 在对 JumpList 进行更改后调用 Apply() 非常重要。
  • 如果您是winforms,当您添加对您的PresentationFramework 的引用时,您会注意到GUI 的外观发生了变化。这似乎与 DPI 意识有关。要修复,请转到您的项目属性 --> 应用程序 --> 查看 Windows 设置。这应该会调出你的 app.manifest。在那里,您会看到关于 dpiaware 的评论部分。取消注释整个部分。尝试将值设置为 true / false。我发现 false 会使 GUI 看起来像以前一样,而 true 提高了我的 GUI 中字体的清晰度。不过,这两个值都应该可以解决问题。

【讨论】:

    猜你喜欢
    • 2011-11-09
    • 2023-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多