Hidden MainForm at startup
-
Hi, I can't seem to hide my MainForm at my application startup. I just want the notifyicon in the systray to be visible. mainform.Hide() dosn't work. It displays the mainform anyway. Does somebody now a way to do this? Andreas Färnstrand
-
Hi, I can't seem to hide my MainForm at my application startup. I just want the notifyicon in the systray to be visible. mainform.Hide() dosn't work. It displays the mainform anyway. Does somebody now a way to do this? Andreas Färnstrand
This could work for you: - set ShowInTaskbar to false - set WindowState to FormWindowState.Minimized
-
This could work for you: - set ShowInTaskbar to false - set WindowState to FormWindowState.Minimized
And/or set Opacity to 0. These all seem like kludges, though. It seems like there should be a way to tweak the create params. Matt Gerrans
-
And/or set Opacity to 0. These all seem like kludges, though. It seems like there should be a way to tweak the create params. Matt Gerrans
Setting
Opacity
to 0 is X| My two line suggestion should be the easiest possible way of doing it. You can override theCreateParams
property like this:protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
// change
return cp;
}
}I never actually overriden this property before. You can give it a try. This posting is provided "AS IS" with no warranties, and confers no rights. Alex Korchemniy
-
Setting
Opacity
to 0 is X| My two line suggestion should be the easiest possible way of doing it. You can override theCreateParams
property like this:protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
// change
return cp;
}
}I never actually overriden this property before. You can give it a try. This posting is provided "AS IS" with no warranties, and confers no rights. Alex Korchemniy
That doesn't quite work by itself (I replaced "// change" with "cp.Style = cp.Style & ~1;"); you still see the window flash for a fraction of a second on startup. Matt Gerrans
-
That doesn't quite work by itself (I replaced "// change" with "cp.Style = cp.Style & ~1;"); you still see the window flash for a fraction of a second on startup. Matt Gerrans
-
Would setting the Location property in the Designer to have a Y value of, say, 3000, to put it off the display entirely, keep the flash from being seen?
I think that's just another kludge, so it would be just as well to stick with the minimized+not-in-taskbar. Most of the time the object oriented wrapping of the underlying Windows API mechanics is a benefit, but there are few rare cases when some things are a little more difficult. Hiding the main window on startup was also not obvious with MFC and Borland C++ Builder. If you ever wrote Windows apps "in the raw" it was pretty easy to control such things, but all the frameworks hide those details from you. Nevertheless, the productivity gain makes it well worth the price of dealing with the occassional quirk like this. After developing a few graphical apps in C#, there isn't much draw to going back to using the API in C. Matt Gerrans