how can i handle file commands to read and write xml files
-
-
Hi I serialized my data in an xml file but how can I open or save them using Document view architecture.I want to read data from document and use it in view. I will be glad if I get a clear answer. Thanks Pathi Gorantla bhikshapathi_g@semanticspace.com
You have to override CDocument::OnOpenDocument and CDocument::OnSaveDocument. Do not call base class implementaion - just open your own file and read/write. Tomasz Sowinski -- http://www.shooltz.com.pl
-
You have to override CDocument::OnOpenDocument and CDocument::OnSaveDocument. Do not call base class implementaion - just open your own file and read/write. Tomasz Sowinski -- http://www.shooltz.com.pl
Yeah I am trying to override OnOpenDocument() but i cant get the data from file into the document.I declared DISPPARAMS pointer in document and trying to get the data read from file into this pointer but getting an error.my aim is to read from file and show it in view. my code is void componentView::fileOpen() { isFileOpen=true; CFileDialog file(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, GetParent()); file.DoModal(); CString filep=file.GetPathName(); BSTR filepath; TCHAR szStringRepresentation[200]; wsprintf ( szStringRepresentation, _T("%s"), filep ); filepath=_bstr_t(szStringRepresentation) ; CClientDC cdc(this); CPen penStroke(PS_SOLID, 1, RGB(0,0,0)); cdc.SelectObject(&penStroke); parse pa; DISPPARAMS var=pa.readFile(filepath); DISPPARAMS *params; params=&var; VARIANT myVars[2]; VariantInit(&myVars [0]); myVars[0].vt=VT_ARRAY|VT_I4; myVars[0]=params->rgvarg[0]; VariantInit(&myVars [1]); myVars[1].vt=VT_ARRAY|VT_I4; myVars[1]=params->rgvarg[1]; SAFEARRAY* SXArray; SAFEARRAY* SYArray; SXArray=myVars[0].parray; SYArray=myVars[1].parray; long lxbound,lybound; long uxbound,uybound; SafeArrayGetLBound(SXArray,1,&lxbound); SafeArrayGetUBound(SXArray,1,&uxbound); SafeArrayGetLBound(SYArray,1,&lybound); SafeArrayGetUBound(SYArray,1,&uybound); VARIANT ptVar; VariantInit(&ptVar); ptVar.vt=VT_BSTR; int i,j,k,l; for(long p=lxbound;p<=uxbound;p++) { SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); i=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); k=strtol(_bstr_t(ptVar.bstrVal),NULL,10); p++; SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); j=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); l=strtol(_bstr_t(ptVar.bstrVal),NULL,10); cdc.MoveTo(i,k); cdc.LineTo(j,l); } } I did in view but how can I read file in document and draw the lines in view? bhikshapathi_g@semanticspace.com
-
Yeah I am trying to override OnOpenDocument() but i cant get the data from file into the document.I declared DISPPARAMS pointer in document and trying to get the data read from file into this pointer but getting an error.my aim is to read from file and show it in view. my code is void componentView::fileOpen() { isFileOpen=true; CFileDialog file(true, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, GetParent()); file.DoModal(); CString filep=file.GetPathName(); BSTR filepath; TCHAR szStringRepresentation[200]; wsprintf ( szStringRepresentation, _T("%s"), filep ); filepath=_bstr_t(szStringRepresentation) ; CClientDC cdc(this); CPen penStroke(PS_SOLID, 1, RGB(0,0,0)); cdc.SelectObject(&penStroke); parse pa; DISPPARAMS var=pa.readFile(filepath); DISPPARAMS *params; params=&var; VARIANT myVars[2]; VariantInit(&myVars [0]); myVars[0].vt=VT_ARRAY|VT_I4; myVars[0]=params->rgvarg[0]; VariantInit(&myVars [1]); myVars[1].vt=VT_ARRAY|VT_I4; myVars[1]=params->rgvarg[1]; SAFEARRAY* SXArray; SAFEARRAY* SYArray; SXArray=myVars[0].parray; SYArray=myVars[1].parray; long lxbound,lybound; long uxbound,uybound; SafeArrayGetLBound(SXArray,1,&lxbound); SafeArrayGetUBound(SXArray,1,&uxbound); SafeArrayGetLBound(SYArray,1,&lybound); SafeArrayGetUBound(SYArray,1,&uybound); VARIANT ptVar; VariantInit(&ptVar); ptVar.vt=VT_BSTR; int i,j,k,l; for(long p=lxbound;p<=uxbound;p++) { SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); i=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); k=strtol(_bstr_t(ptVar.bstrVal),NULL,10); p++; SafeArrayGetElement(SXArray,&p,(&ptVar.bstrVal)); j=strtol(_bstr_t(ptVar.bstrVal),NULL,10); SafeArrayGetElement(SYArray,&p,(&ptVar.bstrVal)); l=strtol(_bstr_t(ptVar.bstrVal),NULL,10); cdc.MoveTo(i,k); cdc.LineTo(j,l); } } I did in view but how can I read file in document and draw the lines in view? bhikshapathi_g@semanticspace.com
> I did in view but how can I read file in document and > draw the lines in view? You should read the file in OnOpenDocument and store the data in your document class. Use this data in overrided OnDraw in view class and draw whatever you want. Tomasz Sowinski -- http://www.shooltz.com.pl