Windows 7 programming: Taskbar. Part 3 – OverlayIcon.

Windows 7 +1This time we will talk about other feature of task panel of Windows 7 – OverlayIcon. This possibility is very useful for applications which have any state from the point of view of the user.

For example, such applications are programs for an exchange of instant messages (IM). For example, Windows Live Messanger actively uses this possibility. For example, if we open WLM and we will change a state it is possible to see as it is displayed on the task panel of Windows 7.

Windows Live Messanger

Windows Live Messanger Windows Live Messanger

Such functionality can be useful to many applications. Fortunately to implement it not so it is difficult. As well as in the previous examples we will use library .NET Interop Sample Library.

To add a state icon to the main icon of the application, it is necessary to add a file of resources in the project and to place there the necessary icons. Also, we can get Icon objects from other places if it is necessary.


Now everything, that it is necessary to make is to use extension methods, allowing to set icons for our application. For these purposes method SetTaskbarOverlayIcon is defined. We should pass to them a form reference, an icon and a description. Thus, setting of a new icon from a code will look as follows.

WindowsFormsExtensions.SetTaskbarOverlayIcon(this, Icons.Error, "Error");

Also we can remove this icon. For this purpose it is necessary to pass null value instead of the icon.

WindowsFormsExtensions.SetTaskbarOverlayIcon(this, null, String.Empty);

Let’s create the small application in which we can switch a state. It will look as follows.

Sample application

By pressing each of buttons the state which is displayed in the task panel is switched.

Normal state Config state Error stateLogin state Stop state

Sample application:

Leave a Reply

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