tags:

views:

26

answers:

1

I have an ActiveX control (written in Delphi) which I want to host in a WPF application. When I try to load it into the toolbox to add it to the XAML at design time, it is not shown in the list of available controls. Does anyone know what filters this list and why I can't see the control to add it?

Edit

This is where I get to - the host.Child = (ax); statement gets an error (Cannot implicitly convert type 'DemoFrameControl.DemoFrameCtrl' to 'System.Windows.Forms.Control'), hope this helps clarify my problem

    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";
    }

Thanks

+2  A: 

Check out Walkthrough: Hosting an ActiveX Control in WPF.

Update:

How is DemoFrameCtrl defined? Like the error says, it needs to be a subclass of System.Windows.Forms.Control to use WindowsFormsHost. An ActiveX control wrapper will inherit from AxHost which inherits from Control. I think Visual Studio will generate the wrapper if you add a reference to the ActiveX library. If not, you can try using Aximp.exe (Windows Forms ActiveX Control Importer).

Quartermeister
What I am really asking is, when I take the step in http://msdn.microsoft.com/en-us/library/ms748870.aspx, then I still don't see my control.
Mmarquee
Based on your answer and this article http://blogs.msdn.com/b/jasonz/archive/2007/05/07/tip-trick-embedding-activex-in-wpf-with-windowsformshost-video-demo.aspx I have solved my problem. I have to host the control in a winform usercontrol and then host that in WPF
Mmarquee