Aug 122010
 

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>