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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC SDI application: opening documents

MFC SDI application: opening documents

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hey How do I access the files that I select when I goto "Open" in an MFC built SDI app? What is the string of the path, or how can I then open that file for reading?? AND How can I stop the default "new file" on start up, and get it to wait for a document to be specified to open? Please help a desparate newbie! :) Tim T

    L 1 Reply Last reply
    0
    • L Lost User

      Hey How do I access the files that I select when I goto "Open" in an MFC built SDI app? What is the string of the path, or how can I then open that file for reading?? AND How can I stop the default "new file" on start up, and get it to wait for a document to be specified to open? Please help a desparate newbie! :) Tim T

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Come on guys, this is really important to me! Please!

      S 1 Reply Last reply
      0
      • L Lost User

        Come on guys, this is really important to me! Please!

        S Offline
        S Offline
        Stephen McGeown
        wrote on last edited by
        #3

        OK! In your new app, go to the class wizard, select the object ID called "ID_FILE_OPEN". Then click on the COMMAND text in the box marked "Messages". Next, click "Add function" and it'll prompt you to name the function - probably "OnFileOpen". It will generate a member function called OnFileOpen() somewhere in your code, probably as part of your mainframe class. So, you find your OnFileOpen() function, which will be empty except for some comments like "Add your command handler code here". Add some code like this to your OnFileOpen() function: { CString strFilter; CString path; FILE *myfile; CFileDialog MyFileDialog(TRUE, "*.txt", NULL, NULL, "Text file (*.txt)|*.txt" ); /* Display the File Dialog box */ int result = MyFileDialog.DoModal(); /* Return the path (including filename) */ path = MyFileDialog.GetPathName(); /* Open it up */ myfile = fopen(path, "r"); /* etc...*/ } Haven't tested this out but it might be worth a bash. As for your second question, no idea but I've noticed that the behaviour differs between Win9x and Win NT. Hope it helps. Cheers.

        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