如何知道表单是否悬停在组件上?

Dia*_*ian 0 forms delphi components

我需要知道一个(移动)形式是否悬停在一个组件上(可能是没有鼠标的MouseEnter和MouseLeave).

我有这个想法,即获取组件的左,上,高,宽,并计算(移动)表单的位置是否在表单的位置内.(我不确定如何做到这一点)

有关实施我的想法的任何建议?有没有其他方法可以做到这一点?

Rem*_*eau 5

尝试这样的事情:

var
  P: TPoint;  
  R1, R2, I: TRect;
begin
  P := TheComponent.ClientOrigin;
  R1 := TheComponent.ClientRect;
  Windows.OffsetRect(R1, P.X, P.Y);
  P := TheForm.ClientOrigin;
  R2 := TheForm.ClientRect;
  Windows.OffsetRect(R2, P.X, P.Y);
  if Windows.IntersectRect(I, R1, R2) then
    // the Form is over the component
  else
    // the Form is not over the component
end;
Run Code Online (Sandbox Code Playgroud)