CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2001
    Location
    San Diego CA
    Posts
    378

    CMyDocumentArray serialization

    We are extending our application to support opening multiple documents at the same time. we want all of these CMyDocuments to be serialized into a single project file.

    How do I create a ProjectDocumentTemplate that will have an array of CMyDocuments and add it in InitInstance?
    þ|êâšë rä†è rëþ|ïëš †hª† hë|þëd

  2. #2
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CMyDocumentArray serialization

    Why nor to use built in MFC templates?

    Both SDI and MDI applications types support registration of more than one template.

    If you register different document templates, MFC application shows dialog to choose document type to open.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Apr 2001
    Location
    San Diego CA
    Posts
    378

    Re: CMyDocumentArray serialization

    Well we are using MFC document templates. But the problem is we want to save an array of documents that created using the main document template into a different (Project) document template.

    I tried to define a CMyDocuments array and then use that as a project document template but looks like the my document has to be derived directly from CDocument in Document template.

    PHP Code:

    // in application header
        
    typedef CTypedPtrArray<CObArrayCMyDocument*> CProjectMyDocArray


    // in initinstance of application
       // Create the multiple view document template 
        
    m_pDocumentTemplate = new CMultiDocTemplate(IDR_MAINFRAME,
            
    RUNTIME_CLASS(CMyDocument), RUNTIME_CLASS(CMDIChildWnd),
            
    MyViewClasses);        // array of view classes;

        
    AddDocTemplate(m_pDocumentTemplate );

        
    // Create the multiple view document template
        
    m_pProjectDocTemplate = new CMultiDocTemplate(IDR_PROJECT_FRAME,
            
    RUNTIME_CLASS(CProjectMyDocArray), RUNTIME_CLASS(CMDIChildWnd),
            
    ProjectViewClasses);        // array of view classes;
            
    AddDocTemplate(m_pProjectDocTemplate); 
    þ|êâšë rä†è rëþ|ïëš †hª† hë|þëd

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CMyDocumentArray serialization

    Frankly I am more confused than I was before.

    Of course document (as the name implies) has to be derived from CDocument class.

    I fail to understand this part:

    Quote Originally Posted by voidspace
    Well we are using MFC document templates. But the problem is we want to save an array of documents that created using the main document template into a different (Project) document template. . .
    You cannot save anything into a document template.
    Documents (and possibly data members) have ability to use serialization to save data to a document file.

    As for saving data from one document by another document, it is something unconventional. You can design one document type to understand other’s document data.

    Word does that when reading files created by other word processor.

    Maybe you can consider another approach that employs that functionality.

    Any file saves by one, can be read by other.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Apr 2001
    Location
    San Diego CA
    Posts
    378

    Re: CMyDocumentArray serialization

    Ok let me try and clear things up a bit here..

    Our project is an MDI app and curretly only uses one document template. The serialization (via CArchive) is done to a file. These files contain data about analysis settings, instrument data, user settings etc.

    The application has the ability to load only one of these files at a time. The new requirement is to be able to load multiple files of this type and be able to save them into a project file. So the project file should have information about project level settings and data from all the files loaded into the project.

    The project files need to be self containing .. meaning they should contain all the data in themselves without referencing the files through links.

    I was hoping to have project class that contains project informations and an Array of CMyDocuments as a member that would basically serialize to project.
    þ|êâšë rä†è rëþ|ïëš †hª† hë|þëd

  6. #6
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: CMyDocumentArray serialization

    Unless I am missing something:
    I am not sure what would you achieve, having an array of document objects (or pointers to). What you need is information about files that were saved by documents that belong to a project.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

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