C# NotifyIcon实现单击左键也弹出菜单的方法
private void systemNotifyIcon_MouseClick(object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Left:
systemNotifyIcon.ContextMenuStrip = systemNotifyLeftMenuStrip;
Type t = typeof(NotifyIcon);
System.Reflection.MethodInfo mi = t.GetMethod("ShowContextMenu", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
mi.Invoke(this.systemNotifyIcon, null);
systemNotifyIcon.ContextMenuStrip = systemNotifyRightMenuStrip;
break;
case MouseButtons.Right:
systemNotifyIcon.ContextMenuStrip = systemNotifyRightMenuStrip;
break;
case MouseButtons.Middle:
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Normal;
}
break;
case MouseButtons.None:
default:
break;
}//end switch
}//end method