Windows 7 programming: Taskbar. Part 10 (final part) – JumpLists.
One of the major features of the task panel of Windows 7 are Jump Lists. Jump lists are displayed if to select an application icon in the task panel and to press the right button of the mouse. If the application uses functionality of JumpLists, then except standard actions (pin, close) there will be some more additional actions which facilitate our daily work.
This functionality of the task panel various appendices actively use. For example, Windows Media Player displays switching options for play lists. Internet Explorer and Windows Explorer contain in jump lists with references to last places where you came. Windows Live Messanger displays options of switching of a state.
In jump list there can be some various types of elements: tasks, references to last open documents and references to constant documents. Besides, these items can be pinned. Such elements will not disappear from jump list in due course. It is convenient, for example, if we often work with the same document. Schematically jump list it is possible to present as follows.
Actually, each item in jump list represents the reference to the program or a file. So, for example, we can start the calculator, or any document of the some format. Unfortunately, we do not have possibility directly to intercept event of pressing item in jump list. Each time when we choose the item, it will be started a new copy of the application. It is so because jump list it is possible to cause even then when the application is not started. In this case it should be pinned on the task panel. For example, in a following drawing it is visible, that Internet Explorer at present it is not started, but jump list we can open.
So, let's look how similar functionality can be implemented in our applications. For work with jump list we need to use the object of type JumpListManager which is a part of .NET Interop Sample Library. To create it it is necessary at the moment of creation of the button of our application on the task panel. For these purposes it is possible to override WndProc method as follows.
protected override void WndProc(ref Message m)
if (m.Msg == Windows7Taskbar.TaskbarButtonCreatedMessage)
_jumpListManager = WindowsFormsExtensions.CreateJumpListManager(this);
_jumpListManager.UserRemovedItems += (o, e) =>
e.CancelCurrentOperation = false;
// add items
Pay attention to a call of Refresh method after creation of object JumpListManager. The call of this method is necessary for updating of items in jump list. Also obligatory action is the subscription to UserRemovedItems event. It is executed when attempt of removal of out-of-date items from jump list is made. Let's now try add new items in jump list. For these purposes there are classes-wrappers and the necessary methods at object JumpListManager.
The most simple type of items in jump list - tasks. The tasks there can be a start of the external application or our application with any parametres. In WLM in the form of tasks switching of a state of the user is implemented. For task creation in jump list AddUserTask method is used.
Path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "calc.exe"),
Title = "Calculator",
Category = "Applications",
IconLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "calc.exe"),
IconIndex = 0
As we see, the new object of type ShellLink in which the way to the application is transferred, heading and a icon here is created. I have added in the application two tasks and have the following result.
Other variant of filling jump list - references to documents which have been loaded earlier. For these purposes I have created some text files with extension “.myapp” and I have associated this type of files with the application. Whether at an application launch I check the name of a file as parametre is transferred at an application launch. If the name is set, I read out this file and I add it in the list before the loaded files. For these purposes there is AddToRecent method.
if (File.Exists(Environment.GetCommandLineArgs().Skip(1).FirstOrDefault() ?? String.Empty) == true)
_jumpListManager.AddToRecent(Environment.GetCommandLineArgs().Skip(1).FirstOrDefault() ?? String.Empty);
Now from Windows Explorer I will open these files. My demonstration application (if we correctly associated the given type of files with the application) will be started thus. Thus by a call jump list I will see, that in a category “Recent” there were references to earlier open files.
I can pin those items with which I work more often. In this case I can quickly open the documents necessary to me via jump list.
Other way of placing of items in jump list - creation of references to constant documents/programs. In this case we also can group these items into categories. For these purposes there is AddCustomDestination method.
Path = @"about.txt",
Title = "About",
Category = "My application",
IconLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "shell32.dll"),
IconIndex = 11
I have added some such references in jump list and I have following result.
In this drawing it is visible, that there were two additional groups with references inside.
Remarkable feature of jump list is that its contents also are accessible in the "Start" menu. So, for example, if we actively use this functionality it it is possible to be used and from the starting menu.
Thus we can use additional functionality which gives us the task panel of Windows 7 for much as possible comfortable work of the user.
On it I finish a series of articles devoted to programming of the task panel for Windows 7. I hope this information it will appear useful to you and your applications. I wish to notice especially, that implementation of possibilities of the task panel of Windows 7 for your applications will not demand many efforts, but the result will not keep itself waiting long - will communicate with your application much more pleasantly and more conveniently.
Good luck to you in development of your Windows 7 applications!