Using Director > Using Interactive Media Types > Using ActiveX controls |  |

Using ActiveX controls

In Director for Windows, you can embed ActiveX controls that let you take advantage of the technology and adapt ActiveX controls (formerly known as OLE/OCX controls) to make them function as sprites in Director. You can use ActiveX controls to manage application resources for the hosted ActiveX control—for instance, to manage properties, events, and windows and filing properties. You can also manage resources used by the ActiveX control within the Director movie.

The range of uses for ActiveX in Director is as limitless as the variety of ActiveX controls available. Using the Microsoft Web Browser control (installed with Microsoft Internet Explorer 3.0 or higher), you can browse the Internet from within a multimedia production; using the FarPoint Spreadsheet control, you can create and access spreadsheets; using the InterVista VRML control, you can explore virtual worlds; using MicroHelp's extensive library of Windows widget controls, you can build and simulate complete Windows applications.

Note: Not all ActiveX controls expose their methods and properties in all hosts. Test the controls you want to use to see how they work in Director.

Inserting an ActiveX control

You can place ActiveX controls in a Director movie and have them function as sprites. Note that this procedure is designed only for Director for Windows.

To insert an ActiveX control on the Stage:

1 | Make sure that the ActiveX control you want to use in Director is installed on your system.
| Most controls have their own installation utilities provided by the manufacturer of the control.
2 | Choose Insert > Control > ActiveX.
3 | In the dialog box that appears, select the desired ActiveX control and then click OK. The ActiveX Control Properties dialog box appears.
| (If the desired ActiveX control does not appear in the list, it may not have been installed properly by the system. You can attempt to verify this by viewing the list of ActiveX controls in another application such as Visual Basic.)
| The ActiveX Control Properties dialog box lets you edit each ActiveX control and view information regarding each method the control supports and each event the control can generate.
4 | Set the values for each property in the ActiveX control and then click OK. The ActiveX control now appears in the cast.
5 | Drag the ActiveX control from the Cast to the Stage.
| Once the ActiveX control appears on the Stage, it can be repositioned and resized just like any other sprite Xtra. When you pause the movie, the ActiveX control stays in authoring mode and does not react to mouse or keyboard events. When you play the movie, the control responds to user input.

Setting ActiveX control properties

An ActiveX control describes its information using properties—named characteristics or values such as color, text, font, and so on. Properties can include not only visual aspects but also behavioral ones. For example, a button might have a property that indicates whether the button is momentary or push-on/push-off. An ActiveX control's properties define its state—some or all of which properties may persist. Although the control can change its own properties, it is also possible that the container holding the control might change a property, in response to which the control would change its state, user interface, and so on.

When an ActiveX control is inserted into a Director movie, the properties that the control exposes can be viewed and edited by clicking the Properties tab of the Control Properties dialog box for the ActiveX Xtra. Each property exported by the ActiveX control is identified along with the current value of the property. The user edits a property value by simply clicking over the existing value with the mouse. For most properties, such as numeric or string values, the new value can be directly entered into the list using the keyboard.

In Director, all properties that an ActiveX control exports are properties of the corresponding sprite. This is the generic Lingo syntax for setting an ActiveX control property:

    set the PropertyName of sprite X to Value

The generic Lingo syntax for getting an ActiveX control property is as follows:

    put the PropertyName of sprite X into Value

As an example, if the Microsoft Access Calendar control is inserted into a Director movie as the second sprite on the score, the following Lingo code sets the Year property of the Calendar control to a specific year:

    set the Year of sprite 2 to 1995

To get the Year property from the same Calendar control and place it into a Lingo variable named CalendarYear, you can use this Lingo code:

    put the Year of sprite 2 into CalendarYear

Some ActiveX control properties are read-only, and trying to set a property for such a control will cause an error in Director.

Using ActiveX control methods

An ActiveX control describes its functionality using methods. Methods are simply functions implemented in the control that Director can call to perform some action. For example, an edit or other text-oriented control supports methods that let Director retrieve or modify the current text, perhaps performing such operations as copy and paste.

When you insert an ActiveX control in a Director movie, you can view the methods exposed by the control by clicking the Methods tab of the Control Properties dialog box for the ActiveX control. The dialog box displays each method supported by the ActiveX control and a description of the parameters for each method.

In Director, all methods that an ActiveX control supports are functions for the corresponding sprite. The generic Lingo syntax for calling an ActiveX control method is as follows:

    put MethodName (sprite N, param1, param2, ... ) into RetValue

As an example, if the Microsoft Access Calendar control is inserted into a Director movie as the second sprite on the Score, the following Lingo code would increment the year displayed within the Calendar control:

    NextYear (sprite 2)

For the same Calendar control, the following Lingo code would decrement the year displayed by the Calendar control:

    PrevYear (sprite 2)

Parameters passed to the ActiveX control are automatically converted from their Director data types to equivalent ActiveX data types. Likewise, the return value is automatically converted from an ActiveX data type to an equivalent Director data type.

Using ActiveX control events

Each ActiveX control typically generates a variety of events. For example, a button ActiveX control may generate a `click` event when the button is pressed, and a calendar ActiveX control may generate a `dateChanged` event when the date within the calendar is changed. Director converts any event generated by the ActiveX control to a sprite event that it can handle. A list of the control's events appears in the Events tab of the ActiveX Control Properties window.

To respond to an event generated by the ActiveX control, you must write an event handler to capture the event. You can place these event handlers in movie scripts, sprite behaviors, scripts assigned to cast members, or frame behaviors. However, you normally place the handler in the behavior attached to the sprite for the ActiveX control.

As an example, if the Microsoft Access Calendar control is inserted into a Director movie as a sprite on the score, the following Lingo code would capture the `click` event from the Calendar control:

    on click
    	-- Do something interesting here.
    	beep 2
    end

A sprite behavior is a good location for this handler.