Problem showing a Splash Form and then a Main Form (The Main form does not get control.) 
Author Message
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)

I am attempting to show a Splash form and then goto the Main form.  The
program shows the Splash form, hides the Splash form,  show the Main form
and then continues on to end the program.  How do I pass program control to
the Main form?

In VB6,   I would do

Sub Main
    starttime = dateadd("s",3,now())
    frmWelcome.Show
    while now < starttime
        doevents
    wend
    frmWelcome.Hide
    frmMain.Show
End Sub

In VB.NET I have

Public Welcome as new MyApp.frmWelcome()
Public MainForm as new MyApp.frmMain()
Sub Main
    Dim starttime as date
    starttime = dateadd("s",3,now())
    Welcome.Show
    while now < starttime
        application.doevents()
    wend
    Welcome.Hide()
    Main.Show()
end Sub



Mon, 24 May 2004 00:56:25 GMT  
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)

Quote:
> Public Welcome as new MyApp.frmWelcome()
> Public MainForm as new MyApp.frmMain()
> Sub Main
>     Dim starttime as date
>     starttime = dateadd("s",3,now())
>     Welcome.Show
>     while now < starttime
>         application.doevents()
>     wend
>     Welcome.Hide()
>     Main.Show()
> end Sub

Try this

Public Welcome as new MyApp.frmWelcome()
Public MainForm as new MyApp.frmMain()

Sub Main
     Dim starttime as date
     starttime = dateadd("s",3,now())
     Welcome.Show
     while now < starttime
         application.doevents()
     wend
     Welcome.Hide()
     Application.Run(MainForm)
End Sub

The unlike VB6, .NET requires that we start a "message loop" for an
application when you are using a "Sub Main" like you are here. You do this
by calling "Application.Run(<FormVariable>)" like we did above.

Hope this helps,
Cal



Mon, 24 May 2004 01:20:19 GMT  
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)
I do something like that

Private Sub frmMain_Load
        me.hide
        frmWelcome.Show
        ' Initialize main form
        frmWelcome.Hide
        me.show
End Sub

So the splash will dissapear only when the main form is fully
initialized.

On Wed, 5 Dec 2001 11:56:25 -0500, "dick barney"

Quote:

>I am attempting to show a Splash form and then goto the Main form.  The
>program shows the Splash form, hides the Splash form,  show the Main form
>and then continues on to end the program.  How do I pass program control to
>the Main form?

>In VB6,   I would do

>Sub Main
>    starttime = dateadd("s",3,now())
>    frmWelcome.Show
>    while now < starttime
>        doevents
>    wend
>    frmWelcome.Hide
>    frmMain.Show
>End Sub

>In VB.NET I have

>Public Welcome as new MyApp.frmWelcome()
>Public MainForm as new MyApp.frmMain()
>Sub Main
>    Dim starttime as date
>    starttime = dateadd("s",3,now())
>    Welcome.Show
>    while now < starttime
>        application.doevents()
>    wend
>    Welcome.Hide()
>    Main.Show()
>end Sub



Mon, 24 May 2004 01:52:29 GMT  
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)
Benoit,

Thank you for what you showed me but it is slightly different from what I
was doing.  My program started in the Sub Main() and you are showing me the
load event of a form called frmMain.  But I am glad to know your
information.

thanku........dick


Quote:
> I do something like that

> Private Sub frmMain_Load
> me.hide
> frmWelcome.Show
> ' Initialize main form
> frmWelcome.Hide
> me.show
> End Sub

> So the splash will dissapear only when the main form is fully
> initialized.

> On Wed, 5 Dec 2001 11:56:25 -0500, "dick barney"

> >I am attempting to show a Splash form and then goto the Main form.  The
> >program shows the Splash form, hides the Splash form,  show the Main form
> >and then continues on to end the program.  How do I pass program control
to
> >the Main form?

> >In VB6,   I would do

> >Sub Main
> >    starttime = dateadd("s",3,now())
> >    frmWelcome.Show
> >    while now < starttime
> >        doevents
> >    wend
> >    frmWelcome.Hide
> >    frmMain.Show
> >End Sub

> >In VB.NET I have

> >Public Welcome as new MyApp.frmWelcome()
> >Public MainForm as new MyApp.frmMain()
> >Sub Main
> >    Dim starttime as date
> >    starttime = dateadd("s",3,now())
> >    Welcome.Show
> >    while now < starttime
> >        application.doevents()
> >    wend
> >    Welcome.Hide()
> >    Main.Show()
> >end Sub



