windows 处理使用 TrayIcon 的 ShowBalloonTip() 显示的气球提示上的单击

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3181594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:46:13  来源:igfitidea点击:

Handling a click over a balloon tip displayed with TrayIcon's ShowBalloonTip()

c#.netwindowsvb.net

提问by ariel

I use the ShowBalloonTipmethod of a TrayIconclass to display a balloon tip. Is there a way to handle a click over this balloon?

我使用类的ShowBalloonTip方法TrayIcon来显示气球提示。有没有办法处理这个气球上的点击?

When I click over the balloon, no event seem to be generated, and it only closes the balloon.

当我点击气球时,似乎没有生成任何事件,它只会关闭气球。

回答by Jalal

I think you mean NotifyIcon. Use following pattern...

我想你的意思是NotifyIcon。使用以下模式...

NotifyIcon notifyIcon = null;
public Form1()
{
    InitializeComponent();
    notifyIcon = new NotifyIcon();
    // Initializing notifyIcon here...
    notifyIcon.BalloonTipClicked += new EventHandler(notifyIcon_BalloonTipClicked);
}

void notifyIcon_BalloonTipClicked(object sender, EventArgs e)
{
    // Operation you want...
}

I hope it feed your needs...

我希望它满足您的需求...

回答by Jamie Keeling

Have you tried the following snippet? I managed to find it whilst doing a quick google search:

您是否尝试过以下代码段?我在进行快速谷歌搜索时设法找到了它:

private void TrayNotifyIcon_BalloonClick(object sender, EventArgs e)
{
    //Perform Action
}

Obviously you'll need to make sure you specify the correct name in the method signature for your own application.

显然,您需要确保在您自己的应用程序的方法签名中指定正确的名称。

I think this was written in an older version of the .Net Framework and there's probably a newly named method for it.

我认为这是用旧版本的 .Net Framework 编写的,并且可能有一个新命名的方法。

Source: Build a C# Notification System

来源:构建 C# 通知系统