Share via


Visual FoxPro Foxtlib Control

Visual FoxPro includes the Foxtlib ActiveX control (Foxtlib.ocx, located in the Windows System folder), which you can add to and distribute with your applications. ActiveX controls are added to a form in an application with the Visual FoxPro OLE container control.

The Foxtlib ActiveX control lets you access type library information from within a Visual FoxPro application. Type libraries are used to store class information (properties, methods, and so on) for Automation servers that you can create in Visual FoxPro and Visual Basic. Type libraries are typically viewed by Object Browsers and referenced in other application such as Visual Basic or Visual C++ to allow direct object references to be made and compiled into code.

When you create an Automation server in the Project Manager or with the BUILD DLL or BUILD EXE commands, a type library (.tlb) file is generated. The type library file contains information about each class, such as the number of parameters it requires and their data types, the control's return types, references to help topics or help files that provide more information about the class, and so on.

Typelib.vcx, a visual class library example that utilizes the Foxtlib ActiveX control, is installed in the Visual FoxPro \Samples\Classes directory.

The following table lists the methods available for the Foxtlib ActiveX control. For additional information about these methods, consult the Microsoft Developers Network.

Method Description
TLLoadTypeLib(cTypeLibName) Loads the type library file specified with cTypeLibName. CTypeLibName must be a fully qualified path and file name. A positive integer handle to the type library file is returned; a value of 0 or less is returned if the type library file cannot be loaded.
TLRelease(nTypeLibHandle) Releases the loaded type library whose handle is specified with nTypeLibHandle.
TLGetTypeInfoCount(nTypeLibHandle) Returns the number of type infos in the type library whose handle is specified with nTypeLibHandle.
TLGetDocumentation(nTypeLibHandle,
aDocArray, nMemberID, nType)
Creates a three-element array containing information about the type library whose handle is specified with nTypeLibHandle. ADocArray specifies the name of the array that is created.

The 3-element array includes details on the name, document string, and help file for the member specified with nMemberID. nType specifies the member type: 0 -TypeInfo, or 1 - Member.

TLGetTypeInfo(nTypeLibHandle,
nTypeInfoNum)
Returns an integer index for use with the TLGetTypeAttr( ), TlGetNames( ), and TLGetFuncDesc( ) methods. TLGetTypeInfo( ) returns 0 if the method fails.

Use TLGetTypeInfo( ) to enumerate (beginning at 0) through all type infos in the type library whose handle is specified with nTypeLibHandle. NTypeInfoNum specifies the type info for which the index is returned.

TLGetTypeAttr(nTypeInfoIndex,
aTypeArray)
Creates a one-dimensional array containing information about a type info. nTypeInfoIndex specifies the index number for the type info. aTypeArray specifies the name of the array that is created.

The information contained in each element of the array is listed below:

1    GUID.
2    LocaleID.
3    Reserved.
4    Constructor ID.
5    Destructor ID.
6    Reserved.
7    Instance Size.
8    Type Kind.
9    Number of functions.
10    Number of variables/members.
11    Number of implemented interfaces.
12    Size of type's virtual function table.
13    Byte alignment of an instance of this type.
14    Flags.
15    Major version number.
16    Minor version number.

TIGetFuncDesc(nTypeInfoIndex,
aTypeArray, nFunctionIndex, aParmsArray)
Returns information for a function specified in a type info.

The type info is specified with nTypeInfoIndex.

nFunctionIndex specifies the index of the function for which information is returned. nFunctionIndex can be between 0 and the function count returned by aTypeArray[9] of the TLGetTypeAttr( ) method.

TIGetFuncDesc( ) creates two arrays whose names are specified with aTypeArray and aParmsArray.

The aTypeArray contains information about the function. The aParmsArray array contains a listing of the parameters used by the function.

The information contained in each element of aTypeArray is listed below:

1    ID.
2    Func kind - Specifies if the function is virtual, static, or dispatch-only.
3    Invoke kind - Invocation kind; indicates if this is a property function and if so, what type.
4    Callconv - Specifies the function's calling convention.
5    Total number of parameters.
6    Number of optional parameters.
7    For FUNC_VIRTUAL, specifies the offset in the virtual function table.
8    Count of permitted Scodes.
9    Flags.

The Func kinds are listed below:

FUNC_PUREVIRTUAL
The function is accessed through the virtual function table and takes an implicit "this" pointer.

FUNC_VIRTUAL
The function is accessed the same as PUREVIRTUAL, except the function has an implementation.

FUNC_NONVIRTUAL
The function is accessed by static address and takes an implicit "this" pointer.

FUNC_STATIC
The function is accessed by static address and does not take an implicit "this" pointer.

FUNC_DISPATCH
The function can be accessed only through IDispatch.

The Invoke kinds are listed below:

INVOKE_FUNC
The member is called using normal function invocation syntax.

INVOKE_PROPERTYGET
The function is invoked using normal property access syntax.

INVOKE_PROPERTYPUT
The function is invoked using property value assignment syntax. A typical programming language might represent changing a property in the same way as assignment; for example, Object.Property := Value.

INVOKE_PROPERTYPUTREF
The function is invoked using property reference assignment syntax.

The Flags are listed below:

FUNCFLAG_FRESTRICTED = 1
The function should not be accessible from macro languages. This flag is intended for system-level functions or functions that type browsers should not display.

FUNCFLAG_FSOURCE = 0x2
The function returns an object that is a source of events.

FUNCFLAG_FBINDABLE = 0x4
The function supports data binding.

FUNCFLAG_FDISPLAYBIND = 0x10
The function is displayed to the user as bindable, that is, FUNC_FBINDABLE must also be set.

FUNCFLAG_FDEFAULTBIND = 0x20
The function that best represents the object. Only one function in a type info may have this attribute.

FUNCFLAG_FHIDDEN= 0x40
The function should not be displayed to the user, though it exists and is bindable.

TIGetNames(nTypeInfoIndex,
aNameArray, aTypeArray[1])
Returns the number of functions for a type info and creates an array

The type info is specified with nTypeInfoIndex, and aNameArray specifies the name of the array that is created.

aTypeArray[1] specifies the ID returned from the aTypeArray array in the TIGetFuncDesc( ) method.

See Also

ActiveX Controls Overview | OLE Container Control | Creating Automation Servers