473,503 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Webbrowser control closing, how to port to C# . Calling all pros, please

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
Nov 16 '05 #1
1 4392
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
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5529
by: Jim Hubbard | last post by:
I want to implement the same type of activeX restrictions in my browser application that the new SP2 for XP places in Internet Explorer. I have found 2 web pages dealing with this functionality...
2
1833
by: frederik12 | last post by:
Hi all, Today I downloaded and installed VS 2005 C# Express Edition (.NET framework 2.0). I'm very pleased about this new product. In my current application I'm using the WebBrowser control in...
1
5556
by: Tuong | last post by:
I have a situation where i have a form that contains a webbrowser control. With this I was able to implement an application that can browse websites. One particular website i visited opens up...
12
6331
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
8
3383
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
7
4661
by: Vittorio | last post by:
Hi all, I am trying to avoid that a webbrowser object will be closed by a window.close() javascript. Trying to use the WindowClosing event i discovered that it is not fired. I am using VB.NET 1.1...
7
11900
by: Dave Booker | last post by:
I am using a WebBrowser object in my .NET 2.0 application, but it is not shown to the user. Every time a timer event triggers it to perform a m_WebBrowser.Navigate() I get that classic IE 'click'...
2
4275
by: Jeroen | last post by:
We are experiencing a tuff-to-debug problem ever since we introduced a WebBrowser control into our failry large application. I'm not sure if the problem description below contains enough details,...
4
16049
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.