Click to See Complete Forum and Search --> : Can't use DblClick while using Click event?
Jhd.Honza
Jan 25th, 2000, 12:50 AM
Hi again.
I have an Image located on my form. I'm using a Click event, but I want to use the DblClick too. When I run my program and click image, it runs well; when I try to double click, click code is generated too. It looks i don't catch the double click time.
PS: When I delete Click ev., DblClick runs well.
------------------
Thanks,
John, 14 years old
chrisjk
Jan 25th, 2000, 01:21 AM
Unfortunately what you are experiencing is true for the rest of us. When you click, the click event gets fired, BUT when you DblClick, the click event also gets fired.
This is simply because the computer cannot possibly know that you are about to click again with your DblClick, therefore the first click fires the click event, the second click fires the dblclick event.
For this reason, you generally can't have radically different code in the click and dblclick events.
A solution could be if the first click event is delayed somehow, waiting half a second or so to see if a second click occurs. I don't know how to do that with code though... :(
Anyways, good luck
Regards
------------------
- Chris
chris.kilhams@btinternet.com
If it ain't broke - don't fix it :)
MartinLiss
Jan 25th, 2000, 01:32 AM
You won't like this but here is what MSDN Help has to say about the Click event
==================
If there is code in the Click event, the DblClick event will never trigger, because the Click event is the first event to trigger between the two. As a result, the mouse click is intercepted by the Click event, so the DblClick event doesn't occur.
=================
But try this: use your mouse-driver software to slow your double-click speed way down. If that fixes the problem, post another question and ask "How can I temporarily change the users DblClick speed?"
------------------
Marty
Why is it called lipstick if you can still move your lips?
Troy Mac
Jan 25th, 2000, 01:49 AM
Why don't you use right mouse button to do one of you commands or shift mouse click or somthing other than click and dlbclick
------------------
TMacPherson
Customer Suport Software Analyst
t_macpherson@yahoo.com
Aaron Young
Jan 25th, 2000, 02:10 AM
You can use a Timer Control to get around the Problem by delaying the Click Response long enough to Check for a 2nd Click, ie.
Private Sub Picture1_Click()
Timer1.Interval = 200
Timer1.Enabled = True
End Sub
Private Sub Picture1_DblClick()
Timer1.Enabled = False
MsgBox "Double Click Code Goes Here"
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
MsgBox "Click Code Goes Here"
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com
RogerH
Jan 25th, 2000, 02:17 AM
Cool peace of code, Aaron!
Roger
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.