【问题标题】:Hosting ActiveX control in WPF在 WPF 中托管 ActiveX 控件
【发布时间】:2010-06-18 20:47:05
【问题描述】:

我有一个 ActiveX 控件(用 Delphi 编写),我想将它托管在 WPF 应用程序中。当我尝试在设计时将其加载到工具箱中以将其添加到 XAML 时,它未显示在可用控件列表中。有谁知道这个列表的过滤器以及为什么我看不到添加它的控件?

编辑

这就是我要去的地方 - host.Child = (ax); 语句出错(无法将类型“DemoFrameControl.DemoFrameCtrl”隐式转换为“System.Windows.Forms.Control”),希望这有助于澄清我的问题

    private void WindowLoaded(object sender, RoutedEventArgs e)
    {
        // Create the interop host control.
        System.Windows.Forms.Integration.WindowsFormsHost host =
            new System.Windows.Forms.Integration.WindowsFormsHost();

        // Create the ActiveX control.
        DemoFrameControl.DemoFrameCtrl ax = new DemoFrameControl.DemoFrameCtrl();

        // Assign the ActiveX control as the host control's child.
        host.Child = (ax);

        // Add the interop host control to the Grid
        // control's collection of child controls.
        this.grid1.Children.Add(host);

        // Play a .wav file with the ActiveX control.
        //axWmp.URL = @"C:\WINDOWS\Media\Windows XP Startup.wav";
    }

谢谢

【问题讨论】:

    标签: wpf interop


    【解决方案1】:

    查看Walkthrough: Hosting an ActiveX Control in WPF

    更新:

    DemoFrameCtrl 是如何定义的?就像错误所说的那样,它必须是System.Windows.Forms.Control 的子类才能使用WindowsFormsHost。 ActiveX 控件包装器将继承自 AxHost,后者继承自 Control。如果您添加对 ActiveX 库的引用,我认为 Visual Studio 将生成包装器。如果没有,您可以尝试使用Aximp.exe (Windows Forms ActiveX Control Importer)

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-02
    • 2013-05-29
    • 2010-11-17
    • 2014-06-23
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    • 2012-05-12
    相关资源
    最近更新 更多