Print Page | Close Window

Docking Pane’s Layout Serialization

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=1194
Printed Date: 11 December 2024 at 9:14pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Docking Pane’s Layout Serialization
Posted By: singulus
Subject: Docking Pane’s Layout Serialization
Date 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 :)




Replies:
Posted By: Oleg
Date 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


Posted By: singulus
Date 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?

 



Posted By: Oleg
Date 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



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