var i: integer; AForm: TForm; begin for i := 0 to AForm.ComponentCount -1 do begin if AForm.Components[i].ClassName = 'TLabel' then begin //在这里判断 AForm.Components[i].Top .... end; end; end; 分~~~~
var i, j: integer; l1, l2: TLabel; begin for i := 0 to ComponentCount - 1 do if Components[i] is TLabel then begin for j := i + 1 to ComponentCount - 1 do if Components[j] is TLabel then begin l1 := TLabel(Components[i]); l2 := TLabel(Components[j]); if (l1.Parent = l2.Parent) and (PtInRect(l1.BoundsRect, l2.BoundsRect.TopLeft) or PtInRect(l1.BoundsRect, l2.BoundsRect.BottomRight)) then begin ShowMessage(l1.Name + ',' + l2.Name); end; end; end;
var
i: integer;
AForm: TForm;
begin
for i := 0 to AForm.ComponentCount -1 do
begin
if AForm.Components[i].ClassName = 'TLabel' then
begin
//在这里判断
AForm.Components[i].Top ....
end;
end;
end;
分~~~~
i, j: integer;
l1, l2: TLabel;
begin
for i := 0 to ComponentCount - 1 do
if Components[i] is TLabel then
begin
for j := i + 1 to ComponentCount - 1 do
if Components[j] is TLabel then
begin
l1 := TLabel(Components[i]);
l2 := TLabel(Components[j]); if (l1.Parent = l2.Parent) and (PtInRect(l1.BoundsRect, l2.BoundsRect.TopLeft) or PtInRect(l1.BoundsRect, l2.BoundsRect.BottomRight)) then
begin
ShowMessage(l1.Name + ',' + l2.Name);
end;
end;
end;