Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Saving MDI layout
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Saving MDI layout

 Post Reply Post Reply
Author
Message
Andyman View Drop Down
Newbie
Newbie


Joined: 17 April 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andyman Quote  Post ReplyReply Direct Link To This Post Topic: Saving MDI layout
    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
 
 
 
Back to Top
grahamf View Drop Down
Groupie
Groupie
Avatar

Joined: 29 October 2009
Location: United States
Status: Offline
Points: 13
Post Options Post Options   Thanks (0) Thanks(0)   Quote grahamf Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
Andyman View Drop Down
Newbie
Newbie


Joined: 17 April 2012
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote Andyman Quote  Post ReplyReply Direct Link To This Post 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; 

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.