1 procedure TForm1.Timer1Timer(Sender: TObject); 2 var 3 a:TPoint; //用来存放坐标 4 hw:HWND; //用来存放窗口句柄 5 begin 6 GetCursorPos(a); //取得鼠标坐标,并存放进a中 7 hw := WindowFromPoint(a); //取得变量a 对应的 窗口句柄 8 Edit1.Text := IntToStr(a.X); 9 Edit2.Text := IntToStr(a.Y); 10 Edit3.Text := IntToStr(hw); 11 end;