Condividi tramite


Using the Object Browser

The Object Browser makes it possible for you to browse, filter, and search for components that you might want to consume in your projects.

To invoke the Object Browser

  • Click the Object Browser button on the Standard toolbar.

  • From the Tools menu, select Object Browser.

  • From the Command window, type:

    DO (_OBJECTBROWSER)
    

    Note   After it's loaded, the Object Browser can be accessed programmatically by using the _objectbrowser global variable.

You can view any COM class type library that is registered on your system. The left pane shows a list of all loaded class type libraries. You can expand each to show the classes contained in the library. Members associated with those classes appear in the right pane.

Working with Classes

Classes provide complete member information for a particular COM component or ActiveX control that you might want to consume in your application. Instances of these objects typically are created using one of the following Visual FoxPro functions:

CREATEOBJECT( ), CREATEOBJECTEX( ), NEWOBJECT( ), GETOBJECT( ), ADDOBJECT Method

**Note   **ActiveX controls usually are dropped onto a form class directly and are instantiated with the form.

You can drill down into a class to view member detail by selecting the class from the Classes node in the Classes & Members pane. When selected, the properties, methods, and events for that class are displayed in the Members pane on the right. Protected members are shown with a lock icon.

When you click class members in the Members pane, detail information is shown in the Description pane. The contents of the Description pane give details of data types for member parameters and return values. Underlined items in the Description pane are links you can click to go directly to that item for more information. If available, a functional description of the member also will be displayed in the Description pane.

Working with Properties, Methods and Events

The best way to view properties, methods, and events is to use a particular class in the Members pane. Typically you work with a single class at a time. Sometimes you might wish to view all the properties, methods, and events in a library at one time, not filtered by class. To do this, click the appropriate node in the Classes & Members pane. Depending on the size of the type library, it might take several seconds or minutes to list all the members.

When you click a property, method, or event in the Classes & Members pane, you can view all the classes and interfaces that use it in the Members pane.

Working with Cached Classes

When you expand one of the Properties, Methods, or Events nodes in the Classes & Methods pane, it might take a while to display all the contents. Because of this, the Object Browser caches this information in the Objectbrowser.dbf. This saves time when you want to reload a library later. You can click the Refresh button to have properties, methods or events reloaded next time one of these nodes is expanded.

Working with Constants and Enums

Many type libraries contain constants. A constant is the equivalent of a numeric #DEFINE with which Visual FoxPro developers are familiar. Enums are collections of two or more constants.

Enums are special in that a member can denote a specific enum as the data type for a parameter or return value. For a parameter this means that the value passed for a parameter must be one of the Constants associated with the specified Enum.

You can view the value of a constant by clicking it and viewing the numeric value in the Description pane.

When specifying a constant for a method parameter, you must pass in the actual numeric value. Visual FoxPro does not recognize the actual constant name as a reference as with other languages, such as Visual Basic.

You can create a set of #DEFINE directives that represent all the constants by using drag and drop from the Constants node of a type library to an editor window.

Working with Interfaces

Advanced developers might want to work with specific interfaces in the COM library. Interfaces are particularly useful when you create, in Visual FoxPro, COM servers that use the IMPLEMENTS clause of the DEFINE CLASS command. The IMPLEMENTS clause takes the name of an interface and can be used in association with a variety of COM+ Services, as well as the EVENTHANDLER( ) Function.

You can create a class template by using drag and drop from an Interface node to an editor window. This template will contain any IMPLEMENTS statement and member details of the interface.

Searching within Libraries

You can perform searches for text in a library by clicking on the Find button. The Find button displays a unique Find view above the two main panes. The Simple Find view searches for a specified string within all opened libraries. The search is made within all elements of a library and for strings "contained within". The Advanced Find view supports greater refinement of the search.

Persistence of Object Browser Data

The Object Browser session is persisted between uses. Object Browser information is saved to an objectbrowser.dbf table stored in the same location as the Object Browser. This information includes the following:

  • A Recent History list of all previously opened libraries so you can retrieve one of these libraries quickly in the future.
  • Cached properties, methods, and events for a library so it can be loaded quickly next time accessed.
  • All previously loaded add-ins.
  • User preferences specified in the Options dialog box.
  • COM components and ActiveX controls displayed in the Open dialog box (stored in Foxrefs.dbf).

Working with Add-Ins

  • Object Browser add-ins can perform a variety of useful functions not native to the browser itself. These include adding additional user interface elements, new menu items, and drag-drop capabilities.

    Add-ins typically are created as VCX classes.

Existing Add-Ins Install Wizard

The first step of the Existing Add-Ins wizard specifies the following options:

  • Enter a user-friendly name for the add-in as you wish it to appear in the Add-Ins list of the Options dialog box.
  • Enter a description for the add-in as you want it to appear in the Add-Ins list of the Options dialog box.
  • Select an icon to display in the Add-Ins list of the Options dialog box (optional).

The second step specifies input for class information of the add-in.

  • Select the specific class and class library for the add-in class.

The third step is an optional step to provide support information:

  • You can specify a URL to a web page that provides additional information for using the add-in. You also can provide specific HTML that appears in the add-in description.

The last step makes it possible for you to finish the add-in installation.

  • You can specify some advanced options. These include Properties and User Defined Settings.

See Also

Object Browser | Class Browser | _ObjectBrowser System Variable | DEFINE CLASS | EVENTHANDLER( ) | Viewing Type Library Information