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. Opening a new document

Opening a new document

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 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.
  • A Offline
    A Offline
    Andrew Bleakley
    wrote on last edited by
    #1

    How do I open a new document in a MDI app without using CView::OnFileNew(). The app supports multiple doc's and I want to be able to open new one's from anywhere. I am sure it is simple. Thank you in advance.

    V R J 3 Replies Last reply
    0
    • A Andrew Bleakley

      How do I open a new document in a MDI app without using CView::OnFileNew(). The app supports multiple doc's and I want to be able to open new one's from anywhere. I am sure it is simple. Thank you in advance.

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      One solution is CStdioFile. Kuphryn

      1 Reply Last reply
      0
      • A Andrew Bleakley

        How do I open a new document in a MDI app without using CView::OnFileNew(). The app supports multiple doc's and I want to be able to open new one's from anywhere. I am sure it is simple. Thank you in advance.

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

        You need a pointer to the document template you want to open a document for. In MFC these templates are stored in a CDocManager class object pointer which is part of your CWinApp object. You could do this: CDocManager *pDocMan = AfxGetApp()->m_pDocManager; POSITION pos ; pos = pDocMan->GetFirstDocPosition(); while (pos) { CDocTemplate *pTemplate = pDocMan->GetNextTemplate(pos); pTemplate->OpenDocumentFile(filename); // or NULL ofr an empty document } I may have some of the function names wrong here as its from memory. 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!

        1 Reply Last reply
        0
        • A Andrew Bleakley

          How do I open a new document in a MDI app without using CView::OnFileNew(). The app supports multiple doc's and I want to be able to open new one's from anywhere. I am sure it is simple. Thank you in advance.

          J Offline
          J Offline
          Jamie Hale
          wrote on last edited by
          #4

          Roger has one way of doing it... We use CWinApp::OpenDocumentFile(LPCTSTR lpszFileName). Does the same thing, but automatically. :) J

          May the bear never have cause to eat you.

          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