Fire as an OLE Client

Fire applications can include third party OLE automation objects and ActiveX controls. OLE objects can be accessed using the component datatype and associated component functions.

Using third-party automation objects with Fire

To access third party OLE objects from Fire, use the component command to declare an identifier, together with the oleobj() function to create an instance of an OLE object. For example:

# Declare an identifier and assign an ActiveX object to it
component c = oleobj("WMPlayer.ocx")

# Use the object’s automation properties to play an mp3 audio file
c.url = "BirdsOfFire.mp3"

# Do other nice things with it ...

# Release the object
c.kill

In this example, the component identifier c is only a "pointer" to the object, so the command c.kill does not necessarily delete the object, which is external to Fire, but only the pointer to it. In actual fact the kill operation decrements the external object's reference count, thereby releasing it.

In most cases the type library for an object is located using the registry. However, if an object does not install its type library in the registry, (Microsoft's mfccalc is an example), another parameter must be passed to oleobj to explicitly name the path of the object’s type library. For example:

# Declare identifier and assign a calculator object
component c = oleobj("mfccalc.calculator","c:/test/mfccalc.tlb")

# Use object’s automation properties and methods
c.visible = 1
c.button("1")
...
# Release the object
c.kill

As we have seen, component identifiers have objects assigned to them by component functions:
    oleobj() - Creates a new OLE object and returns a component identifier pointing to it
    oleload() - Creates an OLE object from OLE file contents and returns a component identifier pointing to it.

Listing a component will list all its member values and methods. It is typical for a user to know these before the object is instantiated. These are usually available in the form of an API. Trawling the web for the API often helps.

Components can be customized in the same way as other system objects such as windows, channels, databases, etc. For example:

component c = oleobj('WMPlayer.ocx')
c.customize {
    time showdate
    numeric length
}

Embedding visual objects

ActiveX controls can be embedded in Fire using a "component" window. Use the wcomponent command to create a component window. For example:

window mywin = wcomponent oleobj('WMPlayer.ocx')

The ActiveX control itself can then be referenced by the window member mywin.component. Member properties and methods are available (as for Automation Objects), plus, if the object publishes events, you will have callbacks available, which can be programmed in Fire code just like other system objects (e.g. windows and panels).

Components embedded in component windows cannot be released by the .kill member function, but are destroyed automatically when the window is destroyed.

OLE object files

OLE object files are created by invoking the .save() method on an OLE object which supports this facility. For example:

# Create a calendar component
component cal = oleobj('MSCal.Calendar')

# Save it to file for later re-use, then release it
cal.save('calendar.cal')
cal.kill

save() is a method which Fire adds to the OLE object. When called, it invokes the objects’s low-level "save" facility which may or may not be included with the object’s exported methods.

To create a component from a saved OLE object file, declare an identifier and use the oleload() function. For example:

# Declare identifier and load object
component cal2 = oleload('calendar.cal')

# Use object’s automation properties and methods
...
cal2.<property> = "<value>"
...
# Release the object
cal2.kill

Listing available object classes

The objlist command gives a listing of all active objects for which component identifiers have been created in the current Fire session. In addition to the component identifier supplied by the user, all objects are also given an internal handle, in the form obj<n>.

listole.exe, an external utility, is also available. It lists all classes of visually embeddable OLE objects available on the machine. This list would typically be piped into a file in a DOS window. For example:

C:\> listole > obj.dat

The file could then be loaded into a menu to allow user object selection within Fire, for example:

# load object list file
string objs[] = fload( obj.dat )

# Create menu list
wpanel { reg: list objs }

listole has various program options to control which object types and information you are interested in. Consult the Fire Reference Manual for option details.


Prev Chapter    Next Chapter