Sign in to follow this  

MFC multiple document types

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there Would anyone have any kind of rough idea as to how you might have more than one different type of document in a MDI application using MFC? Is there any support for it? like could you have different menus coming up for it and such like? Any ideas would be much appreciated. CHeers

Share this post


Link to post
Share on other sites
Are you using the document/view architecture? If you are, this makes life a lot easier. If you're using the document/view architecture with MDI, then you're already using one document type. Look in the overidden InitInstance method of your application class. You should find some code which creates a new CMultiDocTemplate, initializes it with it's constructor, then calls AddDocTemplate to complete the job. To add new document types, just repeat this process. I'd highly recommend that you get Jeff Prosise's "Programming Windows with MFC, Second Edition" if you want to learn more about this topic, and pretty much anything else to with MFC. Below is some example code illustrating what I said above:

// App-wizard code...
CMultiDocTemplate *pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CBlackDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CBlackView));
AddDocTemplate(pDocTemplate);

// My new document type...
pDocTemplate = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CWhiteDoc),
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CWhiteView));
AddDocTemplate(pDocTemplate);

Share this post


Link to post
Share on other sites

This topic is 4861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this