Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - Docking Pane’s Layout Serialization
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Docking Pane’s Layout Serialization

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


Joined: 16 September 2004
Location: Bulgaria
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote singulus Quote  Post ReplyReply Direct Link To This Post Topic: Docking Pane’s Layout Serialization
    Posted: 21 September 2004 at 5:01am

Hello,

     I need to serialize the docking pane's layout into a CArchive object (e.g. I need to use the classic MFC way of data serialization). However I could not find a way to do this with the support of the XTP Toolkit. I noticed that the layout can only be stored in the system registry. Is there any approach to store the layout in a CArchive? It is really important to serialize the layout this way!

  Thanks to you all :)

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 21 September 2004 at 7:17am

Sorry you only can store it to XML node, then to string, then to archive.

BSTR CDockingPaneCtrl::OleSaveStateToString()
{

 MSXML::IXMLDOMDocumentPtr xmlDocPtr = 0;
 MSXML::IXMLDOMElementPtr xmlRootPtr = 0;

 VERIFY(SUCCEEDED(xmlDocPtr.CreateInstance(MSXML::CLSID _DOMDocument)));

 xmlDocPtr->createElement(_bstr_t(_T("Layout")), &xmlRootPtr);
 xmlDocPtr->appendChild(xmlRootPtr, NULL);
 
 if (xmlRootPtr == 0)
  return FALSE;


 CXTPDockingPaneLayout layout(GetDockingPaneManager());
 GetDockingPaneManager()->GetLayout(&layout);

 layout.SaveToNode(xmlDocPtr, xmlRootPtr, _T("Common"));

 BSTR bstrString = NULL;
 xmlRootPtr->get_xml(&bstrString);

 return bstrString;
}
void CDockingPaneCtrl::OleLoadStateFromString(LPCTSTR lpNode)
{

 MSXML::IXMLDOMDocumentPtr xmlDocPtr = 0;
 MSXML::IXMLDOMElementPtr xmlRootPtr = 0;

 VERIFY(SUCCEEDED(xmlDocPtr.CreateInstance(MSXML::CLSID _DOMDocument)));
 
 VARIANT_BOOL bResult;
 HRESULT hr = xmlDocPtr->loadXML(_bstr_t(lpNode), &bResult);
 if (SUCCEEDED(hr) && bResult == VARIANT_TRUE)
 { 
  xmlDocPtr->get_documentElement(&xmlRootPt r);
  if (xmlRootPtr == 0)
   return;

  BSTR bstrRootName = 0;
  if( FAILED(xmlRootPtr->get_nodeName(&bstrRootName))
   || _bstr_t(_T("Layout")) != _bstr_t(bstrRootName))
  {
   if (bstrRootName) SysFreeString(bstrRootName);
   return;
  }
  if (bstrRootName) SysFreeString(bstrRootName);


  CXTPDockingPaneLayout layout(GetDockingPaneManager());

  if (layout.LoadFromNode(xmlDocPtr, xmlRootPtr, _T("Common")))
  {
   GetDockingPaneManager()->SetLayout(& ;layout);
  }
 }
}

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
singulus View Drop Down
Newbie
Newbie


Joined: 16 September 2004
Location: Bulgaria
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote singulus Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2004 at 3:56am

Thanks, It worked !

There is one more thing about the serialization problem. I need to support serialization versions. There is a problem when the a future version contains more docking panes than the current one. If I deserialize the old version the new version's docking panes won't be created but they should be available since the new version of the product requires them! Is there a way to "merge" the two layouts so the result contains the union of all docking panes?

 

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 23 September 2004 at 4:32am

No. 

You can serialize your version version  to archive and check it before restore layout.

 

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
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.188 seconds.