where : ibrtses delphi

Delphi - open- & savedialog

disclaimer

the source code of this page may not appear correctly in certain browsers
due to special characters. Have a look at the source of this HTML page
with notepad instead


Creating your own opendialog, savedialog is rather trivial :

It can be made as modal popup, or when processing files as always visible component.
As modal popup form : create a new form, give it a caption.
As always visible component : place a TGroupBox on the form, set the caption.

used components

Place a TDriveComboBox (DriveComboBox1), 
      a TDirectoyListBox (DirectoryListBox1) 
      a TFileListBox (FileListBox1)
onto the form or onto the groupbox.

For a modal dialog, at least a button has to be added : TButton (caption='Ok')

link the components

The components have to know each other.

Set the DriveComboBox's DirList to the DirectoyListBox .
 DriveComboBox1.DirList:=DirectoryListBox1;    // to be done in the property inspector
Set the DirectoyListBox's FileList to the FileListBox
 DirectoryListBox1.FileList:=FileListBox1;    // to be done in the property inspector
Set the FileListBox's Mask to your likeing
 FileListBox1.Mask:='*.jpg';		      // to be done in the property inspector
For a SaveDialog add a TEdit (Edit1) and set the FileListBox's FileEdit to the TEdit
 FileListBox1.FileEdit:=Edit1;		     // to be done in the property inspector

Now the events

The used components are now linked such that when the directory changes, the filelist is reloaded, and when the drive changes, the directorylist and the filelist are reloaded.
The real code comes now.

Visually processing a selected file

When just processing single selected files use the Filelistbox's onchange or onclick to do whatever to be done.
 procedure TForm1.FilelistboxClick(sender..);
 begin
  if filelistbox1.itemindex>=0 then begin
   process_file(filelistbox1.filename);
  end;
 end;

processing all files in a directory

When processing all files in a directory, use a FOR loop :
For i:=0 to filelistbox1.items-1 do begin
  filelistbox1.itemindex:=i;
  process_file(filelistbox1.filename);
 end;

modal dialog

For a modal dialog, a button was added : TButton (caption='Ok') This button starts the processing.
procedure TForm2.ButtonClick(sender..);
 begin
  if filelistbox1.itemindex>=0 then begin
   process_file(filelistbox1.filename);
  end;
  close;
 end;





Feedback is welcome




sponsored links





Delphi
home

last updated: 4.june.99

Copyright (99,2000) Ing.Büro R.Tschaggelar