Click here to Skip to main content
15,896,512 members
Articles / Desktop Programming / MFC
Article

Zero or One Document Interface (ZODI)

Rate me:
Please Sign up or sign in to vote.
4.38/5 (5 votes)
25 Feb 2004 43K   1.3K   15   4
This article describes how to create a single-document application using multi-document interface. You may have zero or one document at a time.

What's this?

This article describes how to create a single-document application using multi-document interface. You may have zero or one document at a time.

I've written a CMultiDocTemplate - derived class CZoDocTemplate. It overrides OpenDocumentFile function. OpenDocumentFile works like CSingleDocTemplate one. It reinitializes created document instead of creating one more document. If there is no opened document, new document is created like in MDI case. If you create several document templates, you will have maximum one document per each template.

To create your own ZODI application

  1. Create MDI application with AppWizard.
  2. Add ZoDocTemplate.h & ZoDocTemplate.cpp in your project, named <your app>.
  3. Include ZoDocTemplate.h in <your app>.cpp.
  4. In InitInstance function, replace
    CMultiDocTemplate* pDocTemplate;
    pDocTemplate = new CMultiDocTemplate(...);
    

    with

    CZoDocTemplate* pDocTemplate;
    pDocTemplate = new CZoDocTemplate(...);
    

Similar Article

Here is a similar article: Single View in MultiDoc-Application. I present another more simpler way of "Single View in MultiDoc-Application" implementation. In ZODI, the existing document is reinitialized like in SDI case.

History

Date posted: February 18, 2004.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralOpening New Docs Pin
Tim Gard29-Jun-05 15:37
Tim Gard29-Jun-05 15:37 
The class is very nice, but I have a small question:

If I already have more than a single child window open for a document, and then open another document, all child windows remain open and are now assigned to the new document.

Is there anything harmful about deleting all child views beyond the first view position?

Thank you,
Tim
GeneralRe: Opening New Docs Pin
Constructor7-Jul-05 22:38
Constructor7-Jul-05 22:38 
GeneralRe: Opening New Docs Pin
Tim Gard8-Jul-05 7:38
Tim Gard8-Jul-05 7:38 
GeneralC++ makes bad HTML Pin
Tim Gard13-Jul-05 19:26
Tim Gard13-Jul-05 19:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.