shows how to make a button quiver frantically

Started by nandagopal, May 18, 2009, 04:25 PM

Previous topic - Next topic

nandagopal

In the button's MouseMove event handler, move the mouse and then move it back. The button must move at least far enough to trigger another MouseMove event for the trick to work.


Private Sub Bt_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    Bt.Move Bt.Left + 30, Bt.Top + 30
    Bt.Move Bt.Left - 30, Bt.Top - 30
End Sub


This version moves a button a random, slightly larger distance to create a more chaotic feel.


Private Sub Bt2_MouseMove(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
Dim dx As Single
Dim dy As Single

    dx = 10 + Rnd * 50
    If Rnd < 0.5 Then dx = -dx
    dy = 10 + Rnd * 50
    If Rnd < 0.5 Then dy = -dy
    Bt2.Move m_X0 + dx, m_Y0 + dy
    Bt2.Move m_X0, m_Y0
End Sub