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 Studio …\Samples\Vfp98\Classes directory.
For information about creating custom Automation servers, see Creating Automation Servers in Chapter 16, “Adding OLE.”
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. |
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. The Func kinds are listed below:
FUNC_PUREVIRTUAL
FUNC_VIRTUAL
FUNC_NONVIRTUAL
FUNC_STATIC
FUNC_DISPATCH The Invoke kinds are listed below:
INVOKE_FUNC
INVOKE_PROPERTYGET
INVOKE_PROPERTYPUT
INVOKE_PROPERTYPUTREF The Flags are listed below:
FUNCFLAG_FRESTRICTED = 1
FUNCFLAG_FSOURCE = 0x2
FUNCFLAG_FBINDABLE = 0x4
FUNCFLAG_FDISPLAYBIND = 0x10
FUNCFLAG_FDEFAULTBIND = 0x20
FUNCFLAG_FHIDDEN= 0x40 |
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. |