This article describes how to create a single-document application using a multi-document interface. You may have zero or one documents at a time.
I've written a CMultiDocTemplate-derived class, CZoDocTemplate. It overrides the OpenDocumentFile function. OpenDocumentFile works like CSingleDocTemplate; it reinitializes a created document instead of creating one more document. If there is no opened document, a new document is created as in an MDI case. If you create several document templates, you will have a maximum of one document per template.
To Create Your Own ZODI Application
- Create an MDI application with AppWizard.
- Add ZoDocTemplate.h and ZoDocTemplate.cpp in your project, named <your app>.
- Include ZoDocTemplate.h in <your app>.cpp.
- In the InitInstance function, replace:
CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(...);with
CZoDocTemplate* pDocTemplate; pDocTemplate = new CZoDocTemplate(...);
Here is a similar article, MSDI. In it, I present another, simpler, way of MSDI implementation. In the MSDI example, when opening a new document, the created one is destroyed and a new one is created. In ZODI, the existing document is reinitialized as in the SDI case.
DownloadsDownload demo project - 21 Kb
Download simple exe - 8 Kb
Download source - 4 Kb