Reputation: 11409
I have a form in my project. This form is only there to signalize to other application (for example external ActiveX-exes) that my application is still alive.
I have declared it like this in the main form:
Private m_fVirtualContainer As frmVirtualContainer
Now when I instantiate it, I say:
m_fVirtualContainer = New frmVirtualContainer
However, this does not trigger the form's "Load" event.
I have to add m_fVirtualContainer.Show()
... to trigger the Load event.
In the form I have the following sub:
Private Sub frmVirtualContainer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.Visible = False
End Sub
But I think and hope that this is an overkill. I only want to load the form, not show it.
Can somebody please tell me how to do that? Thank you!
Upvotes: 0
Views: 9114
Reputation: 315
Add a new module to project, this will act as the startup object for the project.
Sub Main()
' Instantiate a new instance of Form1.
Dim f1 as New Form1()
' Display a messagebox. This shows the application is running,
' yet there is nothing shown to the user. This is the point at
' which you customize your form.
System.Windows.Forms.MessageBox.Show("The application is running now, but no forms have been shown.")
' Customize the form.
f1.Text = "Running Form"
' Show the instance of the form modally.
f1.ShowDialog()
End Sub
Upvotes: 1