Click to See Complete Forum and Search --> : Anyone experienced with stretching the bounds of MFC?


hiltonc
March 31st, 1999, 05:43 PM
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?

Igor Povarov
March 31st, 1999, 06:08 PM
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

hiltonc
March 31st, 1999, 10:17 PM
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?

Orlando
April 1st, 1999, 12:46 AM
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.

Dave Lorde
April 1st, 1999, 05:35 AM
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