Link to home
Start Free TrialLog in
Avatar of igor84
igor84

asked on

Getting the time of a dblClick (1000 points for quick good answer)

hi need your help !!!


i need get the time of a dblclick with accuracy of
 1 millisecond how i do it ?


Igor.
Avatar of Epsylon
Epsylon

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    lasttime: Cardinal;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var thistime: Cardinal;
begin
  thistime := GetTickCount;
  if thistime - lasttime < GetDoubleClickTime then
    Caption := IntToStr(thistime - lasttime)
  else
    Caption := 'to slow';
  lasttime := thistime;
end;

end.
Avatar of igor84

ASKER

this function is to slow it gets upto 5 millisec i need upto 1 millisec  sorry ...
Doesn't that depend on the CPU speed...?
Here it is fast enough:


procedure TForm1.Button1Click(Sender: TObject);
begin
  Perform(WM_LBUTTONDOWN, 0, 0);
  Perform(WM_LBUTTONDOWN, 0, 0);
end;


When I press button1, it shows 1 in the caption...
ASKER CERTIFIED SOLUTION
Avatar of alanwhincup
alanwhincup

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Correction: it returns 0 on a 450 MHz CPU...
Avatar of igor84

ASKER

i found an answer by my self
then you should post it.  It's considered rather rude to solicit help, then delete the q after it's been given.  

GL
Mike
> i found an answer by my self

Who says that you didn't use my code....
Avatar of kretzschmar
listening . . .
Epsylon: Lock the question to prevent it being deleted.
Use the PerformanceCounter insted of Ticks.

QueryPerformanceCounter and
QueryPerformanceFrequnecy and

Bullen
Avatar of igor84

ASKER

i found an answer by myself but because some one posted a right answer he deserves the points, and the right answer is from : alanwhincup.

And what about those promised 1000 points?
Avatar of igor84

ASKER

because this solution is not the best and don't realy works on 1 millisec accuracy.

if you posted me a solution like this i would give you 1000 points. i realy don't understand you all obsession to points you all are so greedy ?!

p.s you first solution was at accuracy of 5 millisec so ...

Igor
Why did you delete the question without explanation? Doesn't that mean that you are greedy for answers?
And why didn't you wait for a better solution instead of deleting it?

Look, this point system increases the response time greatly. There is a certain level of competition between experts, and... they are points, not dollars. I and others spent time trying to help you. I don't even see a 'thank you' or something like that.

Promising 1000 points and then deleting the question without explanation, after you received 2 solutions, is really frustrating. It is NOT DONE!

Eps. (really pissed!)
Avatar of igor84

ASKER

i deleted by mistake and like you see after that i accepted alanwhincup answer ! and gave him 100 pts (the question value) but if there were good enghot solution like i asked i would give 1000 pts.

i realy thanks you and all other people that are spending theirs time to help others and i realy thank you for that !

p.s don't be angry.

i asked a day before another question that is very thoght and i promiss you the accepted answer will get 1000 points.

p.s from where are you ?
My solution should give the time to an accuracy of 1ms. It uses a multimedia timer which is implemented using the Win32 multimedia library (winmm.dll). Ive used this instead of any other time because most other timers are limited by the systems resolution.
Avatar of igor84

ASKER

i agree with you in the help file written that give an accurancy of 1 ms but it isn't like that. i checked it and that disappointmented me. sorry ...