Title: ForEach for components hierarchy
Question: How to scan all component on then form?
Answer:
Just declare a type
type
TScanProc = procedure ( C : TComponent ) of object;
and call next procedure
procedure ForEach ( AComponent : TComponent;ScanProc : TScanProc);
var
i : integer;
begin
If Assigned(AComponent) and Assigned(ScanProc) then
begin
For i:= 0 to AComponent.ComponentCount-1 do
begin
ScanProc(AComponent.Components[i]);
ForEach(AComponent.Components[i],ScanProc);
end;
end;
end;
and your code will be calle for each component on the form !