unit Ereignisprotokoll;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.Buttons,
Vcl.ExtCtrls,
Vcl.Grids;
type
TForm2 =
class(TForm)
StringGrid1: TStringGrid;
Panel1: TPanel;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
uses Hauptformular;
procedure SaveStringGrid(StringGrid: TStringGrid;
const FileName: TFileName);
var
f: TextFile;
i, k: Integer;
begin
AssignFile(f, FileName);
Rewrite(f);
with StringGrid
do
begin
Writeln(f, ColCount);
Writeln(f, RowCount);
for i := 0
to ColCount - 1
do
for k := 0
to RowCount - 1
do
Writeln(F, Trim(Cells[i, k]));
end;
CloseFile(F);
end;
procedure LoadStringGrid(StringGrid: TStringGrid;
const FileName: TFileName);
var
f: TextFile;
iTmp,i,k: Integer;
strTemp:
String;
begin
AssignFile(f, FileName);
Reset(f);
with StringGrid
do
begin
Readln(f, iTmp);
ColCount := iTmp;
Readln(f, iTmp);
RowCount := iTmp;
for i := 0
to ColCount - 1
do
for k := 0
to RowCount - 1
do
begin
Readln(f, strTemp);
Cells[i, k] := strTemp;
end;
end;
CloseFile(f);
end;
procedure TForm2.BitBtn1Click(Sender: TObject);
begin
Form2.Visible := false;
Form1.Bearbeiten1.Enabled := false;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
i, j :integer;
begin
Stringgrid1.ColWidths[0] := 5;
Stringgrid1.ColWidths[1] := 25;
Stringgrid1.ColWidths[2] := 70;
Stringgrid1.ColWidths[3] := 70;
Stringgrid1.ColWidths[4] := 100;
StringGrid1.ColWidths[5] := 1000;
StringGrid1.Cells [1,0] := '
';
StringGrid1.Cells [2,0] := '
Date';
StringGrid1.Cells [3,0] := '
Time';
StringGrid1.Cells [4,0] := '
ID';
StringGrid1.Cells [5,0] := '
Event';
for i := StringGrid1.FixedCols
to StringGrid1.ColCount - 1
do
begin
for j :=StringGrid1.FixedRows
to StringGrid1.RowCount - 1
do
begin
StringGrid1.Cells[i,j] := '
';
end;
end;
LoadStringGrid(StringGrid1, ExtractFilePath(ParamStr(0)) + '
Ereignisprotokoll.dat');
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin
DeleteFile(ExtractFilePath(ParamStr(0)) + '
Ereignisprotokoll.dat');
SaveStringGrid(StringGrid1, ExtractFilePath(ParamStr(0)) + '
Ereignisprotokoll.dat');
end;
end