Bagikan melalui


Creating, Copying, and Removing Class Library Files

Every visually designed class is stored in a class library with a .vcx file extension.

Creating a Class Library

You can create a class library in one of three ways.

To create a class library

  • When you create a class, specify a new class library file in the Store In box of the New Class dialog box.

    -or-

  • Use the CREATE CLASS command, specifying the name of the new class library.

    For example, the following statement creates a new class named myclass and a new class library named new_lib:

    CREATE CLASS myclass OF new_lib AS CUSTOM
    

    -or-

  • Use the CREATE CLASSLIB command.

    For example, type the following command in the Command window to create a class library named new_lib:

    CREATE CLASSLIB new_lib
    

Copying and Removing Class Library Classes

Once you add a class library to a project, you can easily copy classes from one library to another or simply remove classes from libraries.

To copy a class from one library to another

  1. Make sure both libraries are in a project (not necessarily the same project).

  2. In the Project Manager, select the Classes tab.

  3. Click the plus sign (+) to the left of the class library that the class is now in.

  4. Drag the class from the original library and drop it in the new library.

    Tip   For convenience and speed, you might want to keep a class and all the subclasses based on it in one class library. If you have a class that contains elements from many different class libraries, these libraries must all be open, so it will take a little longer to initially load your class at run time and at design time.

To remove a class from a library

  • Select the class in the Project Manager and choose Remove.

    -or-

  • Use the REMOVE CLASS command.

To change the name of a class in a class library, use the RENAME CLASS command. Remember, however, that when you change the name of a class, forms that contain the class and subclasses in other .vcx files continue to reference the old name and will no longer function correctly.

Visual FoxPro includes a Class Browser to facilitate using and managing classes and class libraries. For more information, see Class Browser.

See Also

Object-Oriented Programming | Classes and Objects: The Building Blocks of Applications | Classes in Visual FoxPro | Preparation for Class Creation | Creating Classes | Modifying a Class Definition | Subclassing a Class Definition | Operating the Class Designer | Class Member Protection and Hiding | Specifying Design-Time Appearance for a Class | Adding Classes to Forms | Default Property Setting Override | Container Hierarchy Object Referencing | Setting Properties | Calling Methods | Event Response