CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 1999
    Posts
    15

    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?

  2. #2
    Join Date
    Mar 1999
    Posts
    3

    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

  3. #3
    Join Date
    Apr 1999
    Posts
    15

    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?

  4. #4
    Join Date
    Apr 1999
    Posts
    5

    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.

  5. #5
    Join Date
    Apr 1999
    Posts
    383

    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
  •  





Click Here to Expand Forum to Full Width

Featured