Skip to main content
GameDev.net gamedev.net
🔒 Locked

MFC multiple document types

Started by pixienick Aug 25, 2004 at 10:55 AM 0 replies 1.2k views
Original Post
pixienick
pixienick
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
iNsAn1tY
iNsAn1tY
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);
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.