Solved

Double Clicks received twice

Posted on 1997-04-24
5
399 Views
Last Modified: 2010-04-04
In one of my dialogs I have a string grid for which I set
the ControlStyle to include [csClickEvents] (I do this in the
FormShow event handler of the dialog). This makes it possible to catch the OnClick event, which I use to perform certain actions. I catch the DoubleClick events as well ([csDoubleClicks] is in the ControlStyle by default) to toggle a boolean variable.

The problem is that for every double click I give in the string grid, the pertaining event handler is called twice. This is pretty annoying, since it toggles my boolean twice.
When I don't include the csClickEvents in the ControlStyle, there is only one call to the event handler, as expected. I need the single clicks as well, so this no solution for me.

Any ideas ?
0
Comment
Question by:cadenza
5 Comments
 
LVL 4

Expert Comment

by:erajoj
ID: 1335705
I'm probably stupid (I'm swedish), but I don't understand
the question; why do you have to add the events when they're
already there? There should be no problem doing what you want
in the existing event handlers!?. %-)
0
 
LVL 3

Expert Comment

by:sperling
ID: 1335706
I dropped a stringgrid on a form, created an OnClick and an OnDblClick event handler, and it works as expected...

Why do you modify ControlStyle?

Regards,

Erik.
0
 

Author Comment

by:cadenza
ID: 1335707
The OnClick etc. work fine, but not for fixed columns. You can make your OnClick event handler getting called for a Click on a fixed column by adding csClickEvents to the control style as I described, with the described behaviour.

In the mean time I managed to solve the problem myself by
handling the MouseDown (without csClickEvents in the control style). I had tried this before, to no avail. I must have done something wrong then.

Sorry for bothering you with a non-question!
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1335708
Got your mail!
Don't worry about bothering us!
We (I) do this for the fun of it.
I was stupid not to understand the problem since I came
across the same problem two years ago or so.
Next time make sure that the question is complete, and you will
get a complete answer.

/// John
0
 

Accepted Solution

by:
cucumber earned 200 total points
ID: 1335709
Okay, the problem is because of the implementation of TCustomGrid.  It never listen to click event directly as you know and generate click event by explictly calling the Click method in some situation like clicking on the non-fixed cell.

If you force the grid to listen to click event, then you are expected to get 2 events.

The only work around is to build a subclass of TStringGrid and override the MouseDown method. Simply copy the code in TCustomGrid and move the line "Click;" to the end of the method.  

So you will receive click event no matter where you click on the grid :>
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now