C# 任务栏中的 Windows 7 进度条?
如果您注意到在 Windows 7 Beta 中,如果您复制文件或其他系统操作,任务栏中的 Windows 资源管理器图标将填充一个绿色进度条,相当于表单上的进度条。有没有一种方法可以在我的 C# 表单中强制我的任务栏进度条与我正在执行的任何任务的进度相匹配?转换、传输、生成,进度条的用途实在是太多了。
If you've noticed in the Windows 7 beta, if you copy files or other system actions, the windows explorer icon in the taskbar will fill up with a green progress bar equivalent to the progress bar on the form. Is there a way that, in my C# forms, I can force my taskbar progress bar to match the progress of whatever task I'm doing? Converting, transferring, generating, there are so many uses for that progress bar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
我只是想向我的 WinForms 应用程序添加一些任务栏进度动画,
无需下载代码包或切换到 WPF 即可使用 TaskbarItemInfo。
解决方案是使用 ITaskbarList3 接口的类:
使用起来如何简单的示例:
I just wanted to add some taskbar progress animation to my WinForms application,
without having to download code packs or switch to WPF to use TaskbarItemInfo.
The solution was a class that uses the ITaskbarList3 interface:
Example of how easy it is to use:
对于那些想要跳过阅读文档而只想获得有用的东西的人...
Microsoft.WindowsAPICodePack.dll
Microsoft.WindowsAPICodePack.Shell.dll
--
For people who want to skip reading the documentation and just get something that works...
Microsoft.WindowsAPICodePack.dll
Microsoft.WindowsAPICodePack.Shell.dll
--
查看适用于 Microsoft .Net Framework 的 Windows API 代码包。
Look into the Windows API Code Pack for Microsoft .Net Framework.
是的,Microsoft 在以下文档(包括来源)中介绍了新的任务栏功能: Windows 7 任务栏:开发人员资源
Yes, Microsoft covered the new taskbar functions in the following document (sources included): Windows 7 taskbar: Developer Resources
是的,你需要使用这个API。
http://code.msdn.microsoft.com/WindowsAPICodePack
Yes, you need to use this API.
http://code.msdn.microsoft.com/WindowsAPICodePack
使用 Windows 10.0.19044 进行测试
Easily add taskbar progress to the taskbar icon of an existing form.
No NuGet package, no complex coding... just copy/paste.
您需要添加到表单的唯一代码是调用更新图标的新表单属性。 (既然可以避免,为什么还要用 API 调用、过程和枚举来破坏表单呢?)
将以下代码放入项目中的新类模块中。
将
ProgressForm
添加到需要显示进度的表单:将此示例代码添加到您的表单并逐步执行它以观察其工作情况:
Tested with Windows 10.0.19044
Easily add taskbar progress to the taskbar icon of an existing form.
No NuGet package, no complex coding... just copy/paste.
The only code you need to add to your form, are calls to the new form properties which update the icon. (Why junk up your form with API calls, procs, and an enum... when it can be avoided?)
Put the following code into a new class module in your project.
Add
ProgressForm
to the form which needs the ability to show progress:Add this sample code to your form and step through it to watch it work:
我发现了一篇漂亮的文章(链接),为任务栏进度条问题提供了一个简单的解决方案。总之,它指示您从 MSDN 下载 Windows API 包 网站,添加对其包含的 Microsoft.WindowsAPICodePack.Shell.dll 的引用,最后向您的应用程序添加三行代码:
其中 X 是您要显示的进度。
I found a beautiful article (Link) that provides a simple solution to the taskbar progress bar problem. In summary, it instructs you to download the Windows API pack from the MSDN website, adding a reference to the Microsoft.WindowsAPICodePack.Shell.dll that it contains, and finally add three lines of code to your application:
where X is the progress you want to display.