DEFINE CLASS <classname> AS <baseclass>

This line of code tells Microsoft FoxPro that we are creating a class. All code between the DEFINE and the ENDDEFINE relates to this class. <Classname> is the name of the class. <Baseclass> is the name of the class upon which the class is based. This can be a built in class provided with Microsoft Visual FoxPro 3.0 or a class that you create or purchase.

Visual FoxPro 3.0 comes with the following base classes.

Class Name

Description

CheckBox

A standard checkbox control. Similar to the checkbox created in FoxPro 2.x.

Column

A column on a Grid Control.

ComboBox

A combobox is akin to a popup control in FoxPro 2.x.

CommandButton

Equivalent to a push button in FoxPro 2.x

CommandGroup

A group of command buttons that operate together. Equivalent to a group of push buttons in FoxPro 2.x that are controlled by one variable.

Container

A generic object that is designed to hold other objects. This is useful when you are creating a class that has more than one object on it.

Control

The same as the container class with one major difference. In a container class, when the object is instantiated from the class, you can address all objects with in the container. The control class hides all internal objects and only allows communication with the control class.

Custom

This class is primarily used for objects that are not visual. It may contain visual objects as members.

EditBox

Equivalent of a FoxPro 2.6 Edit Region

Form

A single "screen". This is a container object in that it may (and usually does) contain other objects. The equivalent of a FoxPro 2.x Screen.

FormSet

A container type object that has one or more forms as members. This is the equivalent to a FoxPro 2.x screen set.

Grid

A container type object that allows display and editing of information in browse type format.

Header

The Header of a Grid Column

Image

A picture.

Label

Equivalent of placing text on a screen in a FoxPro 2.x screen.

Line

A drawn line.

ListBox

Equivalent of the FoxPro 2.x scrolling list control.

OleControl

A control based on an OLE2 object.

OptionButton

A single radio button type object.

OptionGroup

Multiple radio buttons that operate as a single control. This is the equivalent to a FoxPro 2.x radio button object.

Page

A single page within a page frame.

PageFrame

A tabbed type control. Each tab within a tab control is a separate page. The PageFrame control is a container type control because it may (and usually does) contain many objects.

Shape

A shape (such as a circle or a box).

Spinner

Equivalent of the FoxPro 2.x Spinner Control.

TextBox

Equivalent of a FoxPro 2.x "plain" GET control.

Timer

A visual object that does not display on a form. This control is designed to allow for actions at certain timed intervals.

ToolBar

A toolbar. Toolbars are groups of objects that can be docked at the top, bottom or on the sides. When not docked, looks somewhat like a form.


Although it is beyond the scope of this article to go into each class in detail, understanding each of these classes, their properties and methods, is critical to properly using them when defining classes in Microsoft Visual FoxPro 3.0.

In addition to the base classes included with Microsoft Visual FoxPro 3.0, you can base classes on your own classes. The stop watch example will illustrate this.