MFC Serialize() not being called

Started by
3 comments, last by AcidInjury 20 years, 3 months ago
I tried to bring my problem down to the most simple case, so heres what I got. I generated an MFC application using the Classwizard. It generates the CAppDoc class which inherits from CDocument, nothing special. It also generates the override: virtual void Serialize(CArchive& ar); That function contains one if statement: if(ar.IsStoring()) I''m sure many of you have seen this all numeruous times. My problem is that the Serialize function is never being called. I added a MessageBox call to the top of the function and it never executes. I looked at the MSDN site and it says that Serialize() is called whenever an Open, Save, or Save As menu command is processed. Again, this neer happens. Can anyone guide me toward the light? It would seem that if the classwizard was going to generate a function, it would have some use... BTW I am using Visual Studio.net Thanks, Will
Advertisement
Works fine for me. How are you testing for Serialize? Did you try using a break point instead of a message box?
I just now tried a break point, got no result with that either. When I run the program I click File->Open and select the file. This should trigger the Serialize() function.

I downloaded a project that someone else wrote in VC6.0 and that program triggered serialize as expected. I cannot find any difference between their project and mine.

Does anyone know if this problem is being caused by the .net framework. From what I have read .net changes the way objects are serialized, but I have tried those methods too (which BTW aren''t much different from what I can find).

Grr... Maybe i''ll forget about serializing and write my own code handled by OnOpenDocument, OnNewDocument, etc...

Will
It isn''t .NET, I''m using .NET and everything runs fine for me.

In your app class, what does your message handler look like? And is IMPLEMENT_DYNCREATE is used in your doc class?
Here is the Message Handler.

BEGIN_MESSAGE_MAP(CSerTestApp, CWinApp)	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)	// Standard file based document commands	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)	// Standard print setup command	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)END_MESSAGE_MAP()


and yes I am using IMPLEMENT_DYNCREATE in the doc class. I also tried IMPLEMENT_SERIAL which didn''t help at all.

Will

This topic is closed to new replies.

Advertisement