Directives 

ON EVENT

Event Processing

Formats

1. COM Control via OOP Object:

ON EVENT FROM com_id PROCESS oop_id

2. COM Control via CTL Event:

ON EVENT evtname$ FROM com_id PREINPUT ctl_id

3. Remove CTL Event:

ON EVENT evtname$ FROM com_id REMOVE

Where:

com_id

Numeric CTL value of a Windows COM object.

ctl_id

Numeric CTL signal to generate (pre-input) when a given event occurs.

evtname$

Event name, maximum 255 characters.

oop_id

Numeric identifier of an OOP object. See Object Oriented Programming.

Description

This directive is used to activate support for individual COM events for use in PxPlus applications. This is a feature of the PxPlus Event Handling Interface and Component Object Model (COM), an industry-standard technology used by applications to expose methods, properties and events to development tools, macro languages, and other applications. See Automation in PxPlus.

Format 1

COM Control via OOP Object

ON EVENT FROM com_id PROCESS oop_id

This format is used to register a numeric OOP object identifier (oop_id) to service a given COM control (com_id). The OOP object identifier is stored in a read-only property of the COM object called 'PvxEvents. A comma-separated list of the events that are supported by the COM object is available by querying 'PvxEvents$ via the Apostrophe Operator. Supported events are prefixed with a + (plus sign) while unmanaged events are prefixed with a leading - (minus sign). This format will not work across WindX.

Note:
The list of events reported in 'PvxEvents$ is only available after the ON EVENT FROM com_id PROCESS oop_id has been executed. This behavior is intended to minimize communication with the interop layer when event support is not required.

An invalid com_id generates an Error #65: Window element does not exist or already exists. An invalid oop_id generates an Error #95: Bad Object Identifier. Other errors, such as when a COM object does not support events, will generate an Error #88: Invalid/unknown property name, and if available, place a description of what caused the error in the 'PvxError$ property for the COM object, as well as in MSG(-1).

An oop_id of 0 (zero) deactivates event processing for the current COM object. Dropping a PxPlus OOP object deactivates event processing for all COM objects associated with the OOP object. Issuing a subsequent ON EVENT directive for a COM control discontinues event processing for the first PxPlus OOP object and then activates it for the new OOP object (provided the new oop_id contains a non-zero value).

Formats 2 and 3

COM Control via CTL Event

ON EVENT
evtname$ FROM com_id PREINPUT ctl_id

Generate Event

The PREINPUT option is used to generate a PxPlus CTL event whenever the identified COM event occurs. This format simplifies the event interface by eliminating the need to create an OOP object to manage events. This format will work across WindX. The event process does not have access to any event parameters as it will not be running in-line when the event occurs.

ON EVENT evtname$ FROM com_id REMOVE

Remove Event

The REMOVE option stops the process of generating a CTL signal for the specified event; however, the removal of an assigned event will have no effect on currently queued events.

See Also

Object Oriented Programming
DEF OBJECT Define Windows Object
Apostrophe Operator
Automation in PxPlus