Click here to Skip to main content
       

ATL / WTL / STL

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionOpen file in basic MFC appmemberbkelly135 Dec '12 - 14:45 
Visual Studio 2008, Windows 7
I create the basic MFP application with Single or Multiple documents, then immediately compile and run it. Using the File -> Open option I can navigate to and open a file.
 
However, when looking through the code I do not recognize any variable that might be the handle to a file. How do I acces that file I just opened?
Thanks for your time

AnswerRe: Open file in basic MFC appmvpRichard MacCutchan5 Dec '12 - 21:24 
It's a while since I used MFC but I think the actual handle is held internally by the CDocument object. When you open the file the framework should call your OpenFile() method (I think that's its name) and you then load the data from the file using the CArchive object. The skeleton code should be there in your document class.
One of these days I'm going to think of a really clever signature.

GeneralRe: Open file in basic MFC appmemberbkelly139 Dec '12 - 11:36 
A search for OpenFile returned nothing. I looked around for CDocument and CArchive but did not recognize anything that looked like code to open a file.
Thanks for your time

GeneralRe: Open file in basic MFC appmvpRichard MacCutchan9 Dec '12 - 21:36 
I don't know where you were looking, but MSDN details CDocument::OnOpenDocument[^] and CArchive::Read[^] along with all the various other member functions of each class.
One of these days I'm going to think of a really clever signature.

Generalthe answer ismemberbkelly139 Dec '12 - 12:25 
Override OnOpenDocument, in the CDocument class. That function will be called with the selected file path.   You would normally open and read the file there.  
This answer was courtesy MSDN forums.
 
Thanks for your time

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 21 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid