Share via


CMDIChildWndEx::GetDocumentName

Returns the name of the document that is displayed in the MDI child window.

virtual LPCTSTR GetDocumentName(
   CObject** pObj 
);

Return Value

A pointer to a string that contains the name of a document.

Remarks

A document is what the MDI child window displays. Generally, the window displays data that is loaded from or saved to a file. Therefore, the name of the document is the name of the file. The default implementation of GetDocumentName returns a string obtained from CDocument::GetPathName.

If the window displays a document that is not loaded from a file, override this method in a derived class and return a unique document identifier.

GetDocumentName is called by the framework when it saves the state of all opened documents. The returned string is written to the registry.

When the framework is restoring state later, the document name is read from the registry and passed to CMDIFrameWndEx::CreateDocumentWindow. Override this method in a CMDIFrameWndEx-derived class and create or open a document that has this name and read in the file that has this name. If the document is not based on a file, create the document based on the document identifier itself. You should do the preceding actions only if you intend to save and restore documents.

Example

The following example demonstrates the use of the GetDocumentName method. This code snippet comes from the VisualStudioDemo Sample: MFC Visual Studio Application.

LPCTSTR CChildFrame::GetDocumentName(CObject** pObj)
{
    if (DYNAMIC_DOWNCAST(CStartView, GetActiveView()) != NULL)
    {
        return g_strStartViewName;
    }
    return CMDIChildWndEx::GetDocumentName(pObj);
}

Requirements

Header: afxMDIChildWndEx.h

See Also

Concepts

MFC Hierarchy Chart

Reference

CMDIChildWndEx Class