如何取得当前鼠标在屏幕中的位置?

解决方案 »

  1.   


    需要用到API函数 getcursorpos();
      

  2.   

    var point:Tpoint;
    begin
    GetCursorPos(point);
    Edit1.Text:=inttostr(point.x);
    end;
      

  3.   

    var
      x:integer;
    begin
      x := GetCursorPos(point).x;
    end;
      

  4.   

    直接用全局变量Mouse的属性CursorPos!
      

  5.   

    呵呵,是呀
      Mouse.CursorPos.X
      Mouse.CursorPos.Y
      

  6.   

    在 OnMouseMove事件中
    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    var
      MyPoint:Tpoint;
    begin
      GetCursorPos(MyPoint);  //获取屏幕坐标
      X:=MyPoint.X; //重定位X坐标值
      Y:=MyPoint.Y; //重定位Y坐标值
      Label1.Caption:='X: '+IntToStr(X)+' Y: '+ IntToStr(Y); //将坐标显示出来
    end;