|
-
Oct 4th, 2000, 01:58 PM
#1
Thread Starter
Frenzied Member
Hi,
I want the code in the mouse down event to fire only if the button has been pressed for a certain length of time, like 1 second or so...
I know about the time control but not sure how it would be used in this application.. I also know about the Sleep API function but that won't work because that would cause the button to stay pressed for the sleep time..
Example code would be appreciated..
Dan
-
Oct 4th, 2000, 03:03 PM
#2
Couldn't you put in the mouse down event a timer that is activated for the time you want it down for. Then put in the mouseup event to disable the timer and reset the time. This should stop the event if the user releases the mouse to fast, otherwise, the user will have to hold it down until the timer fires off.
Hope that helps, of course, I didn't try it yet...lol
-
Oct 4th, 2000, 03:27 PM
#3
Frenzied Member
here is what hellswairth is talk about:
Add 1 label and 2 timers
Code:
Private Sub Form_Load()
Timer1.Interval = 2000
Timer2.Interval = 2000
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = True
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer2.Enabled = True
End Sub
Private Sub Timer1_Timer()
'code for mouse down event
Timer1.Enabled = False
End Sub
Private Sub Timer2_Timer()
'code for mouse up event
Timer2.Enabled = False
End Sub
NXSupport - Your one-stop source for computer help
-
Oct 4th, 2000, 04:27 PM
#4
This method only involves 1 timer and 1 commandbutton:
Code:
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Interval = 2000
Timer1.Enabled = True
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
MsgBox "Mouse held down for two secs!"
End Sub
Try it...
Enjoy!
-
Oct 4th, 2000, 04:37 PM
#5
Frenzied Member
but lets say that in the timer event, it said to change the back ground color, then if you disable the timer, the back ground is still what it was when you put your mouse down
NXSupport - Your one-stop source for computer help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|