how to close document handle
-
hi friends, i have have a MDI Application. when i close a document using onclosedocument. my document handle remains active though the members used in document are set to null. so i cannot check this condition if(doc) as it returns true. whereas in the if block it cannot access the members so app crashes eg.
if(doc) //handle =FAEX000
{
doc->getprivatevariable_or_functions(); // the application crashes here
}thanking in anticipation REgards Samir
-
hi friends, i have have a MDI Application. when i close a document using onclosedocument. my document handle remains active though the members used in document are set to null. so i cannot check this condition if(doc) as it returns true. whereas in the if block it cannot access the members so app crashes eg.
if(doc) //handle =FAEX000
{
doc->getprivatevariable_or_functions(); // the application crashes here
}thanking in anticipation REgards Samir
How did you allocated the "document" ? I mean how did you create the pointer
doc
(it seems it is a pointer, right?). When you release your document (for instance by deleting the memory), you also always have to assign null to it, so that you can check whether it has been deallocated. If you do that, then your code will work properly (the if segment won't be entered since doc is NULL).Cédric Moonen Software developer
Charting control [v3.0] OpenGL game tutorial in C++ -
hi friends, i have have a MDI Application. when i close a document using onclosedocument. my document handle remains active though the members used in document are set to null. so i cannot check this condition if(doc) as it returns true. whereas in the if block it cannot access the members so app crashes eg.
if(doc) //handle =FAEX000
{
doc->getprivatevariable_or_functions(); // the application crashes here
}thanking in anticipation REgards Samir
You may override
CDocument::OnCloseDocument
for marking your document as invalid (you may set a custom property for the purpose) and then check for document validity before any access. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You may override
CDocument::OnCloseDocument
for marking your document as invalid (you may set a custom property for the purpose) and then check for document validity before any access. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi pallini Sir, i have main document which has child documents. so in main document i have overridden the function document:oncloseDocumenet() and called ColeDocument:CloseDocument. Thanks For reply Sir.. but prob still not resolved Regards Samir