Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AcidInjury

MFC Serialize() not being called

This topic is 5416 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Works fine for me. How are you testing for Serialize? Did you try using a break point instead of a message box?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!