Trapping double-click before mouse down event

Posted on 1998-10-13
Last Modified: 2010-04-06

I am wondering if it is possible to delay the processing of the MouseDown event until after processing a DoubleClick event.

I need to use MouseDown, but I also have to check for a double-click.  The double-click needs to take precedence over an ordinary mouse down event.

Can the MouseDown event be delayed?
Question by:jdthedj
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 20

Expert Comment

ID: 1342765
That's what I've written on top of my tools unit. It's the order of the mouse messages. "d=down; c=click; u=up; 2=double click".
So you see, the second mouse down comes AFTER the double click event. So all you have to do is set a variable in the double click event that the next down event must not be handled.
Or do you want to delay the FIRST mouse down event? That will not be possible, because at that time noone knows (perhaps even the user not) whether it will be a single or a double click.

Regards, Madshi.

Author Comment

ID: 1342766
Hi Madshi - Thanks for replying

Thanks for the order of processing - it helps a bit - I think, but my application works in a similar way to a lot of regular windows programs - the user may either double-click an item, or single click and then click OK.  

I have to use MouseDown to retrieve the X and Y coordinates of the hotspot area so that I know that the user has clicked in the right place.

Any ideas??

Expert Comment

ID: 1342767

It's simple. in the mousedown procedure, just call the doubleClick event with the correct parameters in the first statement. So in this way, a doubleclick event is called before the mousedown event.

but beware: this is very tricky.

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 1342768
What you want is very easy to achieve using the OnMousemove event.
This event (from Tcontrol, but not always published) fires when the mouse is over the control. And that seems to be the only thing you want?

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
 Caption:='Yes, i"m here';

LVL 20

Expert Comment

ID: 1342769
You mean, you need the position of the mouse at the time the double click has happened?
You could write an own message handler for the WM_LBUTTONDBLCLK message. Windows tells you the position with this message. Delphi hides the position, don't know why.

Add this to your main form:
    procedure LButtonDblClick(var Message: TMessage); message WM_LBUTTONDBLCLK;

Regards, Madshi.

Author Comment

ID: 1342770
Thanks for the replies.  I think I still need to clarify a bit.

If a person double-clicks I need to IGNORE an OnClick event or a MouseDown event, but the problem is that a single click or a mouse down event fires before the double click event.  

Any thoughts?  
LVL 20

Expert Comment

ID: 1342771
Ok, how about that:
you could do nothing but set a timer in the MouseDown or MouseClick event that is fired before the double click event.
Then, if the double click event is fired before the timer has expired, you could stop the timer and do the double click action. Otherwise, when the timer has expired and there were no double click event in the meanwhile you could do the mouse down/mouse click action.
Have I understood this time, what you need?
If I have, this is the only way I can image to solve your problem...

Regards, Madshi.

Author Comment

ID: 1342772
Hi Madshi - Thanks for your patience.

You have shown me what to do, so if you would like to turn your latest reply into an answer I will give you the points.  Thanks again.

Sorry Makli, but your answer was not quite what I was looking for.
LVL 20

Accepted Solution

Madshi earned 100 total points
ID: 1342773
Thanx, jdthedj...    :-)

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month5 days, 1 hour left to enroll

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question