YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
XD++ Library
DocVizor
TFC Library
Free Products
Technical Support
UCanCode.net


Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


VC++ Article: Opening / Saving multiple types of documents in MFC MDI applications

 
 By BabakTaati. 

A simple Visual C++ 6.0 multiple document (MDI) project that allows opening / saving multiple types of documents.

Introduction

This is a simple visual C++ 6.0 multiple document (MDI) project that allows opening / saving multiple types of documents. Normally, when you start an MDI project, you are allowed to associate one file type (i.e. extension) with your project. If you want to be able to open / save more that one type, you need to change your program a bit (Figure 1). MyFirstProject is a simple empty project that handles multiple types.

Sample Image - MDI_MultipleExtension.jpg

What you need to do

All the altered codes are marked (as //Babak) so you can find them easily and just implement them exactly in your own project. Here is a summary of what you need to do:

  • Derive a class from CDocManager (here named CMultDocManager)
    • Override DoPromptFileName
    • Override OnFileNew
    • You will need to copy _AfxAppendFilterSuffix (with a slight change) from mfc/src/ docmgr.cpp (bad programming style)
  • Derive a class from CMultiDocTemplate (here named CMultMultiDocTemplate)
    (this is so your program can recognize multiple file types seperated by a semicolon
    • Override GetDocString
    • Override MatchDocType

(for the last two steps, just add the files MultDocManager.h/cpp and MultMultiDocTemplate.h/cpp to your project)

  • Set m_pDocManager of your main application class (the one that is derived from CWinApp) to new CmultDocManager
  • Open the .rc file of the project and make copies of IDR_...TYPE (for various file types)
  • Go through all the projcet files and everytime IDR_...TYPE is used, also use the new ones you made
  • Override DoSave in your main document class (the one that is derived from CDocument)

References

  • MFC Document/View documentation and enhancements” by Roger Allen on CodeProject.com
  • “How to support two file extensions per MFC document type” Micorosft support document Article ID 141921
  • “DocMgrEx.exe Assoc Multiple File Extension w/2 Doc Tyle” Micorosft support document Article ID 198538
  • “Selecting multiple files in File Open dialog” by Kaus Gutter on CodeGuru.com
  • Opening multiple documents of several types at once” by Ernesto Perales Soto on CodeProject.com

 

Copyright ?1998-2007 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net