C# Archives - Digital Tool Factory blog C# Archives - Digital Tool Factory blog

The Digital Tool Factory Blog

How to automatically start a program in the tray

The Problem: There is no way to start a program minimized in the system tray

The Cause: The correct event is the Shown event, which is not intuitive (to me anyway).

The Solution: Just add in the following code:

private void MyForm_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == WindowState)
{
Hide();
}
}

private void MyForm_Load(object sender, EventArgs e)
{
this.Hide();
}
private void MyForm_Shown(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
Hide();
}

and you’re done!  You can then the start the program and it will automatically minimnize itself to the tray.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


25
Feb 10


Written By Steve French

 

How to fix binding problems with Microsoft.Web.Administration.ServerManager

The Problem: You are trying to create a new website programatically via the Microsoft.Web.Administration.ServerManager and having no luck.  In fact, you are getting invalid binding errors at every turn. Continue reading →


25
Jan 10


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.