I was able to get it working using the method described in this post -
http://tinyurl.com/2uafs
I had to make a few modifications:
Add a field to the IEEvents class.
private Form form;
Add a constructor to the IEEvents class
public IEEvents(Form form)
{
this.form = form;
}
When you instaniate the IEEvents class, be sure to pass in the form.
IEEvents e = new IEEvents(this);
Change the code inside the WindowClosing method
Cancel = true;
//Display custom yes/no messagebox if you want, for now just assume that
you want the form closed
this.form.Close();
"Mike Z..." <an*******@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
Hi! I have a winform with embedded webbrowser control. When a user
navigates to a page that has a link or a button that calls windows.close()
javascript, the control closes yet the form does not. Since the control does
not expose the onQuit() event, I need to capture the message and close my
winform. I found the following Microsoft article that explains on how to do
it in C++. I recently switched from Cold Fusion and have a heck of a time
figuring out how to port the C++ code to C#.
Please help. I can email you the test form to try.
Article URL.
http://support.microsoft.com/default...NoWebContent=1