On the discussion part of the SpicIE home page (http://code.msdn.microsoft.com/SpicIE/Thread/List.aspx) I found an interesting question “Constructor is not called…”.
The reason for this scenario is following. If you build IE extensions with SpicIE you finally constructs COM objects which Internet Explorer creates for you.
In your code these classes seems to be normal objects. But from IE perspective this classes are COM objects which are created only once per IE process room. To understand how Internet Explorer 7/8 handles processes and tabs I recommend you this reading about “Loosely-coupled Internet Explorer Internet Explorer” --> http://code.msdn.microsoft.com/ie8whitepapers/Release/ProjectReleases.aspx?ReleaseId=565
So in your own SpicIE code exists two categories of classes:
The Internet Explorer extension classes have following characteristics:
Here follows a short sample of the HostInstance pattern which could be used to access the Internet Explorer extension class instances.
public partial class HtmlTreeToolbar : SpicIE.Controls.Toolbar { public static HtmlTreeToolbar toolbarInstance;
Assignment of the instance in the object constructor:
public HtmlTreeToolbar() { try { #if DEBUG Host.TraceSink.TraceInformation(string.Format("HtmlTreeToolbar.HtmlTreeToolbar - DEBUG {0} - {1}", System.Reflection.Assembly.GetExecutingAssembly().FullName, DateTime.Now.TimeOfDay.ToString())); #else Host.TraceSink.TraceInformation(string.Format("HtmlTreeToolbar.HtmlTreeToolbar - RELEASE {0} - {1}", System.Reflection.Assembly.GetExecutingAssembly().FullName, DateTime.Now.TimeOfDay.ToString())); #endif toolbarInstance = this;
Finally usage of the instance variable to access functionality of the Internet Explorer extension class instance:
void PageHtmlTree_OnDocumentComplete(object pDisp, ref object url) { if (HtmlTreeToolbar.toolbarInstance != null) { HtmlTreeToolbar.toolbarInstance.StartDisplayNewPageTree( (url!=null) ? url.ToString() : string.Empty ); } }
GunnarD