How do I create a View and assing it his document class
-
When you add a derived CView class to your MFC project how do I relate My View derived Class to my CDocument derived class. I´m trying to add another view to my MFC project.:confused:
You do it in the InitInstance method of your CWinApp derived application class. You will find there something like this: CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_TESTDFTYPE, RUNTIME_CLASS(CTestdfsdDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CTestdfsdView)); AddDocTemplate(pDocTemplate); You register your new document/view pair by copy-paste-edit: pDocTemplate = new CMultiDocTemplate( IDR_MYTYPE, RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CMyView)); AddDocTemplate(pDocTemplate); Don't forget to create document string in resources - see the string of existing document in string table resources for example (IDR_TESTDFTYPE in this case). Sonork 100.15206;PavelK
-
When you add a derived CView class to your MFC project how do I relate My View derived Class to my CDocument derived class. I´m trying to add another view to my MFC project.:confused:
Jose Cruz wrote: Don't forget to create document string in resources - see the string of existing document in string table resources for example (IDR_TESTDFTYPE in this case). First of all thank you for your help. Now do you have some explanation for the above phrase. Every MFC document class has a corresponding definition string in string table resource - ID of the string is ID of the document (IDR_xxx), it defines parameters like name of the document for OLE, filename extension and so on. You need one for every CDocument derived class in Your project. CDocTemplate class uses it. It looks like: NTGen\nNTGen\nNTGen\nNTGen Files (*.mdb)\n.mdb\nNTGen.Document\nNTGen Document Sonork 100.15206;PavelK