Sign in Join
Wiki copytemporary

Howto Use TSaveDialog: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-<figure>
2-<img src="tsavedialog.png" title="tsavedialog.png" />
3-<figcaption>tsavedialog.png</figcaption>
4-</figure>
1+![](/wiki-images/e/e1/Tsavedialog.png)
52
63Simple guideline:
74
851. Place the [[TSaveDialog|SaveDialog]] widget ![](/wiki-images/e/e1/Tsavedialog.png) on your [[TForm|form]] (anyplace, since it will be not visible).\
96 ![](/wiki-images/7/72/Component_Palette_Dialogs.png)\
107 (It is the second left dialog under [[Dialogs tab]])
1182. Add a [[TMemo|memo]] ![](/wiki-images/1/1b/Tmemo.png) in the form.
1293. Add a [[TButton|button]] ![](/wiki-images/b/b2/Tbutton.png) in the form.
1310
1411The [[IDE Window: Object Inspector|Object Inspector]] will display the properties of the object Button1. Change a [[Property|property]] named 'Caption', with the displayed value 'Button1' to 'Save'. Click on the Events tab on the Object Inspector. Select the box to the right of OnClick: a smaller box with three dots (... ellipsis) appears. Click on this, you are taken automatically into the Source Editor and your cursor will be placed in a piece of code starting. Completion code:
1512
1613``` pascal
1714
1815procedure TForm1.Button1Click( Sender: TObject );
1916 begin
2017 if SaveDialog1.Execute then
2118 Memo1.Lines.SaveToFile( SaveDialog1.Filename );
2219 end;
2320```
2421
2522The [[doc:lcl/dialogs/tcommondialog.execute.html|Execute]] [[Method|method]] displays the file save dialog. It returns [[True|true]] when user has selected a file, [[False|false]] when user has aborted.
2623
2724The [[doc:lcl/dialogs/tfiledialog.filename.html|Filename]] property returns the full filename including drive and path.
2825
2926> **Note:** This control only collects the filename. It does not actually open the file for writing. Your code must do that.
3027
3128## See also
3229
3330- [[Howto Use TOpenDialog]]
3431- [[CopyFile]]
3532
3633---
3734*From the Free Pascal wiki, page "Howto Use TSaveDialog", as it stood on 2019-09-08 after a change by Djzepi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history