j’ai recuperé un prototype de programme d’animation d’un curseur avec les touches directionelle du clavier.
et je me demandai si c’est possible d’afficher une image et de la bouger avec les touches directionelles.
si c’est possible alors comment?
visual basic 6 ou bien .net?
bonjour
visual basic 6
Dans l’évenement keypress et la propriété move de l’image, c’est surement possible.
1 form
1 picturebox
1 timer
Private iCode As Integer
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 50
End Sub
Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode >= 37 Or KeyCode <= 40 Then
iCode = KeyCode
Timer1.Enabled = True
End If
End Sub
Private Sub Picture1_KeyUp(KeyCode As Integer, Shift As Integer)
If Timer1.Enabled Then
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
Select Case iCode
Case 37 'left
Picture1.Left = Picture1.Left - 25
Case 38 'up
Picture1.Top = Picture1.Top - 25
Case 39 'right
Picture1.Left = Picture1.Left + 25
Case 40 'down
Picture1.Top = Picture1.Top + 25
End Select
End Sub