How to: Create Classes and Subclasses
You can create classes and subclasses using the Visual FoxPro Class Designer or programmatically. When you use the Class Designer to create classes, you can view the class as you design it.
For convenience and speed, you might want to keep a class and all its subclasses in one class library. If you have a class that contains elements from different class libraries, these libraries must all be open, so it might take longer to initially load the class at design time and run time.
To create a class or subclass
On the File menu, choose New.
In the New dialog box, choose Class, and then click New File.
The New Class dialog box opens.
In the Class Name box of the New Class dialog box, type the name of the class.
In the Based On box, select the name of a Visual FoxPro base class.
To create a user-defined class, choose Custom as the base class. When you choose the Custom base class, the class you create is a non-visual class, which displays a visual element at design time but not at run time. For more information, seeand .
Click the ellipsis (...) button to select a visual class library (.vcx) file.
In the Store In box, type the name of the class library file for storing the class.
The Class Designer opens and displays the class.
When you are finished with creating the class, save the class.
The class is saved in a Visual FoxPro visual class library (.vcx) file.
Visual FoxPro stores classes you create using the Class Designer in visual class library (.vcx) files. These classes include visual and non-visual classes.
For more information about base classes in Visual FoxPro, see. For more information about the Class Designer, see .
You can also add classes and subclasses to an existing class library. For more information, see.
To create classes or subclasses in a project
Open the project for your application.
In the Project Manager, choose the Classes tab, and click New.
The New Class dialog box opens so you can specify information for the new class or subclass.
Follow the steps for creating a class or subclass.
For more information, see.
To create classes and subclasses programmatically
Use the CREATE CLASS command or DEFINE CLASS command.
The CREATE CLASS command opens the Class Designer, while the DEFINE CLASS command is for programmatic use. You can also create and add properties and methods and add code to respond to events for the class by using the DEFINE CLASS command.
If you store class definitions in a program (.prg) file when you use DEFINE CLASS, you can precede, but not follow, class definitions with program code. This is similar to not following procedures with program code in a program.
For more information, seeand .