Article ID: 155261
Article Last Modified on 12/3/2003
***** Start Program Code *****
PUBLIC oForm1
oForm1 = CREATEOBJECT("myform")
oForm1.Show
DEFINE CLASS myform AS form
Name = "myform"
PROTECTED cString
ADD OBJECT command1 AS commandbutton WITH ;
Top = 20, ;
Left = 20, ;
Height = 30, ;
Width = 100, ;
Caption = "Change Property"
ADD OBJECT command2 AS commandbutton WITH ;
Top = 100, ;
Left = 20, ;
Height = 30, ;
Width = 100, ;
Caption = "Call Method"
PROCEDURE command1.Click
* This fails because the Command button
* Cannot change a protected property of the class
This.Parent.cString = "Change Me"
ENDPROC
PROCEDURE command2.Click
* calling a method to change a protected property will work
This.Parent.ChangeString()
ENDPROC
PROCEDURE ChangeString
* because the method is part of the class, it
* can change the cString property
This.cString = "Change Me"
WAIT WINDOW "The Property cString now equals "+This.cString
ENDPROC
ENDDEFINE
***** End Code *****
128633 How Inheritance Affects PROTECTED Methods and Properties
Additional query words: kbdsd vfoxwin
Keywords: KB155261