Windows 7 programming: Taskbar. Part 1 - Progress Bar.

New OS Windows 7 contains a considerable quantity of innovations and improvements. These improvements concern safety, productivity, reliability etc. Also, the big attention is given to the user interface. In several posts we will talk about the innovations and program model.

The first that is appreciable in Windows 7 is, of course, updated task bar. In new taskbar many conceptual changes. One of such changes - possibility of display of progress of performance of a task (progress bar).

Windows 7 taskbar - progress

In this picture it is well visible, that on the taskbar the information on copying process is displayed. Such functionality is realised in Windows 7 with copying of files on a disk, downloading of data from a Internet (IE8). However, it is important, that we can use this functionality and for own applications. Scenarios can be different - display of process of transformation, copying, formation of data, construction of reports, generation of images, etc.

From the point of view of the developer of client Windows applications, process of use of the given functionality is very simple. Interaction occurs to OS on unmanaged level, therefore for.NET application implementation of managed wrappers is necessary. All this work was already done by developers from Microsoft and have placed it in  .NET Interop Sample Library.

The library “.NET Interop Sample Library” consists of set of components and demonstration applications. We will not stop in detail on each of them. For us it is important, that into its structure enters Vista Bridge Sample Library, Windows7.DesktopIntegration and Windows7.DesktopIntegration. Registration.

The project “Windows7.DesktopIntegration” contains those classes which are necessary for us for work with taskbar. As a part of this project there is class WindowsFormsExtensions, which contains a set of extension methods for class Form (Windows Forms). In our case following methods are interested for us:

  • SetTaskbarProgress(float percent)
  • SetTaskbarProgressState(ThumbnailProgressState state)

The call of the first method allows to specify percent of completion of a current task. Because it is extension method for class Form this class is passed in a method in parametre. It is necessary to define handle windows for which actions are carried out.

WindowsFormsExtensions.SetTaskbarProgress(this, 35);


We also have a possibility to specify a progress-bar state. Accessible states:

  • NoProgress – progress is not displayed
  • Indeterminate – progress a bar flickers
  • Normal – usual display of progress
  • Error – error display
  • Paused – pause display

The setting of the state of a progress-bar is carried out by the second method.

WindowsFormsExtensions.SetTaskbarProgressState(this, Windows7Taskbar.ThumbnailProgressState.Normal);

Unfortunately, such extension methods exist only for WinForms applications. However, it is simple to construct a similar class and for WPF applications (see the demo-app).

Finally I have created the small application which shows progress-bar possibilities in the Windows 7 taskbar.

Windows7 taskbar demo application

By means of buttons we can specify current value of a progress-bar, and also we can choose its state.

  • Mode “Normal”
  • Mode “Indeterminate”
  • Mode “Error”
  • Mode “Paused”

Good luck to you in development of your Windows 7 applications!

Sample application:

No Comments