Solved

Double Clicks received twice

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 104
ddeman not working in activex 3 92
Wininet read php file from internet issue 6 80
Dynamically Created Query 3 49
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

930 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

14 Experts available now in Live!

Get 1:1 Help Now