Solved

Double Clicks received twice

Posted on 1997-04-24
5
401 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reconfigure Delphi Install? 2 51
Multiple image collision 13 75
Installshield for Embarcadero EX 10.1 Berlin 4 42
how to change, disabled button color FMX ? 1 33
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 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