Disappearing System Tray icons
Asked Answered
J

4

3

Im creating a system tray application in visual studio 2010, using C#.

When the application starts i create my thread and a system tray icon. THe icon shows, however whenever i mouse over the icon, it disappears ( the application is still running ), and even if i click the button to show all hidden icons, it doesnt display.

However, if i dont try to mouse over on it, then it stays their in the system tray.

Any Thoughts or experience?

Thanks in advance


Thanks for the answers guys.

Uhh, something i did to fix before so although for those who are perhaps curious.

I initially wasnt using a windows form, and this is when the problem occured. However when i set my app to be a windows form, and just hide the form, and not show it in the taskbar, it worked.

Jocularity answered 24/9, 2010 at 15:37 Comment(1)
Are you certain that the process displaying the icon is still running when you hover over the icon?Ruddie
R
3

Paste this code into your form class:

    protected override void OnFormClosing(FormClosingEventArgs e) {
        notifyIcon1.Visible = false;
        base.OnFormClosing(e);
    }

This ensures the icon will disappear without lingering in the tray. Now set a breakpoint on that code and find out why your form is closing. Copy and paste the stack trace into your question if you cannot figure out why.

Roslynrosmarin answered 24/9, 2010 at 16:48 Comment(0)
M
1

This means that tray icon has been removed. That usually happens after process terminates but the tray stays there - it is a windows bug.

So for some reason, your tray icon perhaps "crashes".

Without seeing your code, it would be impossible to comment any further.

Maternal answered 24/9, 2010 at 15:45 Comment(0)
C
1

If you are creating the icon object and letting it go out of scope without any reference to it, the next garbage collection will call it's destructor and this will happens.

Chevron answered 24/9, 2010 at 15:48 Comment(0)
A
0

When the Windows Explorer restarts ,windows will clear all the icons in the notification area and sends a broadcast message TaskbarCreated .One has to use the message to add the notification icon again .

You can use the following code to listen to the event :

UINT WM_TaskBarCreated = ::RegisterWindowMessage(L"TaskbarCreated");

and the use windowproc or MessageHandler to add the icon back in the notifiation area.

Amorous answered 16/1, 2017 at 13:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.