CMDIFrameWndEx::LoadMDIState

Loads the specified layout of MDI Tabbed Groups and the list of previously opened documents.

virtual BOOL LoadMDIState(
   LPCTSTR lpszProfileName 
);

Parameters

  • [in] lpszProfileName
    Specifies the profile name.

Return Value

TRUE if the load succeeded; FALSE if the load failed or there is no data to load.

Remarks

To load or save the state of MDI tabs and groups and the list of opened documents, do the following:

  • Call CMDIFrameWndEx::SaveMDIState when the main frame is being closed

  • Call CMDIFrameWndEx::LoadMDIState when the main frame is being created. The recommended place for this call is before the main frame is displayed for the first time. Add CWinAppEx::EnableLoadWindowPlacement (FALSE); before pMainFrame->LoadFrame (IDR_MAINFRAME);. Add CBCGPWorkspace::ReloadWindowPlacement (pMainFrame); after the call to LoadMDIState to display the main frame at the position that was stored in the registry.

  • Override GetDocumentName in the CMDIChildWndEx- derived class if your application displays documents that are not stored as files. The returned string will be saved in the registry as the document identifier. The base implementation of CMDIChildWndEx::GetDocumentName returns a value obtained from CDocument::GetPathName.

  • Override CMDIFrameWndEx::CreateDocumentWindow to correctly create documents when they are being loaded from the registry. The first parameter is the string that GetDocumentName returned.

Example

The following example shows how LoadMDIState is used in the VisualStudioDemo Sample: MFC Visual Studio Application.

    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);

    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
    {
        if (!pMainFrame->LoadMDIState(GetRegSectionPath()))
        {
            m_pStartDocTemplate->OpenDocumentFile(NULL);
        }
    }
    else
    {
        // Dispatch commands specified on the command line
        if (!ProcessShellCommand(cmdInfo))
            return FALSE;
    }

Requirements

Header: afxMDIFrameWndEx.h

See Also

Reference

CMDIFrameWndEx Class

Hierarchy Chart