Quesion about loading/unloading/hiding forms

A

Anthony P.

Hello Everyone,

I'm writing an application that, so far, only has three forms:

frmSplashScreen
frmLicenseScreen
frmConfigurationScreen

Now, frmSplashScreen has a timer that sits it on screen for 2 seconds
then executes the following commands:

frmLicenseScreen.Show()
Me.Hide()

So, frmLicenseScreen is loaded properly and frmSplashScreen is HIDDEN
(not closed becasue that would kill the application).

Next, there is a button click that executes the following commands:

frmConfigurationScreen.Show()
Me.Close()

At this point, the ONLY form being shown on the screen is
frmConfigurationScreen. That's true for about 2 seconds. After that,
frmLicenseScreen pops up again and we start the process all over
again.

I'm confused. I know I can't Me.Close() frmSplashScreen since that
would kill the application. But what am I doing wrong that is making
frm.LicenseAgreement reopen?

Thanks in Advance,
Anthony
 
M

Miro

You most likely have your main form on a timer that keeps re-running as the
interval hits.

You can assign a splash screen through the Project Properties portion, and
still have your 'Main Form' be your main form.
-In your Solutions explorer, right click on your Project Name, click
properties.
Then go to the 'Application tab' on the left.
Take a look at yoru startup form - and also scroll down to the bottom, and
notice there is a spot to put a splash screen as well ( if you do not want
to do this manually. )

The other manual way of doing this is making your "Main Form" be your main
form, and within the form load of it, open up the other form, show it for 2
seconds, and then close it.

If your frmConfigurationScreen is your 'MainForm', ... I would load that,
and load the others around it.

Miro
 
A

Anthony P.

You most likely have your main form on a timer that keeps re-running as the
interval hits.

You're right. Never even dawned on me that it was the timer creating
the problem. I guess I didn't think that, once a form was hidden, the
timer would keep firing. That solves that!
You can assign a splash screen through the Project Properties portion, and
still have your 'Main Form' be your main form.
-In your Solutions explorer, right click on your Project Name, click
properties.
Then go to the 'Application tab' on the left.
Take a look at yoru startup form - and also scroll down to the bottom, and
notice there is a spot to put a splash screen as well ( if you do not want
to do this manually. )

I knew that but, for some reason (which I can't remember now) chose
not to use it. Since I can't really remember why I didn't use it, I
think I might go back and try it to see what happens.

Thanks for your help!

Anthony
 
M

Miro

If you do not want to,
just do this ( if you still want it to work on a timer )

Start your main form,
start a timer - on an interval

within the timer code put
timer.enabled = false
( so no other forms will pop up )

and then you can close the form whenever you need to.

I wanted to show my splash screen longer for non registered users so I did
somethign like this:
(written in notepad ) but you should get the idea...
main form was loaded
within main form_load i did:
timer1.enabled = true
( i wanted the main form to load and wait 5 seconds before showing the
screen )

on the timer routine i did
timer1.enabled = false
splashscreen.showmodal()

then within splashform on form load I added a new timer ( we will call it
timer 2 )
timer2.enabled = true
within the timer event
form.close()

that way I was able to hit my timer1 anytime i saw fit to show a modal
screen overtop of my mdi form,
and within timer2 i was able to make it last for an X amount of time until I
saw fit befoer it dissapeared.

Was an easy solution to give someone a quick demo of a quick exe that worked
100% but still had a splash screen showing
here and there that was bothersome enough to be an annoyance.

quick and dirty - but it worked.

Miro
 

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