Link to home
Start Free TrialLog in
Avatar of Shake29
Shake29

asked on

Receive notification of when a document window hosing a CHtmlView is closing.

I cannot seem to receive any event notification of when i am closing a document window whose child view is a CHtmlView.

The HTML page captures the OnBeforeUnload event, and it gets called successfully if you navigate to another page.  But unlike when you close an Internet Explorer browser window, the OnBeforeUnload event does not get called on the HTML page when you close SDI or MDI documents hosing a CHtmlView.  The document window and HTML page just shut down.

This is not a problem if my application can receive a notification before the window closes and is the prefered method anyways.

I've tried these things to receive notification of a document window closing....
   1)  Overrided  CDoc::OnDocumentCLose()
                   -- probably doesn't work because i don't use or need serialization
   2)  Overrided CWnd::OnClose()
                   -- manually added it to the message map because Class Wizard did not offer it.
   3)  Overrided CHtmlView::OnBeforeNavigate2()
                   -- I was already certain it would not get called.

None of these events get called when i close the document window.
ASKER CERTIFIED SOLUTION
Avatar of lakshman_ce
lakshman_ce

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shake29
Shake29

ASKER

I became a little confused having moved back to MFC after not working with it in years.

For the record, since I needed the WebBrowser control to still exist when the close event was called, it was actually the CFrameWnd::OnClose() that needed to be overridden, and it is works.

None the less, you answered the question correctly in the way it was asked.  So you get the points.