Ich schon. Ist aber keine saubere .NET-Lösung. Aber solange deine Programme nur auf Windows laufen sollen, mag´s gehen:
Code:
private const int WM_SIZE = 0x0005;
private const int SIZE_MINIMIZED = 1;
protected override void WndProc(ref Message m)
{
if(m.Msg == WM_SIZE && (int)m.WParam == SIZE_MINIMIZED) {
notifyIcon1.Visible = true;
this.ShowInTaskbar = false;
}
base.WndProc(ref m);
}
void MainFormClosing(object sender, System.ComponentModel.CancelEventArgs e)
{
notifyIcon1.Visible = false;
}
#region NotifyIcon
void MenuItem1Click(object sender, System.EventArgs e)
{
if(this.WindowState == FormWindowState.Minimized)
this.WindowState = FormWindowState.Normal;
this.Activate();
notifyIcon1.Visible = false;
this.ShowInTaskbar = true;
}
void MenuItem2Click(object sender, System.EventArgs e)
{
this.Close();
}
#endregion