gpt4 book ai didi

delphi - C#处理delphi activeX控件事件

转载 作者:行者123 更新时间:2023-12-01 16:41:32 28 4
gpt4 key购买 nike

我用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");
}

关于delphi - C#处理delphi activeX控件事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12382606/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com