Disappearing System Tray icons

萝らか妹 提交于 2019-12-06 12:54:43

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.

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.

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.

j-me

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!