Page 1 of 1

looping through picture objects

Posted: Fri Aug 07, 2009 1:14 pm
by ConvertFromOldNGs
by Laurie Bisman >> Tue, 13 Nov 2007 19:27:32 GMT

I have 6 picture objects on a form and need to manipulate some properties at run time. I can do anything I need using the example loop below except I can't change the picture. I get a message that c.picture is unknown property or method.

a sample of what I'm trying to do is shown below.

vars
j : Integer;
c : Control;
etc

in code section

foreach j in 1 to self.controlCount do
c := self.controls(j);
if c.isKindOfPicture then
// manipulate picture
c.picture := some other picture
endif;
endforeach;

obviously not a problem as there are only 6 pictures but what if I had 26?

Re: looping through picture objects

Posted: Fri Aug 07, 2009 1:14 pm
by ConvertFromOldNGs
by Dave Patrick >> Tue, 13 Nov 2007 19:47:43 GMT

You need to type-cast the c variable to a Picture - it's specified as a Control, which doesn't have a picture property or method. So your "manipulate picture" line needs to look like

c.Picture.picture := some other picture

Re: looping through picture objects

Posted: Fri Aug 07, 2009 1:14 pm
by ConvertFromOldNGs
by CLS320 >> Tue, 13 Nov 2007 19:48:09 GMT

Hi,

You need to Typecast c to Picture then refer to the property:

if c.isKindOfPicture then
c.Picture.picture:= some other property

Otherwise it can't find a picture property on the Control class which is all the compiler knows about until you typecast.