Atozed Forums

Full Version: Loop components questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

Maybe my understanding of IWForms versus VCL forms lacks a lot, but could anyone please explain why it is that

"for i := 0 to self.componentcount -1 do" compiles ok and
"for i := 0 to TIWForm1.componentcount -1 do" fails with: Componentcount "inaccessible" here

Isn't self and tiwform1 one and the same in this case ?

Regards
Soren
TIWForm1 is a class not an instance. ComponentCount is not a static so it is not accessible via class reference.

What you have would fail in VCL Forms as well.
Hi Kudzu,

Thank you for the reply. And of curse you're right:

I checked the way I do it in VCL and there I use it with "(sender as TForm)"

So my call would be

getformprops(sender as tform);

and the procedure I call would be

procedure getformprops(f : tform); and then

f.componentcount is valid.

Regards
Soren