Solved

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

Posted on 2004-04-07
2
384 Views
Last Modified: 2013-11-20
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.
0
Comment
Question by:Shake29
2 Comments
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 250 total points
ID: 10776164
Try to Override
CHtmlView::OnDestroy()
{
}

-Lakshman
0
 

Author Comment

by:Shake29
ID: 10782996
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now