Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting click & hold event

Status
Not open for further replies.

paulcat

Programmer
Mar 8, 2000
24
US
I want to be able to tell if the user holds the mouse button down on a command button used to scroll through recordset records, and if so, start scrolling automatically in the direction indicated. [sig][/sig]
 
Use This piece of code. Place a Command Button named 'Command1' and a Timer named 'Timer1'. Set the Enabled property to True and set the Interval property to ( 1000 / (Number of ticks/sec) ).

You can add some other nice features (e.g. waiting for a specified time before begingin tick.)

Another possible feature is to raise Command1's Click event by placing

Command1.Value = True.


Here is the code:


Dim boolIsDown As Boolean

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "Down"
If Button = vbLeftButton Then
Timer1.Enabled = True
End If
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "Up"
If Button = vbLeftButton Then
Timer1.Enabled = False
End If
End Sub

Private Sub Timer1_Timer()
Beep
' Command1.Value = True ' Optional
End Sub
[sig]<p>Mohammad Mehran Nikoo<br><a href=mailto:mohmehran@yahoo.com>mohmehran@yahoo.com</a><br>MCP with experience in VB, ASP, XML, SQL, COM[/sig]
 
Thanks... I'm familiar with the timer control, etc. It was the button _mousedown() and _mouseup() events I wasn't familiar with - I should be able to get it to work now. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top