From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

UI Interest Group Blog

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Using Windows 7 Taskbar Progress bar from LabVIEW

KvZ
Active Participant
Active Participant

Hi Everyone,

I've been using Windows 7 for a while now and I must say I like the improvements to the Taskbar. One feature that stood out to me, and which could be practical in a LabVIEW applications doing post processing for example, was the integrated progressbar in the Taskbar buttons.

Normal Progress.pngPaused Progress.pngError Progress.png

Seeing it's the last day be for Christmas I thought lest try and see if we can control this from LabVIEW. On the MSDN library I quickly found that there are two functions available on the ITaskbarList3 Interfaceto control the Progress bar behavior. Namely SetProgressState for controlling the State of the progressbar (Normal, Paused, Error, Indeterminate and NoProgress) and SetProgressValue for updating the progress. The only problem was that this is a static COM Interface implemented by Microsoft and I was unable to create this with the LabVIEW ActiveX interface API.

If I can't access an arbitrary feature with LabVIEW I typically tend to try and see if it can trough .Net. Because .Net is much more defined it's much easier to use in LabVIEW then a Win32 DLL or ActiveX COM object. In this case the nice developers from Microsoft already made a Interop Libraries for the Windows 7 Taskbar. This is basically a big example that you can add to your own .Net Application to access the Features of the Windows 7 Taskbar without having to program all the interoperability your self.

I just wanted to access the Progress Bar so I browsed trough the examples and build a Assembly that only exposes the two functions I needed (SetProgressState and SetProgressValue). Both functions require the Window Handle indorer to know which taskbar button needed to be updated. I already had VI that used the Win32 FindWindow function to retrieve the Window Handle of any Window based on it's exact Title. (This includes VI Front Panels ). I slightly altered this VI so it would return a IntPtr .Net Object instead of a the plain U32 so it can be used with the .Net InterOp functions. All that was left was wrapping the SetProgressState and SetProgressValue in a SubVI and the fun can begin.

Attached you can find a simple LabVIEW 2009 API and Example that uses the .Net Assembly to call in to the Windows 7 Taskbar. I also Included the C# source code of the assembly for those who are interested.

Have fun and let me know what you think.

Enjoy the Holidays

Karsten

UPDATE: LabVIEW Tools Network Release

The code from this blog post has recently been updated and released to the LabVIEW Tools Network as the LabVIEW Taskbar Progress bar API

This release requires LabVIEW 2010 or later. LabVIEW 2009 users can still use the original code attached to this blog post.

Karsten

Comments