Hiding a form at startup

  • Thread starter Thread starter Randy
  • Start date Start date
R

Randy

Hello,
I've got a little C# app and I want to hide the main form at startup. I've
tried using this.Hide() in the constructor but that doesn't hide the form.
Does anyone know how to do this?
Thanks

Cheers :)
 
Have you tried setting the Visible Property to false?

--
Jared Parsons [MSFT]
(e-mail address removed)
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
 
Hi,

You might execute your code even before creating main form
(Application.Run)?
 
Yes, in fact...I put the this.Visible = false and this.Hide() in the
constructor and in the Form_Load and it the form still shows.
I'm doing a Systray app. I've got a notifyIcon and contextMenu in my app.
I'm trying to get the form to not show at startup and also for the app not
to show in the Taskbar...just a Systray icon.

Thanks

Jared Parsons said:
Have you tried setting the Visible Property to false?

--
Jared Parsons [MSFT]
(e-mail address removed)
This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"

Randy said:
Hello,
I've got a little C# app and I want to hide the main form at startup. I've
tried using this.Hide() in the constructor but that doesn't hide the form.
Does anyone know how to do this?
Thanks

Cheers :)
 
Thanks...
I think what you're saying is do this?
Form1 form = new Form1();
form.Visible = false;
form.Hide();
Application.Run(form);
I did this in main and the main form still shows...


Miha Markic said:
Hi,

You might execute your code even before creating main form
(Application.Run)?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Randy said:
Hello,
I've got a little C# app and I want to hide the main form at startup. I've
tried using this.Hide() in the constructor but that doesn't hide the form.
Does anyone know how to do this?
Thanks

Cheers :)
 
The tricks seem to be to call Hide() in the constructor. They also don't try
to display the form that hosts the NotifyIcon. That form is set to
ShowInTaskBar=false, Size = 1,7, FormBorderStyle=none, etc..

They create a separate form to be displayed based on selection of menu
items.

-Eric
 
For the main form, that hosts the NotifyIcon class:

Me.MaximizeBox = False

Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None

Me.Enabled = False

Me.AccessibleRole = System.Windows.Forms.AccessibleRole.None

Me.ShowInTaskbar = False

Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide

Me.ControlBox = False

Me.MinimizeBox = False

Me.ClientSize = New System.Drawing.Size(1, 7)

Me.Opacity = 0.0#



They use this form to initialize the app and register the NotifyIcon class.
Any form created for display should be of a new type (class).


HTH;
Eric Cadwell
http://www.origincontrols.com
 
Back
Top