MFC Serialize: sometimes OK, sometimes not! 
Author Message
 MFC Serialize: sometimes OK, sometimes not!

I have a simple SDI program that tries to save and re-open
a 2-variable file with the following code. It didn't work,
so I reconstructed it and it worked. Then I tried again
and it didn't work. Is there some required developmental
sequence that I'm missing here? Or a problem with Serialize?

void CTestDoc::Serialize(CArchive& ar)
{       if (ar.IsStoring())
        {       ar << m_szTest1;
                ar << m_szTest2;
        }
        else
        {       ar >> m_szTest1;
                ar >> m_szTest2;
        }

Quote:
}



Tue, 25 May 2004 22:46:30 GMT  
 MFC Serialize: sometimes OK, sometimes not!
What do you mean didn't work? What type of variables are you using? I'm
guessing array[]. If they are you will have to use ar.Write() and ar.Read()
since CArchive doesn't handle arrays. Have you stepped through the code in
both cases to see what's in the variables?


Quote:
> I have a simple SDI program that tries to save and re-open
> a 2-variable file with the following code. It didn't work,
> so I reconstructed it and it worked. Then I tried again
> and it didn't work. Is there some required developmental
> sequence that I'm missing here? Or a problem with Serialize?

> void CTestDoc::Serialize(CArchive& ar)
> { if (ar.IsStoring())
> { ar << m_szTest1;
> ar << m_szTest2;
> }
> else
> { ar >> m_szTest1;
> ar >> m_szTest2;
> }
> }



Wed, 26 May 2004 01:08:56 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Listbox: Sometimes allowing multiple selection and sometimes not ?

2. Update to DataRow sometimes works and sometimes not

3. Detach() seems to sometimes not get called on MFC objects such as CDateTimeCtrl

4. WM_CREATE not called sometimes

5. Why does Parameter Info Not show sometimes?

6. Sometimes, Do not respond to command message

7. TCP: Why should send + closesocket sometimes not work?

8. puzzled socket question: send function sometimes works well,sometimes works failed???

9. puzzled socket question: send function sometimes works well,sometimes works failed???

10. puzzled socket question: send function sometimes works well,sometimes works failed???

11. NetworkStream.Write writes "sometimes"

12. V6 Class View sometimes has classes missing

 

 
Powered by phpBB® Forum Software