Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TForm1 = class(TForm)
- ApplicationEvents1: TApplicationEvents;
- procedure ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
- private
- FLastCtrl: HWND;
- FLastTick: DWORD;
- FClickCnt: Integer;
- end;
- implementation
- procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG; var Handled: Boolean);
- begin
- if Msg.message = WM_LBUTTONDOWN then
- begin
- // if the same control as before was "left mouse button down-ed", then...
- if (Msg.hwnd = FLastCtrl) then
- begin
- // if 1 second elapsed (1000 here is 1000 ms), then...
- if (GetTickCount - FLastTick >= 1000) then
- begin
- // if the user "left mouse button down-ed" at least 3 times the same control in one second, then...
- if FClickCnt >= 3 then
- // somone clicked the same control at least 3 times per second
- // count this click (it is after that elapsed 1 second period)
- FClickCnt := 1;
- // and store this tick
- FLastTick := GetTickCount;
- end
- // the period of 1 second did not yet elapsed, so let's just increase the click counter
- else
- Inc(FClickCnt);
- end
- else
- begin
- // count this click, store this control handle and this tick
- FClickCnt := 1;
- FLastCtrl := Msg.hwnd;
- FLastTick := GetTickCount;
- end;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement