|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
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
|
|
|
|