CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Splash Screen timeout

    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...


  2. #2
    Join Date
    Nov 1999
    Posts
    14

    Re: Splash Screen timeout

    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!


  3. #3
    Join Date
    Nov 1999
    Location
    India
    Posts
    10

    Re: Splash Screen timeout

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured