我有一个桌面应用程序。我添加了跳转列表菜单。当我右键单击任务栏上的图标时,此菜单会出现在 Jumplist 中。问题是当我单击菜单项时,它没有执行任何操作(即,我的应用程序确实捕获了它)。我从以下链接获取代码并相应地对其进行了自定义(注意:此代码跳转列表在我的电脑上也不起作用)。我正在使用 Visual Studio 2013 和 Windows 10。
http://www.codeproject.com/Articles/103913/How-to-Create-a-Custom-Jumplist-with-Custom-Events
在 Program.cs 我添加了以下代码。
[STAThread]
private static void Main()
{
bool firstInstance = false;
Mutex mtx = new Mutex(true, "Jumplist.demo", out firstInstance);
if (firstInstance)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmSelect());
}
else
{
// Send argument to running window
HandleCmdLineArgs();
}
}
public static void HandleCmdLineArgs()
{
if (Environment.GetCommandLineArgs().Length > 1)
{
switch (Environment.GetCommandLineArgs()[1])
{
case "-1":
MessageBox.Show(@"-1");
break;
case "-2":
MessageBox.Show(@"-2");
break;
case "-3":
MessageBox.Show(@"-3");
break;
}
}
}
}
Myjumplist 类具有以下代码
public class MYJumpList
{
private JumpList jumpList;
/// <summary>
/// Creating a JumpList for the application
/// </summary>
/// <param name="windowHandle"></param>
public goJumpList(IntPtr windowHandle)
{
TaskbarManager.Instance.ApplicationId = "MyJumplist";
jumpList = JumpList.CreateJumpListForIndividualWindow(TaskbarManager.Instance.ApplicationId, windowHandle);
jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
BuildList();
}
public void AddToRecent(string destination)
{
jumpList.AddToRecent(destination);
jumpList.Refresh();
}
/// <summary>
/// Builds the Jumplist
/// </summary>
private void BuildList()
{
JumpListLink jlItem1 = new JumpListLink(Assembly.GetEntryAssembly().Location, "Item1");
jlItem1.Arguments = "-1";
JumpListLink jlItem2 = new JumpListLink(Assembly.GetEntryAssembly().Location, "Item2");
jlItem2.Arguments = "-2";
JumpListLink jlItem3 = new JumpListLink(Assembly.GetEntryAssembly().Location, "Item3");
jlItem3.Arguments = "-3";
jumpList.AddUserTasks(jlItem1);
jumpList.AddUserTasks(jlItem2);
jumpList.AddUserTasks(jlItem3);
jumpList.AddUserTasks(new JumpListSeparator());
jumpList.Refresh();
}
}
我的主表单构造函数具有以下跳转列表代码行
jumpList = new MyJumpList(this.Handle);
我不知道哪里错了。请给我任何帮助以在我的应用程序中应用跳转列表