forked from TES5Edit/TES5Edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmTipForm.pas
109 lines (86 loc) · 1.98 KB
/
frmTipForm.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
unit frmTipForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TfrmTip = class(TForm)
Shape1: TShape;
textTip: TStaticText;
StaticText1: TStaticText;
cbShowTip: TCheckBox;
lblNextTip: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure lblNextTipClick(Sender: TObject);
procedure cbShowTipClick(Sender: TObject);
private
{ Private declarations }
slTips: TStringList;
public
{ Public declarations }
procedure NextTip;
end;
var
frmTip: TfrmTip;
procedure ShowTip;
procedure HideTip;
implementation
{$R *.dfm}
uses
wbInterface;
procedure ShowTip;
begin
if not Assigned(frmTip) then begin
frmTip := TfrmTip.Create(Application);
ShowWindow(frmTip.Handle, SW_SHOWNOACTIVATE);
frmTip.Visible := True;
end;
end;
procedure HideTip;
begin
if Assigned(frmTip) then begin
if frmTip.Visible then frmTip.Hide;
FreeAndNil(frmTip);
end;
end;
procedure TfrmTip.NextTip;
begin
if Assigned(slTips) and (slTips.Count <> 0) then
textTip.Caption := slTips[Random(slTips.Count)];
end;
procedure TfrmTip.lblNextTipClick(Sender: TObject);
begin
NextTip;
end;
procedure TfrmTip.cbShowTipClick(Sender: TObject);
begin
wbShowTip := Assigned(cbShowTip) and cbShowTip.Checked;
end;
procedure TfrmTip.FormCreate(Sender: TObject);
var
TipsFile: string;
i: integer;
begin
TipsFile := ExtractFilePath(Application.ExeName) + wbToolName + 'Tips.txt';
try
if not FileExists(TipsFile) then
Exit;
slTips := TStringList.Create;
slTips.LoadFromFile(TipsFile, TEncoding.UTF8);
if slTips.Count = 0 then
Exit;
for i := Pred(slTips.Count) downto 0 do
if Trim(slTips[i]) = '' then
slTips.Delete(i);
NextTip;
except end;
end;
procedure TfrmTip.FormDestroy(Sender: TObject);
begin
if Assigned(slTips) then
slTips.Free;
end;
initialization
Randomize;
end.