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. Save as.. and open

Save as.. and open

Scheduled Pinned Locked Moved C / C++ / MFC
comquestion
18 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.
  • A antonio343

    Hi, I'd like to make the button save as.. and load, but I think that maybe this button is made in visual as activeX or something like that. Do you know if it is made already?

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

    antonio343 wrote:

    Do you know if it is made already?

    Oy vey, you want to know how it is made already! :) Anyway, jewish language jokes aside, you add buttons to your dialog though the UI editor in MFC, bring up the toolbar, drag and drop a button where you want it, give it a meaningfull ID, add a handler, add the code. If that is too much, do a basic tutorial in MFC.

    ============================== Nothing to say.

    A A 2 Replies Last reply
    0
    • A antonio343

      I'd like to add this button in a dialog. But I dnt know where are these button or if its ones is already made

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

      What do you mean "already made"? If you are creating an application then you should know that all toolbar or dialog buttons have to be added to the project by you. In both cases the Visual Studio Framework does most of the hard work for you; all you have to do is use the designer to drag items to the right place.

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      1 Reply Last reply
      0
      • L Lost User

        antonio343 wrote:

        Do you know if it is made already?

        Oy vey, you want to know how it is made already! :) Anyway, jewish language jokes aside, you add buttons to your dialog though the UI editor in MFC, bring up the toolbar, drag and drop a button where you want it, give it a meaningfull ID, add a handler, add the code. If that is too much, do a basic tutorial in MFC.

        ============================== Nothing to say.

        A Offline
        A Offline
        Albert Holguin
        wrote on last edited by
        #11

        I remember this user from before stating he was just starting to learn to use MFC plus he's not a native English speaker... So, we need to be patient with the new ones... :)

        A 1 Reply Last reply
        0
        • L Lost User

          antonio343 wrote:

          Do you know if it is made already?

          Oy vey, you want to know how it is made already! :) Anyway, jewish language jokes aside, you add buttons to your dialog though the UI editor in MFC, bring up the toolbar, drag and drop a button where you want it, give it a meaningfull ID, add a handler, add the code. If that is too much, do a basic tutorial in MFC.

          ============================== Nothing to say.

          A Offline
          A Offline
          antonio343
          wrote on last edited by
          #12

          I'm sorry, I didn't understand very well what you said. What do you mean? I have a button in a dialog, which I'd like to be the open botton (Load). I know that in the toolbar there are this button but they haven't code only BEGIN_MESSAGE_MAP(CAdestApp, CWinAppEx) ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) ..

          L 1 Reply Last reply
          0
          • A Albert Holguin

            I remember this user from before stating he was just starting to learn to use MFC plus he's not a native English speaker... So, we need to be patient with the new ones... :)

            A Offline
            A Offline
            antonio343
            wrote on last edited by
            #13

            Could you show me how to use to load/save file with CFileDialog?? I dont find some example

            C 1 Reply Last reply
            0
            • A antonio343

              Could you show me how to use to load/save file with CFileDialog?? I dont find some example

              C Offline
              C Offline
              Chuck OToole
              wrote on last edited by
              #14

              Gotta learn the joy of Google / Bing. Simple search for CFileDialog(), 2nd returned result was a tutorial. CFileDialog()[^] You'd find it a lot faster yourself rather than wait around for somebody to post an answer.

              A 1 Reply Last reply
              0
              • A antonio343

                I'm sorry, I didn't understand very well what you said. What do you mean? I have a button in a dialog, which I'd like to be the open botton (Load). I know that in the toolbar there are this button but they haven't code only BEGIN_MESSAGE_MAP(CAdestApp, CWinAppEx) ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen) ..

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

                So add a handler. In the dialog editor double click the button, this will present you with a class::name() combo, normally you can accept it, but yiou can change the name if you like. CLick OK, then the code will be created for you (empty code, consisting of just the name and perhaps a return). You then add the code you like to this handler to get it to do something interesting.

                ============================== Nothing to say.

                1 Reply Last reply
                0
                • C Chuck OToole

                  Gotta learn the joy of Google / Bing. Simple search for CFileDialog(), 2nd returned result was a tutorial. CFileDialog()[^] You'd find it a lot faster yourself rather than wait around for somebody to post an answer.

                  A Offline
                  A Offline
                  antonio343
                  wrote on last edited by
                  #16

                  I'm triying to do this:

                  void CDlgResultados::SaveToFile(void)
                  {
                  this->UpdateData();

                  CFile f;
                  
                  CString strFilter =\_T("\*.txt");
                  
                  CFileDialog FileDlg(FALSE, \_T(".txt"), NULL, 0, strFilter);
                  
                  if( FileDlg.DoModal() == IDOK )
                  {
                  f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite);
                  	CArchive ar(&f, CArchive::store);
                  
                  	ar << cadena;
                  	ar.Close();
                  }
                  else
                  	return;
                  
                  f.Close();
                  

                  }

                  Everything run well, but it function save the file in the folder of my project and not when I want. what happen?

                  C 1 Reply Last reply
                  0
                  • A antonio343

                    I'm triying to do this:

                    void CDlgResultados::SaveToFile(void)
                    {
                    this->UpdateData();

                    CFile f;
                    
                    CString strFilter =\_T("\*.txt");
                    
                    CFileDialog FileDlg(FALSE, \_T(".txt"), NULL, 0, strFilter);
                    
                    if( FileDlg.DoModal() == IDOK )
                    {
                    f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite);
                    	CArchive ar(&f, CArchive::store);
                    
                    	ar << cadena;
                    	ar.Close();
                    }
                    else
                    	return;
                    
                    f.Close();
                    

                    }

                    Everything run well, but it function save the file in the folder of my project and not when I want. what happen?

                    C Offline
                    C Offline
                    Chuck OToole
                    wrote on last edited by
                    #17

                    GetFileName() only returns the file name portion. GetPathName() returns the whole file specification. See the docs at http://msdn.microsoft.com/en-us/library/5b9c3c1f(v=VS.80).aspx[^]

                    A 1 Reply Last reply
                    0
                    • C Chuck OToole

                      GetFileName() only returns the file name portion. GetPathName() returns the whole file specification. See the docs at http://msdn.microsoft.com/en-us/library/5b9c3c1f(v=VS.80).aspx[^]

                      A Offline
                      A Offline
                      antonio343
                      wrote on last edited by
                      #18

                      Ok, thank you very much Everything run right

                      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