dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: Splash frame - timeout?

  1. #1
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    Splash frame - timeout?

    I'm back,

    I seem to have in the depths of my memory the fact that you could make splash forms timeout. Now I thought it was part of the template, but it appears not.
    I want to have a splash screen on for only a max of 4 seconds before it carries on with the main form program, but by clicking it also it would continue.

    Regards

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Usually, the splash screen does not block the program execution, it is just displayed while the main program (typically in the Main sub) initializes itself (creates resources, connects to a database, check for permissions etc), when the initialization is done you have the choice to dismiss the splash, or to wait few seconds more.
    In the Main, after the initialization, I use DateDiff to check how much time I spent doing it, is less then a certain time (like 5 seconds) I activate a Timer to dismiss the splash later, otherwise I dismiss the splash right away (because my initialization goes through the network, there is now way for me to predict how long it will take)

    Have fun, Big Kev, and welcome back to the force
    I am actually now using .NET, but with a legacy of dozens of VB6 projects that we cannot afford to rewrite... and beside: they work!
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  3. #3
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    Wait 5 - short test routine that works for me.

    Hi all,
    After a little deliberation the following seems to work OK.
    Code:
    Public x As Integer
    Public timeoutvalue As Boolean
    
    Private Sub Command_Click()
        Unload Me
    End Sub
    
    Private Sub Form_Load()
        timeoutvalue = False
        Form1.Visible = True
        Form1.Refresh
        wait 2
        Label1.Caption = "Timer completed"
    End Sub
    
    Public Sub wait(secondscount)
        x = secondscount + 1    ' set up the number of seconds
        Timer1.Enabled = True   ' activate the timer
        While timeoutvalue = False
           DoEvents             'make sure life carries on
        Wend
    End Sub
    
    Private Sub Timer1_Timer()
        If x > 0 Then x = x - 1
        If x = 0 Then
            Timer1.Enabled = False
            timeoutvalue = True ' when the right number of events have happened make it true
        End If
    End Sub
    Not saying it's good code, but it works under test.

    Comments or refinements welcome.
    Regards
    Big Kev
    Last edited by Hack; 10-21-2010 at 11:39 AM. Reason: Added Code Tags

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    I once had a programming instructor tell us that 'if it works, it is good code'

    I guess that is true, although the code optimizers out there might have a different opinion.

    That isn't why I'm posting, however.

    I edited your post and added [code]your code goes here[/code] tags as it makes reading posted code a lot easier.

    Thanks.

  5. #5
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21
    Hi Hack,

    Many thanks for the

    Code:
    information
    I hope I get it right next time.

    Regards
    Big Kev

  6. #6
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote Originally Posted by Hack View Post
    I once had a programming instructor tell us that 'if it works, it is good code'

    I guess that is true ...
    Until the first time that code needs to be modified
    And at that point a good wastebasket comes in handy

    PS:
    I just wanted to comment the "if it works, it is good code" line (with which I strongly disagree, with few exceptions, but I am open to discussion), not the code posted here.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  7. #7
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    Wait 5 - short test routine that works for me.

    HI all,
    Sorry I'm back, I got my code segment working fine as an inline test..

    However I want to use it in various sections of a program.

    I just can't seem to get it to function if I put it in the .bas section.
    that is the wait(..) and the timer1.() sections.

    I can't remember how to declare the various bits so that it will work whatever section of my software I need it in?

    Regards
    Big Kev

  8. #8
    Join Date
    Oct 2010
    Posts
    22

    Re: Splash

    Try This

    Create a project with a Form, Splash Form and module.

    Add Timer to frmSplash
    Add the following code to the Timer() Event

    Code:
    Private Sub Timer1_Timer()
    Timer1.Enabled = False
    timeoutvalue = True
    Unload Me
    End Sub
    In your Module1.bas add the following

    Code:
    Public timeoutvalue As Boolean
    
    Public Sub wait(secondscount)
        frmSplash.Timer1.Interval = secondscount * 1000
        frmSplash.Timer1.Enabled = True   ' activate the timer
        timeoutvalue = False
        frmSplash.Show
        While timeoutvalue = False
           DoEvents             'make sure life carries on
        Wend
    End Sub
    In Form1 add a Command button and this code

    Code:
    Private Sub Command1_Click()
    wait 5
    End Sub
    
    Private Sub Form_Load()
    frmSplash.Show
    wait 5
    End Sub
    Hope this helps

  9. #9
    Join Date
    Oct 2010
    Location
    North Yorkshire
    Posts
    21

    Wait 5

    Hi and thanks for the reply.

    Well that works for me, excellent.
    I had spent hours trying to get my old head around the logic... came up with my result, but then got stuck.

    That works well and is now integrated in my project.

    Cheers again for that.
    Regards
    Big Kev

Similar Threads

  1. splash screen for J2ME
    By wrappingduke in forum Mobile
    Replies: 4
    Last Post: 05-15-2008, 04:17 PM
  2. Application timeout
    By neo00 in forum ASP.NET
    Replies: 4
    Last Post: 11-29-2005, 11:20 AM
  3. Frame Set up query
    By Jas in forum Architecture and Design
    Replies: 0
    Last Post: 10-01-2001, 05:30 AM
  4. Another Frame Question
    By Micah Nasarow in forum Web
    Replies: 1
    Last Post: 08-24-2001, 07:31 PM
  5. Controlling Menu from another frame
    By Moose in forum Java
    Replies: 0
    Last Post: 06-06-2000, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center