Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Andy Kramek
  Where is Andy Kramek?
 Westminster Circle, Akron
 Ohio - United States
 Andy Kramek
 To: Matt Pegg
  Where is Matt Pegg?
 Ballarat
 Australia
 Matt Pegg
 Tags
Subject: RE: Width_assign method fires on access ?
Thread ID: 200823 Message ID: 200829 # Views: 45 # Ratings: 1
Version: Not Applicable Category: Classes and Objects
Date: Thursday, October 30, 2008 2:45:04 AM         
   


> 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



COMPLETE THREAD
Width_assign method fires on access ? Posted by Matt Pegg @ 10/30/2008 2:09:06 AM
RE: Width_assign method fires on access ? Posted by Andy Kramek @ 10/30/2008 2:45:04 AM
RE: Width_assign method fires on access ? Posted by Matt Pegg @ 10/30/2008 4:27:42 AM