I want an action to repeat while the left mouse button is held down over an image box (like the way that you hold rewind on media player and it rewinds). Does anyone know how i would do this?
Printable View
I want an action to repeat while the left mouse button is held down over an image box (like the way that you hold rewind on media player and it rewinds). Does anyone know how i would do this?
Code:Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Print "Rewinding..."
End Sub
Actually, that will not continuously repeat the event. If you want to do so then use this code instead.
Add to a form with a Timer and an Image.
Code:Private Sub Form_Load()
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Timer1.Enabled = True
End Sub
Private Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Print "Rewinding..."
End Sub
Thanks a lot it worked great!
Here's another method you could use, wihtout having to use a timer control, so you can have more control over the "rewinding" processs...
Code:Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Do While GetAsyncKeyState(1)
Caption = "Rewinding"
'do your rewinding here
DoEvents
Loop
Caption = "Paused"
End Sub
I wondered if there were any activex controls or anything which make cool buttons like office toolbars (if you know what i mean)
go look at my homepage ;)