Sign in Join
Wiki copytemporary

Howto Use TSaveDialog: what changed

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

Title: Howto Use TSaveDialog

OldNewLine
1+<figure>
2+<img src="tsavedialog.png" title="tsavedialog.png" />
3+<figcaption>tsavedialog.png</figcaption>
4+</figure>
5+
6+Simple guideline:
7+
8+1. Place the [[TSaveDialog|SaveDialog]] widget ![](/wiki-images/e/e1/Tsavedialog.png) on your [[TForm|form]] (anyplace, since it will be not visible).\
9+ ![](/wiki-images/7/72/Component_Palette_Dialogs.png)\
10+ (It is the second left dialog under [[Dialogs tab]])
11+2. Add a [[TMemo|memo]] ![](/wiki-images/1/1b/Tmemo.png) in the form.
12+3. Add a [[TButton|button]] ![](/wiki-images/b/b2/Tbutton.png) in the form.
13+
14+The [[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:
15+
16+``` pascal
17+
18+procedure TForm1.Button1Click( Sender: TObject );
19+ begin
20+ if SaveDialog1.Execute then
21+ Memo1.Lines.SaveToFile( SaveDialog1.Filename );
22+ end;
23+```
24+
25+The [[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.
26+
27+The [[doc:lcl/dialogs/tfiledialog.filename.html|Filename]] property returns the full filename including drive and path.
28+
29+> **Note:** This control only collects the filename. It does not actually open the file for writing. Your code must do that.
30+
31+## See also
32+
33+- [[Howto Use TOpenDialog]]
34+- [[CopyFile]]
35+
36+---
37+*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