Open a specific file in a MFC single document
-
Hello, Can someone help me figure out how to make my MFC single document application open a specific file type. I created the MFC single document application using the VS C++ 7.0 Wizard. It defaults to open all file types. I found the ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) in MyProject.cpp. How do I customize this so I can open a specific file type such as a .txt? I looked at the scribble example, but that is a multiple document type and I couldn't see how they did this without overriding OnFileOpen(). Is there a better example that I can learn from? I am assuming I am not supposed to overwrite the OnFileOpen, but where is this stored and once I select the file and click OK... Where is the filename stored? What is the correct way to do this? Thanks.
-
Hello, Can someone help me figure out how to make my MFC single document application open a specific file type. I created the MFC single document application using the VS C++ 7.0 Wizard. It defaults to open all file types. I found the ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) in MyProject.cpp. How do I customize this so I can open a specific file type such as a .txt? I looked at the scribble example, but that is a multiple document type and I couldn't see how they did this without overriding OnFileOpen(). Is there a better example that I can learn from? I am assuming I am not supposed to overwrite the OnFileOpen, but where is this stored and once I select the file and click OK... Where is the filename stored? What is the correct way to do this? Thanks.
hi, U have create own Method for ID_FILE_OEPN This will help you.. void CAView::OnFileOpen() { char szFilters[]= "TXT Files (*.txt)|*.txt|Jpeg File (*.jpg)|*.jpg|Gif file (*.gif)|*.gif|"; CFileDialog dlg (true, "txt", "",OFN_OVERWRITEPROMPT, szFilters, this); if (dlg.DoModal()==IDOK){ //Add what u want to do when OK button is pressed } }
-
hi, U have create own Method for ID_FILE_OEPN This will help you.. void CAView::OnFileOpen() { char szFilters[]= "TXT Files (*.txt)|*.txt|Jpeg File (*.jpg)|*.jpg|Gif file (*.gif)|*.gif|"; CFileDialog dlg (true, "txt", "",OFN_OVERWRITEPROMPT, szFilters, this); if (dlg.DoModal()==IDOK){ //Add what u want to do when OK button is pressed } }