cks*_*ubs 3 c# windows click winforms
我正在创建一个仅限System-Tray的应用程序.拥有没有主窗体的图标有点复杂,但是通过StackOverflow上的先前主题我已经解决了.右键单击工作正常,我已在上下文菜单中链接等.
我在左键单击时遇到问题.据我所知,"notifyIcon1_Click"事件根本没有触发.
private void notifyIcon1_Click(object sender, EventArgs e)
{
Debug.WriteLine("Does it work here?");
if (e.Equals(MouseButtons.Left))
{
Debug.WriteLine("It worked!");
}
}
Run Code Online (Sandbox Code Playgroud)
这些调试行都没有输出,该事件中的断点不会停止程序等.
我做错了吗?我的下一步应该是什么?我正在使用Windows 7在C#中对此进行编码,如果这对任务栏行为完全重要的话.
如果要确定是左键还是右键,请将MouseClick连接,而不是单击.
这样你会得到这样的签名:
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
//Do the awesome left clickness
else if (e.Button == MouseButtons.Right)
//Do the wickedy right clickness
else
//Some other button from the enum :)
}
Run Code Online (Sandbox Code Playgroud)