Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DblClick event raised when switching app...

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

I have a simple modal form from within the a user can make a selection. That is, the form contains only a TStringGrid and two TBitBtn: OK-Cancel. To be more user-friendly, I've implemented the OnDblClick event (which simply calls the btnOK_Click).

The problem occurs when clicking on a row (simple click), and then switching to another running application (Windows Explorer for example). When returning back, if the user clicks on the TStringGrid to reactivate my app (instead of clicking the title bar), the DblClick event is raised but I don't want to...

Is there a way to keep my OnDblClick event and simply implement a [if] statement to check if the previous click was not delayed by switching to another app?

Maybe somthing like to reset the click event queue when switching app???

Thank you all for reading...


 
rcloutie,

what delphi version are you using? I'm trying to simulate this...?

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
hi whosrdaddy,
I'm using delphi 2006 enterprise.

Thank you.
 
Check TForm.OnDeactivate event in the Delphi help. You need to intercept both TForm.OnDeactivate and TApplication.OnDeactivate. If any of those events fire, DESELECT the item in the list.

The best way is pointing both TForm.OnDeactivate and TApplication.OnDeactivate to the same procedure.

buho (A).
 
Hi buho,

I don't think that to deselect the item in the grid will solve the problem: when returning back to my app, DblClick is fired even if single click on another row...

But you got something here: is there a way to reset clicks queue from within TForm.OnDeactivate?

Thank you,

Rej
 
Very strange behaviour.

I doubt the clicks being resetable, actually the decision about clicking/double clicking is made by Windows and not by Delphi.

Lemme do some trys and check the SDK.

buho (A).
 
I can't reproduce the behaviour with D5 and W2K.

I played with the double click speed in the configuration panel, tried quickly clicking in two different rows, alternating clicks in one row, the form, the desktop and in another application, all times the internal counter cleared.

Of course, waiting a little time between clicks cleared the counter too.

May be you can implement your own "double click" using OnClick?

BTW: have you the mouse captured? I have not tried capturing it. Are you managing it "by hand" in any way (like moving it in code)?

buho (A).
 
Hello buho,

I'm not doing anything special with mouse except DblClick event... Working on it today and will post news...

Thank you very much,

Rej Cloutier
 
Ah Ahhh!

The TStringGrid was in fact a home made VCL based on TStringGrid in which I've intercepted WM_SETFOCUS to assign controls according to specific column.

To determine the real column clicked, MouseDown event must have been raised. That's why the instruction ProcessMessages was there. And that was the faulty line!

Sorry, my mistake...

Thank you anyway for your appreciated help,

Have a nice day,

Rej Cloutier
 
Nice to see you managed to solve this [thumbsup]

next time though, TELL us that you weren't using the standard TStringGrid so we don't lose time trying to reproduce the fault. etc... [noevil]

Cheers,

Daddy



-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top