C++ saveFileDialog
-
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?
-
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?
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.
-
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?
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.
-
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.
-
If
ShowDialog()
returnsDialogResult.OK
, usesaveFileDialog1->FileName
to open file file and write the contents. -
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?
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
-
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
-
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.