1.For this tutorial add a memo, a button and a tsavedialog in the form
2.Change the caption of button1 to "save". if you want you can change the line property of tmemo1. for example "The most important thing is to decide the most important thing".
3.Double click on save button and write onclick event:
procedure TForm1.Button1Click( Sender: TObject ); begin if SaveDialog1.Execute then Memo1.Lines.SaveToFile( SaveDialog1.Filename ); end;
4.The Execute method displays the file save dialog. It returns true when user has selected a file, false when user has aborted.
The Filename property returns the full filename.
5.if we want we can make some changes for example let's adda different dialog title. At formcreate event add the following code:procedure TForm1.FormCreate(Sender: TObject); begin saveDialog1.Title := 'Save your love letter as: '; end;6. we can also set the default extension for our file andadd a filter which allow only .txt types to be saved.so we add the follow lines in form create eventsaveDialog1.DefaultExt := 'txt'; //default extension saveDialog1.Filter := 'Text file|*.txt';
don't forget to check the object inspector for further options
Thats all for now!