0

Does anyone know which of these are quicker?

procedure SetMousePos(Point: TPoint);
begin
  Mouse.CursorPos := Point;
end;

function GetMousePos: TPoint;
begin
  Result := Mouse.CursorPos;
end;
procedure SetMousePos(Point: TPoint);
begin
  SetCursorPos(Point.X, Point.Y);
end;

function GetMousePos: TPoint;
begin
  GetCursorPos(Result);
end;

Edited by JacobBruce: n/a

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by pritaeas
0

Ah~Every procedure only has one sentence,so directly use(don't use in procedure) may quicker.And I think,Mouse.CursorPos may be quicker.
And there is another way(perhaps quicker):

Procedure GetMouse(Var s,x,y:Word);
 Var
  _s,_x,_y:Word;
 Begin
  Asm
   MOV ax,3
   INT $33
   MOV _s,bx
   MOV _x,cx
   MOV _y,dx
  End;
  s:=_s;
  x:=_x;
  y:=_y;
 End;
Procedure SetMouse(x,y:Word);
 Begin
  Asm
   MOV ax,4
   MOV cx,x
   MOV dx,y
   INT $33
  End;
 End;
0

If you really want to know in detail, profile it. Add timing functions and run them a couple of thousand times. GetCursorPos is a windows call. Mouse.CursorPos is a VCL wrapper that calls a method that calls GetCursorPos . So in theory the former is always faster.

Edited by pritaeas: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.