Manage new window from MS WebBrowser control

L

Lizard

Hi,

I have a WinForms application written in C#, in which I am using an
embedded Microsoft WebBrowser ActiveX control. Based on certain
events, I need to open a window from the browser control, something
like (in javascript) -
window.open("http://www.google.com,"","top=0,left=0,location=no,menubar=no,resizable=no,toolbar=no,status=no,scrollbars=no,width=790,height=550")

What is an elegant way of doing this? I currently, get the Document
object of the browser and cast it to type IHTMLDocument2 and then use
its "open" method. For example,

IHTMLDocument2 id = (IHTMLDocument2) AxWebBrowser.Document;
id.open (sURL, "", "top=0,left=0,location=no,menubar=no,resizable=no,toolbar=no,status=no,scrollbars=no,width=790,height=550",
true);

Second and more important question - How do I close the window that I
just spawned from the control, when I exit my application? It does not
automatically close the window when I close the application.

Thanks in advance,
August
 
L

Lizard

Thanks for the response.

Unfortunately, that is not a valid cast. The open() method of the
IHTMLDocument2 interface returns an object of type "object". When I
try to cast that to IHTMLDocument2, I get a "Cast not valid"
exception.

Any other ideas?

August
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top