Interactive Widget Triggers for OCX Controls

The OCX container widget does not have a fixed set of interactive triggers because each OCX has its own set of events. You can implement widget triggers (previously known as extended triggers) to respond to these events.

Although you can map OCX events to Uniface some Uniface triggers (detail, valueChanged, or receiveMessage), using OCX-specific widget triggers is more flexible, and usually preferred.

To implement widget triggers, define triggers for the desired events in the field's Script container. For example, for the Windows Media Player OCX, you could define a trigger for the Click event:

trigger Click
params
 numeric nButton : in
 numeric nShiftState : in
 numeric fX : in
 numeric fY : in
endparams
...
end ; trigger Click

Implement only the triggers you need. If a widget trigger is present in the field's Script container, Uniface attempts to call it when the associated OCX event occurs, even if the trigger contains no code. This can cause performance problems.

For the widget trigger names, you can use the event names as displayed in the Widget Properties form in the Fire ... On properties. For parameters, use Uniface data types that are mapped by the COM connector to Visual Basic Types. See Uniface-COM Data Type Mappings in COM and Uniface Parameter Data Types .

For information on the events and parameters that the OCX supports, consult the technical documentation for the OCX.

The widget triggers can respond to OCX events only if the Use Extended Triggers property is true. Otherwise, events are directed to the corresponding detail, valueChanged, or receiveMessage triggers (if defined in the Fire ... On properties).

Limitations

It is not possible to use OUT or INOUT parameters with a widget trigger in an Uniface OCX container widget because these widget triggers are handled asynchronously. By the time Uniface can handle an OCX event, it has already been completely processed by the OCX control. The process sequence is as follows:

  • When an OCX event takes place, the OCX Container adds the event to an asynchronous message queue.
  • Uniface checks the message queue (or event queue) of the OCX container widget for new events when it is in an idle state.
  • If it finds new events, Uniface reads them from the queue and fires the corresponding widget trigger (if present).

It is not possible to call a property or method of an OCX control from a widget trigger, because it is only valid within the context of a specific event. For example, the Accept method of the Microsoft Winsock control is valid only in the context of the ConnectionRequest event (see Accept Method in the MSDN for more information).

Related Topics