-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuhistory.pas
124 lines (102 loc) · 2.7 KB
/
uhistory.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
unit uhistory;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ValEdit,
CheckLst, ExtCtrls, StdCtrls;
type
{ TFrmHistory }
TFrmHistory = class(TForm)
CheckListBox1: TCheckListBox;
Edit1: TEdit;
lbHistory: TLabel;
Panel1: TPanel;
procedure CheckListBox1ItemClick(Sender: TObject; Index: integer);
procedure CheckListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure CheckListBox1SelectionChange(Sender: TObject; User: boolean);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Limpa;
private
public
procedure Add( cStr: String );
end;
var
FrmHistory: TFrmHistory;
implementation
{$R *.lfm}
{ TFrmHistory }
procedure TFrmHistory.FormCreate(Sender: TObject);
begin
if FileExists( ExtractFilePath( Application.ExeName ) + 'history.sys' ) then
begin
CheckListBox1.Items.LoadFromFile( ExtractFilePath( Application.ExeName ) + 'history.sys' );
end;
end;
procedure TFrmHistory.FormShow(Sender: TObject);
var
i: integer;
begin
for i:= 0 to CheckListBox1.Items.count-1 do
begin
ChecklistBox1.Checked[i]:= false;
end;
end;
procedure TFrmHistory.CheckListBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i: Integer;
begin
lbHistory.caption:= '';
if Key = 13 then
begin
if CheckListBox1.SelCount > 0 then
begin
for i:= 0 to CheckListBox1.Items.count-1 do
begin
if CheckListBox1.Selected[i] then
lbHistory.caption:= CheckListBox1.Items[i];
end;
end;
ModalResult:= mrOk;
end
else if Key = 10 then
ModalResult:= mrOk
else if Key = 27 then
ModalResult:= mrCancel;
end;
procedure TFrmHistory.CheckListBox1SelectionChange(Sender: TObject;
User: boolean);
var
i: integer;
begin
for i:= 0 to CheckListBox1.Items.count-1 do
begin
if CheckListBox1.Checked[i] then
lbHistory.caption:= CheckListBox1.Items[i];
end;
end;
procedure TFrmHistory.CheckListBox1ItemClick(Sender: TObject; Index: integer);
begin
end;
procedure TFrmHistory.Limpa;
begin
CheckListBox1.Items.Clear;
CheckListBox1.Items.SaveToFile( ExtractFilePath( Application.ExeName ) + 'history.sys' );
end;
procedure TFrmHistory.Add( cStr: String );
var
lMore: Boolean;
begin
lMore:= False;
if CheckListBox1.Items.count >0 then
begin
lMore:= True;
end;
if not lMore then
CheckListBox1.Items.Insert( 0, cStr )
else if ( trim( CheckListBox1.Items[0] ) <> trim( cStr ) ) then
CheckListBox1.Items.Insert( 0, cStr );
CheckListBox1.Items.SaveToFile( ExtractFilePath( Application.ExeName ) + 'history.sys' );
end;
end.