Hack
Aug 17th, 2005, 12:51 PM
This is a little piece of code that will fade the screen, on unload, in one of four different directions. Each time the screen is closed, it will fade in a direction different than the last time it was closed. I use this on my About boxes.Option Explicit
Private Sub FadeScreen(pfForm As Form, pstrWhichWay As String)
Dim sngVertical As Single
Dim sngHorizontal As Single
Dim sngMoveToRight As Single
Dim sngMoveTop As Single
Dim i As Integer
Const cnstStep = 1000
sngVertical = pfForm.Width / cnstStep
Select Case UCase(pstrWhichWay)
Case "TR"
'fade to top right '
sngMoveToRight = pfForm.Height / cnstStep
sngHorizontal = sngMoveToRight
Case "BL"
'fade to bottom left
sngMoveTop = pfForm.Height / cnstStep
sngVertical = sngMoveTop
sngHorizontal = pfForm.Height / cnstStep
Case "BR"
'fade to bottom right
sngMoveTop = pfForm.Height / cnstStep
sngVertical = sngMoveTop
sngMoveToRight = pfForm.Height / cnstStep
sngHorizontal = pfForm.Height / cnstStep
Case Else
'default to top left if you put something else in
sngHorizontal = pfForm.Height / cnstStep 'size of horizontal steps
End Select
'save direction to registry
SaveSetting "FormName", "Unload Screen", "Direction", pstrWhichWay
For i = 1 To cnstStep - 1
pfForm.Move pfForm.Left + sngMoveToRight, pfForm.Top + sngMoveTop, _
pfForm.Width - sngHorizontal, pfForm.Height - sngVertical
Next
Unload Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim strRegSetting As String
Dim strNewDirection As String
strRegSetting = GetSetting("FormName", "Unload Screen", "Direction")
If strRegSetting = vbNullString Then
FadeScreen Me, "BR"
Exit Sub
Else
Select Case strRegSetting
Case "BR"
strNewDirection = "BL"
Case "BL"
strNewDirection = "TR"
Case "TR"
strNewDirection = "BR"
End Select
End If
FadeScreen Me, strNewDirection
End Sub
Private Sub FadeScreen(pfForm As Form, pstrWhichWay As String)
Dim sngVertical As Single
Dim sngHorizontal As Single
Dim sngMoveToRight As Single
Dim sngMoveTop As Single
Dim i As Integer
Const cnstStep = 1000
sngVertical = pfForm.Width / cnstStep
Select Case UCase(pstrWhichWay)
Case "TR"
'fade to top right '
sngMoveToRight = pfForm.Height / cnstStep
sngHorizontal = sngMoveToRight
Case "BL"
'fade to bottom left
sngMoveTop = pfForm.Height / cnstStep
sngVertical = sngMoveTop
sngHorizontal = pfForm.Height / cnstStep
Case "BR"
'fade to bottom right
sngMoveTop = pfForm.Height / cnstStep
sngVertical = sngMoveTop
sngMoveToRight = pfForm.Height / cnstStep
sngHorizontal = pfForm.Height / cnstStep
Case Else
'default to top left if you put something else in
sngHorizontal = pfForm.Height / cnstStep 'size of horizontal steps
End Select
'save direction to registry
SaveSetting "FormName", "Unload Screen", "Direction", pstrWhichWay
For i = 1 To cnstStep - 1
pfForm.Move pfForm.Left + sngMoveToRight, pfForm.Top + sngMoveTop, _
pfForm.Width - sngHorizontal, pfForm.Height - sngVertical
Next
Unload Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim strRegSetting As String
Dim strNewDirection As String
strRegSetting = GetSetting("FormName", "Unload Screen", "Direction")
If strRegSetting = vbNullString Then
FadeScreen Me, "BR"
Exit Sub
Else
Select Case strRegSetting
Case "BR"
strNewDirection = "BL"
Case "BL"
strNewDirection = "TR"
Case "TR"
strNewDirection = "BR"
End Select
End If
FadeScreen Me, strNewDirection
End Sub