Click here to Skip to main content
15,925,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalappear<-> dissapear Pin
gamitech16-Jun-04 0:07
gamitech16-Jun-04 0:07 
GeneralRe: appear<-> dissapear Pin
User 665816-Jun-04 1:15
User 665816-Jun-04 1:15 
Generalfinding mail server Pin
gamitech16-Jun-04 0:05
gamitech16-Jun-04 0:05 
GeneralRe: finding mail server Pin
Henry miller16-Jun-04 3:40
Henry miller16-Jun-04 3:40 
GeneralCArchive & Nested Objects Pin
Anonymous15-Jun-04 23:44
Anonymous15-Jun-04 23:44 
GeneralRe: CArchive & Nested Objects Pin
Weiye Chen15-Jun-04 23:51
Weiye Chen15-Jun-04 23:51 
GeneralRe: CArchive & Nested Objects Pin
Anonymous16-Jun-04 0:10
Anonymous16-Jun-04 0:10 
GeneralRe: CArchive & Nested Objects Pin
Weiye Chen16-Jun-04 3:04
Weiye Chen16-Jun-04 3:04 
Anonymous wrote:
OK but I have one or more CSubject objects and I wish to serialize them all to disk.

Method 1
- Inherit your CSubject from CObject
- Put all your CSubject objects into an array like CObArray
- To save them, call m_oMyObArray.Serialize(...)

Method 2
Assume you have implemented a save function of your CSubject as below:
void CSubject::Save(CArchive& ar)
{
   // Save or load data to or from file
   m_Books.Serialize(ar);
}
Just call Save(...) for each of your CSubject objects, passing in your CArchive object. For example,
void SomeFunction()
{
   CFile oFile;
   if(oFile.Open("C:\\library.dat", CFile::modeCreate | CFile:modeWrite) != FALSE)
   {
      CArchive oArchive(&oFile, CArchive::store);
      oMySubject1.Save(oArchive);
      oMySubject2.Save(oArchive);
      oMySubject3.Save(oArchive);
 
      oArchive.Close();
   }
}


Anonymous wrote:
Is this something that CObject will do for me if all my object data members are simple?

You need to override Serialize for your CBook class. e.g.
void CBook::Serialize(CArchive& oArchive)
{
   if(oArchive.IsStoring() != FALSE)
      oArchive << m_iMyInteger << m_dMyDouble;
 
   else
      oArchive >> m_iMyInteger >> m_dMyDouble;
}



<font=arial>Weiye Chen
When pursuing your dreams, don't forget to enjoy your life...
GeneralRe: CArchive &amp; Nested Objects Pin
Anonymous16-Jun-04 4:08
Anonymous16-Jun-04 4:08 
QuestionCan I protect my process from the task manager's kill signal? Pin
kelkava15-Jun-04 23:25
kelkava15-Jun-04 23:25 
AnswerRe: Can I protect my process from the task manager's kill signal? Pin
toxcct15-Jun-04 23:52
toxcct15-Jun-04 23:52 
AnswerRe: Can I protect my process from the task manager's kill signal? Pin
gamitech16-Jun-04 0:04
gamitech16-Jun-04 0:04 
GeneralRe: Can I protect my process from the task manager's kill signal? Pin
toxcct16-Jun-04 0:12
toxcct16-Jun-04 0:12 
AnswerRe: Can I protect my process from the task manager's kill signal? Pin
David Crow16-Jun-04 3:19
David Crow16-Jun-04 3:19 
GeneralDebugging the spawned process. Pin
Anthony_Yio15-Jun-04 23:15
Anthony_Yio15-Jun-04 23:15 
GeneralRe: Debugging the spawned process. Pin
valikac16-Jun-04 3:29
valikac16-Jun-04 3:29 
GeneralRe: Debugging the spawned process. Pin
Blake Miller16-Jun-04 13:48
Blake Miller16-Jun-04 13:48 
GeneralRe: Debugging the spawned process. Pin
Anthony_Yio16-Jun-04 18:38
Anthony_Yio16-Jun-04 18:38 
GeneralString conversion Pin
Cedric Moonen15-Jun-04 23:13
Cedric Moonen15-Jun-04 23:13 
GeneralRe: String conversion Pin
Anthony_Yio15-Jun-04 23:37
Anthony_Yio15-Jun-04 23:37 
GeneralRe: String conversion Pin
Cedric Moonen15-Jun-04 23:49
Cedric Moonen15-Jun-04 23:49 
GeneralRe: String conversion Pin
Rodrigo Pinto Pereira de Souza16-Jun-04 7:11
Rodrigo Pinto Pereira de Souza16-Jun-04 7:11 
GeneralCEdit.SetWindowText(...); Pin
V.15-Jun-04 22:36
professionalV.15-Jun-04 22:36 
GeneralRe: CEdit.SetWindowText(...); Pin
Dominik Reichl15-Jun-04 22:49
Dominik Reichl15-Jun-04 22:49 
GeneralRe: CEdit.SetWindowText(...); Pin
V.15-Jun-04 22:57
professionalV.15-Jun-04 22:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.