Re: Error message when using OpenDocumentFile on read-only files
From: Dieter Lorenz (dieter_lorenz_at_web.de)
Date: 01/19/05
- Next message: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Previous message: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- In reply to: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Next in thread: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Reply: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 Jan 2005 21:55:32 +0100
I think I have to tell more details :-)
I started my project with the AppWizard including "full-server" document
support and multiple documents. When I compile this application (nothing
added manual to the source code), I get an error message when I try to open
a file with write-protection.
I can not call a member function of a document when I did not create the
document yet.
Which function do I have to call to create a document and its view from the
application class? Or am I totally wrong?
Regards
Dieter
"Tom Serface" <tserface@msn.com> schrieb im Newsbeitrag
news:uldg63k$EHA.3700@tk2msftngp13.phx.gbl...
> You could simply override OnOpenDocument() instead and just manage the
file
> yourself. Be sure to open the file with a shared mode if you don't want
to
> lock it. Better yet, read the file into a buffer and close it as quickly
as
> you can.
>
> BOOL CMyAppDoc::OnOpenDocument(LPCTSTR lpszPathName)
> {
> if(!CDocument::OnOpenDocument(lpszPathName))
> return false;
>
> CString cs, XMLString;
> BOOL m_bXMLDocument = false;
> CStdioFile MyFile;
> if(MyFile.Open( lpszPathName, CFile::modeRead | CFile::typeText ) ) {
> while(MyFile.ReadString(cs)) {
> // We need to skip the CDATA part so just add the close on
> // to the end of the string so we don't get a parsing error.
> if(cs.Find("<![CDATA") != -1) {
> XMLString += "</QuickDiscDoc>\n";
> break;
> }
> XMLString += cs;
> }
> MyFile.Close();
> m_bXMLDocument = XMLString.Left(2) == _T("<?");
> return true;
> }
>
> Tom
>
> "Dieter Lorenz" <dieter_lorenz@web.de> wrote in message
> news:356k1dF4ilu6eU1@individual.net...
> >I want to use the OpenDocumentFile function to open and show a document
in
> > my application.
> > This works fine for files without write protection but for files which
are
> > read-only I get an error message from
> >
> > CDocument* CTestApp::OpenDocumentFile(LPCTSTR lpszFileName)
> > {
> > // TODO: Add your specialized code here and/or call the base class
> >
> > return CWinApp::OpenDocumentFile(lpszFileName);
> > }
> >
> > The other problem I have with this application is that the files which
are
> > open by my application are locked.
> >
> > I believe that these two items are closely related to each other.
> >
> > Any ideas or do you need more informations?
> >
> > Best regards
> > Dieter
> >
> >
>
>
- Next message: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Previous message: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- In reply to: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Next in thread: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Reply: Tom Serface: "Re: Error message when using OpenDocumentFile on read-only files"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|