Visual Basic - como hago un movimiento

Life is soft - evento anual de software empresarial
 
Vista:

como hago un movimiento

Publicado por Diego (15 intervenciones) el 22/05/2001 19:31:36
Como es el programa que antes de que pueda tocar un boton este se desplace por la pantalla cada vez que me acerco
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RTA

Publicado por José Ariel (165 intervenciones) el 22/05/2001 21:02:18
crea un form (grande o mejor que arranque maximizado) y pegale un command button con nombre command1 y pega esto en el codigo del form

Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Form_Load()
Command1.Caption = "Cerrar!"
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim offsetX As Long
Dim offsetY As Long

Dim NewX As Long
Dim NewY As Long

With Command1
offsetX = (2 * Rnd * .Width) - .Width
offsetY = (2 * Rnd * .Height) - .Height

NewX = .Left + offsetX
NewY = .Top + offsetY

' Movimiento "en seco"
'.Move NewX, NewY

' Movimiento Suave
mover Command1, NewX, NewY
End With
End Sub
Private Sub mover(C As Control, X As Long, Y As Long)
Dim I As Integer, SignoX As Integer, SignoY As Integer
Dim Intervalo As Long, IncX As Single, IncY As Single

If Abs(C.Left - X) > Abs(C.Top - Y) Then
Intervalo = Abs(C.Left - X)
Else
Intervalo = Abs(C.Left - Y)
End If

If C.Left - X < 0 Then SignoX = -1 Else SignoX = 1
If C.Top - Y < 0 Then SignoY = -1 Else SignoY = 1

IncX = Abs(C.Left - X) / Intervalo
IncY = Abs(C.Top - Y) / Intervalo

For I = 0 To Intervalo Step 60
C.Move C.Left + IncX * 60 * SignoX, C.Top + IncY * 60 * SignoX
Me.Refresh
Next
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar