home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 March
/
Chip_2002-03_cd1.bin
/
zkuste
/
delphi
/
kompon
/
d5
/
WAKFMON.ZIP
/
Demo1
/
Unit1.pas
< prev
Wrap
Pascal/Delphi Source File
|
2001-10-25
|
3KB
|
115 lines
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, FileCtrl, filemon10, mon_thread10;
type
TForm1 = class(TForm)
DirBox: TEdit;
StartBtn: TButton;
StopBtn: TButton;
CheckBox1: TCheckBox;
Label1: TLabel;
Label2: TLabel;
BrowseBtn: TButton;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
FileMonitor: TFileMonitor;
SubDirChkBox: TCheckBox;
ActiveLabel: TLabel;
procedure BrowseBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure CheckBoxChange(Sender: TObject);
procedure StartBtnClick(Sender: TObject);
procedure StopBtnClick(Sender: TObject);
procedure FileMonitorChange(Sender: TObject);
procedure FileMonitorStart(Sender: TObject);
procedure FileMonitorStop(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BrowseBtnClick(Sender: TObject);
var
S: string;
begin
SelectDirectory('Select Directory', 'C:\', S);
DirBox.Text := IncludeTrailingBackslash(S);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
with FileMonitor do
begin
// Set up the attribute check boxes
CheckBox1.Checked := (fcFileName in AttrFlags);
CheckBox2.Checked := (fcDirName in AttrFlags);
CheckBox3.Checked := (fcFileAttr in AttrFlags);
CheckBox4.Checked := (fcFileSize in AttrFlags);
CheckBox5.Checked := (fcFileWriteTime in AttrFlags);
CheckBox6.Checked := (fcFileAccessTime in AttrFlags);
CheckBox7.Checked := (fcSecurity in AttrFlags);
end;
end;
procedure TForm1.CheckBoxChange(Sender: TObject);
begin
with FileMonitor do
begin
// Set up attributes according check boxes
AttrFlags := [];
if CheckBox1.Checked then AttrFlags := AttrFlags + [fcFileName];
if CheckBox2.Checked then AttrFlags := AttrFlags + [fcDirName];
if CheckBox3.Checked then AttrFlags := AttrFlags + [fcFileAttr];
if CheckBox4.Checked then AttrFlags := AttrFlags + [fcFileSize];
if CheckBox5.Checked then AttrFlags := AttrFlags + [fcFileWriteTime];
if CheckBox6.Checked then AttrFlags := AttrFlags + [fcFileAccessTime];
if CheckBox7.Checked then AttrFlags := AttrFlags + [fcSecurity];
end;
end;
procedure TForm1.StartBtnClick(Sender: TObject);
begin
FileMonitor.Directory := DirBox.Text;
FileMonitor.SubDirs := SubDirChkBox.Checked;
FileMonitor.Active := true;
end;
procedure TForm1.StopBtnClick(Sender: TObject);
begin
FileMonitor.Active := false;
end;
procedure TForm1.FileMonitorChange(Sender: TObject);
begin
MessageDlg('A change has occured', mtInformation, [mbOK], 0);
end;
procedure TForm1.FileMonitorStart(Sender: TObject);
begin
if FileMonitor.Active then ActiveLabel.Visible := true; // To check that it was successfully turned off
end;
procedure TForm1.FileMonitorStop(Sender: TObject);
begin
// if FileMonitor.Active = false then ActiveLabel.Visible := false;
end;
end.