2.2.4.32.15 OriginObject::GetEventHandler

Description

Get the event handler class name if present

Syntax

string GetEventHandler( BOOL bCheckValid = false, BOOL bDeafult = FALSE )

Parameters

bCheckValid
[input] TRUE will check to see if class name represents a compiled Origin C class that is registered with the OC_REGISTERED keyword
bDeafult
[input] TRUE will return an internal deafult name, of no name has been set using SetEventHandler

Return

If bCheckValid = [input] false, simply return the class name or empty string if no event handler was installed.

If bCheckValid = [input] true, then only return the class name if it is valid.

Examples

EX1

#include <Origin.h>
#include <GetNBox.h>
#include <control.h>
#include <..\originlab\wkbook.h>
#include <..\originlab\OriginEvents.h>
#include <..\originlab\OneColHeaderHandler.h>

// OneColHeaderHandler is a user define class here, before running, must replace with real class otherwise cannot pass compiling
void OriginObject_GetEventHandler_Ex1()
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
        return;
    Column cc(wks, 1);
    if(!cc)
        return;
    
    string strClassName = cc.GetEventHandler(true);
    if(!strClassName.IsEmpty())
    {
        OneColHeaderHandler& co = (OneColHeaderHandler&)Project.FindClass(strClassName);
        if(co)
        {
            out_str("Found handler for column, invoking context menu");
            
            int x = 0;
            int y = 0;
            //co.DoContextMenu(cc, x, y, GetWindow()); // removed
        }
    }
}

Remark

See Also

OriginObject::SetEventHandler

Project::FindClass

Header to Include

origin.h