Documents with the same file name extension
Olivier Courtois -- Olivier.Courtois@di.epfl.ch Tuesday, June 04, 1996 Environment VC++ 4.0 Windows 95 I am trying to merge two different SDI into one general MDI application. One of my problem is that some of the images I am trying to read, were readen in one app as 2D images and as 3D images in the other, and that they use the file extension ".mdfs". In order to cope with that,I have defined two different strings in the ressource String table: IDR_MAPIMAMDFSTYPE 130 \nPC Viewer 2D\nPC Viewer 2D\nImages Smdfs 2D (*.mdfs)\n.MDFS\nMap2D.mdfs\nSmdfs 2D Document IDR_SMDFS3D 147 \nPC Viewer 3D\nPC Viewer 3D\nImages Smdfs 3D (*.mdfs)\n.MDFS\nMap3D.mdfs\nSmdfs 3D Document and then declared in my initinstance ///////////// Format de visualisation des images Smdfs 2D AddDocTemplate(new CMultiDocTemplate(IDR_MAPIMAMDFSTYPE, RUNTIME_CLASS(CMapImageDoc), RUNTIME_CLASS(CMDIChildWnd), RUNTIME_CLASS(CMapImageView))); ///////////// Format de visualisation des images Smdfs 3D AddDocTemplate(new CMultiDocTemplate(IDR_SMDFS3D, RUNTIME_CLASS(CSmdfs3DDoc), RUNTIME_CLASS(CMDISmdfs3DChildFrame), // MDI child frame RUNTIME_CLASS(CSmdfs3DView))); Unfortunately when I try to open an .mdfs file it always uses the first solution (here:IDR_MAPIMAMDFSTYPE) even if I have choosen the second in the "Files of type" combo box in the Open dialog box. I think that the problem may come from the code of the "CDocManager::OpenDocumentFile" function in Docmgr.cpp where it tests the best match for the different templates. I think it uses only the extension to choose the best match. Does anyone know how it works exactly, and how to force it to choose the way it opens not only with the extension of the file but also with the parameter defined in the "Files of type" combo box, and finally how to implement it easily (if possible) ? Any comment will be helpful. Thanks -- OO=======================OO=============================OO==================OO || _ /_/_/ _/_/_/ || Olivier Courtois || || || _ / / _/ || EPFL-LSP (CH) || L'optimisme || || _ / _/ _/ _/\ || Olivier.Courtois@di.epfl.ch || est le desespoir || || _ /_/_/ _/_ /_/ _/ _\ || Tel: ++41 21 693-3944 || de la raison || || _/ || Fax: ++41 21 693-6680 || || OO=======================OO=============================OO==================OO
Sheir Rahman Ali -- al930088@omega.scs.carleton.ca Sunday, June 09, 1996 At 08:15 AM 6/4/96 +0200, you wrote: >Environment VC++ 4.0 Windows 95 > > I am trying to merge two different SDI into one general MDI >application. > One of my problem is that some of the images I am trying to read, were >readen in one app as 2D images and as 3D images in the other, and that they >use the file extension ".mdfs". > In order to cope with that,I have defined two different strings in the >ressource String table: > >IDR_MAPIMAMDFSTYPE 130 \nPC Viewer 2D\nPC Viewer 2D\nImages Smdfs 2D > (*.mdfs)\n.MDFS\nMap2D.mdfs\nSmdfs 2D Document >IDR_SMDFS3D 147 \nPC Viewer 3D\nPC Viewer 3D\nImages Smdfs 3D > (*.mdfs)\n.MDFS\nMap3D.mdfs\nSmdfs 3D Document > >and then declared in my initinstance > >///////////// Format de visualisation des images Smdfs 2D >AddDocTemplate(new CMultiDocTemplate(IDR_MAPIMAMDFSTYPE, > RUNTIME_CLASS(CMapImageDoc), > RUNTIME_CLASS(CMDIChildWnd), > RUNTIME_CLASS(CMapImageView))); >///////////// Format de visualisation des images Smdfs 3D >AddDocTemplate(new CMultiDocTemplate(IDR_SMDFS3D, > RUNTIME_CLASS(CSmdfs3DDoc), > RUNTIME_CLASS(CMDISmdfs3DChildFrame), // MDI child frame > RUNTIME_CLASS(CSmdfs3DView))); > > >Unfortunately when I try to open an .mdfs file it always uses the first >solution (here:IDR_MAPIMAMDFSTYPE) even if I have choosen the second in the >"Files of type" combo box in the Open dialog box. > I think that the problem may come from the code of the >"CDocManager::OpenDocumentFile" function in Docmgr.cpp where it tests the best >match for the different templates. I think it uses only the extension to choose >the best match. > Does anyone know how it works exactly, and how to force it to choose >the way it opens not only with the extension of the file but also with the >parameter defined in the "Files of type" combo box, and finally how to >implement it easily (if possible) ? > Any comment will be helpful. > Thanks > Try using your own File ---> NEW menu. Have the NEW as a popup item. For the popups have one menu item for MAPIMAMDFSTYLE (whatever) and another for SMDFS3D. IE. FILE NEW DOC1 DOC2 Map DOC1 & DOC2 to a handler of your CWinApp. Of course you have have to have 2 pointer object of CMultiDocTemplate (one for each doc type). In the handler just call pDOC1->OpenDocumentFile(NULL); // I think thats what its called // look up members of CMultiDocTemplate ie void myApp::OnNewDoc1() { pDoc1->OpenDocumentFile(NULL); } Hope that helps rahman ******************************************* * Sheir Rahman Ali * * "Licensed Remote Controll Operator" * *******************************************
Roger Onslow -- Roger_Onslow@compsys.com.au Tuesday, June 11, 1996 [Mini-digest: 2 responses] >Environment VC++ 4.0 Windows 95 > > I am trying to merge two different SDI into one general MDI >application. > One of my problem is that some of the images I am trying to read, were >readen in one app as 2D images and as 3D images in the other, and that they >use the file extension ".mdfs". > In order to cope with that,I have defined two different strings in the >ressource String table: > >IDR_MAPIMAMDFSTYPE 130 \nPC Viewer 2D\nPC Viewer 2D\nImages Smdfs 2D > (*.mdfs)\n.MDFS\nMap2D.mdfs\nSmdfs 2D Document >IDR_SMDFS3D 147 \nPC Viewer 3D\nPC Viewer 3D\nImages Smdfs 3D > (*.mdfs)\n.MDFS\nMap3D.mdfs\nSmdfs 3D Document > >and then declared in my initinstance > >///////////// Format de visualisation des images Smdfs 2D >AddDocTemplate(new CMultiDocTemplate(IDR_MAPIMAMDFSTYPE, > RUNTIME_CLASS(CMapImageDoc), > RUNTIME_CLASS(CMDIChildWnd), > RUNTIME_CLASS(CMapImageView))); >///////////// Format de visualisation des images Smdfs 3D >AddDocTemplate(new CMultiDocTemplate(IDR_SMDFS3D, > RUNTIME_CLASS(CSmdfs3DDoc), > RUNTIME_CLASS(CMDISmdfs3DChildFrame), // MDI child frame > RUNTIME_CLASS(CSmdfs3DView))); > > >Unfortunately when I try to open an .mdfs file it always uses the first >solution (here:IDR_MAPIMAMDFSTYPE) even if I have choosen the second in the >"Files of type" combo box in the Open dialog box. The "File of type" only specifies a pattern match for file names to appear in the dialog box. It has no bearing on what how the file is opened, or what type of CDocument is created. Only place where you get a choice is in the FileNew, where you are asked what type of document you want, and then selected correct doc template. > I think that the problem may come from the code of the >"CDocManager::OpenDocumentFile" function in Docmgr.cpp where it tests the best >match for the different templates. I think it uses only the extension to choose >the best match. > Does anyone know how it works exactly, and how to force it to choose >the way it opens not only with the extension of the file but also with the >parameter defined in the "Files of type" combo box, and finally how to >implement it easily (if possible) ? Yes (more of less). > Any comment will be helpful. OpenDocumentFile calls the "MatchDocType" virtual function of the CDocTemplate document template. Define your own template class (derived from CMultiDocTemplate) which overrides this. Unfortunately, this is only given the file name to work from. But if it is possible to determine the file type by looking at some kind of file header, then you could open and read the header part and determine the type from there. Alternatively, if you "know" what type to expect, you can return an appropriately. Or perhaps pop up a message box asking the user what type to file it is? Roger Onslow -----From: George VoronoffIf you have MSDN, there is an article called: "How to Create New Documents Without CWinApp::OnFileNew" You might find some help there. G
| Вернуться в корень Архива |