Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Triggering OnDblClick without triggering OnClick

Posted on 2005-03-17
Medium Priority
Last Modified: 2010-04-05
basically that's it, I want to Trigger the OnDblClick event without triggering the OnClick event first. This on a TCustomControl descendant. does anyone know how to do it?

Thank you.
Question by:Dissaster
LVL 27

Assisted Solution

BigRat earned 186 total points
ID: 13567129
These events are related to the windows messages and windows always sends a click before the double click. The only way I could see you doing this is to take over the windows message handlers for left button down, left button up and the left double click and ONLY call inherited (which causes the events to occur)  when you are certain that the message is really a click.

 Double-clicking the left mouse button actually generates a sequence of four messages: WM_LBUTTONDOWN, WM_LBUTTONUP, WM_LBUTTONDBLCLK, and WM_LBUTTONUP.
You'd need to delay the Click event waiting for the double click. Not very easy I'm afraid.
LVL 19

Accepted Solution

Barthax earned 189 total points
ID: 13567158
Programmatically, you can simply call the OnDblClick event from elsewhere.  However, if I guess correctly you want the user to perform some double-clicking with the mouse which does not fire the OnClick?  Normally, this is not possible within the form framework - purely because Windows sends a series of WM_xBUTTONx events before Windows resolves it to a WM_xBUTTONDBLCLK event.  See http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/aboutmouseinput.asp for the MSDN overview of event structures.  To get around the whole scenario you would have to trap and program the events for each of the events prior to the DBLCLK event and figure out your own way of resolving what it is you need...

Alternatively, you could move your code from the OnClick event to a timer and start the timer in the OnClick and stop the timer int he OnDblClick to prevent it from firing.
LVL 17

Expert Comment

ID: 13567213
You can assign Onclick := nil ?

Author Comment

ID: 13567715
I can not assign onclick := nil, because i want two different actions to be done on click an ondblclick

so basically this is a windows limitation, well, I'll see if i can find a workaround to do this, thanks..

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

581 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