デスクトップアプリケーションがあります。ジャンプリストメニューを追加しました。タスクバーのアイコンを右クリックすると、このメニューがジャンプリストに表示されます。問題は、メニュー項目をクリックしてもアクションが実行されないことです (つまり、アプリがそれをキャッチします)。次のリンクからコードを取得し、それに応じてカスタマイズしました (注: このコード ジャンプリストは、私の PC でも機能しません)。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);
どこが悪いのかわからない。私のアプリケーションでジャンプリストを適用するのを手伝ってください