How can I close a NotifyIcon BallonToolTip from code?

Viewed 1100

We are using a NotifyIcon to alert the user when they receive a new message that needs their attention. In the event that someone else gets to the message first, the notify icon should get hidden again, however I am having a problem with figuring out how to close the balloon from code behind.

My code looks something like this:

myNotifyIcon.ShowBalloonTip(2000, title, message, icon);

I have tried the suggestions found here, but none are suitable.

  • Using myNotifyIcon.Visible = true does not hide it

  • Using myNotifyIcon.Visible = false; myNotifyIcon.Visible = true; will hide it, but it also hides the icon in the tray and when it is shown again, it shows up a a different location.

  • myNotifyIcon.Show(0) is not a valid method

  • myNotifyIcon.ShowBalloonTip(0) or myNotifyIcon.ShowBalloonTip(1) does not appear to work as the balloon just gets shown and doesn't appear to go away on its own at all.

I read this question about using the WinAPI to find the window and send it a WM_CLOSE message, but I'm not too sure how to do that reliably.

How can I close a NotifyIcon from the code behind?

2 Answers
Related