Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splash form not showing

Status
Not open for further replies.

JohnBates

MIS
Feb 27, 2000
1,995
US
I want my splash form to appear for 5 seconds.<br>
<br>
Private Sub MDIForm_Load()<br>
<br>
frmSplash.Show<br>
Sleep 5000<br>
Unload frmSplash<br>
mdiMain.Show<br>
<br>
End Sub<br>
<br>
The project's Start-up object is mdiMain.<br>
<br>
Problem: Only the frame for the splash is visible for 5 seconds, (then the MDI form appears). <br>
<br>
Question: Why is the splash form itself not visible? <br>
Tried making the splash an MDI-child...did not help.<br>
<br>
Thanks from a beginner. John<br>

 
Try using your Splash as the startup form and go from there.
 
<br>
One thing you can do is to see how Microsoft does it...<br>
<br>
Create a new VB application, select Application Wizard as the project type. This will prompt you for various types of forms to include in the new app, One of which is a splash screen. Then simply look at the code that it generates and copy it to your application.<br>
<br>

 
The problem is that the Sleep command starts before the Show command has had a chance to load and display the form. Insert a DoEvents command between the two commands and it should fix the problem.
 
IMHO, DoEvents isn't a terribly effective way of handling this problem. Its all in the sequencing, and in VB, the proper sequencing can be a nightmare in a host of situations.

For the longest time I was having trouble getting my MDI child forms to load..there was always a three second delay
before the background on the form would show up, though the controls would appear instantaniously.

The following is what solved both the splash screen and child form problems for me.

Global textwindows(1) As New frmDocument
Public fMainForm As frmMain
Declare Sub Sleep Lib &quot;kernel32&quot; (ByVal dwMilliseconds As Long)


Sub Main()
frmSplash.Show
frmSplash.Refresh
Sleep (3000)
Set fMainForm = New frmMain
Load fMainForm
fMainForm.Show
Unload frmSplash
End Sub
 
Here's the commented version for peeps really new to this stuff. More comments than code, but I had a prof..okay a TA
in comp sci 101 who would give you a B even if the program
didn't work if you commented it to death and explained what each line of code did. FYI I got an A in the class, so I can usually make it work and explain it too. :)

Global textwindows(1) As New frmDocument
'Declare array of 2 form objects. These are my MDI Child forms

Public fMainForm As frmMain
'Declare a form object. This is the MDI parent.
'This style of may seem cumbersome (you could just call
'fMainForm.load &.show directly) but for those of us
'doing the reverse migration from C++ to VB its
'quiteinviting, and it makes logical sense and it complies
'with the object oriented paradigm (model)

Declare Sub Sleep Lib &quot;kernel32&quot; (ByVal dwMilliseconds As Long)
'Declare sleep function using an API call


Sub Main() 'found in a module (module1 in my case)
frmSplash.Show 'Show splash form
frmSplash.Refresh 'refresh splashform
Sleep (3000)' sleep for three seconds
'its important to put the sleep function after
'the refresh method.
Set fMainForm = New frmMain
'creates new instance of the main form. Oddly enough,
'this statement eliminates the need for the above
'declaration, but you can't use the above declaration
'without this line and expect the code to work err 91
'is generated at runtime if you try.
Load fMainForm
fMainForm.Show
Unload frmSplash 'Notice the main form is displayed over
'the splash form before the splash form is told to
'disappear (unload)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top