Answered Hosting Out-of-process ActiveX control in WPF

  • Tuesday, December 02, 2008 6:05 PM
     
     
    Hi to all!

    Can anybody help me?

    I have an out-of process third-party ActiveX control. I just need to host it in the WPF Application. What should I do for it? I have not seen any examples of doing this in the internet.

    Thanks

    P.S. This third-party out-of-process ActiveX Control was created in C++/Qt using ActiveQt

All Replies

  • Thursday, December 04, 2008 3:31 AM
     
     Answered
    Hi,

     

    Here is an useful document with a ready-to-run example of hosting ActiveX controls in your WPF based application, you can follow it step by step.

     

    Link: http://msdn.microsoft.com/en-us/library/ms742735.aspx

    Some code snippets are shown in the following:

    XAML code:

     <Window x:Class="HostingActiveX.Window1"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="Hosting the Terminal Services ActiveX Control">

          <DockPanel Name="panel" Margin="10">

            <StackPanel Margin="0,0,0,10" DockPanel.Dock="Top" Orientation="Horizontal">

              <TextBox x:Name="serverBox" Width="200" Margin="0,0,10,0"/>

              <Button x:Name="connectButton" Click="connectButton_Click">Connect</Button>

            </StackPanel>

          </DockPanel>

    </Window>

     

    In the code behind:

     

    using System.Windows;

    using System.Windows.Forms.Integration;

    using System;

     

    namespace HostingActiveX

    {

        public partial class Window1 : Window

        {

            AxMSTSCLib.AxMsTscAxNotSafeForScripting termServ;

     

            public Window1()

            {

                InitializeComponent();

     

                // Create the host and the ActiveX control

                WindowsFormsHost host = new WindowsFormsHost();

                termServ = new AxMSTSCLib.AxMsTscAxNotSafeForScripting();

     

                // Add the ActiveX control to the host, and the host to the WPF panel

                host.Child = termServ;

                panel.Children.Add(host);

            }

     

            void connectButton_Click(object sender, RoutedEventArgs e)

            {

                termServ.Server = serverBox.Text;

                termServ.Connect();

            }

        }

    }

     

    Hope this helps.


    Thanks.


    Jim Zhou -MSFT
    • Marked As Answer by Jim Zhou - MSFT Friday, December 05, 2008 12:47 PM
    •  
  • Tuesday, May 15, 2012 10:06 AM
     
     
    This one works but I cannot click on the program opened  in the remote machines. I cannot start new program from the remote desktop session launched through this.