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. C++ saveFileDialog

C++ saveFileDialog

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
9 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.
  • M Offline
    M Offline
    mmagill0
    wrote on last edited by
    #1

    I am making a text editor in C++ and want it to save rtf an txt files. I have made a rich text box called richTextBox1, a toolstrip button called ToolStripButton1 and a save file dialog called saveFileDialog1. I need the save file dialog to save the contents of the rich text box when the tool strip button is clicked. Here is my code so far: private: System::Void toolStripButton11_Click(System::Object^ sender, System::EventArgs^ e) { saveFileDialog1->Filter="Text File|*.txt|Rich Text Document|*.rtf|All Files|*.*"; saveFileDialog1->Title="Save As"; this->saveFileDialog1->ShowDialog(); } How do I make the dialog save the contents of the rich text box?

    L L D 3 Replies Last reply
    0
    • M mmagill0

      I am making a text editor in C++ and want it to save rtf an txt files. I have made a rich text box called richTextBox1, a toolstrip button called ToolStripButton1 and a save file dialog called saveFileDialog1. I need the save file dialog to save the contents of the rich text box when the tool strip button is clicked. Here is my code so far: private: System::Void toolStripButton11_Click(System::Object^ sender, System::EventArgs^ e) { saveFileDialog1->Filter="Text File|*.txt|Rich Text Document|*.rtf|All Files|*.*"; saveFileDialog1->Title="Save As"; this->saveFileDialog1->ShowDialog(); } How do I make the dialog save the contents of the rich text box?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, the saveFileDialog is a dialog, it communicates with the user, it does not save a thing. Your code has to perform the necessary save actions upon the user's choices. So check for the dialog result, and if "OK", save the data yourself to the selected file. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      1 Reply Last reply
      0
      • M mmagill0

        I am making a text editor in C++ and want it to save rtf an txt files. I have made a rich text box called richTextBox1, a toolstrip button called ToolStripButton1 and a save file dialog called saveFileDialog1. I need the save file dialog to save the contents of the rich text box when the tool strip button is clicked. Here is my code so far: private: System::Void toolStripButton11_Click(System::Object^ sender, System::EventArgs^ e) { saveFileDialog1->Filter="Text File|*.txt|Rich Text Document|*.rtf|All Files|*.*"; saveFileDialog1->Title="Save As"; this->saveFileDialog1->ShowDialog(); } How do I make the dialog save the contents of the rich text box?

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

        mmagill0 wrote:

        How do I make the dialog save the contents of the rich text box?

        You don't; the dialog merely gives the user the opportunity to select the destination file where the data will be saved. Your program then has to write the data into that file in the format relevant to the file type.

        It's time for a new signature.

        M 1 Reply Last reply
        0
        • L Lost User

          mmagill0 wrote:

          How do I make the dialog save the contents of the rich text box?

          You don't; the dialog merely gives the user the opportunity to select the destination file where the data will be saved. Your program then has to write the data into that file in the format relevant to the file type.

          It's time for a new signature.

          M Offline
          M Offline
          mmagill0
          wrote on last edited by
          #4

          so how do I use the information returned from the dialog to save the file?

          J L 2 Replies Last reply
          0
          • M mmagill0

            so how do I use the information returned from the dialog to save the file?

            J Offline
            J Offline
            Joe Woodbury
            wrote on last edited by
            #5

            If ShowDialog() returns DialogResult.OK, use saveFileDialog1->FileName to open file file and write the contents.

            1 Reply Last reply
            0
            • M mmagill0

              I am making a text editor in C++ and want it to save rtf an txt files. I have made a rich text box called richTextBox1, a toolstrip button called ToolStripButton1 and a save file dialog called saveFileDialog1. I need the save file dialog to save the contents of the rich text box when the tool strip button is clicked. Here is my code so far: private: System::Void toolStripButton11_Click(System::Object^ sender, System::EventArgs^ e) { saveFileDialog1->Filter="Text File|*.txt|Rich Text Document|*.rtf|All Files|*.*"; saveFileDialog1->Title="Save As"; this->saveFileDialog1->ShowDialog(); } How do I make the dialog save the contents of the rich text box?

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

              In addition to what's already been suggested, you might receive more help by posting to the correct forum.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              "Man who follows car will be exhausted." - Confucius

              M 1 Reply Last reply
              0
              • D David Crow

                In addition to what's already been suggested, you might receive more help by posting to the correct forum.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                "Man who follows car will be exhausted." - Confucius

                M Offline
                M Offline
                mmagill0
                wrote on last edited by
                #7

                if i'm using winforms with C++, do I post in winforms or C++??

                L 1 Reply Last reply
                0
                • M mmagill0

                  if i'm using winforms with C++, do I post in winforms or C++??

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

                  I think you are fine here; although your program uses Winforms (Managed C++/CLI) your question relates to C++ and Windows API.

                  It's time for a new signature.

                  1 Reply Last reply
                  0
                  • M mmagill0

                    so how do I use the information returned from the dialog to save the file?

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

                    mmagill0 wrote:

                    so how do I use the information returned from the dialog to save the file?

                    The only information you have from the dialog is the file name and destination directory. From this you create the file and write your data to it, the dialog has no further influence on this process.

                    It's time for a new signature.

                    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