> Hi all,
>
> I have a problem at the moment in that it appears if I have an Assign
> method on either the Width or Height property of a Control, that assign
> method is executed when the property is accessed.
>
> If I have both assign & access methods, then assign will fire when
> I set the property, but BOTH access and assign will fire when I read
> the property.
>
> I've tested this on Labels, Containers and Textboxes in VFP 9 & 6, and
> it happens in all cases - only for Width and Height though.
>
> Anyone have an idea as to why ?
>
> eg.
>
> DEFINE CLASS TestLabel AS Label
>
> PROCEDURE Width_ACCESS
> MESSAGEBOX("Label Width Access")
> RETURN THIS.Width
> ENDPROC
>
> PROCEDURE Width_ASSIGN
> LPARAMETERS vNewVal
> MESSAGEBOX("Label Width Assign")
> THIS.Width = m.vNewVal
> ENDPROC
>
> ENDDEFINE
>
> m.lnWidth = THISFORM.TestLabel1.Width
>
>
> will result in both Messages being displayed.
> Note: Assign will fire whether Access exists or not, and the reverse doesnt happen.
> ie. Access doesnt (and shouldnt) fire when we set the property.
>
> cheers,
> Matt.
This is documented behavior as noted in the Help file under "Access and Assign Methods"
Note
The Assign method will fire for certain native properties when their value is queried and not changed. These include dimensional properties such as Top, Left, Height, Width as well as a few others like Visible. This is due to how Visual FoxPro handles these properties internally. Regards
Andy Kramek
Microsoft MVP (Visual FoxPro)
Tightline Computers Inc, Akron Ohio, USA