2

我需要知道 C# 中 windows vista 和更高版本的任务栏右键单击应用程序上下文菜单的代码。对于旧版本的 Windows,此代码为 0x313。在 vista 及更高版本中,此代码意味着 shift + 右键单击​​。我只能在任务栏的应用程序上下文菜单中找到右键单击的代码。

4

1 回答 1

-1

您正在寻找的是 关联上下文菜单与 Windows 窗体 NotifyIcon 组件

Windows 窗体 NotifyIcon 组件在任务栏的状态通知区域中显示一个图标。通常,应用程序允许您右键单击此图标以向它所代表的应用程序发送命令。通过将 ContextMenu 组件与 NotifyIcon 组件相关联,您可以将此功能添加到您的应用程序中。

public NotifyIcon notifyIcon1 = new NotifyIcon();
public ContextMenu contextMenu1 = new ContextMenu();

public void createIconMenuStructure()
{
   // Add menu items to context menu.
   contextMenu1.MenuItems.Add("&Open Application");
   contextMenu1.MenuItems.Add("S&uspend Application");
   contextMenu1.MenuItems.Add("E&xit");

   // Set properties of NotifyIcon component.
   notifyIcon1.Visible = true;
   notifyIcon1.Icon = new System.Drawing.Icon
      (System.Environment.GetFolderPath
      (System.Environment.SpecialFolder.Personal)
      + @"\Icon.ico");
   notifyIcon1.Text = "Right-click me!";
   notifyIcon1.ContextMenu = contextMenu1;
}
于 2012-08-21T08:17:59.493 回答