Freigeben über


Managing Classes with the Class Browser

You can create subclasses, copy classes from one class library to another, remove classes and library files, rename a class, or redefine the relationship of a class.

**Caution   **If you remove, rename, or redefine a class, the forms that are not currently displayed in a Class Browser window and that rely on the class might not run properly.

To add a subclass

  1. In the Class Browser, open a class library.
  2. Select the class you want to subclass, and then choose the New Class button.
  3. In the New Class dialog box, enter the name for the new subclass.
  4. In the Class Designer, define and save the subclass.
  5. The Class Browser displays the new subclass.

To copy a class from one class library to another

  1. In the Class Browser, open the source class library.
  2. From the Tools menu, open a second instance of the Class Browser and select the destination library file.
  3. In the source class library, select the class you want to copy, and then while pressing the Ctrl key, drag the Class Move icon picture located above the class list to the class icon picture in the destination library. The cursor appears with a plus sign when you are over the destination class icon.

To copy multiple classes from one class library file to another

  1. Open the source class library in the Class Browser.
  2. If you want to filter the class list, type a filter in the Type box to limit the classes you want to copy from the file.
  3. From the Tools menu, open a second instance of the Class Browser and select the destination library file.
  4. In the source class library, select the class library file you want to copy, and then while pressing the Ctrl key, drag the class icon picture located above the class list to the class icon picture in the destination library. The cursor appears with a plus sign when you are over the destination class icon picture.

To remove a class, class library, or form

  1. Open the class library or form in the Class Browser.
  2. In the Class list, select the class, class library, or form you want to remove or delete, and then choose the Remove button. For classes, the record in the library is marked for deletion the next time you choose Clean Up Library. For class libraries and forms, the file is deleted from the disk.

To rename a class in a class library

  1. Open the class library in the Class Browser.

  2. In the Class list, select the class you want to rename, and then choose the Rename button.

    **Caution   **If you rename a class that has associated subclasses that are not currently contained in an open Class Browser window, the subclasses will not be able to reference properties that are inherited from the renamed class.

  3. In the Rename Class dialog box, type the new name, and then choose Rename.

  4. The Class Browser displays the new name and the new name is automatically referenced in all the affected forms and classes currently displayed in Class Browser windows.

To change the parent class of a class

  1. Open the class library in the Class Browser.
  2. In the Class list, select the class you want to redefine, and then choose the Redefine button.
  3. In the As box of the Redefine dialog box, select the name of the new parent class using the drop down list. You can redefine some base classes

You can also use drag and drop functionality to manage classes in the Class Browser. Managing files in the Class Browser is the recommended way to update project files as well as class libraries and forms. Changes made in the Class Browser are cascaded through every open .vcx and .scx file. Common Drag and drop moves an object from one location to another. Modifier keys with drag and drop provide the following behaviors:

Drag and drop with… To…
CTRL Copy a class between Class Browser windows
Right-click Instantiates object in a container:

to Command window – generates instantiation code
to desktop – instantiates in Class Browser
to form – instantiates object and can open a builder.

SHIFT Creates instance of the class but doesn't display it. Drag to Command window functions as a simple drag and drop.

See Also

Browsing Classes with the Class Browser | Class Browser Buttons | Class Browser Methods | Class Browser Properties | Class Browser Window | Customizing the Class Browser | Filtering the Class Browser Class List | Modifying Class Icons and Descriptions | Running the Class Browser | Viewing Class Hierarchies | Viewing Type Library Information