Partilhar via


CMDIFrameWndEx::SaveMDIState

Saves the current layout of MDI Tabbed Groups and the list of previously opened documents.

virtual BOOL SaveMDIState(
   LPCTSTR lpszProfileName 
);

Parameters

  • [in] lpszProfileName
    Specifies the profile name.

Return Value

TRUE if the save succeeded; FALSE if the save failed.

Remarks

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

  • Call SaveMDIState when the main frame is being closed

  • Call CMDIFrameWndEx::LoadMDIState when the main frame is being created. The recommended location for this call is before the main frame is displayed for the first time.

  • Call CWinAppEx::EnableLoadWindowPlacement(FALSE); before pMainFrame->LoadFrame (IDR_MAINFRAME);

  • Call CWinAppEx::ReloadWindowPlacement(pMainFrame) after 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 a document identifier. For more information, see CMDIChildWndEx::GetDocumentName.

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

Example

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

void CMainFrame::OnClose()
{
    SaveMDIState(theApp.GetRegSectionPath());
    CMDIFrameWndEx::OnClose();
}

Requirements

Header: afxMDIFrameWndEx.h

See Also

Reference

CMDIFrameWndEx Class

Hierarchy Chart