![]() |
Saving MDI layout |
Post Reply ![]() |
Author | |
Andyman ![]() Newbie ![]() Joined: 17 April 2012 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() 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 ![]() |
|
![]() |
|
grahamf ![]() Groupie ![]() ![]() Joined: 29 October 2009 Location: United States Status: Offline Points: 13 |
![]() ![]() ![]() ![]() ![]() |
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. |
|
![]() |
|
Andyman ![]() Newbie ![]() Joined: 17 April 2012 Status: Offline Points: 3 |
![]() ![]() ![]() ![]() ![]() |
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; |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |