victor.sauermann

Hi everybody!

I'm just creating a BHO in C# and use until now the ShDocVw namespace and the WebBrowser interface of this namespace.

I have the IObjectWithSite interface like the following:

[

ComVisible(true),

InterfaceType(ComInterfaceType.InterfaceIsIUnknown),

Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")

]

public interface IObjectWithSite

{

[PreserveSig]

int SetSite ([MarshalAs(UnmanagedType.IUnknown)]object site);

[PreserveSig]

int GetSite (ref Guid guid, out IntPtr ppvSite);

}

And in the implementation of this interface I use the SetSite method:

1: [PreserveSig()]

2: int IObjectWithSite.SetSite(object site)

3: {

4: if (site == null)

5: {

6: browser.DocumentComplete -=

7: new ShDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(

8: bhoListener.OnDocumentComplete);

9: browser = null;

10: }

11: else

12: {

13: Logging.logDebug("SetSite(browser)");

14: browser = (ShDocVw.WebBrowser)site;

15: bhoListener.Browser = browser;

16: browser.DocumentComplete +=

17: new ShDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(

18: bhoListener.OnDocumentComplete);

19: }

20: return 0;

21: }

Now: This all is okay, but I read that the namespace System.Windows.Forms also delivers a WebBrowser class.

I tried to use this one instead, with the following code:

14: browser = (System.Windows.Forms.WebBrowser)site;

It didn't work.

Can anyone help me out What do I have to do to use System.Windows.Forms instead of ShDocVw

Cheers

Vic



Re: Internet Explorer Extension Development System.Windows.Forms instead of ShDocVw namespace

Mattias Sjogren

You simply can't do that. The System.Windows.Forms.WebBrowser class is a wrapper control for the native web browser component.