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 doc/view with non-file-based documents

MFC doc/view with non-file-based documents

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++performance
5 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.
  • T Offline
    T Offline
    Taka Muraoka
    wrote on last edited by
    #1

    I've got a doc/view app where my document contains data *not* stored in a file. How do I create a new document/view pair without passing in a filename to CWinApp::OpenDocumentFile()? I need to attach my in-memory data to the document early on enough in the process for the view to be able to retrieve it in OnInitialUpdate(). Right now I store a pointer to the in-memory data in a global before calling OpenDocumentFile() and the document class constructor picks it up from there but obviously this is not real pretty :-)


    he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

    P 1 Reply Last reply
    0
    • T Taka Muraoka

      I've got a doc/view app where my document contains data *not* stored in a file. How do I create a new document/view pair without passing in a filename to CWinApp::OpenDocumentFile()? I need to attach my in-memory data to the document early on enough in the process for the view to be able to retrieve it in OnInitialUpdate(). Right now I store a pointer to the in-memory data in a global before calling OpenDocumentFile() and the document class constructor picks it up from there but obviously this is not real pretty :-)


      he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

      P Offline
      P Offline
      Prem Kumar
      wrote on last edited by
      #2

      Just process on new document and populate the data in the document. As for the file name just forget it, only visible trace that it is still being used it in the main frame, you can remove it by removing the bit FW_ADDTOTITLE in the mainframe's OnCreate.

      T 1 Reply Last reply
      0
      • P Prem Kumar

        Just process on new document and populate the data in the document. As for the file name just forget it, only visible trace that it is still being used it in the main frame, you can remove it by removing the bit FW_ADDTOTITLE in the mainframe's OnCreate.

        T Offline
        T Offline
        Taka Muraoka
        wrote on last edited by
        #3

        Thanks for the reply. But... 1) Since OpenDocumentFile() only takes a LPCTSTR (the filename), I guess I was asking what is the correct way to pass a pointer to my in-memory data so that the document object gets it when it is eventually created. 2) FWS_ADDTOTITLE only controls whether the MDI child window's title gets included in the main window's title. Clearing it in my document frame class stops the "filename" from appearing in the MDI child windows but MFC uses my application name instead! I haven't yet figured out a way to put *my* title in there.


        he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

        R 1 Reply Last reply
        0
        • T Taka Muraoka

          Thanks for the reply. But... 1) Since OpenDocumentFile() only takes a LPCTSTR (the filename), I guess I was asking what is the correct way to pass a pointer to my in-memory data so that the document object gets it when it is eventually created. 2) FWS_ADDTOTITLE only controls whether the MDI child window's title gets included in the main window's title. Clearing it in my document frame class stops the "filename" from appearing in the MDI child windows but MFC uses my application name instead! I haven't yet figured out a way to put *my* title in there.


          he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

          R Offline
          R Offline
          Roger Allen
          wrote on last edited by
          #4

          If you have a pointer the document template class you can do something like:

          // create an empty document/view
          CMyDocument *pDoc = (CMyDocument*)pDocTemplate->OpenDocumentFile(NULL);

          // make it use my non file data
          pDoc->UseThisData(pYourData);
          pDoc->UpdateAllViews();

          Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

          T 1 Reply Last reply
          0
          • R Roger Allen

            If you have a pointer the document template class you can do something like:

            // create an empty document/view
            CMyDocument *pDoc = (CMyDocument*)pDocTemplate->OpenDocumentFile(NULL);

            // make it use my non file data
            pDoc->UseThisData(pYourData);
            pDoc->UpdateAllViews();

            Roger Allen Sonork 100.10016 In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!

            T Offline
            T Offline
            Taka Muraoka
            wrote on last edited by
            #5

            Tried that. I was hoping to be able to use CWinApp::OpenDocumentFile() since it takes care of the case where the document is already open. Doesn't like a NULL or empty filename, though. I jst thought there might be a Better Way. Oh well :-( Thanks


            he he he. I like it in the kitchen! - Marc Clifton (on being flamed) Awasu v0.4a[^]: A free RSS reader with support for Code Project.

            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