Defines properties and their values for the class definition.
[[PROTECTED | HIDDEN] PropertyName1, PropertyName2 ...] [[.]Object.]PropertyName = eExpression ...] |
Parameters
- [PROTECTED | HIDDEN] PropertyName1, PropertyName2 ...]
-
Specifies one or more class properties to create. Properties are named attributes of the class and define characteristics and behaviors for the class. Use commas to separate each property or declare each property on a separate line.
The PROTECTED keyword prevents access and changes to the specified properties from outside of the class definition. Methods and events in the class or subclass definition can access protected properties. The HIDDEN keyword prevents access and changes to the specified properties from outside of the class definition. However, only methods and events in the class definition, not subclasses, can access hidden properties.
Note: All property definitions must appear before function or procedure definitions. Tip: You can create subclasses with Access and Assign methods if you do not include the HIDDEN keyword.
- [[.]Object.] PropertyName= eExpression ...]
-
Assigns default values to class properties. Using
.Object.
indicates that Visual FoxPro should apply the value to an ActiveX control property when creating it. For more information, see the Examples section.
Remarks
The following code shows a summary of the main clauses of the DEFINE CLASS command:
В | Copy Code |
---|---|
DEFINE CLASS Clause [Property_Definition_Clause] [PEMName_COMATTRIB Clause] [ADD OBJECT Clause] [IMPLEMENTS Clause] [Function_Procedure_Definition_Clause] ENDDEFINE |
For more information and full syntax, see DEFINE CLASS Command. For more information about a particular clause of the DEFINE CLASS command, see the following topics:
Example
The following example creates the form frmOLETest from a Form base class and uses the AddObject method to add an object named OCXTest based on the BlueOLEControl class created by DEFINE CLASS and specifies the OLE class for the Listview ActiveX control. The .Object keyword is used to specify a value for the BackColor property of the control before it is created.
В | Copy Code |
---|---|
PUBLIC frmOLETest frmOLETest = CREATEOBJECT('Form') frmOLETest.Visible = .T. frmOLETest.AddObject('OCXTest', 'BlueOLEControl', 'MSComctlLib.ListViewCtrl') frmOLETest.OCXTest.View = 2 frmOLETest.OCXTest.ListItems.Add(1,'one','Item One') frmOLETest.OCXTest.ListItems.Add(2,'two','Item Two') DEFINE CLASS BlueOLEControl AS OLEControl * Set property for Outline ActiveX control. .Object.Backcolor = 16776960 * Set properties for the OLE Container control. Visible = .T. Height = 100 Width = 200 ENDDEFINE |
For more information, see AddObject Method.