looping through picture objects

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

looping through picture objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

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?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: looping through picture objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: looping through picture objects

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:14 pm

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.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 42 guests