Re: [Delphi 6] Introspection - iterate through all class members of a given type?



On 28 Oct 2005 08:20:49 -0700, "Richard" <radevenz@xxxxxxxxxxxxx>
wrote:

>procedure FooBarInspector(Thing:TObject);
>begin
>
>// how would I code this?
>for each TFooBar (as aFooBar) in Thing do begin
> doSomethingWith (aFooBar);
>end;
>
>end;

procedure FooBarInspector(Thing:TObject);
var
iCtrl : integer;
begin
if Thing is TForm then
for iCtrl := 0 to TForm(Thing).ControlCount - 1 do
if TForm(Thing).Controls[iCtrl] is TFooBar then
doSomethingWith (TFooBar(TForm(Thing).Controls[iCtrl]));
end;

--
Duncan
.