|
From: Peter T. <pe...@us...> - 2003-08-23 23:20:33
|
Update of /cvsroot/jvcl/dev/JVCL3/examples/JvSearchFile
In directory sc8-pr-cvs1:/tmp/cvs-serv5637/JVCL3/examples/JvSearchFile
Added Files:
JvSearchFileMainFormU.dfm JvSearchFileMainFormU.pas
JvSearchFileProj.dpr JvSearchFileProj.res
Log Message:
- Copied jvcl/devtools and jvcl/examples dev/JVCL3
- Copied JVCLConvert *.dat files to dev/JVCL3/converter
--- NEW FILE: JvSearchFileMainFormU.dfm ---
object JvSearchFileMainForm: TJvSearchFileMainForm
Left = 372
Top = 182
AutoScroll = False
Caption = 'JvSearchFiles Demo'
ClientHeight = 318
ClientWidth = 362
Color = clBtnFace
Constraints.MinHeight = 343
Constraints.MinWidth = 370
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object GroupBox1: TGroupBox
Left = 4
Top = 6
Width = 353
Height = 139
Anchors = [akLeft, akTop, akRight]
TabOrder = 0
object Label1: TLabel
Left = 10
Top = 16
Width = 48
Height = 13
Caption = '&Directory:'
FocusControl = JvDirectoryBox1
end
object Label2: TLabel
Left = 8
Top = 44
Width = 47
Height = 13
Caption = '&File mask:'
FocusControl = edFileMask
end
object JvDirectoryBox1: TJvDirectoryEdit
Left = 62
Top = 14
Width = 281
Height = 21
ButtonFlat = False
NumGlyphs = 1
Anchors = [akLeft, akTop, akRight]
TabOrder = 0
Text = 'C:\'
OnChange = OptionsChange
end
object chkRecursive: TCheckBox
Left = 72
Top = 64
Width = 97
Height = 17
Caption = '&Recursive'
Checked = True
State = cbChecked
TabOrder = 2
OnClick = OptionsChange
end
object edFileMask: TEdit
Left = 62
Top = 40
Width = 281
Height = 21
Anchors = [akLeft, akTop, akRight]
TabOrder = 1
Text = '*.*'
OnChange = OptionsChange
end
object cbContainText: TComboBox
Left = 24
Top = 108
Width = 319
Height = 21
Anchors = [akLeft, akTop, akRight]
ItemHeight = 13
TabOrder = 5
OnChange = OptionsChange
end
object rbInclude: TRadioButton
Left = 6
Top = 87
Width = 79
Height = 17
Caption = '&With text:'
Checked = True
TabOrder = 3
TabStop = True
OnClick = OptionsChange
end
object rbExclude: TRadioButton
Left = 132
Top = 87
Width = 113
Height = 17
Caption = 'With&out text:'
TabOrder = 4
OnClick = OptionsChange
end
end
object btnSearch: TButton
Left = 190
Top = 160
Width = 75
Height = 25
Anchors = [akTop, akRight]
Caption = '&Search'
Default = True
ModalResult = 1
TabOrder = 3
OnClick = btnSearchClick
end
object GroupBox2: TGroupBox
Left = 4
Top = 190
Width = 353
Height = 105
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 5
object reFoundFiles: TRichEdit
Left = 6
Top = 12
Width = 341
Height = 87
Anchors = [akLeft, akTop, akRight, akBottom]
PlainText = True
ScrollBars = ssBoth
TabOrder = 0
WordWrap = False
end
end
object btnCancel: TButton
Left = 276
Top = 160
Width = 75
Height = 25
Anchors = [akTop, akRight]
Cancel = True
Caption = '&Cancel'
Enabled = False
ModalResult = 2
TabOrder = 4
OnClick = btnCancelClick
end
object StatusBar1: TStatusBar
Left = 0
Top = 299
Width = 362
Height = 19
Panels = <
item
Text = 'Ready'
Width = 50
end>
SimplePanel = False
end
object chkClearList: TCheckBox
Left = 24
Top = 152
Width = 134
Height = 17
Caption = 'C&lear list before search'
Checked = True
State = cbChecked
TabOrder = 1
end
object chkNoDupes: TCheckBox
Left = 24
Top = 171
Width = 134
Height = 17
Caption = 'Skip d&uplicates'
Checked = True
State = cbChecked
TabOrder = 2
end
object JvSearchFile1: TJvSearchFiles
DirOption = doExcludeInvalidDirs
FileParams.SearchTypes = [stFileMask]
OnBeginScanDir = JvSearchFile1BeginScanDir
OnFindFile = JvSearchFile1FindFile
OnProgress = JvSearchFile1Progress
Left = 234
Top = 72
end
object JvFormStorage1: TJvFormStorage
IniSection = 'Settings'
StoredProps.Strings = (
'edFileMask.Text'
'chkRecursive.Checked'
'JvDirectoryBox1.Text'
'cbContainText.Items'
'cbContainText.Text'
'chkClearList.Checked'
'chkNoDupes.Checked'
'rbInclude.Checked'
'rbExclude.Checked')
StoredValues = <>
Left = 186
Top = 72
end
end
--- NEW FILE: JvSearchFileMainFormU.pas ---
unit JvSearchFileMainFormU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, JvListbox, JvComponent, JvCtrls, JvSearchFiles, Mask, JvToolEdit,
ComCtrls, JvEdit, JvPlacemnt, Menus;
type
TJvSearchFileMainForm = class(TForm)
JvSearchFile1: TJvSearchFiles;
GroupBox1: TGroupBox;
JvDirectoryBox1: TJvDirectoryEdit;
btnSearch: TButton;
Label1: TLabel;
chkRecursive: TCheckBox;
Label2: TLabel;
edFileMask: TEdit;
GroupBox2: TGroupBox;
btnCancel: TButton;
reFoundFiles: TRichEdit;
JvFormStorage1: TJvFormStorage;
StatusBar1: TStatusBar;
chkClearList: TCheckBox;
chkNoDupes: TCheckBox;
cbContainText: TComboBox;
rbInclude: TRadioButton;
rbExclude: TRadioButton;
procedure btnSearchClick(Sender: TObject);
procedure JvSearchFile1FindFile(Sender: TObject; const AName: string);
procedure btnCancelClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure JvSearchFile1BeginScanDir(Sender: TObject;
const AName: String);
procedure OptionsChange(Sender: TObject);
procedure Sort1Click(Sender: TObject);
procedure Clear1Click(Sender: TObject);
procedure JvSearchFile1Progress(Sender: TObject);
private
{ Private declarations }
procedure AddSearchTextToComboBox;
end;
var
JvSearchFileMainForm: TJvSearchFileMainForm;
implementation
uses
JvFunctions;
{$R *.DFM}
procedure TJvSearchFileMainForm.btnSearchClick(Sender: TObject);
begin
btnSearch.Enabled := false;
btnCancel.Enabled := true;
Screen.Cursor := crHourGlass;
try
if chkClearList.Checked then
reFoundFiles.Lines.Clear;
AddSearchTextToComboBox;
JvSearchFile1.Files.Clear;
JvSearchFile1.Directories.Clear;
JvSearchFile1.FileParams.FileMasks.Text := edFileMask.Text;
if chkRecursive.Checked then
JvSearchFile1.DirOption := doIncludeSubDirs
else
JvSearchFile1.DirOption := doExcludeSubDirs;
// don't store file and folder names - we do that in the memo
JvSearchFile1.Options := JvSearchFile1.Options + [soOwnerData];
JvSearchFile1.RootDirectory := JvDirectoryBox1.EditText;
JvSearchFile1.Search;
finally
StatusBar1.Panels[0].Text := Format('(%d matching items found)',[reFoundFiles.Lines.Count]);
btnSearch.Enabled := true;
btnCancel.Enabled := false;
Screen.Cursor := crDefault;
end;
end;
function ContainsText(const Filename,AText:string):boolean;
var S:TMemoryStream;tmp:string;
begin
Result := false;
S := TMemoryStream.Create;
try
S.LoadFromFile(Filename);
if S.Memory <> nil then
begin
tmp := PChar(S.Memory);
tmp := AnsiLowerCase(tmp);
Result := Pos(AnsiLowerCase(AText),tmp) > 0;
end;
finally
S.Free;
end;
end;
procedure TJvSearchFileMainForm.JvSearchFile1FindFile(Sender: TObject;
const AName: string);
begin
StatusBar1.Panels[0].Text := Format('Searching in %s...',[AName]);
StatusBar1.Update;
if (cbContainText.Text <> '') then
if rbInclude.Checked <> ContainsText(AName,cbContainText.Text) then
Exit;
if not chkNoDupes.Checked or (reFoundFiles.Lines.IndexOf(AName) < 0) then
reFoundFiles.Lines.Add(AName);
end;
procedure TJvSearchFileMainForm.btnCancelClick(Sender: TObject);
begin
JvSearchFile1.Abort;
btnCancel.Enabled := false;
end;
procedure TJvSearchFileMainForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
btnCancel.Click;
end;
procedure TJvSearchFileMainForm.FormCreate(Sender: TObject);
begin
JvFormStorage1.IniFileName := ChangeFileExt(Application.ExeName,'.ini');
end;
procedure TJvSearchFileMainForm.JvSearchFile1BeginScanDir(Sender: TObject;
const AName: String);
begin
StatusBar1.Panels[0].Text := Format('Searching in %s...',[ExcludeTrailingPathDelimiter(AName)]);
StatusBar1.Update;
end;
procedure TJvSearchFileMainForm.OptionsChange(Sender: TObject);
begin
rbInclude.Enabled := cbContainText.Text <> '';
rbExclude.Enabled := rbInclude.Enabled;
StatusBar1.Panels[0].Text := 'Ready';
StatusBar1.Update;
end;
procedure TJvSearchFileMainForm.Sort1Click(Sender: TObject);
var S:TStringlist;
begin
S := TStringlist.Create;
try
S.Assign(reFoundFiles.Lines);
S.Sort;
while (S.Count > 0) and (S[0] = '') do S.Delete(0);
reFoundFiles.Lines := S;
finally
S.Free;
end;
end;
procedure TJvSearchFileMainForm.Clear1Click(Sender: TObject);
begin
reFoundFiles.Clear;
end;
procedure TJvSearchFileMainForm.AddSearchTextToComboBox;
begin
with cbContainText do
if (Text <> '') and (Items.IndexOf(Text) < 0) then
Items.Add(Text);
end;
procedure TJvSearchFileMainForm.JvSearchFile1Progress(Sender: TObject);
begin
Application.ProcessMessages;
end;
end.
--- NEW FILE: JvSearchFileProj.dpr ---
program JvSearchFileProj;
uses
Forms,
JvSearchFileMainFormU in 'JvSearchFileMainFormU.pas' {JvSearchFileMainForm};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TJvSearchFileMainForm, JvSearchFileMainForm);
Application.CreateForm(TJvSearchFileMainForm, JvSearchFileMainForm);
Application.Run;
end.
--- NEW FILE: JvSearchFileProj.res ---
(This appears to be a binary file; contents omitted.)
|