Print Page | Close Window

Serialize Reportcontrol state to file?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=14864
Printed Date: 09 May 2024 at 7:04pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Serialize Reportcontrol state to file?
Posted By: unknow
Subject: Serialize Reportcontrol state to file?
Date Posted: 29 July 2009 at 4:40pm
Hi. I am developping a MDI application where the document view is a reportcontrol;
 
I don't want to store the reportcontrol state in the registry because it will be possible to set the column names, orders, size etc... for each document.
 
So instead, I would like to store/restore the reportcontrol state from the document itself, I mean storing the state in a section of my document file.
 
Can it be done ? and if possible in text/XML format, not binary;
 
Thankx!!
 



Replies:
Posted By: mdoubson
Date Posted: 31 July 2009 at 11:44am
Sure you can do it yourself - see void CReportSampleView::LoadReportState()

-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 10 August 2009 at 6:44pm
I found that the CReportSampleView class from the ReportSample sample already has the code to serialize to/from file;
 
void CReportSampleView::LoadReportState()
{
#ifdef XML_STATE
 CXTPPropExchangeXMLNode px(TRUE, 0, _T("ReportControl"));
 if (!px.LoadFromFile(_T("c:\\ReportControl.xml")))
  return;
 
But it saves/restore from a single xml file;
 
I would like to save/restore the reportcontrol state from a portion of my XML document, for example it could be placed after my XML data.
 
So now the question is: can I serialize the reportcontrol state from an already opened file?
 
Thankx!


Posted By: mdoubson
Date Posted: 10 August 2009 at 6:46pm
Sure - void LoadReportState(); and void SaveReportState(); app-level functions. You can make your own ones and select needed settings for load and restore and use your own storage mechanism

-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 11 August 2009 at 3:14pm

Thanks for your reply and sorry if I'm a bit "slow" but can I just use the code provided in the CReportSampleView::LoadReportState + CReportSampleView::SaveReportState and read/write from an already opened file in text mode ?

The idea would be to call this code from the document serialize routine;


Posted By: mdoubson
Date Posted: 11 August 2009 at 3:24pm
I think you can - may be with small modifications.

-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 23 August 2009 at 11:45am
Hi! I found that the CXTPPropExchangeXMLNode class provides LoadFromFile and SaveToFile features;
 
It also provides a LoadFromString feature, but NO "SaveToString" ??
 
I would like to serialize the ReportControl state in XML format as part of my document, so it would be much easier for me to load/save from a CString.
 
How can I save the reportstate to a CString ?


Posted By: mdoubson
Date Posted: 24 August 2009 at 12:34am
You can use different ways: e.g.
derive your own MyPropExchangeXMLNode  from CXTPPropExchangeXMLNode,
or
use CXTPPropExchangeXMLNode and call SaveToFile with temp_file_name generated by Windows API and writable under any user restriction, read generated file to your string and after delete this temporary file....
or
use prev idea but with memory file(?)
or ask Oleg to extend base class CXTPPropExchangeXMLNode
or try to use this advice from http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2004-08/1568.html - http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2004-08/1568.html  :
> The save method in IXMLDOMDocument is defined in MSDN as:
>

> HRESULT save(VARIANT destination);
>
> destination [in] : The type of object to save. This object can represent a file name, an ASP Response object, an XML document object, or a custom
> object that supports persistence. See Remarks for more information.
>
> Remarks:
> Any other custom COM object that supports QueryInterface for IStream, IPersistStream, or IPersistStreamInit can also be provided here, and the
> document will be saved accordingly. In the IStream case, the IStream Write method will be called as it saves the document; in the IPersistStream case,
> IPersistStream Load will be called with an IStream that supports the Read,
> Seek, and Stat methods.
>
> If I want to save the XML document to memory, how should I proceed? What value should be assigned to destination? 

Create a COM object that implements the IStream interface. When you call IXMLDOMDocument::save, put your object's IUnknown pointer into the VARIANT's punkVal member. In your COM object, you must implement the methods of the IStream interface. When your Write method is called, you can do anything you want with the bytes that are passed to it, including stuffing them into a memory buffer.
 
 


-------------
Mark Doubson, Ph.D.


Posted By: Oleg
Date Posted: 25 August 2009 at 5:31am
Hi,
 
Use px.GetXML() string to get Node as string.


-------------
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