|
From: Peter T. <pe...@us...> - 2003-08-24 01:03:17
|
Update of /cvsroot/jvcl/dev/JVCL3/examples/JvLogFile
In directory sc8-pr-cvs1:/tmp/cvs-serv4702/JVCL3/examples/JvLogFile
Added Files:
JvLogFileDemo.dof JvLogFileDemo.dpr JvLogFileDemo.res
JvLogFileMainFormU.dfm JvLogFileMainFormU.pas
Log Message:
- Copied jvcl/devtools and jvcl/examples dev/JVCL3
- Copied JVCLConvert *.dat files to dev/JVCL3/converter
--- NEW FILE: JvLogFileDemo.dof ---
[Directories]
OutputDir=..\..\Bin
UnitOutputDir=..\..\Dcu
SearchPath=..\..\Source;..\..\Common
--- NEW FILE: JvLogFileDemo.dpr ---
program JvLogFileDemo;
uses
Forms,
JvLogFileMainFormU in 'JvLogFileMainFormU.pas' {JvLogFileMainForm};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TJvLogFileMainForm, JvLogFileMainForm);
Application.CreateForm(TJvLogFileMainForm, JvLogFileMainForm);
Application.Run;
end.
--- NEW FILE: JvLogFileDemo.res ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: JvLogFileMainFormU.dfm ---
object JvLogFileMainForm: TJvLogFileMainForm
Left = 382
Top = 192
Width = 421
Height = 300
Caption = 'JvLogFile demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnMouseMove = FormMouseMove
PixelsPerInch = 96
TextHeight = 13
object lblActive: TLabel
Left = 40
Top = 104
Width = 336
Height = 13
Anchors = []
Caption = 'Move the mouse across the form to generate log messages'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = [fsBold]
ParentFont = False
Visible = False
end
object lblInactive: TLabel
Left = 40
Top = 104
Width = 329
Height = 13
Anchors = []
Caption = 'Click on the Start button to start generating log messages'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = [fsBold]
ParentFont = False
end
object btnStart: TButton
Left = 159
Top = 232
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = '&Start'
TabOrder = 0
OnClick = btnStartClick
end
object btnShow: TButton
Left = 239
Top = 232
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = 'S&how'
TabOrder = 1
OnClick = btnShowClick
end
object btnReset: TButton
Left = 319
Top = 232
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = '&Reset'
TabOrder = 2
OnClick = btnResetClick
end
object JvLogFile1: TJvLogFile
Left = 32
Top = 184
end
end
--- NEW FILE: JvLogFileMainFormU.pas ---
unit JvLogFileMainFormU;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, JvComponent, JvLogFile, StdCtrls;
type
TJvLogFileMainForm = class(TForm)
JvLogFile1: TJvLogFile;
btnStart: TButton;
btnShow: TButton;
lblActive: TLabel;
btnReset: TButton;
lblInactive: TLabel;
procedure FormCreate(Sender: TObject);
procedure btnStartClick(Sender: TObject);
procedure btnShowClick(Sender: TObject);
procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure btnResetClick(Sender: TObject);
private
{ Private declarations }
FLogFileName:string;
procedure StartLogging;
procedure StopLogging;
procedure ResetLogging;
end;
var
JvLogFileMainForm: TJvLogFileMainForm;
implementation
{$R *.dfm}
procedure TJvLogFileMainForm.FormCreate(Sender: TObject);
begin
FLogFileName := ChangeFileExt(Application.ExeName,'.log');
end;
procedure TJvLogFileMainForm.btnStartClick(Sender: TObject);
begin
if btnStart.Tag = 0 then
StartLogging
else
StopLogging;
end;
procedure TJvLogFileMainForm.btnShowClick(Sender: TObject);
begin
if btnStart.Tag = 1 then
btnStart.Click; // stop logging
JvLogFile1.ShowLog('Mouse Move Log');
end;
procedure TJvLogFileMainForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if btnStart.Tag = 1 then
JvLogFile1.Add(DateTimeToStr(Now),'Mouse Move',Format('X:%d, Y:%d',[X,Y]));
Caption := Format('JvLogFile Demo - X:%d, Y:%d',[X,Y]);
end;
procedure TJvLogFileMainForm.ResetLogging;
begin
StopLogging;
DeleteFile(FLogFileName);
JvLogFile1.Clear;
end;
procedure TJvLogFileMainForm.StartLogging;
begin
if FileExists(FLogFileName) then
JvLogFile1.LoadFromFile(FLogFileName);
btnStart.Caption := '&Stop';
btnStart.Tag := 1;
lblActive.Visible := true;
lblInactive.Visible := false;
end;
procedure TJvLogFileMainForm.StopLogging;
begin
btnStart.Tag := 0;
lblActive.Visible := false;
lblInactive.Visible := true;
btnStart.Caption := '&Start';
JvLogFile1.SaveToFile(FLogFileName);
end;
procedure TJvLogFileMainForm.btnResetClick(Sender: TObject);
begin
ResetLogging;
end;
end.
|