Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / January 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Howard - 07 Jan 2006 04:40 GMT
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
  .
  .
       case 5:
           content = new Taxiing();
           break;
       default:
           //Nothing to do
           break;
   }

   //Show it
   content.Show();
}

Then in the new content form

private void Taxiing_Load(object sender, EventArgs e)
{
   if (Globals.SoundOn)
   {
       Speech.speak(label2.Text);
   }
}

I'd be grateful if anyone can show me what I have done wrong.

TIA

Steve
Steve Howard - 07 Jan 2006 04:51 GMT
> I have tried a zillion combinations of Hide, Close, SentToBack and
> anything
[quoted text clipped - 4 lines]
> 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
Steve Howard - 07 Jan 2006 18:06 GMT
> 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
Steve Howard - 13 Jan 2006 01:20 GMT
> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.