Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

MFC single document interface

Hi Experts,

I created a single document interface - I'd like to create 2 different kinds of documents for it.  How do I set this up?

Thanks!
Mike
0
thready
Asked:
thready
  • 2
  • 2
1 Solution
 
ZoppoCommented:
Hi thready,

this is not quite easy since SDI really means Single Document Interface. The class responsable for handling documents, frame windows and views is CDocManager, which contains a list of CDocTemplate-derived classes. For SDI this is CSingleDocTemplate, for MDI CMultiDocTemplate. Unfortunateley you cannot use CMultiDocTemplate in a SDI application since a CMultiDocTemplate requires the use of one or more CMDIChildFrame-derived classes as frame windows. This is because GUI elements of the CMainFrame change depending on the active document frame's resources, i.e. menus, toolbars a.s.o.

One possibility would be to use a MDI application with two document templates using the same CMDIChildFrame- and CView-derived classes for two different CDocument-derived classes. I guess it should be possible two override CDocument::OnOpenDocument in a way it doesn't create a new frame and view but re-uses existing ones. And I think it should even be possible to modify the main and/or child frame class in a way the child frame always is maximized. If it's an option for you to use an MDI application like this please tell, then maybe I can give you further help how to do this (but not before tomorrow morning, sorry).

Another possibility is to use take a SDI application which implements two mainframes with two documents and synchronizes the main frames when documents are switched. You can find some sourcecode here: http://www.codeguru.com/cpp/w-d/doc_view/viewmanagement/article.php/c3255/

Hope that helps,

ZOPPO
0
 
threadyAuthor Commented:
Question for you Zoppo- I really need to change my view class (I just realized this)- it's not my document that I need to change.  Is it possible to select from different views for the current open document?
0
 
ZoppoCommented:
0
 
threadyAuthor Commented:
Thanks Zoppo
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now