Serializing data..

This is a mfc dialog based application.
The execution of this program starts when InitInstance() starts and ends when
InitInstance() returns. I need to make certain members(strings) of the application object(theApp) serializable. I used
DECLARE_SERIAL(CLogMasterAMApp) in the
class, and
IMPLEMENT_SERIAL(CLogMasterAMApp, CWinApp, 1) in the implementation file.
I overrode the serialize function.
I performed a test by putting msg boxes
in the storing and loading parts of the serialize function, and it appears that
the serialize function itself is not being called by the framework.
Is there something I did wrong or something I should have done?
The framework calls serialize before
InitInstance() right?
Any help would be appreciated..

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

   I do not believe the framework calls Serialize before InitInstance.  You must do an Open or Save operation.
   The only other thing I can think of is to correctly serialize an object, you must
   1.  Define a constructor with no parameters
   2.  Do not override IsSerializable
   3.  Call base-class Serialize BEFORE you try to load/retrieve data.

Do the following things

in application .h file

         // protected constructor used by dynamic creation
Add a cfile member
CFile *m_pfile;

in application .cpp

in the constructor
m_pfile = new CFile;

Map the serilize function the app class.

Add the following in the initinstance before the DoModal()

BOOL Open = pfile->Open("c:\\end.TXT", CFile :: modeRead);
  CArchive ar(pfile, CArchive :: store, 4096, NULL);
  CObject :: Serialize(ar);
  CLogMasterAMApp::Serialize(ar) ;

where end.TXT is file in to which U will be serializing the data.

In the serialize function  U can store in to this file in
If(Storing )
 ar << something; // where something is a member variabl in //app class

Hope this helps

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

BOOL Open = pfile->Open("c:\\end.TXT", CFile :: modeRead);
BOOL Open = pfile->Open("c:\\end.TXT", CFile :: modeWrite);

cManAuthor Commented:
hank you. your code helped me to resolve
my problem.
U are Welcome

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.