Multiple new files on same DocTemplate
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
Re: Multiple new files on same DocTemplate
Quote:
Originally posted by JonnoA
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.
1. How would you specify the simulation type ( I assume that the simulation type is what decides which CBaseDoc derivative to use , right ? )
2. When you mean just ONE document, do you mean one document object or document class ?
I mean it is not clear. You say you have different documents, but is it that you want to get rid of those and have just one ?