The Visual FoxPro sample class library provide encapsulated functionality that you can easily add to your applications. The Solutions sample application illustrates using most of the sample classes. The sample classes are contained in the following files:
Buttons.vcx contains the following classes.
Class | Description |
CmdOK | A command button that releases the form it is added to. If the form is contained in a form set, cmdOK releases the form set. |
CmdCancel | A subclass of cmdOK with the Caption property set to “Cancel.” |
CmdHelp | A command button that invokes help with the HelpContextID of the form it is added to. |
MailBtn | A container with a command button, a Microsoft MAPI Message control, and a Microsoft MAPI Session control. Code in the Click event of the command button logs on to mail and composes a message containing the values in the current record of a table. For an example of using the MailBtn class, see SENDMAIL.SCX in the Visual FoxPro SAMPLES\SOLUTION\OLE folder. |
VCR | A set of table navigation buttons that allow a user to move the record pointer to the next, prior, top, and bottom records of a table. Set the Skiptable property to the alias of the table you want to move the record pointer in. If Skiptable is empty, the record pointer is moved in the currently selected work area. |
Samples.vcx contains the following classes.
Class | Description |
CboFontName | A combo box that displays all the currently available fonts in the system. |
CboFontSize | A combo box that displays all the available point sizes for a particular font. Pass a font name to the FillList method to populate the combo box. The nLargestFont and nSmallestFont properties delimit the maximum and minimum font sizes displayed. You can use this control in conjuction with the cboFontName class. In the InteractiveChange event of the cboFontName object, call the FillList method of the cboFontSize object:
For an example of using this class, see the tbrEditing class in the same class library. |
Clock | A container that displays the current date and time. The “Display a system clock” component in the Solutions sample also uses the Clock class. |
Datachecker | A custom class that manages resolving data conflicts. Code in the Error event of the VCR class in BUTTONS.vcx calls the CheckConflicts method of this class if an attempt to write buffered data to a table encounters changed values:
The “Run multiple instances of a form” component in the Solutions sample also uses this class to check for data conflicts. For more information, open the class and read the comments in the code. |
Distinct_values _combo |
A combo box that is populated on initialization with the distinct values in the ControlSource alias. For example, if you add this class to a form and set the ControlSource to “customer.country”, the combo box will be populated with the countries in the customer table without displaying the country names more than once. |
FrmNoTitle | A form with properties set so that no title is displayed. If you want to display information in a separate window, you can create an object based on this class and use form graphics methods. The “Display line animation on a form” component in the Solutions sample also uses a form with no title to display the animation. |
Lookup_combo | A combo box that makes it easy to display values from one field, for example a company name, while binding a ControlSource to another field, for example a company id number. This class has four custom properties: order_column: Column to sort the table by (optional). lookup_table: Table to fill the combo box from. display_column: Column in the table to display. return_column: Column whose value is written to the ControlSource. |
MoverLists | A container with two list boxes and four command buttons. A user can move selected items from one list to the other list by clicking the command buttons or dragging and dropping. You need to make sure the RowSourceType of each list box is set to 0 and use the AddItem method to add items to the source list box. MoverLists has three custom properties: CanDropIcon: Cursor to be displayed over a valid target in a drag and drop operation. NoDropIcon: Cursor to be displayed when dropping will not add the selected items to the list box. DragThreshold: Number of pixels before the drag operation begins. The “Move items between list boxes” component in the Solutions sample illustrates the use of this class. |
Print_reports | A modal form that allows a user to preview a report, print it, or direct it to a file. You can set the cReport property of the class to the name of the report or pass the report name in as a parameter:
|
QBF | A container with three command buttons. Add this class and the VCR class to a form with data-bound controls. When the user chooses Enter QBF, the values in the controls are blanked out. Values that the user enters in the controls specify the filter to be set on the table when the user chooses Query. The controls need to have a ControlSource set and the Parent of the controls needs to be the form, not another container. The “Create a query by example form” component in the Solutions sample illustrates the use of this class. |
Resizable | A custom class that manages resizing and repositioning the controls on a form at run time, maintaining their relative sizes and positions. Add the class to a form and, in the Resize event of the form, call the AdjustControls method:
Resizable has two custom properties you need to set: RepositionList: A string containing all the classes for which objects are repositioned. ResizeList: A string containing all the classes for which objects are resized. The “Resize and reposition controls at run time” component in the Solutions sample illustrates the use of this class. |
RTFcontrols | A container class containing cboFontName, cboFontSize and command buttons for Bold, Italic, and ForeColor. The cboFontSize control is refreshed in the InteractiveChange event of cboFontName, but no additional functionality is coded with the Bold, Italic and ForeColor command buttons. The “Use the RichText control” component in the Solutions sample illustrates the use of this class. |
SoundPlayer | This class can be used to play a non-visual multimedia file, such as a .WAV audio file. See Sample Multimedia Classes for details. |
StopWatch | A container class with a timer and labels to display stop watch values. StopWatch has three custom methods you’ll want to use: Start: Starts the stop watch. Stop: Stops the stop watch Reset: Resets the displayed time to 0:00 The “Display a stop watch” component in the Solutions sample illustrates the use of this class. |
TbrEditing | tbrEditing has a custom property and a method you’ll want to use: nAppliesTo Property: This property can be set to 1, 2, or 3.
Refresh: Accepts an object reference as a parameter and sets all the editing controls to the appropriate values of the object. Call the Refresh method in the GotFocus event of a control. The “Change font attributes” component in the Solutions sample illustrates the use of this class. |
Videoframe | This class can be used to play a visual multimedia file, such as a video for Windows file. See Sample Multimedia Classes for details. |
Typelib.vcx contains the following class.
Class | Description |
Typelib | A container class that contains a Foxtlib.ocx control. The ExportTypeLib method of this class calls the methods of the Foxtlib control to read type library information from .OLB, .TLB, and .EXE files. The “View type library information” component in the Solutions sample illustrates the use of this class. |
Utility.vcx contains the following classes.
Class | Description |
Arraylib | A custom class with methods for inserting array elements, deleting array elements, and scanning array columns. |
Execsp | A custom class with methods that facilitate SQL pass through and executing stored procedures on a remote database. |
Filelib | A custom class with methods that perform common string tasks used when manipulating file names, for example, removing the extension, adding a backslash to a path, and so on. |
Menulib | A container class with methods that create a shortcut menu from an array. The “Create dynamic shortcut menus” component in the Solutions sample illustrates the use of this class. |
Registry.prg contains the following classes.
Class | Description |
FileReg | A subclass of the Registry class that provides methods for reading the application associated with particular file extensions and the path to the application. |
FoxReg | A subclass of the Registry class that provides methods for reading and writing Visual FoxPro settings in the Windows Registry. |
ODBCReg | A subclass of the Registry class that provides methods for reading ODBC data source and driver information. |
OldINIReg | A subclass of the Registry class that provides methods for reading and writing to an .INI file. |
Registry | A custom class that provides methods for accessing Windows API functions for manipulating the Windows Registry. |
For examples of using the registry classes, run SOLUTION.app in the VFP\SAMPLES\SOLUTION folder.