CodeItBetter Programming Another VB Programming Blog

How to fade the form away when the user closes it.

Posted on September 15, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'Forms - How to fade the form away when the user closes it.
Private Sub Command1_Click()
    FadeScreen Me, "tl"
End Sub
 
Public Function FadeScreen(frm As Form, strWhichWay As String)
    Dim sngVertSize As Single
    Dim sngHorSize As Single
    Dim sngMoveRight As Single
    Dim sngMoveTop As Single
    Dim i As Integer
    Const cstStep = 100
    sngVertSize = frm.Width / cstStep
    Select Case UCase(strWhichWay)
    Case "TR"
        'fade to top right
        sngMoveRight = frm.Height / cstStep
        sngHorSize = sngMoveRight
    Case "BL"
        'fade to bottom left
        sngMoveTop = frm.Height / cstStep
        sngVertSize = sngMoveTop
        sngHorSize = frm.Height / cstStep
    Case "BR"
        'fade to bottom right
        sngMoveTop = frm.Height / cstStep
        sngVertSize = sngMoveTop
        sngMoveRight = frm.Height / cstStep
        sngHorSize = frm.Height / cstStep
    Case Else
        'default to top left if you put something else in
        sngHorSize = frm.Height / cstStep    'size of horizontal steps
    End Select
    For i = 1 To cstStep - 1
        frm.Move frm.Left + sngMoveRight, frm.Top + sngMoveTop, _
                 frm.Width - sngHorSize, frm.Height - sngVertSize
    Next
    Unload frm
End Function
Filed under: Forms Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.