ActiveXAutomation Class

The ActiveXAutomation class is the abstract class that provides a superclass for all ActiveX automation library and object classes imported into JADE. You can create only transient instances of ActiveXAutomation subclasses.

When you import an ActiveX automation type library into JADE, an abstract class of the specified type library name is created as a subclass of the ActiveXAutomation class. This abstract class becomes the superclass for all classes that are subsequently generated corresponding to objects in the imported automation type library. The following example shows the hierarchy in the RootSchema of the OLE Automation type library that was preloaded into JADE.

Automation is the ability of a client to drive or direct a Component Object Model (COM) object by calling methods or setting properties using one or more interfaces of that object. For example, Microsoft Excel and Word are automation controllers; that is, they are objects that can be controlled by automation. Automation is simply the execution of a set of commands that set and get properties and call methods using the properties and methods of the generated ActiveX interface classes.

To handle events in ActiveX automation, you must register your interest in a specific event, which involves specifying the event method of the interface and the method that you want executed when the event is triggered. (For details, see the beginNotifyAutomationEvent method.)

To use an automation object from within JADE, you simply create an instance of the JADE class (that is, a subclass of the ActiveXAutomation class) that corresponds to the automation object and call the createAutomationObject method before the first property access or method call required to support ActiveX. This creates the automation object in the server and a transient instance of the default interface (which is a subclass of the IDispatch class).

When an automation object (that is, an instance of an ActiveXAutomation subclass) is deleted, JADE notifies COM that it has finished with it so that COM can do whatever it wants with the DLL of the object, and so forth. As this occurs in the destructor of the ActiveXAutomation subclass object, if you do not explicitly delete the instance, the destructor is not called and memory for the transient instance is not removed until the application closes down. You should therefore always delete your transient objects when they are no longer needed.

A reference is established between the automation class and its default interface. You can then call JADE automation class methods as you can for any other JADE class. These method calls are passed by the default interface to the actual automation object.

If the automation object returns a reference to another interface in response to a method call or the getting of a property, JADE creates an instance of the corresponding JADE interface class and returns a reference to that instance instead. (A mapping is maintained between JADE interface instances and automation server interface instances.)

In JADE thin client mode, ActiveX automation objects run on the presentation client by default.

Although you cannot specify the serverExecution method option for ActiveX automation methods, you can use them in a non-GUI application started by using the app.startApplication method that is part of a server execution method.

As most type libraries include the OLE Automation library, this STDOLE2.TLB library has been preloaded into the RootSchema so that it is provided with your installed JADE development environment. The OLE_Automation class provided as a subclass of the ActiveXAutomation class contains the JadeAutoFont and JadeAutoPicture standard object subclasses. You can create and then manipulate instances of the OLE automation object in the same way that you can any other imported ActiveX object.

The following example shows the creation of a font object and the setting of font properties using the supplied JadeAutoFont class.

createAFont();
vars
    autoFont : JadeAutoFont;
begin
    create autoFont;
    write autoFont.bold;         // Outputs false
    autoFont.bold := true;
    write autoFont.bold;         // Outputs true
    delete autoFont;
end;

For details about the methods and properties defined in the preloaded OLE_Automation object class and the JadeAutoFont and JadeAutoPicture subclasses, refer to your COM documentation. For details about importing ActiveX control and automation type libraries into JADE, see Chapter 4 of the JADE External Interface Developer’s Reference.

For details about the properties and methods defined in the ActiveXAutomation class and using an imported ActiveX automation type library within JADE, see "ActiveXAutomation Properties", "ActiveXAutomation Methods", and "Example of Using an Imported ActiveX Automation Object", in the following subsections.

Object

Preloaded OLE_Automation class, automation objects imported by developers