0

How can i open an url after user clicked on NotifyIcon?

this is my code

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();
}

Notification are showed but OpenChrome method never called.

how can i fix it?

farhad
  • 55
  • 1
  • 7

1 Answers1

1

Try changing it to this:

notification.Click += new EventHandler((sender, e) => OpenChrome(url));

Instead of this:

notification.BalloonTipClicked += new EventHandler((sender, e) => OpenChrome(url));

Then the browser will open.

VDWWD
  • 35,079
  • 22
  • 62
  • 79