JavaScript Editor js editor     Web development 

Main Page

Specifies to inherit the interface from another COM component.

[IMPLEMENTS cInterfaceName [EXCLUDE] IN TypeLib | TypeLibGUID | ProgID ]


[IMPLEMENTS cInterfaceName [EXCLUDE] IN TypeLib | TypeLibGUID | ProgID]

Specifies that the class definition inherit the interface or class definition of another COM component. You can include multiple IMPLEMENTS statements.
Certain technologies, such as Microsoft COM+ Events, require the COM component to implement the interface of the event class being bound to.

The EXCLUDE keyword excludes the implemented interface from type library. The IN clause specifies the location of the interface for the COM component. You can specify the type library of the COM object using TypeLib, the GUID of the type library using TypeLibGUID, or the ProgID of the program that initializes the COM object. When you use TypeLibGUID, include the major and minor version designation as shown in the following example:
В Copy Code
IMPLEMENTS IDict1 IN {04BCEF93-7A77-11D0-9AED-CE3E5F000000}#1.0
The TypeLib parameter is the least recommended way to specify the type library because this requires a file name whose path might differ from computer to computer. If you are distributing your .dll, consider using TypeLibGUID or ProgID instead.

When you use the IMPLEMENTS clause, you must include all methods of that interface in the class definition. You must use the interface name exactly as it appears in the type library. However, for interface names preceded by an underscore (_), such as in the ADODB RecordSet class, the underscore is optional. Preface the method name with the interface name, for example, Publisher_ShowPrice. This convention helps avoid conflict between two interfaces that contain methods that have the same name when you include multiple IMPLEMENTS statements in a class definition. As properties are essentially stored as two methods inside a type library, for example, Put and Get, the class definition must include both methods.

To save time, you can use the Visual FoxPro Object Browser to drag and drop interface definitions to your code. Along with the IMPLEMENTS statement, all the implemented methods with their proper parameter signatures are written automatically for you. For more information, see Object Browser Window.


The following code shows a summary of the main clauses of the DEFINE CLASS command:

В Copy Code
   [PEMName_COMATTRIB Clause]
   [ADD OBJECT Clause]
   [IMPLEMENTS Clause]

For more information and full syntax, see DEFINE CLASS Command. For more information about a particular clause of the DEFINE CLASS command, see the following topics:


The following example creates a class named MyPublisherClass as a Custom class, uses the OLEPUBLIC keyword to specify that Automation clients can access the class when included in an Automation server, uses the IMPLEMENTS clause to inherit the class definition inherit from the Publisher class definition in the type library, MyBookStore.dll, and includes the method ShowPrice from the Publisher interface.

В Copy Code
   IMPLEMENTS Publisher IN "MyBookStore.dll"
   PROCEDURE Publisher_ShowPrice(cGetID AS Long) AS Short

See Also

JavaScript Editor js editor     Web development