Groups | Blog | Home
all groups > dotnet interop > july 2003 >

dotnet interop : Hosting ActiveX Controls: .NET versus MS Java


Michel Gallant
7/14/2003 8:24:43 PM
In MS Java, one could host ActiveX controls two different
ways:
- create a JCW (Java callable wrapper) and use that way
- use the ActiveXControl MS Java class directly

the 2nd method did not require generating a COM interop library and
having to deploy it to the clients, and was quite simple (quoting from Java SDK):

---------------------------------------------------------------
The other way to host an ActiveX control involves using the methods in the ActiveX control class.
To create the control, you would pass the CLSID or ProgID to the ActiveXControl constructor.
You can then invoke methods, retrieve properties, or set properties of the control.
Again, suppose you have a control called MyControl that has a method called MyMethod.
You can create the control and add it to the layout, as shown in the following example:
import MyControl.*;
import com.ms.activeX.ActiveXControl;
import java.awt.*;

// create the control
ActiveXControl c = new ActiveXControl("MyControl");

// add the control to the layout
add("Center", c);

// do something interesting
-----------------------------------------------Currently with .NET is it always necessary to
generate and deploya COM interop assembl;y (or embed the COM definitions in source code) ??Is ther
anything analogous to MS Java ActiveXControl class??Thanks, - Mitch

Vadim Melnik
7/15/2003 1:13:18 PM
Hi,

[quoted text, click to view]

Probably there is no similar class in .NET, but it's easy to generate
wrapper based on AxHost:

<code>
public class ActiveXControl : System.Windows.Forms.AxHost
{
public ActiveXControl(string clsid) : base(clsid)
{
}
}
....

private ActiveXControl calendarCtl;
calendarCtl = new ActiveXControl("{8E27C92B-1264-101C-8A2F-040224009C02}");

</code>

...
Regards,
Vadim.

AddThis Social Bookmark Button