I write on a little tool that should watch my server an write me mails when something went wrong like too high ram usage etc...
now to my problem, I want to minimize my Program to system tray and it works fine :) I see for some seconds the icon in the tray. after that my program is gone...closed...dont know process is away :D.
Here my code to minimize to tray:
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);
}
I hope u can help me.