Use summary SaveDialog controls the basic controls of Delphi

First, drag the form to Form a SaveDialog control , Name property to: dlgSave, then add a button, Caption property to: browse, Name property to: btnBrowse.

Then double-click on the Browse button to add the following code:

Procedure Tfoffertool.btnbrowseClick (Sender: TObject);
 var 
  filePath: String ; 
 
the begin 
  dlgSave.Title: = ' Save the file path ' ;            // set the browse dialog title name 
  dlgSave.Filter: = ' text files (* .dbf) | * .dbf ' ;   // set to save the file extension 
  dlgSave.DefaultExt: = ' .dbf ' ;               // extension is automatically added as a save file name 
  IF dlgSave.Execute the then 
  the begin 
    filePath: = Trim (dlgSave.FileName);      // get the save path 
    ShowMessage (filePath);
  end 
end ;

Note: dlgSave.DefaultExt: = '.dbf'; and his party realize that we just fill in the name of the default save file name extension: .dbf; of course we can own a given.

If you want to specify other file formats:

open a file:

dlgOpen.Filter = "(*.txt)|*.txt|(*.doc;*.docx;*.xls;*.xlsx)|*.doc;*.docx;*.xls;*.xlsx|(*.jpg;*.png;*.gif;*.bmp;*.jpeg)|*.jpg;*.png;*.gif;*.bmp;*.jpeg"t|(*.doc;*.docx;*.xls;*.xlsx)|*.doc;*.docx;*.xls;*.xlsx|(*.jpg;*.png;*.gif;*.bmp;*.jpeg)|*.jpg;*.png;*.gif;*.bmp;*.jpeg";
save document:
dlgSave->Filter = "(*.txt)|*.txt|(*.doc;*.docx;*.xls;*.xlsx)|*.doc;*.docx;*.xls;*.xlsx|(*.jpg;*.png;*.gif;*.bmp;*.jpeg)|*.jpg;*.png;*.gif;*.bmp;*.jpeg";

 

Guess you like

Origin www.cnblogs.com/jijm123/p/10992953.html