Hackers Guide to Visual FoxPro 7.0
This, ThisForm, ThisFormSet
The documentation refers to these three as "object references" and we can't think of anything better. They're not commands nor functions; neither are they properties, events nor methods. And they're not exactly variables, either. What they are, in an informal sense, is handles. They let you grab onto objects without knowing the names of the objects.| Usage | This.Property | Method | MemberName ThisForm.Property | Method | MemberName ThisFormSet.Property | Method | MemberName |
| Example | oTest=CREATEOBJECT("TestForm") oTest.SHOW() READ EVENTS DEFINE CLASS TestForm AS Form ScaleMode = 0 && Foxels just to make it easier && to position things ADD OBJECT txtUpdate AS Updater ADD OBJECT cmdClear AS ClearButton ADD OBJECT cmdQuit AS QuitButton PROCEDURE Init * set up Clear button to clear text box This.cmdClear.cWhatToClear="txtUpdate" * position things This.Height=10 This.Width=30 This.AutoCenter=.T. This.txtUpdate.Left=5 This.txtUpdate.Top=2 This.cmdClear.Left=5 This.cmdClear.Top=5 This.cmdQuit.Left=15 This.cmdQuit.Top=5 ENDPROC ENDDEFINE DEFINE CLASS Updater AS Textbox Width=20 Height=1.5 PROCEDURE InteractiveChange * change the form caption ThisForm.Caption=This.Value ENDPROC PROCEDURE ProgrammaticChange * revert the form caption ThisForm.Caption="TestForm" ENDPROC ENDDEFINE DEFINE CLASS ClearButton AS CommandButton Width=7 Height=1.5 Caption="Clear" * add a custom property cWhatToClear="" PROCEDURE Click LOCAL cClearWhat cClearWhat=This.cWhatToClear ThisFORM.&cClearWhat..Value="" ENDPROC ENDDEFINE DEFINE CLASS QuitButton AS CommandButton Caption="Quit" Width=7 Height=1.5 PROCEDURE Click CLEAR EVENTS ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC ENDDEFINE |
| See Also | CreateObject(), Define Class |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории