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. I need help

I need help

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
8 Posts 5 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.
  • F Offline
    F Offline
    Filomela
    wrote on last edited by
    #1

    I have a program and in InitInstance i call a dialog in which i specify a file name for creating a new file and then i create this file calling CWinApp::FileNew.I need to know this file name in My doc class, more exactly in OnNewDocument.How can I do this? I desperately need help.F1!!!!!!!!My time is very short.

    M M V D 4 Replies Last reply
    0
    • F Filomela

      I have a program and in InitInstance i call a dialog in which i specify a file name for creating a new file and then i create this file calling CWinApp::FileNew.I need to know this file name in My doc class, more exactly in OnNewDocument.How can I do this? I desperately need help.F1!!!!!!!!My time is very short.

      M Offline
      M Offline
      mirex
      wrote on last edited by
      #2

      you should be available to get it through ((CYourMainAppClassNameHere*)AfxGetApp())->your_dialog_variable_name.string_variable, and you should update string variable on every change of file name hope it helps at least a little

      F 1 Reply Last reply
      0
      • F Filomela

        I have a program and in InitInstance i call a dialog in which i specify a file name for creating a new file and then i create this file calling CWinApp::FileNew.I need to know this file name in My doc class, more exactly in OnNewDocument.How can I do this? I desperately need help.F1!!!!!!!!My time is very short.

        M Offline
        M Offline
        Mahendra_786
        wrote on last edited by
        #3
        1. After you get the file name from the Dialog create the file using CFile or whatever. 2) In your (added) OnNewDocument function call SetPathName(""); e.g. BOOL CMyDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: add reinitialization code here // (SDI documents will reuse this document) SetPathName("c:\\temp\\a.txt"); // c:\temp\a.txt should exist! return TRUE; } This will not display a Save Dialog when you select "Save" from the File menu. If I have not misunderstood your question this should help! Due Regards Mahendra
        1 Reply Last reply
        0
        • F Filomela

          I have a program and in InitInstance i call a dialog in which i specify a file name for creating a new file and then i create this file calling CWinApp::FileNew.I need to know this file name in My doc class, more exactly in OnNewDocument.How can I do this? I desperately need help.F1!!!!!!!!My time is very short.

          V Offline
          V Offline
          vijayaramaraju
          wrote on last edited by
          #4

          the other responses are correct. my understanding of your statement is you are unable to access the file name from the My Doc class. one way to do this would be declare a variable in your CMyWinApp class and copy the value of the path into it now you can access this variable from your doc class by using. (CMyWinApp*)AfxGetApp()->variable

          1 Reply Last reply
          0
          • F Filomela

            I have a program and in InitInstance i call a dialog in which i specify a file name for creating a new file and then i create this file calling CWinApp::FileNew.I need to know this file name in My doc class, more exactly in OnNewDocument.How can I do this? I desperately need help.F1!!!!!!!!My time is very short.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            So you are naming the file before the app starts as opposed to when it (or the document) ends? Is there a design reason for this, or am I missing something? Normally in an SDI or MDI application, the name of the file is selected when the document is closing (i.e., if IsModified() returns non-zero).


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            F 1 Reply Last reply
            0
            • D David Crow

              So you are naming the file before the app starts as opposed to when it (or the document) ends? Is there a design reason for this, or am I missing something? Normally in an SDI or MDI application, the name of the file is selected when the document is closing (i.e., if IsModified() returns non-zero).


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              F Offline
              F Offline
              Filomela
              wrote on last edited by
              #6

              Yes,this is what my boss is asking.

              1 Reply Last reply
              0
              • M mirex

                you should be available to get it through ((CYourMainAppClassNameHere*)AfxGetApp())->your_dialog_variable_name.string_variable, and you should update string variable on every change of file name hope it helps at least a little

                F Offline
                F Offline
                Filomela
                wrote on last edited by
                #7

                How can i update string variable on every change of file name? Thanks a lot.

                M 1 Reply Last reply
                0
                • F Filomela

                  How can i update string variable on every change of file name? Thanks a lot.

                  M Offline
                  M Offline
                  mirex
                  wrote on last edited by
                  #8

                  Edit box in which you enter the string should have an property function OnEdit or OnChange, which is called everytime when string is changed. Override this function and inside it call UpdateData(); which should update string variable to its current status.

                  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