Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to minimize my windows form to system tray?

Posted on 2008-09-30
2
Medium Priority
?
1,054 Views
Last Modified: 2012-05-05
How to minimize my windows form to system tray?

I have a standalone application developed in Dot net 3.0. When the Minimize button is pressed (it is in running mode), it should automatically go to system tray (it should run in back ground and icon should be there in system tray) and when the user clicks on the icon in system tray, it should display its Main Form. How to achieve this? Can anyone supply me the code for this?
0
Comment
Question by:GouthamAnand
2 Comments
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 2000 total points
ID: 22603340
Add a NotifyIcon to your form. Set the default Visible property to be false.

Add a Form_Resize event handler to the form.

private void Form1_Resize(object sender, System.EventArgs e)
{
      if(this.WindowState == FormWindowState.Minimized)
      {
            this.Visible = false;
            notifyIcon1.Visible = true;
      }
}

Then add an event handler to the NotifyIcon (usually double click) with this code:

this.Visible = true;
notifyIcon1.Visible = false;

And the following sites should help:
http://www.codeguru.com/Csharp/.NET/net_general/tipstricks/article.php/c6933/
http://www.developer.com/net/csharp/article.php/3336751
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp06102002.asp

Credit to EE for the above.
0
 

Author Closing Comment

by:GouthamAnand
ID: 31501476
Thank you..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question