Adds objects from other classes to the class definition.
[ADD OBJECT [PROTECTED] ObjectName AS ClassName2 [NOINIT] [WITH cPropertylist]] |
Parameters
- [ADD OBJECT [PROTECTED] ObjectName AS ClassName2
- Specifies to add an object from a Visual FoxPro base class, user-defined class or subclass, or an ActiveX custom control to the class definition. The PROTECTED keyword prevents access and changes to the object's properties from outside the class or subclass definition.
- [NOINIT]
- Specifies to not execute the Init method of the object when adding it.
- [WITH cPropertyList]]
- Specifies a list of properties and their values for the object that you add to the class definition. 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:
Example
The following example creates a class named MyForm from the Form base class and adds a command button from the CommandButton base class and a check box from the CheckBox base class:
В | Copy Code |
---|---|
DEFINE CLASS MyForm AS Form ADD OBJECT cmdButton1 AS CommandButton ADD OBJECT chkBox1 AS CheckBox ENDDEFINE |
As another example, the following code creates a class called MyForm, adds a command button and check box to the class, and specifies values for the Caption properties of the command button and check box.
В | Copy Code |
---|---|
DEFINE CLASS MyForm AS Form ADD OBJECT cmdButton1 AS CommandButton WITH Caption = "Yes" ADD OBJECT chkBox1 AS CheckBox WITH Caption = "Click Me" ENDDEFINE |