Click to See Complete Forum and Search --> : Splash Screen timeout


November 13th, 1999, 02:01 PM
How do you make a splash screen timeout after a set time? I put the splash screen in my program but it disappears almost immediatly. How would I make it stay on for say, 4 seconds? Thanks...

Eric Gravert
November 16th, 1999, 10:22 AM
The way that i usually do it is to create a splash screen named frmSplash and then in a module I add the following code:


public Declare Function SetWindowPos Lib "user32" (byval hwnd as Long, byval hWndInsertAfter as Long, byval x as Long, byval y as Long, byval cx as Long, byval cy as Long, byval wFlags as Long) as Long
public Const HWND_TOPMOST = -1
public Const SWP_NOMOVE = &H2
public Const SWP_NOSIZE = &H1
public Const SWP_SHOWWINDOW = &H40

public sub main
Dim splash as frmSplash

set splash = new frmSplash
splash.Show
splash.Refresh

frmApp.Show
end sub




I then set sub main to be the start-up object,
and add the following to the activate method of the splashscreen:


SetWindowPos me.hwnd, HWND_TOPMOST, me.Left, me.Top, me.Width, me.Height, SWP_SHOWWINDOW Or SWP_NOSIZE Or SWP_NOMOVE




and then all you have to do is add a timer to the spashscreen and set it to whatever interval you want and unload the splashscreen in the timer event.

Basically what happens is the application starts and goes straight to the sub main code. In here the splash screen is displayed. When the splash screen is displayed the setwindowpos api is called and the form is set as the topmost window and the timer starts. Then the sub main shows the main aplication form underneath the splashscreen. Finally the timer fires and closes the splash screen.

Hope this helps!

Amrit
November 19th, 1999, 12:25 AM
simply use a timer
or after loading put a delay
by
for i = 1 to 9999
for j = 1 to 99
next
next


AmritPalSingh
MTech Production
IIT Delhi
India
110029