2.2.4.32.41 OriginObject::SetEventHandler

Description

Install an Event Handler to the object.

Syntax

BOOL SetEventHandler( LPCSTR lpcszClassName )

Parameters

lpcszClassName
[input] name of the Origin C class, it must be registered and compiled before it can be used

Return

Examples

EX1

// The following code installs an Event Handler class called InsertRelatedCols into every odd column in the worksheet
// OneColHeaderHandler is a class implemented in OriginEvents.c. It is derived from a base class called OneColHeaderHandler
// You can create your own class and install it into columns that require customized event handling. Make sure your class is 
// based on OneColHeaderHandler for column events handling.
void OriginObject_SetEventHandler_Ex1()
{
    Worksheet wks = Project.ActiveLayer();
    int ii = 1;
    foreach(Column cc in wks.Columns)
    {
        string str = "InsertRelatedCols";
        if(ii%2)
            cc.SetEventHandler(str);
        ii++;
    }
}

Remark

Install an Event Handler to the object. Event handlers are Origin C classes that are derived from ObjectCmdTarget class.

In principle, all class objects that are derived from OriginObejct are capable of handling Event Handlers, but not all of them have internal events properly connected to Origin C. Currently, only the followings are supported, more will be added in the future.

GraphObject Worksheet WorksheetPage Column

See Also

OriginObject::GetEventHandler

Header to Include

origin.h