能给我个例子么

解决方案 »

  1.   

    你在Form1里面加一个Timer,Interval属性设置为50,再加两个Label,就可以看到效果了
    procedure TForm1.Timer1Timer(Sender: TObject);
    var
     P:TPoint;
     FormHandle: Hwnd;
    procedure GetRectArea;
    var
     rect:TRect;
    begin
     GetWindowRect(FormHandle,rect);
    end;
    begin
     GetRectArea;
     GetCursorPos(P);
     Form1.label1.caption:='横坐标:'+InttoStr(P.x);
     Form1.label2.caption:='纵坐标:'+InttoStr(P.y);
    end;
      

  2.   

    procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      Form1.Caption:=Format('X坐标:%d,Y坐标:%d',[X,Y]);
    end;