| 1 | Unit SearchDirectoriesFormUnit;
|
|---|
| 2 |
|
|---|
| 3 | Interface
|
|---|
| 4 |
|
|---|
| 5 | Uses
|
|---|
| 6 | Classes,
|
|---|
| 7 | Forms,
|
|---|
| 8 | Buttons,
|
|---|
| 9 | StdCtrls,
|
|---|
| 10 | ACLLanguageUnit,
|
|---|
| 11 | CustomFileControls;
|
|---|
| 12 |
|
|---|
| 13 | Type
|
|---|
| 14 | TSearchDirectoriesForm = Class (TForm)
|
|---|
| 15 | OKButton: TButton;
|
|---|
| 16 | CancelButton: TButton;
|
|---|
| 17 | DirectoriesLabel: TLabel;
|
|---|
| 18 | HelpButton: TButton;
|
|---|
| 19 | AddButton: TButton;
|
|---|
| 20 | AddDirectoryButton: TButton;
|
|---|
| 21 | SubdirectoriesCheckBox: TCheckBox;
|
|---|
| 22 | DirectoryListBox: TCustomDirectoryListBox;
|
|---|
| 23 | DriveComboBox: TCustomDriveComboBox;
|
|---|
| 24 | DirectoriesListBox: TListBox;
|
|---|
| 25 | DriveLabel: TLabel;
|
|---|
| 26 | DirectoryLabel: TLabel;
|
|---|
| 27 | Procedure SearchDirectoriesFormOnSetupShow (Sender: TObject);
|
|---|
| 28 | Procedure AddDirectoryButtonOnClick (Sender: TObject);
|
|---|
| 29 | Procedure SearchDirectoriesFormOnDestroy (Sender: TObject);
|
|---|
| 30 | Procedure AddButtonOnClick (Sender: TObject);
|
|---|
| 31 | Procedure SearchDirectoriesFormOnCreate (Sender: TObject);
|
|---|
| 32 | Procedure OKButtonOnClick (Sender: TObject);
|
|---|
| 33 | Procedure SearchDirectoriesFormOnShow (Sender: TObject);
|
|---|
| 34 | Protected
|
|---|
| 35 | Procedure ShowBrowseControls( Show: boolean );
|
|---|
| 36 |
|
|---|
| 37 | Public
|
|---|
| 38 | {Insert public declarations here}
|
|---|
| 39 | Procedure OnLanguageEvent( Language: TLanguageFile;
|
|---|
| 40 | const Apply: boolean );
|
|---|
| 41 |
|
|---|
| 42 | SelectedFolders: TStringList; // input/output.
|
|---|
| 43 | // On input; if the associated object is non-nil, then
|
|---|
| 44 | // the folder will be displayed as non-selected.
|
|---|
| 45 | CustomDirAdded: boolean; // output
|
|---|
| 46 | End;
|
|---|
| 47 |
|
|---|
| 48 | Var
|
|---|
| 49 | SearchDirectoriesForm: TSearchDirectoriesForm;
|
|---|
| 50 |
|
|---|
| 51 | Implementation
|
|---|
| 52 |
|
|---|
| 53 | Uses
|
|---|
| 54 | ControlsUtility;
|
|---|
| 55 |
|
|---|
| 56 | Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnSetupShow (Sender: TObject);
|
|---|
| 57 | Begin
|
|---|
| 58 | ScaleForm( self, 11, 16 );
|
|---|
| 59 | End;
|
|---|
| 60 |
|
|---|
| 61 | Procedure TSearchDirectoriesForm.AddDirectoryButtonOnClick (Sender: TObject);
|
|---|
| 62 | var
|
|---|
| 63 | Dir: string;
|
|---|
| 64 | i: longint;
|
|---|
| 65 | Begin
|
|---|
| 66 | Dir := DirectoryListBox.Directory;
|
|---|
| 67 | if SubdirectoriesCheckBox.Checked then
|
|---|
| 68 | Dir := Dir + '...';
|
|---|
| 69 |
|
|---|
| 70 | i := DirectoriesListBox.Items.IndexOf( Dir );
|
|---|
| 71 |
|
|---|
| 72 | if i = -1 then
|
|---|
| 73 | begin
|
|---|
| 74 | // not already present...
|
|---|
| 75 | i := DirectoriesListBox.Items.Add( Dir );
|
|---|
| 76 | CustomDirAdded := true;
|
|---|
| 77 | end;
|
|---|
| 78 | DirectoriesListBox.Selected[ i ] := true;
|
|---|
| 79 |
|
|---|
| 80 | DirectoriesListBox.TopIndex := i;
|
|---|
| 81 | End;
|
|---|
| 82 |
|
|---|
| 83 | Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnDestroy (Sender: TObject);
|
|---|
| 84 | Begin
|
|---|
| 85 | SelectedFolders.Destroy;
|
|---|
| 86 | End;
|
|---|
| 87 |
|
|---|
| 88 | // Show or hide controls so they are in the tab order when appropriate
|
|---|
| 89 | Procedure TSearchDirectoriesForm.ShowBrowseControls( Show: boolean );
|
|---|
| 90 | Begin
|
|---|
| 91 | DriveComboBox.Visible := Show;
|
|---|
| 92 | DirectoryListBox.Visible := Show;
|
|---|
| 93 | AddDirectoryButton.Visible := Show;
|
|---|
| 94 | SubdirectoriesCheckBox.Visible := Show;
|
|---|
| 95 | End;
|
|---|
| 96 |
|
|---|
| 97 | Procedure TSearchDirectoriesForm.AddButtonOnClick (Sender: TObject);
|
|---|
| 98 | Begin
|
|---|
| 99 | ShowBrowseControls( true );
|
|---|
| 100 |
|
|---|
| 101 | ClientWidth := DirectoryListBox.Left
|
|---|
| 102 | + DirectoryListBox.Width
|
|---|
| 103 | + DirectoriesListBox.Left; // same margin as left
|
|---|
| 104 | DriveComboBox.Focus;
|
|---|
| 105 |
|
|---|
| 106 | AddButton.Visible := false;
|
|---|
| 107 | End;
|
|---|
| 108 |
|
|---|
| 109 | Procedure TSearchDirectoriesForm.OnLanguageEvent( Language: TLanguageFile;
|
|---|
| 110 | const Apply: boolean );
|
|---|
| 111 | begin
|
|---|
| 112 | Language.LoadComponentLanguage( self, Apply );
|
|---|
| 113 | end;
|
|---|
| 114 |
|
|---|
| 115 | Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnCreate (Sender: TObject);
|
|---|
| 116 | Begin
|
|---|
| 117 | RegisterForLanguages( OnLanguageEvent );
|
|---|
| 118 | ClientWidth := DirectoriesListBox.Left + DirectoriesListBox.Width + DirectoriesListBox.Left;
|
|---|
| 119 |
|
|---|
| 120 | ShowBrowseControls( false );
|
|---|
| 121 |
|
|---|
| 122 | SelectedFolders := TStringList.Create;
|
|---|
| 123 | End;
|
|---|
| 124 |
|
|---|
| 125 | Procedure TSearchDirectoriesForm.OKButtonOnClick (Sender: TObject);
|
|---|
| 126 | var
|
|---|
| 127 | i: longint;
|
|---|
| 128 | begin
|
|---|
| 129 | // SelectedDrives := '';
|
|---|
| 130 | SelectedFolders.Clear;
|
|---|
| 131 | for i := 0 to DirectoriesListBox.Items.Count -1 do
|
|---|
| 132 | begin
|
|---|
| 133 | if DirectoriesListBox.Selected[ i ] then
|
|---|
| 134 | begin
|
|---|
| 135 | SelectedFolders.Add( DirectoriesListBox.Items[ i ] );
|
|---|
| 136 | end;
|
|---|
| 137 | end;
|
|---|
| 138 | end;
|
|---|
| 139 |
|
|---|
| 140 | Procedure TSearchDirectoriesForm.SearchDirectoriesFormOnShow (Sender: TObject);
|
|---|
| 141 | var
|
|---|
| 142 | i: longint;
|
|---|
| 143 | Begin
|
|---|
| 144 | // AddButton.Visible := true;
|
|---|
| 145 | CustomDirAdded := false;
|
|---|
| 146 | OKButton.Default := true;
|
|---|
| 147 |
|
|---|
| 148 | DirectoriesListBox.CLear;
|
|---|
| 149 |
|
|---|
| 150 | for i := 0 to SelectedFolders.Count - 1 do
|
|---|
| 151 | begin
|
|---|
| 152 | DirectoriesListBox.Items.Add( SelectedFolders[ i ] );
|
|---|
| 153 | if SelectedFolders.Objects[ i ] = nil then
|
|---|
| 154 | DirectoriesListBox.Selected[ i ] := true;
|
|---|
| 155 | end;
|
|---|
| 156 | // SelectedFolders
|
|---|
| 157 | // DriveListBox.Clear;
|
|---|
| 158 | // SetAllCheckListItems( DirectoriesListBox, true );
|
|---|
| 159 | // End;
|
|---|
| 160 | End;
|
|---|
| 161 |
|
|---|
| 162 | Initialization
|
|---|
| 163 | RegisterClasses ([TSearchDirectoriesForm, TButton,
|
|---|
| 164 | TLabel, TCustomDirectoryListBox, TCustomDriveComboBox, TListBox, TCheckBox]);
|
|---|
| 165 | End.
|
|---|