Steve Maughan 26 Posted February 4, 2019 I have a TPaintBox where I normally process OnMouseDown, OnMouseMove and OnMouseUp events. I'd like to perform an action using the DoubleClick even. It seems that when the user double clicks the order of events is as follows: OnMouseDown OnMouseUp OnDblClick OnMouseDown OnMouseUp I'd like to cancel / "eat" the second OnMouseDown and OnMouseUp events. How can I do this? Setting them to "nil" doesn't seem to work. Thanks - Steve Share this post Link to post
Steve Maughan 26 Posted February 4, 2019 I figured it out. Set a flag on the DblClick event, exit out of the OnMouseDown if the flag is set, then do the same for OnMouseUp but also reset the flag. Share this post Link to post
Steve Maughan 26 Posted February 4, 2019 Looks like I haven't figured it out at all. It seems much more complex. Here's the order of events: OnMouseDown (processed with no problem) OnMouseUp (processed with no problem) OnDblClick - I'm showing a form for the user at this point. The GUI is recording the mousemove actions and generating OnMouseMove messages OnMouseDown - the second OnMouseDown of the double click, which can be ignored using a flag OnMouseUp - the second OnMouseUp of the double click, which can be ignored using a flag, and the fag can be reset Multiple OnMouseMove - then all of the OnMouseMove messages that were generated while the form was showing are now processed How do I either ensure the OnMouseMove messages aren't generated when the form is shown, or how do I remove them from the message queue? Here's a short video that shows the behavior: All help appreciate! Thanks, Steve Share this post Link to post
Attila Kovacs 629 Posted February 4, 2019 (edited) We just had a similar discussion the other day. Take a look at my solution (on the bottom of the thread) and try to adopt it. Use it only on the form you really need it, but if you are going to show a modal form from the dobule-click handler there is no guarantee that the following messages are captured by your map's form but by the newly created/shown modal form. You can also try to just to call ReleaseCapture before showing the modal window. Edited February 4, 2019 by Attila Kovacs Share this post Link to post
Steve Maughan 26 Posted February 4, 2019 Hi Attila, Thanks! Yes - I managed to get it working using a similar technique. I set a flag in the DblClick event and then sent a message to clear the flag. Steve Share this post Link to post
PeterBelow 238 Posted February 5, 2019 Perhaps these old routines can help you. They are Windows-only, though. {! <summary> Remove all key messages from the calling thread's message queue.</summary> } procedure EmptyKeyQueue; var Msg: TMsg; begin while PeekMessage(Msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE or PM_NOYIELD) do ; end; {! <summary> Remove all mouse messages from the calling thread's message queue.</summary> } procedure EmptyMouseQueue; var Msg: TMsg; begin while PeekMessage(Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE or PM_NOYIELD) do ; end; {! <summary> Remove all key and mouse messages from the calling thread's message queue.</summary> } procedure DiscardPendingInput; begin EmptyMouseQueue; EmptyKeyQueue; end; Share this post Link to post