I've tried searching for "delete pDocument", but only found two
instances where it is deleting the object to cleanup after an error
occurred.
Where does MFC call delete on the document object when the user closes
the app and a WM_CLOSE message is sent?
I've converted an SDI application to a DLL. Works great with the
exception that MFC has deleted the document object before OnClose() is
called, for some reason. This causes an exception error because the
document is still references in OnClose() and it would be easier to
trace if I could find where the object is being deleted the first
time. Then I can determine what is causing the confusion.
Thank you for your help,
Mario
> Does anyone know exactly where CDocument is destroyed in the MFC
> source code for an SDI or MDI application?
>
> I've tried searching for "delete pDocument", but only found two
> instances where it is deleting the object to cleanup after an error
> occurred.
>
> Where does MFC call delete on the document object when the user closes
> the app and a WM_CLOSE message is sent?
>
The Document ist destroyed when the last View is disconnected from the
CDocument.
The destructor of CView calls CDocument::RemoveView. RemoveView deletes the
view from the list and calls CDocument::OnChangedViewList. OnChangedViewList
calls OnCloseDocument if there is no more view and m_bAutoDelete is set to
TRUE (default).
HTH
--
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
Thank you very much for your help. You saved me hours of searching. I
was able to solve the problem with your information. (Vielen Dank)
For anyone else who wants to convert an SDI MFC doc/view application
to DLL: consider overriding the WM_CLOSE message and using
OnCloseDocument() instead, because WM_QUIT appears to destroy the
document object twice if you have manually used the message pump in
your DLL version.
Mario
"Martin Richter [MVP]" <martin....@grutzeck.de> wrote in message news:<3cc4f9fa$1...@news.grutzeck.local>...