Sign in Join
Wiki copytemporary

Howto Use TSaveDialog

Deutsch · English · Español · Français · Polski · Slovenčina · Suomi · Русский · 日本語

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:

pascal
 
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.

Note: This control only collects the filename. It does not actually open the file for writing. Your code must do that.

See also


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.

Revision 2, last changed by WikiArchive .

Edited on wiki.freepascal.org by 7 people, 2008–2019

From the official wiki's backup of 26 May 2024: who edited this page there, and when. Edits made there after that date were not recorded, and the earlier versions are not shown here; the main page says why.

WhenWhoWhat changed
DjzepiNew page: Howto Use TSaveDialog Image:tsavedialog.png Simple guideline: 1. Place the SaveDialog widget on your form (anyplace, since it will be not visible). [[Image:Component_Palette_Dial...
Djzepi
Miyatakejiro
VincentText replace - "delphi>" to "syntaxhighlight>" (minor)
Chronos
FTurtle+ categories (minor)
Rfc1394
Rfc1394
BartRemoved a wrong statement. The dialog does in fact have an option to check that a file already exists
Djzepi
Djzepi
Djzepi

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.