Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - Minimize to tray at system startup

In my application, I have an option to start the application when Windows is started. That works great. I also have it so that, when minimized, the application is minimized to the system tray. Is there a way that I could have it be automatically minimized when started up at the same time as Windows? The only way I could think of, is to retrieve the amount of time that they system has been on and use that data to decide whether the machine had recently started. Obviously there are a lot of flaws with that theory. Anybody have any other ideas as to how this could be done?

like image 200
user Avatar asked Dec 23 '22 08:12

user


2 Answers

Implement a command line switch in your program that causes your program to minimize to the tray. When you start the program with Windows startup, just include the switch.

http://msdn.microsoft.com/en-us/library/acy3edy3.aspx

like image 76
Robert Harvey Avatar answered Jan 07 '23 11:01

Robert Harvey


In your Form "Properties" in WindowState change to "Minimized", or in code:

     //After this:
     InitializeComponent();
     //Place this line:
     WindowState = FormWindowState.Minimized;

Hope this help!

like image 35
Roman Polen. Avatar answered Jan 07 '23 12:01

Roman Polen.