Progress Indicator in Windows 7 Taskbar

One of little things that mean a lot in Windows 7 is (at least for me) ability to show progress in taskbar. There is no longer need to Alt-Tab every minute or so into long running task (most often file copy). Progress of any long-running operation can (and should) be visible in taskbar button itself.

It is surprisingly easy to use this feature in our programs. Everything that we need is contained withing two functions: SetProgressState and SetProgressValue. Setting percentage is as easy as

var res = _taskbarList.SetProgressValue(owner.Handle, (ulong)newProgressPercentage, 100);

Although that minimal code will do it's work, there is need for some additional preparation around it. We need to initialize feature itself, we need to check whether function is even available (XP is pretty much alive) and some error checking would be nice touch.

Because of this I made sample class in C# that should enable your program to have all those goodies. And, as always, sample is available for download.

Leave a Reply

Your email address will not be published. Required fields are marked *