Hide main form initially

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.
 
H

Herfried K. Wagner [MVP]

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...
 
O

Oleg Ogurok

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.
 
H

Herfried K. Wagner [MVP]

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.
 
J

Jim in Arizona

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
 
M

Matt Lacey

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());
}
 
M

Marius Horak

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top