Compartir a través de


CWinApp::OpenDocumentFile

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

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

Parameters

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

Return Value

A pointer to a CDocument if successful; otherwise NULL.

Remarks

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.

Example

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);
}

Requirements

Header: afxwin.h

See Also

Reference

CWinApp Class

Hierarchy Chart

Other Resources

CWinApp Members