Geeks With Blogs

Windows 7 +1Earlier I wrote how it is possible to add a icon of a state for your application in the task panel of Windows 7. We considered static images for these purposes. I will remind, that for this purpose we used SetTaskbarOverlayIcon method in which parametres the reference on Icon is transferred.

However, there are other scenarios in which on a place of an overlay icon few information is displayed. For example, it can be current download speed if your software something downloads from a network. Or it can be quantity of new letters in a mail box if it is the post client.

I will remind, that to set the static image it is necessary to execute the following code.

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

As the second parametre Icon object here is transferred. However who prevents to us to generate this object dynamically? Let's take advantage of a simple code and we will do it. I will create a method which will generate such image and I will show this icon.

private static Icon BuildIcon(int param)
    Bitmap image = Icons.BLANK2334242;
    Graphics.FromImage(image).DrawString(param.ToString(@"D2"), new Font("Arial", 54), Brushes.White, 10, 25);
    return Icon.FromHandle(image.GetHicon());
private void ShowStatus(object sender, EventArgs e)
    WindowsFormsExtensions.SetTaskbarOverlayIcon(this, BuildIcon(50, "Status");

Thus, by means of method BuildIcon the new icon which will be displayed on the task panel will be generated.

Custom OverlayIcon

On the given screenshot it is well visible, that to a standard icon we have added the text and have displayed it on the task panel.

In the sample application I have created the timer which simulates work of the download manager, giving out constantly different speed of downloading.

Sample application:

Posted on Tuesday, May 19, 2009 1:47 AM | Back to top

Comments on this post: Windows 7 programming: Taskbar. Part 4 – Custom OverlayIcon.

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © | Powered by: