-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUnitNewCode.pas
More file actions
167 lines (148 loc) · 3.81 KB
/
UnitNewCode.pas
File metadata and controls
167 lines (148 loc) · 3.81 KB
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
unit UnitNewCode;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Buttons, IniFiles, ComCtrls;
type
TnewCode = class(TForm)
RadioGroup1: TRadioGroup;
StatusBar1: TStatusBar;
LabeledEdit1: TLabeledEdit;
BitBtn2: TBitBtn;
Label1: TLabel;
Memo1: TMemo;
Button1: TButton;
CheckBox1: TCheckBox;
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure FormClick(Sender: TObject);
procedure LabeledEdit1Change(Sender: TObject);
procedure LabeledEdit1DblClick(Sender: TObject);
private
{ Private declarations }
_readme, _APP, _ex : TStringList;
public
{ Public declarations }
myini : ^TiniFile;
mName : string;
mOK : Boolean;
ProgramDir : string;
mNo : integer;
procedure load;
end;
var
newCode: TnewCode;
implementation
uses UnitG;
{$R *.dfm}
procedure TnewCode.BitBtn2Click(Sender: TObject);
begin
Close;
end;
procedure TnewCode.FormCreate(Sender: TObject);
begin
mOK := False;
_readme := TStringList.Create ;
_APP := TStringList.Create ;
_ex := TStringList.Create ;
end;
procedure TnewCode.RadioGroup1Click(Sender: TObject);
var
s : string;
t : Integer;
begin
t := RadioGroup1.ItemIndex;
if t<0 then exit;
s := _readme[t];
Memo1.Clear;
Memo1.Lines.Add(s);
StatusBar1.Panels[1].Text := _APP[t];
LabeledEdit1Change(self);
end;
procedure TnewCode.load;
var
Count , i ,t : Integer;
s : string;
begin //
Count := myini^.ReadInteger('NewCode','Count',0);
if Count>0 then
begin
RadioGroup1.Items.Clear;
_readme.Clear;
_APP.Clear;
for i := 0 to Count-1 do
begin
s := myini^.ReadString('NewCode', 'check'+inttostr(i), '');
RadioGroup1.Items.Add(s);
s := myini^.ReadString('NewCode', 'readme'+inttostr(i), '');
_readme.Add(s);
t := myini^.ReadInteger('NewCode', 'APP'+inttostr(i), 0);
s := myini^.ReadString('App-ID', IntToStr(t), '');
_APP.Add(s);
s := myini^.ReadString('NewCode', 'ex'+inttostr(i), '');
_ex.Add(s);
end;
RadioGroup1.ItemIndex := 0;
Memo1.Clear;
Memo1.Lines.Add(_readme[0]);
StatusBar1.Panels[1].Text := _APP[0];
end;
end;
procedure TnewCode.FormClose(Sender: TObject; var Action: TCloseAction);
begin
_readme.Free ;
_APP.Free ;
_ex.Free;
end;
procedure TnewCode.Button1Click(Sender: TObject);
var
s : string;
begin
mName := LabeledEdit1.Text;
if Length(mName)=0 then
begin
MessageDlg('文件名称未填写。', mtError, [mbOK], 0) ;
exit;
end;
if not IsValidFileName(mName) then
begin
MessageDlg('文件名称不符合命名方式!', mtError, [mbOK], 0) ;
exit;
end;
s := ExtractFileExt(mName);
if Length(s)=0 then
begin
MessageDlg('文件名称请加上扩展名。', mtError, [mbOK], 0) ;
exit;
end;
mOK := true;
mNo := RadioGroup1.ItemIndex ;
//对于某些文件要预先拷贝文件模版。
close;
end;
procedure TnewCode.FormClick(Sender: TObject);
begin
StatusBar1.Panels[2].Text := inttostr(RadioGroup1.ItemIndex);
end;
procedure TnewCode.LabeledEdit1Change(Sender: TObject);
var
s : string;
t : integer;
begin
t := RadioGroup1.ItemIndex;
if t<0 then exit;
if checkbox1.Checked and (length(_ex[t])>0) then
begin
s := LabeledEdit1.Text;
s := ChangeFileExt(s, _ex[t]) ;
LabeledEdit1.Text := s;
end;
end;
procedure TnewCode.LabeledEdit1DblClick(Sender: TObject);
begin
LabeledEdit1.SelectAll;
end;
end.