【问题标题】:Taskbar right click application context menu for windows vista and higherwindows vista 及更高版本的任务栏右键单击应用程序上下文菜单
【发布时间】:2012-08-21 08:13:11
【问题描述】:

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

【问题讨论】:

标签: c# taskbar windows-messages


【解决方案1】:

您正在寻找的是 Associating a Context Menu with a Windows Forms NotifyIcon Component

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;
}

【讨论】:

  • 右键单击托盘图标时,我已经有了菜单。现在我需要为 taskbar 中的按钮复制它。不同的东西。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多