Difference between revisions of "Howto Use TSaveDialog"
Miyatakejiro (talk | contribs) |
m (Text replace - "delphi>" to "syntaxhighlight>") |
||
Line 28: | Line 28: | ||
placed in a piece of code starting. Completion code: | placed in a piece of code starting. Completion code: | ||
− | < | + | <syntaxhighlight> |
procedure TForm1.Button1Click( Sender: TObject ); | procedure TForm1.Button1Click( Sender: TObject ); | ||
begin | begin | ||
Line 34: | Line 34: | ||
Memo1.Lines.SaveToFile( SaveDialog1.Filename ); | Memo1.Lines.SaveToFile( SaveDialog1.Filename ); | ||
end; | end; | ||
− | </ | + | </syntaxhighlight> |
The [[doc:lcl/dialogs/tcommondialog.execute.html | Execute]] method displays the file save dialog. It returns [[True|true]] when user has selected a file, [[False|false]] when user has aborted. | The [[doc:lcl/dialogs/tcommondialog.execute.html | Execute]] method displays the file save dialog. It returns [[True|true]] when user has selected a file, [[False|false]] when user has aborted. |
Revision as of 15:31, 24 March 2012
│
Deutsch (de) │
English (en) │
español (es) │
suomi (fi) │
français (fr) │
日本語 (ja) │
polski (pl) │
русский (ru) │
slovenčina (sk) │
Howto Use TSaveDialog
Simple guideline:
1. Place the SaveDialog widget on your form (anyplace, since it will be not visible).
(It is the second left dialog under Dialogs tab)
2. Add a memo in the form.
3. Add a button in the form.
The Object Inspector will display the properties of the object Button1. Change a 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:
procedure TForm1.Button1Click( Sender: TObject );
begin
if SaveDialog1.Execute then
Memo1.Lines.SaveToFile( SaveDialog1.Filename );
end;
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 including drive and path