Come prima cosa aggiungiamo a design il componente “NotifyIcon” e lo chiamiamo “notifyIcon”.
Impostiamo la proprietà visible a false.
Siccome non abbiamo un evento minimized, implementiamo il seguente codice usando l’evento Resize della form:
private void FrmMain_Resize(object sender, EventArgs e)
{
if (System.Windows.Forms.FormWindowState.Minimized == WindowState)
{
this.Hide();
notifyIcon.Visible = true;
}
}
Ora implementiamo il seguente codice per l’evento DoubleClick sulla notifyIcon e il gioco è fatto:
private void notifyIcon_DoubleClick(object sender, EventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
notifyIcon.Visible = false;
}
Nessun commento:
Posta un commento