-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGFTipDlgForm.pas
106 lines (93 loc) · 2.31 KB
/
GFTipDlgForm.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
{ GF ver 1.0 }
unit GFTipDlgForm;
interface
{$I gf_base.inc}
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, gf_misc, gf_miscvcl;
type
TGFTipForm = class(TForm)
TipPanel: TPanel;
ShowChk: TCheckBox;
Button_OK: TButton;
Button_Next: TButton;
Button_Prev: TButton;
TipLbl: TLabel;
Image_Hint: TImage;
TipTitleLbl: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button_NextClick(Sender: TObject);
procedure Button_PrevClick(Sender: TObject);
procedure Button_OKClick(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
Tips : TStrings;
CurrentTip : integer;
CRLF : string;
IsRandom : boolean;
OriginalCaptionText : string;
end;
var
GFTipForm: TGFTipForm;
implementation
{$R *.DFM}
procedure TGFTipForm.FormCreate(Sender: TObject);
begin
if _TahomaFontInstalled then
Font.Name := 'Tahoma';
Tips := TStringList.Create;
end;
procedure TGFTipForm.FormDestroy(Sender: TObject);
begin
Tips.Free;
end;
procedure TGFTipForm.Button_NextClick(Sender: TObject);
var
i : integer;
begin
if IsRandom then
begin
Randomize;
i := Round(Random(Tips.Count-1));
if (i = CurrentTip) and (Tips.Count > 1) then Inc(i);
CurrentTip := i;
end
else
begin
if CurrentTip < Tips.Count-1 then
Inc(CurrentTip)
else
CurrentTip := 0;
end;
TipLbl.Caption := Tips[CurrentTip];
Caption := Format( '%s - %d of %d', [OriginalCaptionText,CurrentTip+1,Tips.Count] );
end;
procedure TGFTipForm.Button_PrevClick(Sender: TObject);
begin
if CurrentTip = 0 then
CurrentTip := Tips.Count-1
else
Dec(CurrentTip);
TipLbl.Caption := Tips[CurrentTip];
Caption := Format( '%s - %d of %d', [OriginalCaptionText,CurrentTip+1,Tips.Count] );
end;
procedure TGFTipForm.Button_OKClick(Sender: TObject);
begin
Close;
end;
procedure TGFTipForm.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ( key = 27 ) and ( shift = [] ) then
begin
key := 0;
Close;
end;
end;
end.