Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Mar 24, 2001

ExplodeForm - Show a form with an explode effect

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

' Show a form with an explosion effect.
' the lNumSteps parameter is the number of steps to increase the form size from 
' 0 to the original size
' the lStepDuration argument is the number of milliseconds between each step

' Example:
'   Private Sub Form_Load()
'       ExplodeForm Me, 20, 2
'   End Sub

Sub ExplodeForm(frm As Form, Optional ByVal lNumSteps As Long = 25, _
    Optional ByVal lStepDuration As Long)
    Dim sngLeft As Single, sngTop As Single
    Dim sngHeight As Single, sngWidth As Single
    Dim sngNewHeight As Single, sngNewWidth As Single
    Dim sngHeightStep As Single, sngWidthStep As Single
    Dim iStep As Long
    
    On Error Resume Next
   
    'exit if the form is minimized/maximized
    If frm.WindowState <> vbNormal Then Exit Sub
    
    'save current size and position
    sngLeft = frm.Left
    sngTop = frm.Top
    sngHeight = frm.Height
    sngWidth = frm.Width
    
    'calc the step for the height/width increase
    sngHeightStep = sngHeight / lNumSteps
    sngWidthStep = sngWidth / lNumSteps
    
    'resize the form in several steps
    For iStep = 1 To lNumSteps
        'calc the new height/width
        sngNewHeight = sngNewHeight + sngHeightStep
        sngNewWidth = sngNewWidth + sngWidthStep
        ' display the form
        frm.Move sngLeft + (sngWidth - sngNewWidth) / 2, _
            sngTop + (sngHeight - sngNewHeight) / 2, sngNewWidth, sngNewHeight
        frm.Visible = True
        frm.Refresh
        ' pause if so requested
        Sleep lStepDuration
    Next
    
    ' ensure that the form is completely visible
    frm.Move sngLeft, sngTop, sngWidth, sngHeight
    
End Sub
Marco Bellinaso
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap