unit U_TelRegThreed;
interface
uses
Classes,ExtCtrls,Dialogs,SysUtils,U_TelReg;
type
TConnect = class(TThread)
private
{ Private declarations }
fHosId,fDocId,fUserId:string;
fBalance,fTime,fRate:double;
//i:integer;
fTimer:TTimer;
procedure Timers(Sender:TObject);
procedure AccountTime();
protected
procedure Execute;
override;
public
constructor Create(Suspended:Boolean;HosId,DocId,UserId:string;Balance,Time,Rate:double);
end;
var
i:integer=0;
implementation
{ Important: Methods and properties of objects in VCL or CLX can only be used
in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure TConnect.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end;
}
{ TConnect }
procedure TConnect.Timers(Sender:TObject);
begin
i:=i+1;
FTelReg.SB.Panels[0].Text :='预计:'+floattostr(fTime)+' 分钟';
FTelReg.SB.Panels[1].Text :='开始时间:'+Timetostr(Time);
FTelReg.SB.Panels[2].Text :='计时:'+floattostr(i)+' 分钟';
FTelReg.SB.Panels[3].Text :='状态:通话中……';
end;
procedure TConnect.AccountTime();
begin
fTimer:=TTimer.create(nil);
fTimer.Interval :=1000;
fTimer.OnTimer :=Timers;
end;
constructor TConnect.Create(Suspended:Boolean;HosId,DocId,UserId:string;Balance,Time,Rate:double);
begin
inherited Create(Suspended);
fHosId:=HosId;
fDocId:=DocId;
fUserId:=UserId;
fBalance:=Balance;
fTime:=Time;
fRate:=Rate;
FreeOnTerminate:=True;
end;
procedure TConnect.Execute;
begin
{ Place thread code here }
AccountTime();
end;
procedure TFTelReg.BitBtn1Click(Sender: TObject);
begin
inherited;
TConnect.Create(false,'102','0301','3518600029',156,48.75,3.2);
end;
为甚不执行procedure TConnect.Timers(Sender:TObject);???