我写在一个小工具,应该看到我的服务器,写我的邮件,当事情出了问题,如太高的内存使用率等。
现在,对于我的问题,我想最小化我的程序到系统托盘,它工作得很好:)我看到在托盘中的图标几秒钟。在那之后,我的程序是gone...closed...dont,知道进程离开了:D。
这里我的代码尽量减少到托盘:
InitializeComponent();
var icon = new NotifyIcon();
icon.Icon = new Icon("watchdog.ico");
icon.Visible = true;
icon.DoubleClick +=
delegate(object sender, EventArgs args)
{
this.Show();
this.WindowState = WindowState.Normal;
};
protected override void OnStateChanged(EventArgs e)
{
if (WindowState == WindowState.Minimized)
this.Hide();
base.OnStateChanged(e);
}我希望你能帮我。
发布于 2016-11-16 16:17:22
在Server 2012上,当最小化到托盘时,我也得到了一个异常,但是它在Windows 7 Pro计算机上会正常工作。在我能够远程调试之后,问题非常清楚:
引发的异常:“System.ArgumentException”在System.Windows.Forms.dll中 附加信息:气球提示文本必须具有非空值。
修复方法是将气球提示文本添加到图标:
var icon = new NotifyIcon();
icon.BalloonTipText = "Program is minimized. Click the tray icon to restore it.";https://stackoverflow.com/questions/15811857
复制相似问题