如何在用户单击NotifyIcon后打开url
这是我的代码
public void ShowNotofication(string messages, string url)
{
var notification = new System.Windows.Forms.NotifyIcon()
{
Visible = true,
Icon = System.Drawing.SystemIcons.Information,
// optional - BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info,
// optional - BalloonTipTitle = "My Title",
BalloonTipText = messages,
};
notification.BalloonTipClicked += new EventHandler((sender, e) => OpenChrome(url));
notification.ShowBalloonTip(5000);
}
public void OpenChrome(string url)
{
Process process = new Process();
process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
process.StartInfo.Arguments = url + " --new-window";
process.Start();
}将显示通知,但从未调用过OpenChrome方法。
我怎么才能修复它?
发布于 2020-09-13 05:37:30
尝试将其更改为以下内容:
notification.Click += new EventHandler((sender, e) => OpenChrome(url));而不是这样:
notification.BalloonTipClicked += new EventHandler((sender, e) => OpenChrome(url));然后浏览器将打开。
https://stackoverflow.com/questions/63859994
复制相似问题