'0'; //输入字数
szdf.Caption:='0'; //得分现在
jczs.Caption:='0'; //正确字数
cwzs.Caption:='0'; //错误字数
srzs.Caption:=IntToStr(Length(RichEdit2.Text)); //输入字数
RichEdit1.SelectAll;
RichEdit1.SelAttributes.Color:=clBlack ;
RichEdit1.SelStart:=0;
RichEdit1.SelLength:= Length(RichEdit2.Text);
RichEdit1.SelAttributes.Color:=clRed ;
for I:= 1 to Length(RichEdit2.Text) do begin
if copy(RichEdit1.Text,I,1) = copy(RichEdit2.Text,I,1) then Y:=Y+1 else N:=N+1 ;
jczs.Caption:=IntTostr(Y); //正确字数
cwzs.Caption:=IntTostr(N); //错误字数
szdf.Caption:=IntTostr(Length(RichEdit2.Text)-5*N); //现在得分
end;
end;
procedure TMainForm.Timer1Timer(Sender: TObject);
var
vIniFile:TIniFile;
vIniStr:String;
cj:tstrings;
begin
iTime:=iTime-1;
UsedTime.Caption:=IntToStr(iTime); //已用时间
if Clipboard.HasFormat(CF_TEXT) then ClipBoard.Clear;
if iTime = 0 then
begin
//向INI中写入成绩
vIniStr:=szdf.Caption+';'+jczs.Caption+';'+cwzs.Caption+';'+MaskEdit1.Text ;
vIniFile:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'Note.ini');
vIniFile.WriteString('成绩记录',Edit1.Text,vIniStr);
RichEdit2.ReadOnly:=True; //不允许输入字
Timer1.Enabled:=false; //停止计时器
UpDown1.Enabled:=false; //
UpDown2.Enabled:=True; //禁止设置字号
cj := TStringList.Create;
cj.Add(''+edit1.Text);
cj.Add('得分'+szdf.Caption);
cj.SaveToFile('c:\'+edit1.Text+'.txt');
cj.Free;
showmessage('已经按设定时间测试完毕') ;
Caption:='
计算机考试';
Edit1.Text:='';
Edit1.SetFocus;
RichEdit1.Lines.LoadFromFile(ExtractFilePath(ParamStr(0))+'wsNote.txt');
RichEdit2.Clear;
Button1.Enabled:=True;
N2.Enabled:=True ;
end;
end;
procedure TMainForm.MaskEdit1Change(Sender: TObject);
begin
SetTime.Caption:=IntToStr(StrToInt(MaskEdit1.Text)*60) ;
UsedTime.Caption:=IntToStr(StrToInt(MaskEdit1.Text)*60) ;
end;
procedure TMainForm.UpDown2Changing(Sender: TObject;
var AllowChange: Boolean);
begin
RichEdit1.Font.Size:=StrToInt(MaskEdit2.Text);
RichEdit2.SelectAll;
RichEdit2.Font.Size:=StrToInt(MaskEdit2.Text);
end;
proc
edure TMainForm.FormShow(Sender: TObject);
begin
RichEdit1.Lines.LoadFromFile(ExtractFilePath(ParamStr(0))+'wsNote.txt');
end;
procedure TMainForm.RichEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if (Key = #3) or (Key = #22) or (Key = #24) then showMessage('你正在参加比赛,请不要使用此功能');
Abort;
end;
procedure TMainForm.N2Click(Sender: TObject);
begin
Button1.OnClick(Self);
end;
procedure TMainForm.N6Click(Sender: TObject);
begin
AboutBox.show;
end;
procedure TMainForm.Button2Click(Sender: TObject);
begin
iTime:=2;
end;
end.