|
private void Form1_Load(object sender, EventArgs e)
{
notifyIcon1.BalloonTipText = "This application was minimized to tray";
notifyIcon1.BalloonTipTitle = "My Sample Application";
//Display the Notify Baloon for 1 second
notifyIcon1.ShowBalloonTip(1000);
//Set the WindowState in Minimized Mode
WindowState = FormWindowState.Minimized;
}
Then on Form_Resize event, add this code.
private void Form1_Resize(object sender, EventArgs e)
{
//On minimize mode, show the form in System Tray only
if (FormWindowState.Minimized == WindowState)
{
Hide();
}
}
Now to
restore the form upon double-click on NotifyIcon control.
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
//Display the Form in normal state
WindowState = FormWindowState.Normal;
Show();
}
|