How to implement an import command
Posted on 1998-08-17
I need to implement an import command in my MDI application but I cannot figure out how to do it using the MFC serialization mechanism. My application needs to import files coming from different machines (these files have no extension). I have tried to follow the tips given in the Technical note 22:
"One common customization of ID_FILE_OPEN is to customize the FileOpen
dialog or add additional file filters. The recommended way to customize
this is to replace the default implementation with your own FileOpen
dialog, and call CWinApp::OpenDocumentFile with the document's file or path
name. There is no need to call the base class."
I have followed this procedure but without success. This is the code:
//In this dialog, the user must set in the m_fileType member variable
//the file format.
//Later, the MyDoc::Serialize function will use this variable to proceed.
I have discovered that when CMyApp::OnFileOpen is overrided, the CMyDoc::Serialize function is not called so I cannot do something as follows:
void MyDoc::Serialize (CArchive& ar)
// Storing code
// Reading code
if (m_FileType== FILE_TYPE_A)
//import doc A
if (m_FileType== FILE_TYPE_B)
//import doc B
What am I doing wrong?
Might be there is a best way to implement an import option, but I don't really know how.