This discussion is archived
1 Reply Latest reply: Oct 29, 2012 7:25 AM by 971211 RSS

ActiveX event handlers

user2238254 Newbie
Currently Being Moderated
Has anyone an example of how to catch the OnFileEvent of the activeX control?
In the object browser the signature is this

public delegate void IID_ISource_onFileEventEventHandler(object sender, AxJVueAXLib.IID_ISource_onFileEventEvent e)
Member of AxJVueAXLib

When the handler catches it, the event id or description doesnt seem to be available

public void OnFileEventEventHandler(object sender, AxJVueAXLib.IID_ISource_onFileEventEvent e)
{
String eventParam;
     //This returns a valid control
     AxJVueAXLib.AxJVueAXControl jvc = (AxJVueAXLib.AxJVueAXControl)sender;

     //Returns System.__ComObject
     eventParam = e.ToString();

     //This does not work
     //int eventID = e.getEventID();
     //eventParam = e.getEventParameter();

     //This does not work
     //int eventID = e.arg0.getEventID();

     //This does not work
     //var arg = e.arg0;
     //int EventID = arg.GetType().GetMethod("getEventID", System.Reflection.BindingFlags.IgnoreCase).Invoke(arg, null);
               
}
  • 1. Re: ActiveX event handlers
    971211 Newbie
    Currently Being Moderated
    Event object full declaration (implementation) is not known at compilation
    time, so late binding on the base of .NET Reflection mechanism should be used
    to access the object methods and data, i.e.

    Type eventType = e.arg0.GetType();
    Int id =(int)eventType.InvokeMember("getEventID",System.Reflection.BindingFlags.InvokeMethod, null, e.arg0, null);

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points