Print Page | Close Window

Saving MDI layout

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=19659
Printed Date: 28 March 2024 at 8:46pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Saving MDI layout
Posted By: Andyman
Subject: Saving MDI layout
Date Posted: 17 April 2012 at 4:19am
Hey Guys
Is it possible to save and restore the layout of an MDI application. Eg. In the GUI_VisualStudio example to be able to restore the 3 new view tabs....
 
Cheers
 
 
 



Replies:
Posted By: grahamf
Date Posted: 18 April 2012 at 11:05am
Yes it is. You hammer through the document list and save the document/frame/view information for each. This is a snippet of what our XML 'workspace' file looks like:

<Documents Count="2">
  <Document0 docpath=".\\ELB Sale Pad 2.ksp" docguid="<docprogid1>" doctitle="ELB Sale Pad 2.ksp" docapplet="Sale Pad">
    <Frames Count="1">
      <Frame0 paneid="0">
        <Placement showcmd="1" minposition="-1, -1" maxposition="-4, -23" normalposition="0, -8, 1019, 268"/>
        <Views Count="1">
          <View0 isactive="0" isvisible="1"/>
        </Views>
      </Frame0>
    </Frames>
  </Document0>
  <Document1 docpath=".\\ELB Analysis Pad 2.kap" docguid="<docprogid2>" doctitle="ELB Analysis Pad 2.kap" docapplet="Analysis Pad">
    <Frames Count="1">
      <Frame0 paneid="0">
        <Placement showcmd="1" minposition="-1, -1" maxposition="-1, -1" normalposition="1, 266, 1020, 591"/>
        <Views Count="1">
          <View0 isactive="1" isvisible="1"/>
        </Views>
      </Frame0>
    </Frames>
  </Document1>
</Documents>

The Placement tag is done by deriving a new class from CXTPWindowPos that serialises via DoPropExchange() - why that is there I don't know...

The docguid attribute is the document template progid-like string - necessary only if you use multiple document templates.

The paneid attribute is necessary only if you dock CView derivatives.

The only other thing to note is the path is saved relative to the 'workspace' file itself - that way they can all be picked up and moved/copied to other directories without having to worry about absolute path nonsense.



Posted By: Andyman
Date Posted: 05 December 2012 at 10:38pm
Thanks for the reply Graham. I've only just got around to trying out your suggestion (6 months later, ha!), but I can't get it to work. I was kind of hoping to use the property exchange stuff to save and restore also, but no luck with that either. 

I tried modifying "XtremeToolkit\Samples\ToolkitPro\MDITabWindow" as below...

Left file: C:\Users\amanessis\AppData\Local\Temp\Rar$DR89.840\Samples\ToolkitPro\MDITabWindow\bncvw.cpp
Right file: C:\Source\XtremeToolkit\Samples\ToolkitPro\MDITabWindow\bncvw.cpp
354a355
> static CString str; 
359,367c360,372
< CColorDialog dlgColor(pDoc->m_clrBall);
< if (dlgColor.DoModal() == IDOK)
< {
< pDoc->SetCustomBallColor(dlgColor.GetColor());
< pDoc->ClearAllColors();
< pDoc->m_bCustom = TRUE;
< MakeNewBall();
< }
---
>   
>   /// TEST STUFF...
>   
>   CMainFrame *f = (CMainFrame*)AfxGetMainWnd ();
>   CXTPDockingPaneManager *manager = &f->m_paneManager;
>   CXTPPropExchangeXMLNode px(FALSE, 0, _T("Settings"));
>   if (px.OnBeforeExchange()) 
>     {
>     CXTPPropExchangeSection custom(px.GetSection(_T("CustomLayout")));
>     CXTPPropExchangeSection pxDockingPane(custom->GetSection(_T("DockingPane")));
>     manager->DoPropExchange(&pxDockingPane);
>     str = px.GetEncodedXML();
>     }
469c474,495
---
>   // TEST STUFF...
>   CXTPPropExchangeXMLNode px(TRUE, 0, _T("Settings"));
>   px.LoadFromEncodedString(str);
>   if (px.OnBeforeExchange()) 
>     {
>     CXTPPropExchangeSection sec(px.GetSection(_T("CustomLayout")));  
>     CMainFrame *f = (CMainFrame*)AfxGetMainWnd ();
>     CXTPDockingPaneManager *manager = &f->m_paneManager;
>     CXTPPropExchangeXMLNode px(TRUE, 0, _T("Settings"));
>     if (px.OnBeforeExchange()) 
>       {
>       CXTPPropExchangeSection custom(px.GetSection(_T("CustomLayout")));
>       CXTPPropExchangeSection pxDockingPane(custom->GetSection(_T("DockingPane")));
>       manager->DoPropExchange(&pxDockingPane);
>       manager->RecalcFramesLayout();
>       manager->RedrawWindow();
>       manager->RedrawPanes ();
>       }
>     }
>   return; 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net