Results 1 to 7 of 7

Thread: Splash Form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    67

    Post

    I want to create a splash form, just Delphi does.
    Is there someone who know the way to do that.

    And i don't want to here, just put a timer on your
    form...

    For those who don't know a splash form is a form that
    displayed while the main form is loading and disapear
    when all the loadin process of the main form are finished.

    So is there some one who knows how to do that?
    If possible please provide codes.
    Process by example is the best way to learn.

  2. #2

  3. #3
    Guest
    If it's a small program, you need to place a Timer in it. Well, actually you can substitute it with using a Loop, but you need some sort of pause.

    If it's a larger program, however, you do not need to use a Timer because all of the loading will add up to about 1 second.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    67

    Post

    -MartinLiss :
    Sorry don't work
    When it doesn't show my mani form until i clocse de splash
    form myself, because of the modal property. And when i
    dont use the vbmodal it doesnt show my splah form.

    Désolé!


    -Megatron :

    It's not a big program but it generates a lot of processing
    on start up. So it take about four or five sec. to Show up.

    Could you show me exactly how i would use the loop or
    is it just a Do ... Loop processing with nothing in it?


    Thanks guy! It was very fast
    If possible please provide codes.
    Process by example is the best way to learn.

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'can't remember if I tested this or not
    'found it somewhere on the web.
    Code:
    'splash screen demo
    '
    ' <<<<<<<<<<<<<<<<  code for frmMain  >>>>>>>>>>>>>>>>>>>>
    '
    Option Explicit
    
    Private Declare Sub Sleep Lib "kernel32" _
    (ByVal dwMilliseconds As Long)
    
    Public Sub Main()
       
      'show the splash screen
       frmSplash.ShowAsSplash = True
       frmSplash.Show
       frmSplash.Refresh
    
      'perform any pre-form initialization required
      '{code}
      
      'Sleep is *only* for testing to simulate pre-form
      'initialization- remove for real use (unless you
      'need the splash screen to hang around) before
      'the main screen loads
       Call Sleep(2000)  '2 seconds
       
      'show the main application and pause for
      'its paint messages to process
       frmSplash.Label3 = "Creating application window..."
       frmSplash.Refresh
       
      'Sleep is *only* for testing to simulate a delay
      'that may occur because of code in your application's
      'Form_Load event. Remove for real use
       Call Sleep(1000)  '1 second
      
       frmMain.Show
       DoEvents
    
      'perform any other startup functions as required
      '{code}
      
       frmSplash.Label3 = "Finalizing settings..."
       frmSplash.Refresh
      
      'Sleep is *only* for testing to simulate post-form
      'initialization- remove for real use (unless you
      'need the splash screen to hang around) after
      'the main screen loads
       Call Sleep(1000)  '1 second
      
      
      'unload the splash screen and free
       Unload frmSplash
       Set frmSplash = Nothing
       
    End Sub
    
    Private Sub Form_Load()
    Call Main
    
    End Sub
    '
    '<<<<<<<<<<<<<<<  frmSplash Code  >>>>>>>>>>>>>>>>>>>>>>>>>>>
    '
    'Design your own splash form,
    'but for this demo, as a minimum have
    'three labels (Label Label2 Label3)
    'and a command button (Command1).
    'Add the following code:
    
    Option Explicit
    
    'Constants for topmost.
    Private Const HWND_TOPMOST = -1
    Private Const HWND_NOTOPMOST = -2
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const SWP_NOACTIVATE = &H10
    Private Const SWP_SHOWWINDOW = &H40
    Private Const TOPMOST_FLAGS = SWP_NOMOVE Or SWP_NOSIZE
    
    Private 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
    
    'For property. If using in VB3, VB4-16 or VB4-32,
    'delete this variable and delete the two form
    'Property routines in this code. Declare
    'ShowAsSplash as a Boolean Public (or Global)
    'variable in the BAS module instead.
    Private m_mode As Boolean
    
    
    Private Sub Command1_Click()
    
      'if the command button is visible,
      'then the splash screen is being
      'shown as a modal About dialog, so
      'the user is responsible for closing
      'the form.
       Unload Me
       Set frmSplash = Nothing
       
    End Sub
    
    
    Private Sub Form_Load()
    
       Dim tmp As String
       
      'some text
       tmp = "Put your legal license text here."
       
       Label1 = "Your application name " & App.Major & "." & App.Minor
       Label2 = tmp
       Label3 = "Initializing application. Please wait..."
       
      'initialize the form members.  If the mode
      'is 'splash', hide the command button (use
      'that when showing the form as an About form)
      'and display the loading status label.
       Command1.Visible = ShowAsSplash = False  'the OK button
       Label3.Visible = ShowAsSplash = True     'the "Initializing ..." label
       
      'center (sort of) and set topmost
       Me.Move (Screen.Width - Width) \ 2, ((Screen.Height - Height) \ 2) - 500
       Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS)
       
       Me.Refresh
    
    End Sub
    
    
    Public Property Get ShowAsSplash() As Boolean
    
       ShowAsSplash = m_mode
    
    End Property
    
    
    Public Property Let ShowAsSplash(ByVal vNewValue As Boolean)
    
       m_mode = vNewValue
    
    End Property


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    dndstef: You are correct, the example I gave you does not work. In order to make it work, change the ControlBox property of frmSplash to False and then do this:

    frmSplash.Show
    '
    '
    ' Do other stuff here
    '
    '
    frmMain.Show
    unload frmSplash

  7. #7
    Guest
    If you would like a small pause, you can use the Timer function.

    Set the startup object to Sub Main

    Code:
    Sub main
        frmSplash.Show 1
        
        'Initialize other tasks
    
        'Pause for 1 second
        Start = Timer
        Do While Timer < Start + 1
        DoEvents
        Loop
    
        frmMain.Show
        Unload frmSplash
    End Sub

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