OnOpenDocument same file?
-
Hi, I have an MFC MDI app. If one user, running one instance of the app opens a file using OnOpenDocument then another user, running another instance of the same app opens the same file, MFC reports "Failure to open document". The app does not edit the file, it's just a viewer, so I don't care if many people are opening the document. How can I tell this to MFC? thanks, Kristian.
-
Hi, I have an MFC MDI app. If one user, running one instance of the app opens a file using OnOpenDocument then another user, running another instance of the same app opens the same file, MFC reports "Failure to open document". The app does not edit the file, it's just a viewer, so I don't care if many people are opening the document. How can I tell this to MFC? thanks, Kristian.
I've made an empty MFC app using wizard, added some serialization, and can't reproduce the behavior you're describing - two instances can open the same file. Did you override OnOpenDocument? If this is the case, please post the code. Tomasz Sowinski -- http://www.shooltz.com
-
I've made an empty MFC app using wizard, added some serialization, and can't reproduce the behavior you're describing - two instances can open the same file. Did you override OnOpenDocument? If this is the case, please post the code. Tomasz Sowinski -- http://www.shooltz.com
BOOL CSaturn2Doc::OnOpenDocument(LPCTSTR lpszPathName) { // the following line fails. The serialize function is empty. if (!COleServerDoc::OnOpenDocument(lpszPathName)) return FALSE; blah blah blah... } My document is derived from COleServerDoc.
-
BOOL CSaturn2Doc::OnOpenDocument(LPCTSTR lpszPathName) { // the following line fails. The serialize function is empty. if (!COleServerDoc::OnOpenDocument(lpszPathName)) return FALSE; blah blah blah... } My document is derived from COleServerDoc.
Oooooh - you're using OLE. My experience is limited in this area, all I can advise is stepping inside COleServerDoc::OnOpenDocument and checking which call fails - probably it'll be call to something like StgOpenStorage. Tomasz Sowinski -- http://www.shooltz.com
-
Oooooh - you're using OLE. My experience is limited in this area, all I can advise is stepping inside COleServerDoc::OnOpenDocument and checking which call fails - probably it'll be call to something like StgOpenStorage. Tomasz Sowinski -- http://www.shooltz.com
That's right, in COleDocument::OnOpenDocument() the call to StgIsStorageFile() fails. I guess I could work around this by copying every document I intend to open to a temporary file but that sucks.
-
That's right, in COleDocument::OnOpenDocument() the call to StgIsStorageFile() fails. I guess I could work around this by copying every document I intend to open to a temporary file but that sucks.
So is the file your viewer reads a 'compound storage file'? Tomasz Sowinski -- http://www.shooltz.com
-
So is the file your viewer reads a 'compound storage file'? Tomasz Sowinski -- http://www.shooltz.com
I see where you are going with this. I found a call to EnableCompoundFile() in my document class, which I changed to EnableCompoundFile(FALSE). Now everything is groovy. Thanks. :-D