-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathufrmparam.pas
178 lines (152 loc) · 3.73 KB
/
ufrmparam.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
unit UFrmParam;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
Buttons,LCLType,LCLIntf;
type
{ TFrmParam }
TFrmParam = class(TForm)
BtnCancel: TBitBtn;
BtnOk: TBitBtn;
EdtLogin: TLabeledEdit;
EdtChat: TLabeledEdit;
EdtPassword: TLabeledEdit;
TBView: TToggleBox;
procedure BtnCancelKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure EdtKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState);
procedure EdtUTF8KeyPress(Sender:TObject;var UTF8Key:TUTF8Char);
procedure FormKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState);
procedure TBViewChange(Sender:TObject);
procedure EdtNumKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState);
procedure BtnOkClick(Sender:TObject);
procedure BtnCancelClick(Sender:TObject);
private
DigLastChar:Char;
prev_dw:DWORD;
public
Procedure InitCfg;
Procedure LoadCfg;
Procedure Open;
end;
var
FrmParam: TFrmParam;
implementation
Uses
ULog,Main;
{$R *.lfm}
Procedure TFrmParam.InitCfg;
begin
Config.WriteString('base','zurl' ,DefZURL);
Config.WriteString('base','login' ,'');
Config.WriteString('base','oAuth' ,'');
Config.WriteString('base','chat' ,base.chat);
end;
Procedure TFrmParam.LoadCfg;
begin
base.chat :=Trim(Config.ReadString('base','chat' ,base.chat));
base.login :=Trim(Config.ReadString('base','login' ,base.login));
end;
Procedure TFrmParam.Open;
begin
try
EdtLogin.Text :=base.login;
EdtPassword.Text:=Config.ReadString('base','oAuth','');
EdtChat.Text :=base.chat;
except
on E:Exception do
begin
DumpExceptionCallStack(E);
end;
end;
if ShowModal=1 then
begin
base.chat :=EdtChat.Text;
base.login :=EdtLogin.Text;
try
Config.WriteString('base','login' ,base.login);
Config.WriteString('base','oAuth' ,EdtPassword.Text);
Config.WriteString('base','chat' ,base.chat);
except
on E:Exception do
begin
DumpExceptionCallStack(E);
end;
end;
end;
EdtPassword.Text:='';
end;
procedure TFrmParam.EdtKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState);
begin
DigLastChar:=#0;
if [ssAlt,ssCtrl]*Shift=[] then
Case Key of
ord(' '):Key:=0;
96..105:DigLastChar:=Char(Key-48);
ord('A')..ord('Z'):
begin
if (GetKeyState(VK_CAPITAL) and 1)<>0 then
begin
if ssShift in Shift then
Shift:=Shift-[ssShift]
else
Shift:=Shift+[ssShift];
end;
if not (ssShift in Shift) then
DigLastChar:=lowerCase(Char(Key))
else
DigLastChar:=Char(Key);
end;
end;
FormKeyDown(Sender,Key,Shift);
end;
procedure TFrmParam.BtnCancelKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
begin
Case Key of
13:BtnCancelClick(Sender);
end;
end;
procedure TFrmParam.EdtUTF8KeyPress(Sender:TObject;var UTF8Key:TUTF8Char);
begin
if (DigLastChar<>#0) then UTF8Key:=DigLastChar;
end;
procedure TFrmParam.FormKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState);
begin
Case Key of
13:BtnOkClick(Sender);
end;
end;
procedure TFrmParam.TBViewChange(Sender:TObject);
begin
Case TToggleBox(Sender).Checked of
True :EdtPassword.EchoMode:=emNormal;
False:EdtPassword.EchoMode:=emPassword;
end;
Case TToggleBox(Sender).Checked of
True :TToggleBox(Sender).Caption:='*';
False:TToggleBox(Sender).Caption:='a';
end;
end;
procedure TFrmParam.EdtNumKeyDown(Sender:TObject;var Key:Word;Shift:TShiftState);
begin
if [ssAlt,ssCtrl]*Shift=[] then
Case Key of
8,9,37,39:;
ord('0')..ord('9'):;
else
Key:=0;
end;
FormKeyDown(Sender,Key,Shift);
end;
procedure TFrmParam.BtnOkClick(Sender:TObject);
begin
ModalResult:=mrOk;
Hide;
end;
procedure TFrmParam.BtnCancelClick(Sender:TObject);
begin
ModalResult:=mrCancel;
Close;
end;
end.