RAD Studio
|
The Type Library interface as represented in the Type Library Editor can seem overwhelmingly complicated at first. This is because it represents information about a great number of elements, each of which has its own characteristics. However, many of these characteristics are common to all elements. For example, every element (including the type library itself) has the following:
An interface describes the methods (and any properties expressed as get and set functions) for an object that must be accessed through a virtual function table (vtable). If an interface is flagged as dual, it will inherit from IDispatch, and your object can provide both early-bound, vtable access, and runtime binding through OLE automation. By default, the type library flags all interfaces you add as dual.
Interfaces can be assigned members: methods and properties. These appear in the object list pane as children of the interface node. Properties for interfaces are represented by the get and set methods used to read and write the property's underlying data. They are represented in the tree view using special icons that indicate their purpose.
Special Icons for 'get' and 'set' Methods
|
A write (set, put) by value property function. |
|
A read (get) | write (set, put) | write by reference property function. |
|
A read (get) property function. |
The Attributes page lets you give the property or method a name and dispatch ID (so that it can be called using IDispatch). For properties, you also assign a type. The function signature is created using the Parameters page, where you can add, remove, and rearrange parameters, set their type and any modifiers, and specify function return types.
Interfaces are more commonly used than dispinterfaces to describe the properties and methods of an object. Dispinterfaces are only accessible through dynamic binding, while interfaces can have static binding through a vtable.
You can add methods and properties to dispinterfaces in the same way you add them to interfaces. However, when you create a property for a dispinterface, you can't specify a function kind or parameter types.
A CoClass describes a unique COM object that implements one or more interfaces. When defining a CoClass, you must specify which implemented interface is the default for the object, and optionally, which dispinterface is the default source for events. Note that you do not add properties or methods to a CoClass in the Type Library editor. Properties and methods are exposed to clients by interfaces, which are associated with the CoClass using the Implements page.
Enumerations, aliases, records, and unions all declare types that can then be used elsewhere in the type library.
Enums consist of a list of constants, each of which must be numeric. Numeric input is usually an integer in decimal or hexadecimal format. The base value is zero by default. You can add constants to your enumeration by selecting the enumeration in the object list pane and clicking the Const button on the toolbar or selecting NewConst command from the object list pane context menu.
mbLeft = 0 [helpstring 'mbLeft']; mbRight = 1 [helpstring 'mbRight']; mbMiddle = 3 [helpstring 'mbMiddle'];
typedef enum TxMouseButton { [helpstring("mbLeft")] mbLeft = 0, [helpstring("mbRight)] mbRight = 1. [helpstring("mbMiddle)] mbMiddle = 2 } TxMouseButton;
An alias creates an alias (type definition) for a type. You can use the alias to define types that you want to use in other type info such as records or unions. Associate the alias with the underlying type definition by setting the Type attribute on the Attributes page.
A record consists of a list of structure members or fields. A union is a record with only a variant part. Like a record, a union consists of a list of structure members or fields. However, unlike the members of records, each member of a union occupies the same physical address, so that only one logical value can be stored.
Add the fields to a record or union by selecting it in the object list pane and clicking the field button in the toolbar or right clicking and choosing field from the object list pane context menu. Each field has a name and a type, which you assign by selecting the field and assigning values using the Attributes page. Records and unions can be defined with an optional tag.
Members can be of any built-in type, or you can specify a type using alias before you define the record.
A module defines a group of functions, typically a set of DLL entry points. You define a module by
For module constants, use the Attributes page to specify a name, type, and value.
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|