how to prevent double clicks ?

smig

Registered User.
Local time
Today, 08:48
Joined
Nov 25, 2009
Messages
2,209
I have a form (form1) with a small picture having an .OnClick event to open another form (form2)
clicking on specific places in form2 will open a third form (form3)

My problem is if user is double clicking this small picture (instead of single click) then form2 will open and the "second click" will be triggered by Form2 and in many cases will also open form3.

How do I prevent the double clicks ?

Thanks,
Tal
 
You could either add a message box to stop the double click or possibly add an exit statement once it has activated the second form.

Sample shown

Private Sub Command25_Click()
MsgBox "Yep single click"

End Sub

Second

Private Sub Command25_Click()
MsgBox "Yep single click"
Exit Sub
End Sub
 
You could either add a message box to stop the double click or possibly add an exit statement once it has activated the second form.
A message box is not an option here.

I want the user to be able to click on the second form. I don't want this "Click" to be triggered as the "Second click" of the first DoubleClick.
 
i think this is a question of finding the best working interface

can you not find a clear way of distinguishing between the two "click" areas, so the users know what will happen.

otherwise there is no easy way of preventing the behavior, i think,

you could always popup a decision form asking the users what he wants, but this involves more input from the user
 
Why not just sink the double-click event?
 
Why not just sink the double-click event?
Mean what?
Don't forget form2 is open after three first click

I think that after some time the user will learn to click once only :D
 
Maybe, and this is a bodge but would work I think:
Have a timer set to 500ms (ish) on form2 and in the timer event switch off the timer (it ticks once and turns itself off). Then in the Click event you're talking about only do it if the timer is switched off.
 
To avoid just that issue, I always use the double-click event to open other objects rather than the click event. The click event is for buttons or hyperlinks. The double-click event is for everything else. That's the "Windows" way. It is not the "Web" way though but on web pages, they use hyperlinks which are a different color and sometimes even a different font. I also occassionaly use hyperlinks and they operate with one click. You need to work with your user's expectations.

To solve the problem, you'll need code in the double click event to just exit. You don't really want to do anything. You just don't want the click going any further so you need to absorb it.
 
Using the timer solved the problem

Thank you all for the help
 
The timer event can cause problems for you, the developer so ALWAYS make sure it is not running when you're trying to modify some other object.

Having a double click event that simply exits solves the problem and doesn't cause additional problems.
 
Well it will only run for half a second when that form loads so it shouldn't be a problem
 
There wouldn't be the need for a kludge if the double click event was trapped as it should be.
 
There wouldn't be the need for a kludge if the double click event was trapped as it should be.
Double click can't be traped as form2 is opened modal at first click.

Funny thing it take time to form2 to show, because it's rather complicated form, and still the second click triggered by it.

500 mSec does not cause any problem or delay. I set the timer as first line in the FormLoad event. Timer is already off when the form load is done. And still it prevent the trap of the second click
 

Users who are viewing this thread

Back
Top Bottom