用C#处理delphi的activeX控件事件



我用Delphi实现了一个activeX控件。现在我想为它添加一个事件。我使用类型库编辑器添加这样的事件。

procedure OnActionMethod(ActionType: Integer; x1: Integer; 
  y1: Integer; x2: Integer; y2: Integer; param1: Double); dispid 213;
TezDICOMXOnActionMethod = procedure(ASender: TObject; 
  ActionType: Integer; x1: Integer; y1: Integer; x2: Integer; y2: Integer; 
  param1: Double) of object;

一切都很顺利。

现在我构建了一个C#应用程序,使用该ActiveX控件并尝试实现一个事件处理程序。

private AxezDICOMax.AxezDICOMX the_ezdicom; // this is the activeX object
public void onActionHandler(object sender,long actiontype, 
    long x1, long y1, long  x2,long  y2, double param1)
{
  MessageBox.Show("abcabc" + x1.ToString() + x2.ToString());
}
private void MainForm_Load(object sender, System.EventArgs e)
{           
  the_ezdicom.OnActionMethod += new 
    AxezDICOMax.IezDICOMXEvents_OnActionMethodEventHandler(this.onActionHandler);
}

但是编译器抱怨这个错误

Error 1  No overload for 'onActionHandler' matches delegate 
  'AxezDICOMax.IezDICOMXEvents_OnActionMethodEventHandler'
  OnActionMethodEventHandler

我做错了什么?我在Delphi源代码中找不到OnActionMethodEventHandler()

我使用Visual studio的自动完成功能来知道真正的方法应该是

void  onActionHandler(object sender, AxezDICOMax.IezDICOMXEvents_OnActionMethodEvent e)
{
    MessageBox.Show("abc");
}

最新更新