Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CWinApp::OpenDocumentFile
Collapse the table of content
Expand the table of content

CWinApp::OpenDocumentFile

The framework calls this method to open the named CDocument file for the application.

virtual CDocument* OpenDocumentFile(
   LPCTSTR lpszFileName 
   BOOL bAddToMRU = TRUE
);

[in] lpszFileName

The name of the file to be opened.

[in] bAddToMRU

TRUE indicates the document is one of the most recent files; FALSE indicates the document is not one of the most recent files.

A pointer to a CDocument if successful; otherwise NULL.

If a document that has that name is already open, the first frame window that contains that document will get the focus. If an application supports multiple document templates, the framework uses the file name extension to find the appropriate document template to try to load the document. If successful, the document template then creates a frame window and view for the document.

if (m_lpCmdLine[0] == _T('\0'))
{
   // Create a new (empty) document.
   OnFileNew();
}
else
{
   // Open a file passed as the first command line parameter.
   OpenDocumentFile(m_lpCmdLine);
}

Header: afxwin.h

Show:
© 2015 Microsoft