As I promised sometime ago I was preparing a new blog series for Windows 7 development and how you can take advantage of some new APIs for TaskBar development etc. All of my examples were based on a library that Rob Jarett provided me. It was the same library he used during PDC for his own demos. When I was about to start posting and get it live, Windows API Code Pack made its appearance. Pretty much a very few parts regarding the TaskBar changed. All I had to do is use the new methods and namespaces to get them working.

Enough with the chit-chat, I updated my demos and my new post is ready.

If you’re not familiar with Windows API Code Pack you can get your hands on it at MSDN Code Gallery (http://code.msdn.microsoft.com/WindowsAPICodePack).

By the time this was getting posted, version number was 0.85. Download and extract and you’ll get a few new folders filled with samples and complete source code of each one of them. It covers from basics to DirectX 10 and of course the TaskBar. Unfortunately Multitouch API is missing. I’m not sure if it’s not going to be there at all.

Taskbar is not all about icons and how they look, but it’s also JumpList, ProgressBar and overlays. A Jumplist is categorized in either custom ones or build-in, like “Tasks” and “Frequent”. For each item we want to add in the Tasks category, we get a reference of the JumpList using a class called “TaskBar” and then we add new items to that list (UserTasks) just like this:

JumpList jumpList = Taskbar.JumpList;
jumpList.UserTasks.Add(new JumpListLink
{
    Title = "Ένα μήλο",
    Path = Path.Combine(Application.StartupPath, "apple.exe"),
    IconReference = new IconReference
        (Path.Combine(Application.StartupPath, "apple.exe"), 0)
});

Each JumpListLink has a lot of properties like a “Title”, “Path”, which icon is used, if you want command line arguments, what’s the working directory etc. A lot of people wonder when they first get in touch with the API “Is there a way I can call a method from my application when a JumpListLink is clicked, instead of calling a new application?”. Well, the answer is no. At least there is no easy way to do it. What it can do, is call itself (the host process) and you can take it over from there, use your favorite IPC way and notify your, already running, application to execute a specific command. If you look carefully that’s what Windows Live Messenger doing. Click to change your status from the Jumlist and pay attention how many processes will spawn. A new msgmsngr process is spawned which stays alive for about 3 seconds and then it exits.

In case you want to add a split line between links you simply add a new “JumpListSeperator” to the targt list and a horizontal line will appear.

jumpList.UserTasks.Add(new JumpListSeparator());

Keep in mind as we move on I’ll provide the full source code of my examples.

In my next post I’ll mess with the ProgressBar and explain how I can show progress on the TaskBar Icon.

‘Till next time, take care!