Hide main form initially

  • Thread starter Thread starter Oleg Ogurok
  • Start date Start date
O

Oleg Ogurok

Hi there,

Is there a way to start a Windows Forms application with the main
window not visible? Then later on when an external event occurs, I
want to display the form.

Thanks.
 
Oleg Ogurok said:
Is there a way to start a Windows Forms application with the main
window not visible? Then later on when an external event occurs, I
want to display the form.

Simply do not show the form...
 
Simply do not show the form...

Easier said than done. Application.Start(form) accepts a reference to
the main form and immediately shows it. How do I get around it?

-O.
 
Oleg Ogurok said:
Easier said than done. Application.Start(form) accepts a reference to
the main form and immediately shows it. How do I get around it?

Are you referring to 'Application.Run'? Note that there is a parameterless
overload.
 
Youre right, I can't find a way to do it either, at least, not with anything
I'd normally try.

This works, however, but the form may actually show up for a split second
before it disappears.

Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Shown
Me.Hide()
End Sub
 
Hi there,

Is there a way to start a Windows Forms application with the main
window not visible? Then later on when an external event occurs, I
want to display the form.

Thanks.


Just don't display the form.

Edit the 'Main' procedure to do whatever you need and then launch your
main form when required.

The example below, simply delays opening the main form.
It could have waited for your (unspecified) external event, rather
than just shown a mesage box.


static void Main()
{
while (MessageBox.Show("show main form now?", "",
MessageBoxButtons.YesNo) == DialogResult.No)
{
MessageBox.Show("MainForm not run yet");
}

Application.Run(new Form1());
}
 
Oleg said:
Hi there,

Is there a way to start a Windows Forms application with the main
window not visible? Then later on when an external event occurs, I
want to display the form.

You can always put your form at (9000,9000) location.

MH
 
Back
Top