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: 

Re: 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
pflores
NI Employee (retired)

Very cool, I can definitely use this on my next project...

Thanks for sharing!

---

Peter Flores
Applications Engineer
TCPlomp
Trusted Enthusiast

Karsten, could you re-uploda the images?

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
KvZ
Active Participant
Active Participant

Hi Ton,

Don't know what happend there. I recreated the image again and it looks to be ok now.

Karsten

aThanatos
Member

Very nice!!!!

NJKirchner
Active Participant

Please make this a VI Package (ala, JKI.net VIPackage manager and post to either LAVA (http://www.lavag.org) or the LabVIEW Tools Network (http://www.ni.com/labviewtools/)

It will help others use it by having it easily in a palette, help you by allowing you to have it versioned, and help everyone by being able to easily install it.

Great work    

~,~

David_L
Active Participant

Karsten (et al). 

I agree, this is a great little tool, and a good candidate for the LabVIEW Tools Network.  For more information on packaging a LabVIEW API into a VI Package and posting it on the LabVIEW Tools Network, you can either view the LabVIEW Add-On Dev Center or contact the LabVIEW Partner Program and someone from our team would be glad to help.

David

KvZ
Active Participant
Active Participant

Norm / David,

Thanks, Good suggestion, I'll have a look at this next week it's been a while since I last looked at this code.

Karsten

Mr_J
Member

I've got this error when using it in an exe. How to avoid it?

error.jpeg

Thank you

KvZ
Active Participant
Active Participant

Hi Mr J

I've build the example that comes with the API into an application and this worked fine for me.

- Did you distribute the required Windows7Taskbar.dll with your application?

- You can also try to run the application as administrator. It looks like your hitting some sort of security problem.

If it runs as Administrator then the issue may be that the user account running the executable is missing cartain privalages. Running as the standard user should work fine as far as I know. It may be worth involving a IT expert at your site that knows about any restrictions that my apply for your particaler site / user?

Hope this helps.

Karsten

RobertCharly123
Member

You rule bro, thanks!

HunterSeeker
Member

Is there a Win 10 version of this?