Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC - Problem with serialization, previous contents of list is shown when selecting 'new' or 'openfile'

MFC - Problem with serialization, previous contents of list is shown when selecting 'new' or 'openfile'

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++graphicsjson
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simon alec smith
    wrote on last edited by
    #1

    when I execute my simple program that I have implmented serialization with. scenario: I go about drawing a few shapes, which are added to my element list, and then save the file, which it successfuly does but a problem occurs when I select "new" or "open file": The previous content is still shown on 'new' and also with a the opened file: So I have then added code to the mfc-document "onNewDocument()" to delete all the elements in the list. And I have also added the code to remove all the elements as well to the virtual function I have added "OpenDocument" which also works fine. My only problem know is, if I save a document, and then do some extra drwaing, and then try to reload the the last save, the current drawing I am doing, remains, and the saved document remains unseen. Can anybody know why this implkmentation is not working, my understanding that mfc serialzation automatcaly takes care of these automatically Thanks V much if you can help Simon

    B K 2 Replies Last reply
    0
    • S simon alec smith

      when I execute my simple program that I have implmented serialization with. scenario: I go about drawing a few shapes, which are added to my element list, and then save the file, which it successfuly does but a problem occurs when I select "new" or "open file": The previous content is still shown on 'new' and also with a the opened file: So I have then added code to the mfc-document "onNewDocument()" to delete all the elements in the list. And I have also added the code to remove all the elements as well to the virtual function I have added "OpenDocument" which also works fine. My only problem know is, if I save a document, and then do some extra drwaing, and then try to reload the the last save, the current drawing I am doing, remains, and the saved document remains unseen. Can anybody know why this implkmentation is not working, my understanding that mfc serialzation automatcaly takes care of these automatically Thanks V much if you can help Simon

      B Offline
      B Offline
      bob16972
      wrote on last edited by
      #2

      simon alec smith wrote:

      element list

      Display the declaration for this.

      simon alec smith wrote:

      mfc serialzation automatcaly takes care of these automatically

      That depends, what does your implementation of CDocument::Serialize look like?

      1 Reply Last reply
      0
      • S simon alec smith

        when I execute my simple program that I have implmented serialization with. scenario: I go about drawing a few shapes, which are added to my element list, and then save the file, which it successfuly does but a problem occurs when I select "new" or "open file": The previous content is still shown on 'new' and also with a the opened file: So I have then added code to the mfc-document "onNewDocument()" to delete all the elements in the list. And I have also added the code to remove all the elements as well to the virtual function I have added "OpenDocument" which also works fine. My only problem know is, if I save a document, and then do some extra drwaing, and then try to reload the the last save, the current drawing I am doing, remains, and the saved document remains unseen. Can anybody know why this implkmentation is not working, my understanding that mfc serialzation automatcaly takes care of these automatically Thanks V much if you can help Simon

        K Offline
        K Offline
        krmed
        wrote on last edited by
        #3

        You may be approaching this wrong. First, since you didn't say, I'm guessing that you have an SDI application. If that's the case, the document is never destroyed until the application exits. When you choose "new" or "open" the framework calls the CDocument's DeleteContents() function. You need to override that and clean up any previous work or data you may have created - basically, return all values to the point they would be when you first open the application. Hope that helps.

        Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

        modified on Thursday, August 20, 2009 6:32 AM

        S 1 Reply Last reply
        0
        • K krmed

          You may be approaching this wrong. First, since you didn't say, I'm guessing that you have an SDI application. If that's the case, the document is never destroyed until the application exits. When you choose "new" or "open" the framework calls the CDocument's DeleteContents() function. You need to override that and clean up any previous work or data you may have created - basically, return all values to the point they would be when you first open the application. Hope that helps.

          Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

          modified on Thursday, August 20, 2009 6:32 AM

          S Offline
          S Offline
          simon alec smith
          wrote on last edited by
          #4

          thanks, what you said helps Simon

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups