I'm using a NotifyIcon control in one of my child (modal) forms and it is working fine. SHowing balloon tips as expected, handling mouse events etc... It doesn't however vanish when I would expect it to. Specifically, when i exit the child form and the parent is back in control the icon still remains. It's tooltip is accessible so it is very much "alive" as it were.
When I then exit my application as a whole the image still remains until the point i hover the cursor over it. Once moused it disappears.
How can I get it to behave normally? Ok normally is a bad word :-0 How can I get it to disappear when the form that created it disappears?
Could someone explain what is causing this as well, I thought .net was supposed to clean up after itself?
G
EDIT: If I call the Dispose method in the form closed evernt this works, but do I really have to do this? G
Here's a thought, not sure if this will make a difference, but are you calling Dispose() on the NotifyIcon when the child form closes?
EDIT: Just saw your edit, yes I'm not surprised that this helps, and yes you should do it. Under the covers something is using some unmanaged resourced, and you need to release it. Generally, anything in your app that implements IDisposable that you're using, do yourself a favor and Dispose it.
Icon.Visible = false
would also work. Anyway, Dispose
should still be called to dispose of the Windows handle.
This question is similar.
If you're okay with new program instances cleaning up the system-tray instead of trying to guarantee cleanup on any kind of shut down, the following simulates a notification tray cleanup. It uses a SendMessage solution that simulates a user-mouse-over cleanup that doesn't involve needing to actually move the user's cursor around.
Note that on Windows 7 machines the name Notification Area
should be replaced with User Promoted Notification Area
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With