在 ax 2009 中处理 activeX 事件

发布于 2024-08-14 12:50:14 字数 1760 浏览 7 评论 0原文

我有一个包含多个事件的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无所谓啦 2024-08-21 12:50:14

我假设您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文