TForm和TPanel都有OnMouseMove事件,而TWebBrowser没有,所以只能在时钟里每隔一会儿取一下鼠标的坐标吧!procedure TForm1.Timer1Timer(Sender: TObject); var C, S: TPoint; W: TWinControl; begin//Timer1.Interval = 100 S := Mouse.CursorPos; W := FindControl(WindowFromPoint(S)); if W <> nil then begin C := W.ScreenToClient(S); Text := Format('屏幕坐标(%d, %d), 控件坐标(%d, %d)', [S.X, S.Y, C.X, C.Y]) end else Text := Format('屏幕坐标(%d, %d)', [S.X, S.Y])end;
var
C, S: TPoint;
W: TWinControl;
begin//Timer1.Interval = 100
S := Mouse.CursorPos;
W := FindControl(WindowFromPoint(S));
if W <> nil then
begin
C := W.ScreenToClient(S);
Text := Format('屏幕坐标(%d, %d), 控件坐标(%d, %d)', [S.X, S.Y, C.X, C.Y])
end else
Text := Format('屏幕坐标(%d, %d)', [S.X, S.Y])end;