0

New to VB.NET so sorry if this is a dumb question : I'm trying to add a progressbar behind the taskbar icon of my Windows Forms App to show it's status. I'd like to replicate the "Indeterminate" and "Paused" status : Taskbar Progress States

This Microsoft documentation explains what I'm looking to do but the property isn't recognized. I can't seem to find if I need to Import something or if it is simply not possible to do this with a Windows Forms App.

Thanks.

Guillaume G
  • 313
  • 1
  • 2
  • 15
  • The documentation refers to PresentationFramework (WPF). You can add references to these assemblies and import the namespaces you need. Note that as soon as you import WPF assemblies, your WinForms app will become DpiAware (`SystemAware`) - in case you're targeting .Net Framework - which may mess with your UI if you haven't built it with Dpi Awareness in mind (especially if your Forms are set to scale to Font). – Jimi May 20 '22 at 13:27
  • Thanks for your answer @Jimi. I didn't build it with DPI awareness in mind (since I didn't even knew that was a thing) but since my UI is quite "basic" I'm ready to try it out and see if it works. However I didn't find a lot ([or I didn't understood it](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/systems/xaml-resources-how-to-define-and-reference?view=netdesktop-6.0)) about WPF references... Can you tell me more about it ? – Guillaume G May 20 '22 at 13:43
  • It depends on what .Net version you're targeting. If it's .Net Framework, you need to add references to the `PresentationFramework` and `WindowsBase` and add a Imports directive to include `System.Windows.Shell`. You also need a WPF Window -- -- If you're targeting .Net 5+, you need to add `true` to the Project's file (`.vbproj`) -- IIRC, Windows API Code Pack -Shell should include this functionality, which can be applied to a Form. – Jimi May 20 '22 at 13:47
  • I'm using .NET Framework and I added everything however I can't seem to get [how to install the Windows API Code Pack](https://stackoverflow.com/a/24420985/17903744). Like, am I supposed to execute one of these lines on the Command Prompt ? Which one ? Thanks for taking the time to aswer me @Jimi. – Guillaume G May 20 '22 at 13:58
  • To install that package, in Visual Studio open up the NuGet Package Manager and search for `windows api code pack` -- It should be v. `1.1.4` – Jimi May 20 '22 at 14:00
  • Okay I got it thanks @Jimi. Now, how can I convert my form into a WPF one using the API Code Pack ? -- I got the `1.1.2` – Guillaume G May 20 '22 at 14:12
  • You don't need to. A WPF Window is required if you're using `PresentationFramework` assemblies. The Shell Api functionality applies to your Forms. No need for WPF stuff. – Jimi May 20 '22 at 14:15
  • Nope, you got the wrong one. You need this one: [Microsoft-WindowsAPICodePack-Shell](https://www.nuget.org/packages/Microsoft-WindowsAPICodePack-Shell/) (v. 1.1.4) – Jimi May 20 '22 at 14:30
  • Okay had to change my .NET Framework version but it installed thanks @Jimi. What did it actually changed ? Should the documentation work by now ? Because it's saying to me that I can't use `TaskbarItemProgressState` as an expression... -- PS : Not at work until monday so no need to hurry, thanks again – Guillaume G May 20 '22 at 14:46
  • 1
    As mentioned, that documentation is related to the WPF assemblies. The Shell Api Code Pack still uses WPF (so the same issues related to DpiAwareness will arise), but with its own methods. Take a look at [the sample code](https://github.com/contre/Windows-API-Code-Pack-1.1/tree/master/source) in relation to the `TaskbarWindow`. – Jimi May 20 '22 at 14:54

0 Answers0