No.1 GetCursorPos函数
var
  vPoint: TPoint;
begin
  GetCursorPos(vPoint);
end;No.2 Mouse对象
Mouse->CursorPos

解决方案 »

  1.   

    Caption := Format('x:%d,y:%d', [Mouse.CursorPos.X, Mouse.CursorPos.Y]);
    //这是绝对位置ScreenToClient(Mouse.CursorPos) //这是相对位置你就直接说目的不就可以了?
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Label1: TLabel;
        procedure Button1Click(Sender: TObject);
        procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
          Y: Integer);
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      switch:boolean;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    switch:=not switch;
    end;procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
    if switch=true then
    label1.Caption :='水平位置:'+inttostr(x)+'     '+'垂直位置:'+inttostr(y)
    else
    label1.Caption :='已停止鼠标位置的探测';
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
    switch:=false;
    end;end.
      

  3.   

    Mouse.CursorPos.X的值是什么???
    怎和最后一例的数值不同啊
      

  4.   

    她取得是鼠标在屏幕的绝对位置,我取得是鼠标在该程序运行时的窗体的位置。你没有说是要哪一种的位置啊!!这样就跟他的程序结果一样了:
    label1.Caption :='水平位置:'+inttostr(x+form1.left)+'     '+'垂直位置:'+inttostr(y+form1.top)