-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmDeveloperMessageForm.pas
205 lines (176 loc) · 4.97 KB
/
frmDeveloperMessageForm.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
unit frmDeveloperMessageForm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls,
JvExStdCtrls, JvRichEdit, FileContainer, JvHtControls;
type
TdmChoice = (dmcPatreon, dmcKoFi, dmcPayPal);
TfrmDeveloperMessage = class(TForm)
reMain: TJvRichEdit;
fcMessage: TFileContainer;
fcMessageThanks: TFileContainer;
pnlElminster: TPanel;
imgElminster: TImage;
fcImage: TFileContainer;
tmrEnableButton: TTimer;
pnlBottom: TPanel;
btnOops: TButton;
cbDontShowAgain: TCheckBox;
btnCancel: TButton;
btnOK: TButton;
btnKoFi: TButton;
btnPayPal: TButton;
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnOopsClick(Sender: TObject);
procedure tmrEnableButtonTimer(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure btnKoFiClick(Sender: TObject);
procedure btnPayPalClick(Sender: TObject);
private
procedure FixZoom;
public
Choice : TdmChoice;
end;
implementation
{$R *.dfm}
uses
wbInterface,
frmViewMain,
Vcl.Styles.Utils.SystemMenu;
procedure TfrmDeveloperMessage.FixZoom;
var
i, CharCount : Integer;
pt : TPoint;
begin
if RichEditVersion >= 3 then begin
reMain.Zoom := reMain.Zoom - 1;
reMain.SelLength := 0;
reMain.SelStart := 100000;
i := reMain.SelStart;
reMain.SelText := #13#13;
reMain.SelStart := 100000;
CharCount := reMain.SelStart;
pt := reMain.GetCharPos(CharCount);
while pt.Y < reMain.Height do begin
reMain.Zoom := reMain.Zoom + 1;
pt := reMain.GetCharPos(CharCount);
end;
while pt.Y > reMain.Height do begin
reMain.Zoom := reMain.Zoom - 1;
pt := reMain.GetCharPos(CharCount);
end;
while pt.Y < reMain.Height do begin
reMain.Zoom := reMain.Zoom + 1;
pt := reMain.GetCharPos(CharCount);
end;
while pt.Y > reMain.Height do begin
reMain.Zoom := reMain.Zoom - 1;
pt := reMain.GetCharPos(CharCount);
end;
pt := reMain.GetCharPos(80);
pnlElminster.Top := reMain.Top + 10;
pnlElminster.Height := pt.y - 20;
pnlElminster.Width := pnlElminster.Height;
pnlElminster.Left := (reMain.Left + reMain.Width) - (pnlElminster.Width + 10);
reMain.SelStart := i;
reMain.SelLength := 1000;
reMain.SelText := '';
reMain.SelStart := 0;
end else
pnlElminster.Visible := False;
end;
procedure TfrmDeveloperMessage.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if not (btnCancel.Enabled or (ModalResult = mrOk)) then
Action := caNone;
end;
procedure TfrmDeveloperMessage.FormCreate(Sender: TObject);
var
Stream: TStream;
begin
wbApplyFontAndScale(Self);
Stream := fcImage.CreateReadStream;
try
imgElminster.Picture.LoadFromStream(Stream);
finally
Stream.Free;
end;
if wbPatron then begin
btnOops.Visible := True;
cbDontShowAgain.Caption := '&Don''t show again until changed';
Stream := fcMessageThanks.CreateReadStream
end else begin
btnOops.Visible := False;
cbDontShowAgain.Caption := '&Don''t show again for a while';
Stream := fcMessage.CreateReadStream;
end;
try
reMain.Lines.LoadFromStream(Stream);
finally
Stream.Free;
end;
if wbThemesSupported then
with TVclStylesSystemMenu.Create(Self) do begin
ShowNativeStyle := True;
MenuCaption := 'Theme';
end;
end;
procedure TfrmDeveloperMessage.FormShow(Sender: TObject);
begin
tmrEnableButton.Enabled := True;
FixZoom;
end;
procedure TfrmDeveloperMessage.btnOKClick(Sender: TObject);
begin
Choice := dmcPatreon;
end;
procedure TfrmDeveloperMessage.btnOopsClick(Sender: TObject);
var
Stream: TStream;
begin
wbPatron := False;
LockWindowUpdate(Handle);
try
btnOops.Visible := False;
btnOK.Visible := True;
btnKoFi.Visible := True;
btnPayPal.Visible := True;
btnOK.Enabled := True;
btnKoFi.Enabled := True;
btnPayPal.Enabled := True;
btnOK.Default := True;
btnCancel.Default := False;
cbDontShowAgain.Caption := '&Don''t show again for a while';
cbDontShowAgain.Left := 0;
btnCancel.Left := cbDontShowAgain.Left + cbDontShowAgain.Width + 5;
btnOK.Left := btnCancel.Left + btnCancel.Width + 5;
btnKoFi.Left := btnOK.Left + btnOK.Width + 5;
btnPayPal.Left := btnKoFi.Left + btnKoFi.Width + 5;
Stream := fcMessage.CreateReadStream;
try
reMain.Lines.LoadFromStream(Stream);
finally
Stream.Free;
end;
FixZoom;
finally
LockWindowUpdate(0);
end;
end;
procedure TfrmDeveloperMessage.btnKoFiClick(Sender: TObject);
begin
Choice := dmcKoFi;
end;
procedure TfrmDeveloperMessage.btnPayPalClick(Sender: TObject);
begin
Choice := dmcPayPal;
end;
procedure TfrmDeveloperMessage.tmrEnableButtonTimer(Sender: TObject);
begin
tmrEnableButton.Enabled := False;
btnCancel.Enabled := True;
end;
end.