JavaScript Editor js editor     Web development 



Main Page

One of the most powerful features of Visual FoxPro is the ability to create classes that can easily be used and reused in various pieces of your applications. Once you've created classes, you can add them to your forms.

To add an object based on a custom class

  • In the Project Manager Window, drag the class onto the container.

You can also add your classes directly from the Form Controls toolbar when you add them to your toolbar.

Adding Class Libraries to the Controls Toolbar

You need to register your class libraries before they can be displayed in the Form Controls toolbar.

To register a class library

  1. From the Tools menu, choose Options.

  2. In the Options dialog box, choose the Controls tab.

  3. Choose Add.

  4. In the Open dialog box, choose a class library to add to the Selected list and choose Open.

  5. Repeat steps 3 and 4 until you've added all the libraries you want to register.

Classes in the class libraries in the Selected list can be used in the Form Designer as easily as Visual FoxPro base classes can be used.

Tip:
If you want the class libraries to be available from the Form Controls toolbar every time you run Visual FoxPro, choose Set as Default in the Options dialog box.

You can also register libraries directly in the Form Designer.

To register a class library in the Form Designer

  1. In the Form Controls toolbar, choose the View Classes button.

  2. From the submenu, choose Add.

  3. In the Open dialog box, choose a class library to add to the Form Controls toolbar and choose Open.

Adding Objects to a Form from a Class Library

Once you've added class libraries in the Classes tab of the Options dialog box or from the View Classes submenu, you can access them in the Form Designer.

To add a custom object from the Controls toolbar

  1. In the Form Controls toolbar, choose the View Classes button.

  2. From the list of registered class libraries, select the library that contains the control you want to add to the form.

    The toolbar is populated with the controls in the library you selected.

  3. Click the control you want and drag it to size in the form.

    Note:
    You can remove a visual class library from the View Classes toolbar menu by selecting the library in the Selected list in the Controls tab of the Options dialog box, and choosing Remove.

When you add objects to a form based on anything other than the Visual FoxPro base classes, a relative path to the class library (.vcx file) is stored in the form's .scx file. If you move either the form or the class library to a different location, Visual FoxPro displays a dialog box when you try to run the form so that you can manually locate the class library.

To determine how many controls are on a form

The Controls property of the form allows you to reference each control on the form. The following program prints the Name property of all the controls on the currently active form.

В Copy Code
ACTIVATE SCREEN  && to print to the main Visual FoxPro window
FOR nCnt = 1 TO Application.ActiveForm.ControlCount
   ? Application.ActiveForm.Controls[nCnt].Name
ENDFOR

See Also



JavaScript Editor js editor     Web development