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 VC++ 6.0

MFC VC++ 6.0

Scheduled Pinned Locked Moved C / C++ / MFC
c++questioncomtutorial
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.
  • L Offline
    L Offline
    LOSTTWARE com
    wrote on last edited by
    #1

    I used MFC wizzard to create a mdi application. I have the common app.cpp view.cpp doc.cpp mainfraim.cpp and child.cpp along with a hundred add ons. I couldn't find a good File new template chooser so I am making one from scratch. I am at the point where the user presses OK, on the type he wants. I simply want to open from a read only file, like a template I create. Kinda like if I were to click File Open. I wasn't sure how to do this, so I looked at how the application was set up to open a file. All it has is: BOOL CFDPDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // TODO: return TRUE; } Well, that is the only real code that it has on File open, I just want to make a similar instance to open only that template I will make. How do I do that? thanks guys LOSTTWARE.com

    L 1 Reply Last reply
    0
    • L LOSTTWARE com

      I used MFC wizzard to create a mdi application. I have the common app.cpp view.cpp doc.cpp mainfraim.cpp and child.cpp along with a hundred add ons. I couldn't find a good File new template chooser so I am making one from scratch. I am at the point where the user presses OK, on the type he wants. I simply want to open from a read only file, like a template I create. Kinda like if I were to click File Open. I wasn't sure how to do this, so I looked at how the application was set up to open a file. All it has is: BOOL CFDPDoc::OnOpenDocument(LPCTSTR lpszPathName) { if (!CDocument::OnOpenDocument(lpszPathName)) return FALSE; // TODO: return TRUE; } Well, that is the only real code that it has on File open, I just want to make a similar instance to open only that template I will make. How do I do that? thanks guys LOSTTWARE.com

      L Offline
      L Offline
      LOSTTWARE com
      wrote on last edited by
      #2

      Well, I really need someones help on this. Basically all I want to do is make a function that instead of opens a file that the user chooses, I can right the file it opens into that function. How do I write a function that does that with my MDI application? Josh

      A R 2 Replies Last reply
      0
      • L LOSTTWARE com

        Well, I really need someones help on this. Basically all I want to do is make a function that instead of opens a file that the user chooses, I can right the file it opens into that function. How do I write a function that does that with my MDI application? Josh

        A Offline
        A Offline
        Antti Keskinen
        wrote on last edited by
        #3

        So you need a function that instead of opening the file a user chooses, it opens the file stream into a function ? Easy, just override the necessary message (ID_FILE_NEW or a custom message), create a CFile object, use it to open the designated file (OPENFILENAME struct) and off you go. You can now use the object to read/write data from the attached file. Is this what you want ? If not, you'd need to write a bit more clearer on what you need accomplishing. Remember to check your posts before posting them. Make sure they have no grammar or word bugs in them, so they are easy to understand. Misunderstanding issues are a huge problem in this field :) -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.

        1 Reply Last reply
        0
        • L LOSTTWARE com

          Well, I really need someones help on this. Basically all I want to do is make a function that instead of opens a file that the user chooses, I can right the file it opens into that function. How do I write a function that does that with my MDI application? Josh

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

          If I understand correctly you have many CDocTemplate objects registered in your application, and you want to open a specific document type? You can do that by getting a pointer to the correct CDocTemplate object and calling OpenDocumentFile() on it. Pass NULL to open an empty document, or pass a filename if you need to open an existing file. If you need to do this from an existing open document and need to open the same type of document, you can call GetDocTemplate(0 to get the CDocTemplate pointer you need. If not, then you need to acquire a pointer to it through the CWinApp:m_pDocManager pointer. You can iterate the list of CDocTemplate objects using GetFirstDocTemplatePosition() and GetNextDocTemplate(). When you find the right one (if you know which one it is) you can proceed from there. This article of mine may also be of help: Doc/View stuff[^] Roger Allen - Sonork 100.10016 If your dead and reading this, then you have no life!

          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