Cicode Programming Reference > Cicode Function Categories > ActiveX Objects Introduction > ObjectAssociateEvents


Allows you to change the ActiveX object's event class. If you have inserted an object on a graphics page using Graphics Builder, it allows you to change the event class to something other than the default of PageName_ObjectName


ObjectAssociateEvents(sEventClass, hSource)


The class of the object. You can use the object's human readable name, its program ID, or its GUID. If the class does not exist, the function will report an error.


The source object firing the events which are to be handled by the event handler.

For example:

Return Value

0 (zero) if successful, otherwise an error is returned.

Related Functions

DspAnCreateControlObject, CreateControlObject


Inserting ActiveX objects using Cicode

If you have created an ActiveX object using Cicode (for example, by calling the function CreateControlObject()), the parameter 'sEventClass' would have required you to define an event class for the object to enable event handling. If you want to change the class you used, you can call ObjectAssociateEvents().

Inserting ActiveX objects via Graphics Builder

If you have inserted an ActiveX object in Graphics Builder, runtime will automatically create an event class for the object in the form PageName_ObjectName. If this is the case, you may want to change the object's event class.

Using the example of an ActiveX sludge tank controller, the default event class for the object could be "PageName_AN35". This means any events handlers for the object would take the form "PageName_AN35_Click" (presuming this example relates to a click event). You may want to define this more clearly, in which case you can call the following:

// This function redefines the event class for the ActiveX sludge
tank controller at AN35 to "SludgeTank". //
ObjectAssociateEvents ("SludgeTank", ObjectByName("AN35"));

With the event class for the object now defined as "SludgeTank", the event handlers can take the form "SludgeTank_Click".

This would be useful if you define event handlers in relation to an object that will eventually be copied to other graphics pages, as it will reduce the need to redefine the event handlers to identify the default event class associated with each new placement of the object.

See Also

ActiveX Functions