I am creating a type of screen saver that is built into my application (the windows one is disabled). I am trying to reduce if not eliminate the flickering of it. It is a form and a label that "bounces" off the forms edges. Below is the code that I am using. I have read several posts on here about different techniques and haven't had much luck. I thought that someone here could look at my code and give me an idea of where I could head next. The form is in the 0,0 position of the screen and fills the height and width of the screen. The timer interval is set to 500. The LeftIncr value is 125 and the TopIncr value is 75
Code:
Private Sub tmrMove_Timer()
Static MovingLeft As Boolean
Static MovingUp As Boolean
Dim NewLeft As Single
Dim NewTop As Single
tmrQuit.Enabled = False
tmrMove.Enabled = False
tmrTime.Enabled = False
LockWindowUpdate Me.hwnd
If MovingLeft Then
If (lblMessage.Left - LeftIncr) < 0 Then
NewLeft = 0
lblMessage.Move 0
MovingLeft = Not MovingLeft
Else
NewLeft = lblMessage.Left - LeftIncr
End If
Else
If (lblMessage.Left + lblMessage.Width + LeftIncr) > Me.Width Then
NewLeft = Me.Width - lblMessage.Width
MovingLeft = Not MovingLeft
Else
NewLeft = lblMessage.Left + LeftIncr
End If
End If
If MovingUp Then
If (lblMessage.Top - TopIncr) < 0 Then
NewTop = 0
MovingUp = Not MovingUp
Else
NewTop = lblMessage.Top - TopIncr
End If
Else
If (lblMessage.Top + lblMessage.Height + TopIncr) > Me.Height Then
NewTop = Me.Height - lblMessage.Height
MovingUp = Not MovingUp
Else
NewTop = lblMessage.Top + TopIncr
lblMessage.Top = lblMessage.Top + TopIncr
End If
End If
lblMessage.Move NewLeft, NewTop
LockWindowUpdate 0&
tmrQuit.Enabled = True
tmrMove.Enabled = True
tmrTime.Enabled = True
End Sub