我有以下代码允许我的控制台应用程序使用图标进入托盘:
Sub Main()
Dim tray As New NotifyIcon()
tray.Icon = My.Resources.phoneIcon
tray.Text = "Left Click to show console window"
tray.Visible = True
AddHandler tray.Click, AddressOf iconClicked
ShowWindow(int, False)
System.Windows.Forms.Application.Run()
End Sub
Private Sub iconClicked(ByVal sender As Object, ByVal e As EventArgs)
if mouseLeft then
ShowWindow(int, True)
else
ShowWindow(int, False)
end if
End Sub
它还允许在左键单击托盘图标时重新启动控制台。问题是,我需要能够右键单击以将其取回。
如何使用 ByVal e As EventArgs 或 ByVal sender As Object 来检测按下了哪个鼠标按钮?