Freigeben über


CWinApp::OpenDocumentFile

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

virtual CDocument* OpenDocumentFile(
   LPCTSTR lpszFileName 
);

Parameters

  • lpszFileName
    The name of the file to be opened.

Return Value

A pointer to a CDocument if successful; otherwise NULL.

Remarks

If a document with that name is already open, the first frame window that contains that document will be activated. If an application supports multiple document templates, the framework uses file extension to find the appropriate document template to attempt 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

Concepts

CWinApp Class

CWinApp Members

Hierarchy Chart