Welcome to MSDN Blogs Sign in | Join | Help

Wriju's BLOG

.NET and everything
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!!!

 

Posted: Tuesday, June 16, 2009 11:20 PM by wriju
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker