消失的系统托盘图标 [英] Disappearing System Tray icons

查看:131
本文介绍了消失的系统托盘图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林创建在Visual Studio 2010的系统托盘应用程序,使用C#。

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.

任何想法或经验?

在此先感谢

感谢。

呃,我做的事之前,所以尽管对于那些谁也许好奇地解决。

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

我最初使用的是windows窗体wasnt,这就是,当问题发生。然而,当我把我的应用程序是一个Windows窗体,只是隐藏的形式,而不是显示它在任务栏,它的工作。

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.

推荐答案

此代码粘贴到你的窗体类:

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.

这篇关于消失的系统托盘图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