Solved

Double Clicks received twice

Posted on 1997-04-24
5
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
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 this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month4 days, 8 hours left to enroll

635 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