Cannot get form A to disappear before form B does something ...

S

Steve Howard

I guess I am still missing something in the Event Driven paradigm ...


I have a menu that gives the user access to sections in my code ... this is
a training application, so think of it as access to chapters.

When the user selects a button, I launch a 'splash' form that shows for a
couple of seconds, then I launch a second form that has course content. I
want some things to happen once the content form has opened, specifically
some audio needs to play.

When I close the Splash form and open the Content form, the audio plays
after about 2 seconds as expected, but the Splash form is still on screen.


Initially I used one container for the forms, like this

newForm= new SectSplash(ChoiceNum);

newForm.Show();



......



newForm = new Content(ChoiceNum);

//Show it

newForm.Show();



So I tried using two different containers:-





splash= new SectSplash(ChoiceNum);

splash.Show();



......



content= new Content(ChoiceNum);

//Show it

content.Show();





It made no difference.



I have tried a zillion combinations of Hide, Close, SentToBack and anything
else I could find.

I have tried all sorts in the opening form , running the code to play audio
on Load, on getFocus, on Activated etc, and even tried putting in a cludgy
delay in numerous different places to try to give the PDA time to kill the
form



for (int i = 1; i <= 100000; i++)

{

//nothing;

}



None of this seems to change the fact that the audio plays when the Splash
*should* be gone, but is somehow still visible.



Having said all that, here's the code.





private void LaunchSplash(int ChoiceNum)
{
splash = new SectSplash(ChoiceNum);
//Show it
splash.Show();

Clock = new Timer();
Clock.Interval = 2000;
Clock.Enabled = true;
this.Clock.Tick += new System.EventHandler(this.Clock_Tick);
}

void Clock_Tick(object Sender, EventArgs e)
{
//close slash
splash.SendToBack();
splash.Close();
//Stop timer
Clock.Enabled = false;
//Launch the lesson
launchLesson();
}

private void launchLesson()
{
switch (choiceNum)
{ // Set DECtalk voice
 
S

Steve Howard

I have tried a zillion combinations of Hide, Close, SentToBack and
anything
else I could find.

I have tried all sorts in the opening form , running the code to play
audio on Load, on getFocus, on Activated etc, and even tried putting in a
cludgy delay in numerous different places to try to give the PDA time to
kill the form

To clarify.

Once the Audio has played, the content form becomes visible. I want the
content form to become visible THEN have it play the audio.


Steve
 
S

Steve Howard

Once the Audio has played, the content form becomes visible. I want the
content form to become visible THEN have it play the audio.


Wow - finally managed to come up with the right search term to return
something that helps. I added a timer to the designer with an interval of 1.


Steve
 
S

Steve Howard

Wow - finally managed to come up with the right search term to return
something that helps. I added a timer to the designer with an interval of
1.


This was a fundamental misunderstanding of mine. I didn't realise that

form Content = new formName()


was lauding and running the form. Later in my code I was calling form.show,
when really I should have waited until that point to call new formName()
too.


When I finally realised this I revised the code and dropped the timer.


Steve
 

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