Hiding the main app form

  • Thread starter Thread starter Peter Steele
  • Start date Start date
P

Peter Steele

I'm writing a tray application and naturally I want to hide the main form
when the app starts. I've experimented with a couple of techniques to do
this, including setting Opacity to 0, but this seems a bit kludgy. I ended
up doing this:

static void Main()
{
new MyAppForm();
Application.Run();
}

This differs from a normal Main by calling the void version of the Run
method and moving the new call out as a separate statement. I haven't been
able to find any good description as to whether this is a safe thing to do.
It seems to work fine and my service behavs as expected, responding properly
to its context menu accesses. I like this better than setting Opacity to 0.
Another solution I experiented with was to use the normal Run call:

Application.Run(new MyAppForm());

and in the constructor of the main form call Hide(), but for some reason
this doesn't work. So, unless someone has a better solution or tells me that
I shouldn't use the void Run call, I'll stick with doing it this way.

Peter Steele
CIENA Corp.
 
Back
Top