Form Shake

  • Thread starter Thread starter pmclinn
  • Start date Start date
P

pmclinn

I have a splash screen that boots with music in the background. I want
the splash screen to look like it is shaking, or is being shaked. What
is the best way to do this?
 
Hi put a button on a form

and then paste this code, I hope this is enough shaking for you, probably
there are some nicer solutions but this should give you an idea

Hope this helps

Greetz Peter


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
shakeMe()
End Sub

Private Sub shakeMe()
Dim myLoc As Point, myLocDef As Point
myLocDef = Me.Location
myLoc = Me.Location
For i As Integer = 0 To 100
For x As Integer = 0 To 4
Select Case x
Case 0
myLoc.X = myLocDef.X + 10
Case 1
myLoc.X = myLocDef.X - 10
Case 2
myLoc.Y = myLocDef.Y - 10
Case 3
myLoc.Y = myLocDef.Y + 10
Case 4
myLoc = myLocDef
End Select
Me.Location = myLoc
Me.Refresh()
Next
Next
Me.Location = myLocDef
Me.Refresh()
End Sub
 
pmclinn said:
I have a splash screen that boots with music in the background. I want
the splash screen to look like it is shaking, or is being shaked. What
is the best way to do this?

Place a timer on the form and move the form within its 'Tick' event handler
('Form.{Location, Left, Top}').
 
Back
Top