Program flow control

E

Eric A. Johnson

I'm trying to create an invisible form to start my program with. It will be
the startup object; I have it set at 0% opacity, since there is no Visible
property to set for forms (at least, not that I can see... correct me if I
am wrong). What I want it to do is to create an instance of the splash
screen, show the splash screen, detect when the splash screen closes itself,
then create an instance of and show the main game screen. I'm guessing that
you can't have the control form do a me.close(), unless you want to close
the entire program, since it is the one that creates the other form
instances.

So far, I have it so that the Splash screen appears okay (thank you,
DoEvents()! ) and disappears okay. In order to determine when to create the
instance of the Game form, I'm using the following snippet of code:

While Not (Splash is Nothing)
' Wait for Splash screen to exit
DoEvents()
End While

.... This is not working. I'm sure many of you are probably laughing at me
right now... I feel like a real n00b. The timer within the Splash screen
increases the value of my ProgressBar, and when it reaches the full value,
it activates the Me.Hide() and Me.Close() code, which I had thought would
set the value of Splash to Nothing. Instead, when I pause and look at the
code, since it's still running, it shows me that Splash =
Youghtzy.frmSplash. It doesn't seem to dispose of it at all. Is there any
way I can force it to dispose, or better yet, find some way to automatically
notify the Master form that the Splash form is Closed?

Thanks,
Eric
 
E

Eric A. Johnson

Hah! Actually, I figured out one way to handle it. Instead of waiting for
(Splash is Nothing), it loops While (Splash.Visible = True), handling
DoEvents; it then, after it gets past that loop, shows the game screen. In
this fashion, I suppose, I can continue to handle things... as long as I
know which event to wait for, in what order.

What I still want to learn how to do is to have an event handler that would
look for the closing of a different form altogether. Is that possible? Can
you create an event handler if one form that only activates when a different
form is closed? For that matter, can anyone share what their optimal way of
handling such a situation is? Thank you!
 
C

CMM

Declare a private variable WithEvents and set the new form to it.

Private WithEvents m_childForm As Form

.... in some code
m_childForm = New Form2
m_childForm2.Show()

Public sub m_childForm_Closing(...) Handles m_childForm.Closing
....
End Sub
 
E

Eric A. Johnson

That is exactly what I needed! :-D Thank you ever so much. I shall be
certain to remember this.

-- Eric
 
C

Cor Ligthert [MVP]

Eric,

Will you please be so kind to response next time to the original questions.
I thought that I had seen your question before and now I saw it. This is
really anoying for the ones who answer because they have to start everytime
new or don't see the answers from others.

Thanks in advance.

Cor
 

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