When an ActiveX control or COM object event procedure exits, it can send information back to the control through the event parameters. These parameters are stored in the control and can be set by calling C$SETEVENTDATA before the control's event procedure exits.
CALL "C$SETEVENTDATA" USING EVENT-CONTROL-HANDLE, SRC-ITEM-1, [SRC-ITEM-2, ...] GIVING RESULT-CODE
EVENT-CONTROL-HANDLE USAGE HANDLE | Handle to the control that triggered the event. |
SRC-ITEM-1 Any COBOL data type | The first source data item. |
SRC-ITEM-2, . . . Any COBOL data type (optional) | Any number of source items. |
RESULT-CODE Signed numeric value | Receives the result-code for the operation. This will be 0 to indicate success or a negative value to indicate failure. (Microsoft defines many standard result codes in their documentation. Note that these are usually in hexadecimal notation.) |
C$SETEVENTDATA converts the COBOL-type data in the source items to the corresponding event parameter types.
You are responsible for specifying compatible types. For example, if the source item you specify is alphabetic, and the event parameter you are setting is a signed integer, C$SETEVENTDATA will try to read a number from the alphabetic item and move it to the event parameter. This is not a programming error and neither the compiler nor runtime will warn you about it.
Suppose you have displayed an ActiveX control that triggers an event called AxEventOne which has three parameters. You would use the following COBOL syntax to get the event parameters, add two to each one and set the event parameters to their new values:
WHEN AxEventOne CALL "C$GETEVENTDATA" USING EVENT-CONTROL-HANDLE, PARAM-1, PARAM-2, PARAM-3 ADD 2 TO PARAM-1 ADD 2 TO PARAM-2 ADD 2 TO PARAM-3 CALL "C$SETEVENTDATA" USING EVENT-CONTROL-HANDLE, PARAM-1, PARAM-2, PARAM-3
See ActiveX and COM Events for more examples of how to set event parameters for ActiveX events.