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. OnOpenDocument same file?

OnOpenDocument same file?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
7 Posts 2 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.
  • K Offline
    K Offline
    Kristian Nilssen
    wrote on last edited by
    #1

    Hi, I have an MFC MDI app. If one user, running one instance of the app opens a file using OnOpenDocument then another user, running another instance of the same app opens the same file, MFC reports "Failure to open document". The app does not edit the file, it's just a viewer, so I don't care if many people are opening the document. How can I tell this to MFC? thanks, Kristian.

    T 1 Reply Last reply
    0
    • K Kristian Nilssen

      Hi, I have an MFC MDI app. If one user, running one instance of the app opens a file using OnOpenDocument then another user, running another instance of the same app opens the same file, MFC reports "Failure to open document". The app does not edit the file, it's just a viewer, so I don't care if many people are opening the document. How can I tell this to MFC? thanks, Kristian.

      T Offline
      T Offline
      Tomasz Sowinski
      wrote on last edited by
      #2

      I've made an empty MFC app using wizard, added some serialization, and can't reproduce the behavior you're describing - two instances can open the same file. Did you override OnOpenDocument? If this is the case, please post the code. Tomasz Sowinski -- http://www.shooltz.com

      K 1 Reply Last reply
      0
      • T Tomasz Sowinski

        I've made an empty MFC app using wizard, added some serialization, and can't reproduce the behavior you're describing - two instances can open the same file. Did you override OnOpenDocument? If this is the case, please post the code. Tomasz Sowinski -- http://www.shooltz.com

        K Offline
        K Offline
        Kristian Nilssen
        wrote on last edited by
        #3

        BOOL CSaturn2Doc::OnOpenDocument(LPCTSTR lpszPathName) { // the following line fails. The serialize function is empty. if (!COleServerDoc::OnOpenDocument(lpszPathName)) return FALSE; blah blah blah... } My document is derived from COleServerDoc.

        T 1 Reply Last reply
        0
        • K Kristian Nilssen

          BOOL CSaturn2Doc::OnOpenDocument(LPCTSTR lpszPathName) { // the following line fails. The serialize function is empty. if (!COleServerDoc::OnOpenDocument(lpszPathName)) return FALSE; blah blah blah... } My document is derived from COleServerDoc.

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          Oooooh - you're using OLE. My experience is limited in this area, all I can advise is stepping inside COleServerDoc::OnOpenDocument and checking which call fails - probably it'll be call to something like StgOpenStorage. Tomasz Sowinski -- http://www.shooltz.com

          K 1 Reply Last reply
          0
          • T Tomasz Sowinski

            Oooooh - you're using OLE. My experience is limited in this area, all I can advise is stepping inside COleServerDoc::OnOpenDocument and checking which call fails - probably it'll be call to something like StgOpenStorage. Tomasz Sowinski -- http://www.shooltz.com

            K Offline
            K Offline
            Kristian Nilssen
            wrote on last edited by
            #5

            That's right, in COleDocument::OnOpenDocument() the call to StgIsStorageFile() fails. I guess I could work around this by copying every document I intend to open to a temporary file but that sucks.

            T 1 Reply Last reply
            0
            • K Kristian Nilssen

              That's right, in COleDocument::OnOpenDocument() the call to StgIsStorageFile() fails. I guess I could work around this by copying every document I intend to open to a temporary file but that sucks.

              T Offline
              T Offline
              Tomasz Sowinski
              wrote on last edited by
              #6

              So is the file your viewer reads a 'compound storage file'? Tomasz Sowinski -- http://www.shooltz.com

              K 1 Reply Last reply
              0
              • T Tomasz Sowinski

                So is the file your viewer reads a 'compound storage file'? Tomasz Sowinski -- http://www.shooltz.com

                K Offline
                K Offline
                Kristian Nilssen
                wrote on last edited by
                #7

                I see where you are going with this. I found a call to EnableCompoundFile() in my document class, which I changed to EnableCompoundFile(FALSE). Now everything is groovy. Thanks. :-D

                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