Hi Coders !
Windows 7 comes with a cool feature of Jump Lists.
When we right click an application on taskbar, a list appears showing the recently opened items and pinned items for this application. That list is known as Jump List.
.Net 4.0 comes with handy Classes known as JumpTask and JumpList. By using these classes we can add custom items under custom categories to our application.
Here we go:
Works only in .NET Framework 4.0 and on Microsoft Windows 7 OS
Add the reference to the following 2 .NET assemblies:
1: Presentation Framework
2: Windows Base
Then on the Main Form of the application, import the following namespace:
Code:
Imports System.Windows.Shell
Now double click the Main Form or in the loading event of your main form, add the following code:
Code:
Dim newTask As New JumpTask
newTask.Title = "Visual Basic .NET"
newTask.Description= "Visit MPGH for VB.NET Tutorials."
newTask.Arguments = "/update...or what ever you want to do on clicking..."
newTask.CustomCategory = "MPGH"
Dim newList As New JumpList
newList.JumpItems.Add(newTask)
Dim app As New System.Windows.Application
JumpList.SetJumpList(app, newList)
Explaination:
Dim newTask As New JumpTask
Creates a new item for our list.
newTask.Title = "Visual Basic .NET"
Set the title of the item.
newTask.Description= "Visit MPGH for VB.NET Tutorials."
Set the description of the item. This will be shown when the user will move the mouse over the item.
newTask.Arguments = "/update...or what ever you want to do on clicking..."
Set the arguments for the item. Set this to perform the operation on clicking the item.
newTask.CustomCategory = "MPGH"
This will set the category for the item. By default, we see "Frequent", "Recent" and "Pinned" Items list in Windows 7. But we can have our own category and you can name it whatever you want. In this case I chose "MPGH".
Dim newList As New JumpList
Creates the list. We will add items in this list.
newList.JumpItems.Add(newTask)
Add the item to the list.
Dim app As New System.Windows.Application
We need to give a reference to our application so that Windows can recognize our application and can add the custom list and items to it. This will create a new recognizable instance of our application.
JumpList.SetJumpList(app, newList)
Finally call the JumpList method directly and add the list to the application. It takes two parameters. In the first we will refer our application instance. And in the second we will add the list.
Note: You can also turn on Frequent list and Recent list by using:
newList.ShowFrequentCategory
And
newList.ShowRecentCategory
You can now test the list by right clicking the application in the task bar.
Credits: This tutorial was originally written by Christian Mosers for WPF in C#. I converted the code to Windows Forms Application. e.g; Created the application instance and references. Also there's no original explaination of the code.
Greetz, MJLover