PreviousTutorials and Guide to Samples (9.1 revision 1) Next

Lesson 1: ActiveX Tutorials with Delphi

Show this topic in Library frames

This section discusses how to install and manipulate the ActiveX interface with Delphi. The tasks are as follows:

Installing the ActiveX interface into the Delphi IDE

  1. Following the instructions in the Delphi online help or documentation, click Components, then Import ActiveX control from the Delphi main menu.
  2. From the list in the resulting Import ActiveX control dialog box, click Pervasive ActiveX Data Source (Version 1.0).


  3. Click Install, and follow the directions to generate Delphi wrappers for the control and its members.
  4. When that importation is complete, repeat the complete process for the Pervasive Bound controls (Version 1.0).


  5. Check to see that the Data Source control and the Bound controls appear on the ActiveX page of the Delphi Component Palette.

Using the VAccess control in Delphi

  1. Add the control to a form or Data Module:
    1. In the Delphi IDE, click the component palette tab containing the ActiveX interface. In a default installation, this tab is titled ActiveX. The ActiveX icons are visible on the palette.


    2. Left click the mouse on the desired control.
    3. Now either left click on the form where you want the control inserted, or drag the mouse on the form with the left button down to size and shape the control on the form.
  2. Set the Btrieve File properties of the control.
    1. Open the VAccess control Properties dialog box. In the Delphi 3 IDE, view the form containing the ActiveX control. Right-click on the control, and select Properties from the pop-up menu, or double-click on the control.


Set the Btrieve file properties on the File Information tab as follows:

Using a VAListBox control

  1. Add a control to the form. See page 4-4, "Add the control to a form or Data Module:"
  2. Set the VAccess property of a bound control.
    1. Open the Properties dialog box of the bound control.
    2. Click on the down arrow of the VAccessName combo box.
    3. Select the desired control from the drop-down list.


  3. Select the fields to display.
    1. To select a single field to display, left-click the down arrow of the VAFieldName combo box. Select the desired field from the drop-down list.
    2. To display multiple fields to display, left-click the text field of the VAFieldName combo box. Type in the fields you wish to display, separated by semicolons (`;') or Select the "..." button beside the VAFieldName Combo box, and select the desired fields from the resulting dialog box.
  4. Set Column Widths
    1. Click on the ellipsis (...) button next to the ColumnWidth Edit box.
    2. In the Edit Box, double click at the desired right edge of the first column of the VAListBox. Repeat for each column except the last. You may drag the column lines to new positions after this is done.


  5. Set the VAAutoScroll property.
  6. Setting this property False prevents the currently selected list box item from automatically scrolling to the top of the list if the list is used as an auto-fill record list (VARecordList = True)

    The default behavior of the record list VAListBox (VARecordList = True) is to keep the current record as the first item in the list box, whether or not the positioning was changed by the list box or by other means, such as a scrollbar or a GetEqual command.

    If VAAutoScroll is False, this default behavior is defeated and the VAListBox moves the current record to the top of the list only when positioning is changed by a source other than the list box itself. For example, clicking on an item in the list box will reposition the VAccess control, but will not change the items in the list box.

  7. Set the VARecordList property.
  8. Setting this property True changes the mode of the list box or combo box control from a field-bound control to a record browser.

    The VARecordList property causes the list control to be filled with as many records as it can hold. The top item of the list is the current record (unless the VAAutoScroll property is set to False, in which case the selected list item represents the current record.

    When VARecordList = True, several added features are available and may be accessed at design time via buttons on the property page. The VAFieldName and VAFormat properties, which are limited to one entry when the control is in field-bound mode (when the VARecordList property is False), can contain a list of fields and formats, respectively, separated by semicolons. In addition, the VAAutoScroll and ColumnWidth properties become active.

Using a VAText control

  1. Add the control for a form. See page 4-4, "Add the control to a form or Data Module:"
  2. See page 4-8, "Set the VAccess property of a bound control.".
    1. Open the Properties dialog box of the bound control. .
    2. Click on the down arrow of the VAccessName combo box.
    3. Select the desired control from the drop-down list.


  3. Set the VAFieldName property.
    1. Open the Properties of the bound control.
    2. Click on the down arrow of the VAFieldName combo box.
    3. Select the desired field from the drop-down list.
  4. Set the VASearch property
  5. Setting this property to true causes the VAccess control to perform a GetGreaterOrEqual method using the value in the text box for the first segment of the index specified by the IndexNumber property of the data source each time the text changes. The setting of the VAFieldName property is ignored.

    1. Open the Properties dialog box of the bound control.
    2. To set the property to True, select the VASearch check box.
    3. To set the property to False, clear the VASearch check box.


Joining two VAccess controls

The Join property of the VAccess control allows you to specify that two files should be linked by a key value, such that any changes in the record positioning of the first (master) file will also affect the records retrieved from the second (slave) file. The Join property provides a simple mechanism for browsing a relational database.

The joined fields in the slave control must be index fields and must contain the same raw data as their corresponding fields in the master control. The fields in the master control do not have to be indexes. The IndexNumber property of the slave control must remain set to the index involved in the join or the join will be broken.

One-to-one, many-to-one, and one-to-many joins are all supported. Note that a one to many relationship is most effective if the ExtendedOps property of the slave VAccess control is set to True. In this case, the slave control automatically retrieves all records which match the key value in the master control, and makes the field data available through its RowColumnValue property. The data can be displayed in a VAListBox in record list mode by setting its VAccessName property to the name of the slave control and its VAFieldName property to the fields to be displayed.

  1. Set the Join property of the slave control.
  2. Open the slave control's Properties dialog box.
  3. In the Delphi 3 IDE, view the form containing the ActiveX control, right-click on the control, and select Properties from the pop-up menu, or double-click on the control.

  4. Click the Join button on the File Information tab.
  5. Left-click the down arrow of the To VAccess combo box.
  6. Select the Master file from the drop-down list.
  7. In the Where list box, select the slave file index to link to the master file.
  8. In the Fields list box, double click on the Master file field to which you want to link the slave file.
  9. Click OK to close the Join controls dialog box.

Chapter contents
Publication contents

Prev topic: Advanced Pervasive.SQL Tutorials Using Delphi
Next topic: Lesson 2: Btrieve API Tutorials with Delphi