|
-
Dec 17th, 2000, 01:41 AM
#1
Thread Starter
Lively Member
How to do something while mousedown is true
example: Decrement the year while a label mousedown event is true, & stop decrement after releasing the mouse button
An ass may bray a good long time before he shakes the stars down.
T.S. Elliot
-
Dec 17th, 2000, 02:08 AM
#2
Member
MouseUp event
Place a timer at your form. set the clock to execute the decrement every, say, 1 sec, by seting it's Interval property to 1000 (ms).
Now disable the timer at designtime and add these events:
Code:
Private Sub Label1_MouseDown(....)
Timer1.Enabled = True
End Sub
Private Sub Label1_MouseUp(....)
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
count = count - 1
End Sub
Code:
Dim yosef as Programmer
more.list.AddItem "Java", vbMore
yosef.AddList("VB", "C++", "Pascal", more.list)
-
Dec 17th, 2000, 10:43 AM
#3
PowerPoster
yosef, I don't think we really need a Timer for this simple task. If you affraid the Label1.Caption change too fast, then you can perform a delay by calling the Sleep API like what I've did.
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private IsMouseDown As Boolean
Private Sub Form_Load()
IsMouseDown = False
End Sub
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsMouseDown = True
Do While IsMouseDown
Label1.Caption = Val(Label1.Caption) - 1
Sleep 250 'delay 250ms
DoEvents
Loop
End Sub
Private Sub Label1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsMouseDown = False
End Sub
-
Dec 17th, 2000, 11:42 PM
#4
Thread Starter
Lively Member
Chris
Your solution works well with slight modification in my app
without the overhead of a timer.
Thanks
An ass may bray a good long time before he shakes the stars down.
T.S. Elliot
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
|