Microsoft KB Archive/190539

= How To Make Move or Resize Call Form's THIS_ACCESS Method =

Article ID: 190539

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q190539



SUMMARY
Visual FoxPro 6.0 gives you the ability to attach events to properties. This is accomplished using Access and Assign methods. These events will fire when a property value is queried (that is, accessed) or set to a value (that is, assigned). The THIS_ACCESS method is a special case that is fired whenever any property of an object is queried or set. Normally, this method will be fired only when properties are programmatically set or queried. This article describes how to ensure the THIS_ACCESS method is called even if a property is implicitly changed. An example of when you may want to do this would be when a form is moved the form's Top property is changed.



MORE INFORMATION
This example demonstrates how THIS_ACCESS is not called by properties that are implicitly changed.   Run the following code from a program (.prg) file: PUBLIC oform1

oform1=NEWOBJECT("form1") oform1.SHOW RETURN

DEFINE CLASS form1 AS FORM

DOCREATE = .T.        CAPTION = "Form1" NAME = "Form1"

PROCEDURE this_access LPARAMETERS cMemberName ? cMemberName, TTOC(DATETIME) RETURN THIS ENDPROC

ENDDEFINE  Resize or move the form with the mouse. Note that no output is echoed to the form.

This example shows how to make THIS_ACCESS be called when moving or resizing a form by adding code to the form's Moved and Resize methods.   Run the following code from a program (.prg) file. Note the code added to the Moved and Resize methods. PUBLIC oform1

oform1=NEWOBJECT("form1") oform1.SHOW RETURN

DEFINE CLASS form1 AS FORM

AUTOCENTER = .T.        CAPTION = "Form1" NAME = "Form1"

PROCEDURE this_access LPARAMETERS cMemberName ? cMemberName, TTOC(DATETIME) RETURN THIS ENDPROC

PROC MOVED = THIS.TOP = THIS.LEFT ?        ENDPROC

PROC RESIZE = THIS.WIDTH = THIS.HEIGHT ?        ENDPROC

ENDDEFINE  Resize or move the form with the mouse. Note that the properties that are queried get echoed to the form.

