Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Double Clicks received twice

Posted on 1997-04-24
5
Medium Priority
?
412 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 400 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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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