NotifyIcon : Display Windows Form in System Tray
While talking to different people I get this question. And in Visual Studio it is very easy to do,
You need Windows Forms Application, then drag and drop NotifyIcon there. Set one icon with that control so that it is visible,
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
notifyIcon1.BalloonTipText = "Current Time : " + DateTime.Now.ToString();
notifyIcon1.BalloonTipTitle = "This is Test";
//Keep the Baloon for 1 second
notifyIcon1.ShowBalloonTip(1000);
//Start the window in Minimized Mode
WindowState = FormWindowState.Minimized;
}
//While minimizing the Form show only in System Tray
private void Form1_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == WindowState)
{
Hide();
}
}
//Restore the Form State Back to normal
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
WindowState = FormWindowState.Normal;
Show();
}
}
Namoskar!!!
Comments
- Anonymous
June 16, 2009
PingBack from http://blog.a-foton.ru/index.php/2009/06/17/notifyicon-display-windows-form-in-system-tray/