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