在 ax 2009 中处理 activeX 事件
我有一个包含多个事件的 activeX 组件。在 .net 中调试这个 dll 证明,事件被引发并且可以断点(这是一个词吗?;)) 通过 regasm /codebase 注册这个 dll 是可行的,我可以在表单上的 axe 中添加这个 activeX。这些事件列在 ax 的 activeX-explorer 中。 但似乎我没有机会处理 axe 中引发的事件。
使用另一个activeX(例如Microsoft日期和时间选择器控件)效果很好。
我很感激任何提示或技巧!
这是我谈论的几行代码。
namespace <someNamespace>
{
[ProgId("<someProgID>")]
[ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof( <myInterface> ))]
[Guid("<someGUID>")]
[ComVisible(true)]
public class <ClassName>
{
[instantiate some COM-Object, named dummy]
public
<ClassName>( ...)
{
init();
}
public delegate void <someDelegate>( int a, int b );
public event someDelegate myDelegate;
[ComVisible(true)]
public void OnEvent( int a, int b )
{
if ( myDelegate != null )
{
Console.WriteLine( "yippie" );
}
}
[ComVisible(true)]
public void run( ... )
{
this.myDelegate += new someDelegate( this.OnEvent );
}
private void
onEvent( int a, int b )
{
myDelegate( a, b );
}
#endregion
}
}
[Guid("<someOtherGUID>")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface <myInterface>
{
[DispId(1)]
void myDelegate( int a, int b );
}
}
这些是与事件相关的基本功能(希望我没有忘记其中之一)。 activeX 本身是 com 对象的包装器,据我所知,它本身无法集成到 ax 中。 “onEvent”是由 com 对象的事件调用的函数,并触发“myDelegate”。所有这一切都工作正常,在 Visual Studio 中进行测试 - 该事件可以在表单上处理,调用 activeX 部分。 最后一步是在 axe 中处理此事件。 正如我已经写的,事件本身在 activeX-explorer 中正确列出,但我没有找到在 x++ 中对此事件做出反应的方法。
i've got an activeX component with several events. debugging this dll in .net proofs, that the events are raised and can be breakpointed ( is this a word? ;) )
registering this dll via regasm /codebase works and i can add this activeX in ax on a form. the events are listed in the activeX-explorer in ax.
but it seems, that i've got no chance to handle the events raised in ax.
using another activeX ( eg Microsoft Date and Time Picker Control ) works fine.
i appreciate any hints or tips!
here are some lines of the code, which i talk about.
namespace <someNamespace>
{
[ProgId("<someProgID>")]
[ClassInterface(ClassInterfaceType.AutoDual), ComSourceInterfaces(typeof( <myInterface> ))]
[Guid("<someGUID>")]
[ComVisible(true)]
public class <ClassName>
{
[instantiate some COM-Object, named dummy]
public
<ClassName>( ...)
{
init();
}
public delegate void <someDelegate>( int a, int b );
public event someDelegate myDelegate;
[ComVisible(true)]
public void OnEvent( int a, int b )
{
if ( myDelegate != null )
{
Console.WriteLine( "yippie" );
}
}
[ComVisible(true)]
public void run( ... )
{
this.myDelegate += new someDelegate( this.OnEvent );
}
private void
onEvent( int a, int b )
{
myDelegate( a, b );
}
#endregion
}
}
[Guid("<someOtherGUID>")]
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface <myInterface>
{
[DispId(1)]
void myDelegate( int a, int b );
}
}
these are the basic functions ( hope i didn't forget one of them ) relating to the event-thing.
the activeX itself is a wrapper for a com-object, which itself can't be integrated in ax, afaik.
"onEvent" is a function called by an event of the com-object and fires "myDelegate". all this is working fine, testing in visual studio - the event can be handled on a form, calling the activeX-part.
the last step would be to handle this event in ax.
as i already wrote, the event itself is listed correctly in the activeX-explorer, but i didn't find a way to react on this event in x++.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您的 ActiveX 也是用 .NET 编写的。
在 .NET 中编写 ActiveX 控件时有一些有趣的事情。其中之一是您需要一个单独的接口来处理 ActiveX 控件公开的事件。当满足任何条件时,您还需要手动引发控件中的事件。
我回答了关于 从 Javascript 处理 ActiveX 事件(用 C# 编写)。也许可以查看我在那里发布的 ActiveX 结构。
I assume your ActiveX is also written in .NET.
There are a couple of funnies when writing ActiveX controls in .NET. One of them is you need a separate interface for the events exposed by the ActiveX control. You will also need to manually raise the event in your control, when whatever conditions are met.
I answered a similar question about handling ActiveX events (written in C#) from Javascript. Maybe check out the ActiveX structure I posted there.