SavePictureDialog (Delphi)
From RAD Studio Code Examples
Language:
Description
This code displays a Save Picture dialog box with the TBitmap default extension that is added automatically to files that are given no extension. Confirm that the bitmap file has been saved under the filename and path specified.
Code
procedure TForm1.Button1Click(Sender: TObject); var NewFileName, OldFileName: string; NewFile, OldFile: TFileStream; begin SavePictureDialog1.DefaultExt := GraphicExtension(TBitmap); SavePictureDialog1.Filter := GraphicFilter(TBitmap); OldFileName := 'factory.bmp'; if SavePictureDialog1.Execute then begin NewFileName := SavePictureDialog1.FileName; OldFile := TFileStream.Create( OldFileName, fmOpenRead or fmShareDenyWrite); try NewFile := TFileStream.Create( NewFileName, fmCreate or fmShareDenyRead); try NewFile.CopyFrom(OldFile, OldFile.Size); finally FreeAndNil(NewFile); end; finally FreeAndNil(OldFile); end; end; end; procedure TForm1.FormCreate(Sender: TObject); begin Image1.Picture.LoadFromFile('factory.bmp'); end;
Uses
- Vcl.Graphics.GraphicExtension ( fr | de | ja )
- Vcl.Graphics.GraphicFilter ( fr | de | ja )
- Vcl.Dialogs.TOpenDialog.DefaultExt ( fr | de | ja )
- Vcl.Dialogs.TOpenDialog.Filter ( fr | de | ja )
- Vcl.Dialogs.TOpenDialog.FileName ( fr | de | ja )
- Vcl.ActnList.TCustomAction.Execute ( fr | de | ja )
- System.SysUtils.FreeAndNil ( fr | de | ja )