dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Loading and restoring MDI groups

  1. #1
    Join Date
    Jan 2009
    Posts
    270

    Loading and restoring MDI groups

    I have an example of MDI app, where I tried to save and then restore a MDI tab group. And the example id from microsoft: RibbonMDIDemo ... but simply not working:
    Code:
    	CCommandLineInfo cmdInfo;
    	ParseCommandLine(cmdInfo);
    
    	OnFileNew();
    	OnFileNew();
    	OnFileNew();
    	OnFileNew();
    
    	if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
    	{
    		if (! pMainFrame->LoadMDIState(GetRegSectionPath()))
    		{
    			if (! ProcessShellCommand(cmdInfo))
    				return FALSE;
    		}
    	}
    	else
    	{
    		// Dispatch commands specified on the command line
    		if (! ProcessShellCommand(cmdInfo))
    			return FALSE;
    	}
    and
    Code:
    BOOL CRibbonMDIDemoApp::SaveAllModified()
    {
    	if (!CWinAppEx::SaveAllModified ())
    	{
    		return FALSE;
    	}
    
    	CMDIFrameWndEx* pMainFrame = DYNAMIC_DOWNCAST (CMDIFrameWndEx, m_pMainWnd);
    	if (pMainFrame != NULL)
    	{
    		pMainFrame->SaveMDIState(GetRegSectionPath ());
    	}
    
    	return TRUE;
    }
    now, if I move some view in another tab group, and when I close the app, why this secnod tab group is not saved ? I attach the demo project, which is from microsoft in fact: RibbonMDI.zip

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,836

    Re: Loading and restoring MDI groups

    Debug your app. Step into
    LoadMDIState
    SaveMDIState
    GetRegSectionPath

    and see what the methods are saving into the registry to find what data is missing. Also, do you need to add a second SaveMDIState/LoadMDIState pair on the window that isn't getting saved?

  3. #3
    Join Date
    Jan 2009
    Posts
    270

    Re: Loading and restoring MDI groups

    Yes, I noticed that views must be saved in order to be saved, but I don't know why this is not happen every run test ... and how can I save/restore views that, as you said, haven't been saved ? Let say I am display something that could not be saved ...
    Last edited by mesajflaviu; December 6th, 2018 at 08:21 AM.

  4. #4
    Join Date
    Jan 2009
    Posts
    270

    Re: Loading and restoring MDI groups

    If I would handle the saving and restoring of opened documents on my own, how can I open a new document/view in a specific tab group ?

    Later edit: I guess is not a good idea, I should not re-invent the wheel ... I only need to find how to use it
    Last edited by mesajflaviu; December 6th, 2018 at 08:48 AM.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,836

    Re: Loading and restoring MDI groups

    Quote Originally Posted by mesajflaviu View Post
    Yes, I noticed that views must be saved in order to be saved, but I don't know why this is not happen every run test ... and how can I save/restore views that, as you said, haven't been saved ? Let say I am display something that could not be saved ...
    Put breakpoints on the Load and Save MDIState methods. Then debug by manipulating the view that works. When the break points get hit, use the call stack window to back up the stack to notice the chain of method calls that initially invoke the load or save. Next compare with the views that don't work to find out what code is missing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)