|
-
March 31st, 1999, 06:43 PM
#1
Anyone experienced with stretching the bounds of MFC?
Perhaps I wasn't very clear when I asked this question a while back, so I'd like to try again and see if anyone has some experience with this situation.
My application needs to be able to handle two different file types. One of these is read and written using Serialize(). The other is a text file, and is read and written using a CStdioFile. What is the smoothest way to get my app to read both file types?
-
March 31st, 1999, 07:08 PM
#2
Re: Anyone experienced with stretching the bounds of MFC?
Hi
It is very simple .
You need to write two pair classes (doc-view) (and may be two frame classes).
In the first you need to use (add your code) Serialize() method
And in other (CDocument) you need to use (rewrite) method
BOOL CWtapeDoc::OnOpenDocument(const char* pszPathName)
(and do nothing with Serialize() )
And you need to add some code like
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_WTAPETYPE, ///!!!!!!!!!!!!!!!
RUNTIME_CLASS(CWtapeDoc),
RUNTIME_CLASS(CWtapefrm),
RUNTIME_CLASS(CWtapeView));
AddDocTemplate(pDocTemplate);
pDocTemplate = new CMultiDocTemplate(
IDR_STAPE, /// !!!!!!!!!!!!!!!!!!
RUNTIME_CLASS(CSecDoc),
RUNTIME_CLASS(CStapefrm),
RUNTIME_CLASS(CPrimView));
AddDocTemplate(pDocTemplate);
in your InitInstance() method
Best Regards
-
March 31st, 1999, 11:17 PM
#3
Re: Anyone experienced with stretching the bounds of MFC?
Do you think it will work if I only use one template (since for both document types I am using the same classes), and then intercept the OnOpenDocument() for the document class, calling CDocument:OnOpenDocument() for serialize, and a special function for direct file access? It seems ok, except that the open dialog only lists one filter, for the serializable type. How can I get it to list the other type, does anyone know?
-
April 1st, 1999, 01:46 AM
#4
Re: Anyone experienced with stretching the bounds of MFC?
Hi,
I think if you modify your Application on initinstance function to add the
second templete as suggested by
the previous answer (and maybe the resource file) then the additional filter
should show in the file open dialog.
Suck it and see.
-
April 1st, 1999, 06:35 AM
#5
Re: Anyone experienced with stretching the bounds of MFC?
This should work. I believe you can put multiple filter name and extension strings in the doc string resource (see CDocTemplate::GetDocString). I'm not sure what the seperator should be for multiple filter details (comma?, space?, semi-colon?).
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|