I admit I know enough about COM and IE architecture only to be dangerous. I have a working C# .NET ActiveX control similar to this:
using System;
using System.Runtime.InteropServices;
using BrowseUI;
using mshtml;
using SHDocVw;
using Microsoft.Win32;
namespace CTI
{
public interface CTIActiveXInterface
{
[DispId(1)]
string GetMsg();
}
[ComVisible(true), ClassInterface(ClassInterfaceType.AutoDual)]
public class CTIActiveX : CTIActiveXInterface
{
/*** Where can I get a reference to SHDocVw.WebBrowser? *****/
SHDocVw.WebBrowser browser;
public string GetMsg()
{
return "foo";
}
}
}
I registered and created a type library using regasm:
regasm CTIActiveX.dll /tlb:CTIActiveXNet.dll /codebase
And can successfully instantiate this in javascript:
var CTIAX = new ActiveXObject("CTI.CTIActiveX");
alert(CTIAX.GetMsg());
How can I get a reference to the client site (browser window) within CTIActiveX? I have done this in a BHO by implementing IObjectWithSite, but I don't think this is the correct approach for an ActiveX control. If I implement any interface (I mean COM interface like IObjectWithSite) on CTIActiveX when I try to instantiate in Javascript I get an error that the object does not support automation.