我做的时候是在定义线程的类里面放了些东西,然后在Create里面附值,这样是不是就访问了VCL里面的东西
下面是我的类和create函数的定义,
type
SaveChartToJpg = class(TThread)
private
{ Private declarations }
DBChart:TDBchart;
BDateTime:TDateTime;
EDateTime:TDateTime;
ChtSvPath:string;
ChtPara:integer;
ObjIns:Tstrings;
ObjNm:Tstrings;
AttrID:Tstrings;
Attr:Tstrings;
Attr_C:Tstrings;
AttrLabelNm:Tstrings;
protected
procedure Execute;
override;
public
constructor Create(Suspended:Boolean;TmpDBChart:TDBChart;TmpBDateTime:TDateTime;
TmpEDateTime:TDateTime;TmpChtSvPath:string;TmpChtPara:integer;TmpObjIns:Tstrings;
TmpObjNm,TmpAttrID,TmpAttr,TmpAttr_C,TmpAttrLabelNm:Tstrings);
end;
constructor SaveChartToJpg.Create(Suspended:Boolean;TmpDBChart:TDBChart;TmpBDateTime:TDateTime;
TmpEDateTime:TDateTime;TmpChtSvPath:string;TmpChtPara:integer;TmpObjIns:Tstrings;
TmpObjNm,TmpAttrID,TmpAttr,TmpAttr_C,TmpAttrLabelNm:Tstrings);
begin
inherited Create(Suspended);
DBChart:=TmpDBChart;
BDateTime:=TmpBDateTime;
EDateTime:=TmpBDateTime;
ChtSvPath:=TmpChtSvPath;
ChtPara:=TmpChtPara;
ObjIns:=TStringList.Create;
ObjIns.Text:=TmpObjIns.Text;
ObjNm:=TStringList.Create;
ObjNm.Text:=TmpObjNm.Text;
AttrID:=TStringList.Create;
AttrID.Text:=TmpAttrID.Text;
Attr:=TStringList.Create;
Attr.Text:=TmpAttr.Text;
Attr_C:=TStringList.Create;
Attr_C.Text:=TmpAttr_C.Text;
AttrLabelNm:=TStringList.Create;
AttrLabelNm.Text:=TmpAttrLabelNm.Text;
FreeOnTerminate:=True;
end;