Just for interest sake:
Also Note:
NCCLog is the name of the picture
VB Code:
Private Sub TNCC_Timer()
'you could call either of the listed subs in the timer event
MoveNCC
'or
MoveUPD
'or
MoveLER
End Sub
To Bounce on the screen walls do this:
VB Code:
Private Sub MoveNCC()
Select Case Motion
Case 1
' Move the graphic left and up by 20 twips using the Move method.
NCCLog.Move NCCLog.Left - 20, NCCLog.Top - 20
' If the graphic reaches the left edge of the form, move it to the right and up.
If NCCLog.Left <= 0 Then
Motion = 2
' If the graphic reaches the top edge of the form, move it to the left and down.
ElseIf NCCLog.Top <= 0 Then
Motion = 4
End If
Case 2
' Move the graphic right and up by 20 twips.
NCCLog.Move NCCLog.Left + 20, NCCLog.Top - 20
' If the graphic reaches the right edge of the form, move it to the left and up.
' Routine determines the right edge of the form by subtracting the graphic
' width from the form width.
If NCCLog.Left >= (Width - NCCLog.Width) Then
Motion = 1
' If the graphic reaches the top edge of the form, move it to the right and down.
ElseIf NCCLog.Top <= 0 Then
Motion = 3
End If
Case 3
' Move the graphic right and down by 20 twips.
NCCLog.Move NCCLog.Left + 20, NCCLog.Top + 20
' If the graphic reaches the right edge of the form, move it to the left and down.
If NCCLog.Left >= (Width - NCCLog.Width) Then
Motion = 4
' If the graphic reaches the bottom edge of the form, move it to the right and up
' Routine determines the bottom of the form by subtracting
' the graphic height from the form height less 680 twips for the height
' of title bar and menu bar.
ElseIf NCCLog.Top >= (Height - NCCLog.Height) - 680 Then
Motion = 2
End If
Case 4
' Move the graphic left and down by 20 twips.
NCCLog.Move NCCLog.Left - 20, NCCLog.Top + 20
' If the graphic reaches the left edge of the form, move it to the right and down.
If NCCLog.Left <= 0 Then
Motion = 3
' If the graphic reaches the bottom edge of the form, move it to the left and up.
ElseIf NCCLog.Top >= (Height - NCCLog.Height) - 680 Then
Motion = 1
End If
End Select
End Sub
To move up and down, Down and up (and right)
VB Code:
Private Sub MoveUPD()
Static MDown As Boolean
Static NShiftToRight As Boolean
Select Case True
Case NCCLog.Left + NCCLog.Width >= Me.Width
NCCLog.Move 0, 0
MDown = True
Case NCCLog.Top <= 0
MDown = True
If NShiftToRight Then
NCCLog.Left = NCCLog.Left + NCCLog.Width
NShiftToRight = False
End If
Case NCCLog.Top + NCCLog.Width >= Me.Height
MDown = False
NShiftToRight = True
NCCLog.Left = NCCLog.Left + NCCLog.Width
End Select
If MDown Then
NCCLog.Top = NCCLog.Top + NCCLog.Height
Else
NCCLog.Top = NCCLog.Top - NCCLog.Height
End If
End Sub
To move left to right, Right to left (and down)
VB Code:
Private Sub MoveLER()
Static MRight As Boolean
Static NShiftToBottom As Boolean
Select Case True
Case NCCLog.Top + NCCLog.Height >= Me.Height
NCCLog.Move 0, 0
MRight = True
Case NCCLog.Left <= 0
MRight = True
If NShiftToBottom = True Then
NCCLog.Top = NCCLog.Top + NCCLog.Height
NShiftToBottom = False
End If
Case NCCLog.Left + NCCLog.Height >= Me.Width
MRight = False
NShiftToBottom = True
NCCLog.Top = NCCLog.Top + NCCLog.Height
End Select
If MRight Then
NCCLog.Left = NCCLog.Left + NCCLog.Width
Else
NCCLog.Left = NCCLog.Left - NCCLog.Width
End If
End Sub