Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We use an embedded browser to show a specific webpage that has a rich text editor.

This text editor has hooked itself onto some events to detect when the browser tries to close/leave the page. The editor will validate that the latest changes are saved, and if not it will prompt the user to do so.


If the page is opened in a standalone Internet explorer, both navigating away (by typing new url), and closing the tab/window, will trigger the javascript.


When the page is shown in the embedded Iwebbrowser2 control and we send a new url, the javascript is properly triggered. But we are unable to get the event for close.

When we close the frame the control is hosted in, all the panels/controls just gets destroyed.

How do I programmatically tell the Iwebbrowser2, that we are about to close?

I have also tried to call the Quit function when I receive the onCloseEvent for my frame.
Calling Iwebbrowser2::Quit has so far not worked at all. The function does always return e_fail.



I can demonstrate it with the wxactivex sample.
I have changed it to default open this url: http://www.4guysfromrolla.com/demos/OnB ... dDemo1.htm
Closing the program does not bring up the confirmation dialog.

File: https://dl.dropbox.com/u/13322788/wxactivex/wxactivex.zip[^]
Posted

1 solution

Navigate to a predefined link as the 'close command'.
Use BeforNavigate2 to check the new link - if it is the predefined link close the dialog.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900