tomascz
tomascz

Reputation: 245

Multiple document types in SDI application (or just a capability of MDI?)

I have a (maybe ridiculous) question about MFC - can an SDI application support multiple document types? (Along with showing the "choose-document" dialogue when creating a new document, but that's not absolutely necessary and I could handle it myself.) What I want to do is my app to behave like modern office programs, that is each new document (of some type) residing in its own instance of the application, instead of sharing a common space with other open documents (the concept of MDI).

If SDI cannot give such functionality (which my recent experimentation suggests), could someone advice me how to handle the "open" command under MDI to open the file in a new instance of the application? (The same then applies to the "new" command.)

Upvotes: 0

Views: 918

Answers (2)

Vlad Feinstein
Vlad Feinstein

Reputation: 11321

MFC calls this application type "Multiple top-level documents", and you can select it in MFC App Wizard:

MFC App Wizard

Upvotes: 1

Robson
Robson

Reputation: 926

you just have to add the document tamplates using CWinApp::AddDocTemplate The msdn link provides only the example with CMultiDocTemplate, so I've included here the example with CSingleDocTemplate that is generated when you create a new project with visual studio.

// Register the application's document templates.  Document templates
//  serve as the connection between documents, frame windows and views
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CSDITestDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(CSDITestView));
if (!pDocTemplate)
    return FALSE;
AddDocTemplate(pDocTemplate);

Upvotes: 0

Related Questions