I am writing some modelling software. A variety of models/simulations can be run which are chosen from sub menu items in File>New. A simulation may not work, in which case a new document will not be opened.

Currently I have several CMultiDOcTemplates and corresponding CDocument classes derived from a 'standard' CBaseDoc base class, one for each simulation type. The derived classes override OnNewDocument. ie:

CBaseDoc : public CDocument // the one provided by app wizard
{...
BOOL OnFileOpen()...
BOOL OnSaveAs(pathname)...

};

CSimulation1Doc : public CBaseDoc
{
BOOL OnFileNew() {
// code for this simulation. If it fails return FALSE, else returnTRUE
}
};

CSimulation2Doc : public CBaseDoc
{
BOOL OnFileNew() {
// code for this simulation. If it fails return FALSE, else returnTRUE
}
};

All the document fuctionality is in CBaseDoc, except for OnNewDocument, which is in the derived classes.

In the WinApp derived class, the different templates are setup to use the different documents, but with the same CView and IDR_resource, which includes the string resource.

The File>New part of this works well. However, since there are several document templates, opening a file shows the same filter extension several times (as you would expect).

I don't really like the above solution because there should only really one document type.

I would be very grateful if someone could suggest a 'neat' solution to providing different data in new documents, depending on the type of simulation chosen, using just ONE document and ONE document template.

There must not be a situation where a blank document is created (eg if the simulation fails and fails to fill the arrays in the document)

Thanks

Jon