Click to See Complete Forum and Search --> : Serialize Help


klins
October 30th, 2006, 05:46 PM
I am beginner in visual c++ . I am using it for my coursework to develop a simple CAD software that draw lines, rectangles , arcs with rubber banding effects etc etc. My program works fine when minimize , maximizze window , update all views. Problem happens when i try to use serialize to save my drawings in the program that i created. When i retrieved the drawing, the program will automatically draw an extra lines. For example when idrew 5 lines, after i load the drawing, it became 6 lines .

Variable in Document class
int Numlines - as an array index and to save # of lines
CPoint FPoint[numlines] - line start point;
CPoint LPoint[numlines] - line end point ;

I set that the each end point as the next line FPoint.

I hope i can get help from anyone of u . More info can be given .

MrViggy
October 30th, 2006, 05:58 PM
Post your serialization function.

Viggy

klins
October 30th, 2006, 07:11 PM
void Cproject1Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
int i;
ar<<NumLines;
for (i=0;i<=NumLines;i++)
{ar<<FPoint[i]<<LPoint[i];}

else
{
// TODO: add loading code here
int i;
ar>>NumLines;
for (i=0;i<=NumLines;i++){ar>>FPoint[i]>>LPoint[i];}

klins
October 30th, 2006, 07:12 PM
above is my serizliez function .. pls pls pls . I duno wat the problem is .