unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Unit2;
type
TForm1 =
class( TForm )
Label1: TLabel;
Label2: TLabel;
procedure FormMouseMove( Sender: TObject; Shift: TShiftState; X, Y: Integer );
private
FCounter1, FCounter2: Integer;
FMouseMoveThrottle : TThrottle<TPoint>;
procedure OnThrottledMouseMove( Sender: TObject;
const APos: TPoint );
public
procedure AfterConstruction;
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.AfterConstruction;
begin
inherited;
FMouseMoveThrottle := TThrottle<TPoint>.Create( Self );
FMouseMoveThrottle.Interval := 100;
FMouseMoveThrottle.OnChanged := OnThrottledMouseMove;
end;
procedure TForm1.FormMouseMove( Sender: TObject; Shift: TShiftState; X, Y: Integer );
begin
// Nur zur Info
Inc( FCounter1 );
Label1.Caption := Format( '
%d ( %d, %d )', [ FCounter1, X, Y ] );
FMouseMoveThrottle.Send( TPoint.Create( X, Y ) );
end;
procedure TForm1.OnThrottledMouseMove( Sender: TObject;
const APos: TPoint );
begin
// Nur zur Info
Inc( FCounter2 );
Label2.Caption := Format( '
%d ( %d, %d )', [ FCounter2, APos.X, APos.Y ] );
end;
end.