Mon, 24 May 2004 04:22:29 GMT  
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)
Cali,

That works perfectly.  Obviously,  I need to read about the Application
class.

Again thank you............dick barney


Quote:
> > Public Welcome as new MyApp.frmWelcome()
> > Public MainForm as new MyApp.frmMain()
> > Sub Main
> >     Dim starttime as date
> >     starttime = dateadd("s",3,now())
> >     Welcome.Show
> >     while now < starttime
> >         application.doevents()
> >     wend
> >     Welcome.Hide()
> >     Main.Show()
> > end Sub

> Try this

> Public Welcome as new MyApp.frmWelcome()
> Public MainForm as new MyApp.frmMain()

> Sub Main
>      Dim starttime as date
>      starttime = dateadd("s",3,now())
>      Welcome.Show
>      while now < starttime
>          application.doevents()
>      wend
>      Welcome.Hide()
>      Application.Run(MainForm)
> End Sub

> The unlike VB6, .NET requires that we start a "message loop" for an
> application when you are using a "Sub Main" like you are here. You do this
> by calling "Application.Run(<FormVariable>)" like we did above.

> Hope this helps,
> Cal



Mon, 24 May 2004 04:23:29 GMT  
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)
Since you seem already able to show your main form in sub main I
haven't showed it to you again.  But if you really need it:

Sub Main
  Dim frmMain as new frmMain()
  frmMain.ShowDialog
End Sub

' Next code in go frmMain
Private Sub frmMain_Load
  me.hide
  Dim frmWelcome as new frmWelcome()
  frmWelcome.Show
  ' Initialize main form
  frmWelcome.Hide
  me.show
End Sub

Dick?

On Wed, 5 Dec 2001 15:22:29 -0500, "dick barney"

Quote:

>Benoit,

>Thank you for what you showed me but it is slightly different from what I
>was doing.  My program started in the Sub Main() and you are showing me the
>load event of a form called frmMain.  But I am glad to know your
>information.

>thanku........dick



>> I do something like that

>> Private Sub frmMain_Load
>> me.hide
>> frmWelcome.Show
>> ' Initialize main form
>> frmWelcome.Hide
>> me.show
>> End Sub

>> So the splash will dissapear only when the main form is fully
>> initialized.

>> On Wed, 5 Dec 2001 11:56:25 -0500, "dick barney"

>> >I am attempting to show a Splash form and then goto the Main form.  The
>> >program shows the Splash form, hides the Splash form,  show the Main form
>> >and then continues on to end the program.  How do I pass program control
>to
>> >the Main form?

>> >In VB6,   I would do

>> >Sub Main
>> >    starttime = dateadd("s",3,now())
>> >    frmWelcome.Show
>> >    while now < starttime
>> >        doevents
>> >    wend
>> >    frmWelcome.Hide
>> >    frmMain.Show
>> >End Sub

>> >In VB.NET I have

>> >Public Welcome as new MyApp.frmWelcome()
>> >Public MainForm as new MyApp.frmMain()
>> >Sub Main
>> >    Dim starttime as date
>> >    starttime = dateadd("s",3,now())
>> >    Welcome.Show
>> >    while now < starttime
>> >        application.doevents()
>> >    wend
>> >    Welcome.Hide()
>> >    Main.Show()
>> >end Sub



Mon, 24 May 2004 05:42:16 GMT  
 Problem showing a Splash Form and then a Main Form (The Main form does not get control.)

Quote:
> That works perfectly.  Obviously,  I need to read about the Application
> class.

> Again thank you............dick barney

Dick,

Glad I could be of help. ;-)

Cal



Mon, 24 May 2004 05:47:32 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. VB3: modal form gets hidden by main MDI form in Win98

2. Sub Main which shows form not in TaskBar

3. Problem showing 1st form from sub main.

4. main form loading interferes with splash screen!!!

5. changing stuff in your main form from another form

6. Unhandled exception in system.windows.forms.dll (in my main form) - argh

7. Help altering main form from other forms

8. how to change properties of the main form from a another form

9. maximize child form display multiple tool box controls on main form

10. create main form and Sub Form

11. Forms on top of Main Form

12. How to auto size the main form/ MDI form

 

 
Powered by phpBB® Forum Software